https://github.com/perry-ca created https://github.com/llvm/llvm-project/pull/109852
Several lit tests look for messages with text generated from strerror() such as "no such file or directory". The value can change slightly from system to system. Use the llvm-lit macro `%errc_<ERRCODE>` instead. This was really noticable on z/OS because the generated text includes an error code as well as the text. >From f8bb9d99ae9b9e8fd546d8a5a801681c721cb11d Mon Sep 17 00:00:00 2001 From: Sean Perry <pe...@ca.ibm.com> Date: Fri, 13 Sep 2024 16:49:02 -0500 Subject: [PATCH] use errc instead of hard coded text for messages --- clang/test/Driver/cl-options.c | 4 ++-- clang/test/Driver/cl-zc.cpp | 4 ++-- clang/test/Driver/config-file-errs.c | 6 +++--- clang/test/Driver/response-file-errs.c | 4 ++-- llvm/test/Support/interrupts.test | 4 ++-- .../tools/dsymutil/X86/remarks-linking-archive.text | 10 +++++----- llvm/test/tools/gold/X86/stats-file-option.ll | 4 ++-- llvm/test/tools/llvm-ar/read-only-archive.test | 6 +++--- .../llvm-ctxprof-util/llvm-ctxprof-util-negative.test | 4 ++-- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c index a6f338533ad763..07a25da0269fd3 100644 --- a/clang/test/Driver/cl-options.c +++ b/clang/test/Driver/cl-options.c @@ -406,9 +406,9 @@ // RUN: /Zm \ // RUN: /Zo \ // RUN: /Zo- \ -// RUN: -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s +// RUN: -### -- %s 2>&1 | FileCheck -DMSG=%errc_ENOENT -check-prefix=IGNORED %s // IGNORED-NOT: argument unused during compilation -// IGNORED-NOT: no such file or directory +// IGNORED-NOT: [[MSG]] // Don't confuse /openmp- with the /o flag: // IGNORED-NOT: "-o" "penmp-.obj" diff --git a/clang/test/Driver/cl-zc.cpp b/clang/test/Driver/cl-zc.cpp index c7cf5b1b6525be..9b1ea53888ceb5 100644 --- a/clang/test/Driver/cl-zc.cpp +++ b/clang/test/Driver/cl-zc.cpp @@ -133,9 +133,9 @@ // RUN: /Zc:inline \ // RUN: /Zc:rvalueCast \ // RUN: /Zc:ternary \ -// RUN: -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s +// RUN: -### -- %s 2>&1 | FileCheck -DMSG=%errc_ENOENT -check-prefix=IGNORED %s // IGNORED-NOT: argument unused during compilation -// IGNORED-NOT: no such file or directory +// IGNORED-NOT: [[MSG]] // Negated form warns: // RUN: %clang_cl /c \ diff --git a/clang/test/Driver/config-file-errs.c b/clang/test/Driver/config-file-errs.c index 96b49b2acf8ab4..dc4fcdebf44bca 100644 --- a/clang/test/Driver/config-file-errs.c +++ b/clang/test/Driver/config-file-errs.c @@ -6,13 +6,13 @@ //--- Argument of '--config' must be existing file, if it is specified by path. // -// RUN: not %clang --config somewhere/nonexistent-config-file 2>&1 | FileCheck %s -check-prefix CHECK-NONEXISTENT -// CHECK-NONEXISTENT: configuration file '{{.*}}somewhere{{.}}nonexistent-config-file' cannot be opened: {{[Nn]}}o such file or directory +// RUN: not %clang --config somewhere/nonexistent-config-file 2>&1 | FileCheck -DMSG=%errc_ENOENT %s -check-prefix CHECK-NONEXISTENT +// CHECK-NONEXISTENT: configuration file '{{.*}}somewhere{{.}}nonexistent-config-file' cannot be opened: [[MSG]] //--- All '--config' arguments must be existing files. // -// RUN: not %clang --config %S/Inputs/config-4.cfg --config somewhere/nonexistent-config-file 2>&1 | FileCheck %s -check-prefix CHECK-NONEXISTENT +// RUN: not %clang --config %S/Inputs/config-4.cfg --config somewhere/nonexistent-config-file 2>&1 | FileCheck -DMSG=%errc_ENOENT %s -check-prefix CHECK-NONEXISTENT //--- Argument of '--config' must exist somewhere in well-known directories, if it is specified by bare name. diff --git a/clang/test/Driver/response-file-errs.c b/clang/test/Driver/response-file-errs.c index efde7575a51e06..5331c8e308f487 100644 --- a/clang/test/Driver/response-file-errs.c +++ b/clang/test/Driver/response-file-errs.c @@ -11,5 +11,5 @@ // If file in `@file` is a directory, it is an error. // -// RUN: not %clang @%S/Inputs -### 2>&1 | FileCheck --check-prefix=DIRECTORY %s -// DIRECTORY: cannot not open file '{{.*}}Inputs': {{[Ii]}}s a directory +// RUN: not %clang @%S/Inputs -### 2>&1 | FileCheck -DMSG=%errc_EISDIR --check-prefix=DIRECTORY %s +// DIRECTORY: cannot not open file '{{.*}}Inputs': [[MSG]] diff --git a/llvm/test/Support/interrupts.test b/llvm/test/Support/interrupts.test index 4768ac61dff026..0966586106cc7a 100644 --- a/llvm/test/Support/interrupts.test +++ b/llvm/test/Support/interrupts.test @@ -1,9 +1,9 @@ ## Show that SIGINT and similar signals don't cause crash messages to be ## reported. # RUN: %python %s wrapper llvm-symbolizer 2> %t.err -# RUN: FileCheck --input-file=%t.err %s +# RUN: FileCheck -DMSG=%errc_ENOENT --input-file=%t.err %s -# CHECK: {{.*}} error: 'foo': {{[Nn]}}o such file or directory +# CHECK: {{.*}} error: 'foo': [[MSG]] # CHECK-NOT: {{.+}} import os diff --git a/llvm/test/tools/dsymutil/X86/remarks-linking-archive.text b/llvm/test/tools/dsymutil/X86/remarks-linking-archive.text index e23d0b620cac1b..47f9df82296fed 100644 --- a/llvm/test/tools/dsymutil/X86/remarks-linking-archive.text +++ b/llvm/test/tools/dsymutil/X86/remarks-linking-archive.text @@ -14,9 +14,9 @@ RUN: llvm-bcanalyzer -dump %t/basic.macho.remarks.archive.x86_64.dSYM/Contents/R Check that we don't error if we're missing remark files from an archive, but we warn instead. Instead of creating a new binary, just remove the remarks prepend path. -RUN: dsymutil -oso-prepend-path=%p/../Inputs %t/basic.macho.remarks.archive.x86_64 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING +RUN: dsymutil -oso-prepend-path=%p/../Inputs %t/basic.macho.remarks.archive.x86_64 2>&1 | FileCheck -DMSG=%errc_ENOENT %s --check-prefix=CHECK-MISSING -RUN: dsymutil --linker parallel -oso-prepend-path=%p/../Inputs %t/basic.macho.remarks.archive.x86_64 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING +RUN: dsymutil --linker parallel -oso-prepend-path=%p/../Inputs %t/basic.macho.remarks.archive.x86_64 2>&1 | FileCheck -DMSG=%errc_ENOENT %s --check-prefix=CHECK-MISSING CHECK: <Meta CHECK: <Remark Num @@ -42,9 +42,9 @@ CHECK: <Remark Num CHECK: <Remark Num CHECK-NOT: <Remark Num -CHECK-MISSING: warning: '/remarks/basic1.macho.remarks.x86_64.opt.bitstream': No such file or directory +CHECK-MISSING: warning: '/remarks/basic1.macho.remarks.x86_64.opt.bitstream': [[MSG]] CHECK-MISSING-NEXT: note: while processing {{.*}}libbasic.a(basic1.macho.remarks.x86_64.o) -CHECK-MISSING-NEXT: warning: '/remarks/basic2.macho.remarks.x86_64.opt.bitstream': No such file or directory +CHECK-MISSING-NEXT: warning: '/remarks/basic2.macho.remarks.x86_64.opt.bitstream': [[MSG]] CHECK-MISSING-NEXT: note: while processing {{.*}}libbasic.a(basic2.macho.remarks.x86_64.o) -CHECK-MISSING-NEXT: warning: '/remarks/basic3.macho.remarks.x86_64.opt.bitstream': No such file or directory +CHECK-MISSING-NEXT: warning: '/remarks/basic3.macho.remarks.x86_64.opt.bitstream': [[MSG]] CHECK-MISSING-NEXT: note: while processing {{.*}}libbasic.a(basic3.macho.remarks.x86_64.o) diff --git a/llvm/test/tools/gold/X86/stats-file-option.ll b/llvm/test/tools/gold/X86/stats-file-option.ll index a0009a7a874d77..c0c6ffd1f10802 100644 --- a/llvm/test/tools/gold/X86/stats-file-option.ll +++ b/llvm/test/tools/gold/X86/stats-file-option.ll @@ -21,5 +21,5 @@ define i32 @foo() { ; Try to save statistics to an invalid file. ; RUN: not %gold -plugin %llvmshlibdir/LLVMgold%shlibext -plugin-opt=stats-file=%t2/foo.stats \ -; RUN: -m elf_x86_64 -r -o %t.o %t.bc 2>&1 | FileCheck --check-prefix=ERROR %s -; ERROR: LLVM gold plugin: No such file or directory +; RUN: -m elf_x86_64 -r -o %t.o %t.bc 2>&1 | FileCheck -DMSG=%errc_ENOENT --check-prefix=ERROR %s +; ERROR: LLVM gold plugin: [[MSG]] diff --git a/llvm/test/tools/llvm-ar/read-only-archive.test b/llvm/test/tools/llvm-ar/read-only-archive.test index 0365f6ad054da6..e3659903d8cb36 100644 --- a/llvm/test/tools/llvm-ar/read-only-archive.test +++ b/llvm/test/tools/llvm-ar/read-only-archive.test @@ -11,12 +11,12 @@ # RUN: chmod 444 %t/archive.a # RUN: not llvm-ar r %t/archive.a %t/3.txt \ -# RUN: FileCheck %s --check-prefix=ERROR -DFILE=%t/archive.a +# RUN: FileCheck %s --check-prefix=ERROR -DFILE=%t/archive.a -DMSG=%errc_ENOENT -# ERROR: error: [[FILE]]: no such file or directory +# ERROR: error: [[FILE]]: [[MSG]] # RUN: not llvm-ar q %t/archive.a %t/3.txt \ -# RUN: FileCheck %s --check-prefix=ERROR -DFILE=%t/archive.a +# RUN: FileCheck %s --check-prefix=ERROR -DFILE=%t/archive.a -DMSG=%errc_ENOENT # RUN: not llvm-ar m %t/archive.a t/1.txt \ # RUN: FileCheck %s --check-prefix=ERROR-2 -DFILE=%t/archive.a diff --git a/llvm/test/tools/llvm-ctxprof-util/llvm-ctxprof-util-negative.test b/llvm/test/tools/llvm-ctxprof-util/llvm-ctxprof-util-negative.test index 08c83c9f907fbf..e8668a7f198a98 100644 --- a/llvm/test/tools/llvm-ctxprof-util/llvm-ctxprof-util-negative.test +++ b/llvm/test/tools/llvm-ctxprof-util/llvm-ctxprof-util-negative.test @@ -3,7 +3,7 @@ ; RUN: not llvm-ctxprof-util nofile.json 2>&1 | FileCheck %s --check-prefix=NO_CMD ; RUN: not llvm-ctxprof-util invalidCmd --input nofile.json 2>&1 | FileCheck %s --check-prefix=INVALID_CMD ; RUN: not llvm-ctxprof-util fromJSON nofile.json 2>&1 | FileCheck %s --check-prefix=NO_FLAG -; RUN: not llvm-ctxprof-util fromJSON --input nofile.json 2>&1 | FileCheck %s --check-prefix=NO_FILE +; RUN: not llvm-ctxprof-util fromJSON --input nofile.json 2>&1 | FileCheck -DMSG=%errc_ENOENT %s --check-prefix=NO_FILE ; RUN: not llvm-ctxprof-util fromJSON --input %S/Inputs/bad.json 2>&1 | FileCheck %s --check-prefix=BAD_JSON ; RUN: not llvm-ctxprof-util fromJSON --input %S/Inputs/invalid-no-vector.json 2>&1 | FileCheck %s --check-prefix=NO_VECTOR ; RUN: not llvm-ctxprof-util fromJSON --input %S/Inputs/invalid-no-ctx.json 2>&1 | FileCheck %s --check-prefix=NO_CTX @@ -15,7 +15,7 @@ ; NO_CMD: Unknown subcommand 'nofile.json' ; INVALID_CMD: Unknown subcommand 'invalidCmd' ; NO_FLAG: Unknown command line argument 'nofile.json'. -; NO_FILE: 'nofile.json': No such file or directory +; NO_FILE: 'nofile.json': [[MSG]] ; BAD_JSON: Expected object key ; NO_VECTOR: expected array ; NO_CTX: missing value at (root)[0].Guid _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits