Skip to content

Commit 8336819

Browse files
authored
Use %errc to get text for system errors (#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.
1 parent 852b648 commit 8336819

File tree

9 files changed

+23
-23
lines changed

9 files changed

+23
-23
lines changed

clang/test/Driver/cl-options.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,9 @@
406406
// RUN: /Zm \
407407
// RUN: /Zo \
408408
// RUN: /Zo- \
409-
// RUN: -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s
409+
// RUN: -### -- %s 2>&1 | FileCheck -DMSG=%errc_ENOENT -check-prefix=IGNORED %s
410410
// IGNORED-NOT: argument unused during compilation
411-
// IGNORED-NOT: no such file or directory
411+
// IGNORED-NOT: [[MSG]]
412412
// Don't confuse /openmp- with the /o flag:
413413
// IGNORED-NOT: "-o" "penmp-.obj"
414414

clang/test/Driver/cl-zc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@
133133
// RUN: /Zc:inline \
134134
// RUN: /Zc:rvalueCast \
135135
// RUN: /Zc:ternary \
136-
// RUN: -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s
136+
// RUN: -### -- %s 2>&1 | FileCheck -DMSG=%errc_ENOENT -check-prefix=IGNORED %s
137137
// IGNORED-NOT: argument unused during compilation
138-
// IGNORED-NOT: no such file or directory
138+
// IGNORED-NOT: [[MSG]]
139139

140140
// Negated form warns:
141141
// RUN: %clang_cl /c \

clang/test/Driver/config-file-errs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
//--- Argument of '--config' must be existing file, if it is specified by path.
88
//
9-
// RUN: not %clang --config somewhere/nonexistent-config-file 2>&1 | FileCheck %s -check-prefix CHECK-NONEXISTENT
10-
// CHECK-NONEXISTENT: configuration file '{{.*}}somewhere{{.}}nonexistent-config-file' cannot be opened: {{[Nn]}}o such file or directory
9+
// RUN: not %clang --config somewhere/nonexistent-config-file 2>&1 | FileCheck -DMSG=%errc_ENOENT %s -check-prefix CHECK-NONEXISTENT
10+
// CHECK-NONEXISTENT: configuration file '{{.*}}somewhere{{.}}nonexistent-config-file' cannot be opened: [[MSG]]
1111

1212

1313
//--- All '--config' arguments must be existing files.
1414
//
15-
// RUN: not %clang --config %S/Inputs/config-4.cfg --config somewhere/nonexistent-config-file 2>&1 | FileCheck %s -check-prefix CHECK-NONEXISTENT
15+
// 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
1616

1717

1818
//--- Argument of '--config' must exist somewhere in well-known directories, if it is specified by bare name.

clang/test/Driver/response-file-errs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111

1212
// If file in `@file` is a directory, it is an error.
1313
//
14-
// RUN: not %clang @%S/Inputs -### 2>&1 | FileCheck --check-prefix=DIRECTORY %s
15-
// DIRECTORY: cannot not open file '{{.*}}Inputs': {{[Ii]}}s a directory
14+
// RUN: not %clang @%S/Inputs -### 2>&1 | FileCheck -DMSG=%errc_EISDIR --check-prefix=DIRECTORY %s
15+
// DIRECTORY: cannot not open file '{{.*}}Inputs': [[MSG]]

llvm/test/Support/interrupts.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
## Show that SIGINT and similar signals don't cause crash messages to be
22
## reported.
33
# RUN: %python %s wrapper llvm-symbolizer 2> %t.err
4-
# RUN: FileCheck --input-file=%t.err %s
4+
# RUN: FileCheck -DMSG=%errc_ENOENT --input-file=%t.err %s
55

6-
# CHECK: {{.*}} error: 'foo': {{[Nn]}}o such file or directory
6+
# CHECK: {{.*}} error: 'foo': [[MSG]]
77
# CHECK-NOT: {{.+}}
88

99
import os

llvm/test/tools/dsymutil/X86/remarks-linking-archive.text

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ RUN: llvm-bcanalyzer -dump %t/basic.macho.remarks.archive.x86_64.dSYM/Contents/R
1414

1515
Check that we don't error if we're missing remark files from an archive, but we warn instead.
1616
Instead of creating a new binary, just remove the remarks prepend path.
17-
RUN: dsymutil -oso-prepend-path=%p/../Inputs %t/basic.macho.remarks.archive.x86_64 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING
17+
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
1818

19-
RUN: dsymutil --linker parallel -oso-prepend-path=%p/../Inputs %t/basic.macho.remarks.archive.x86_64 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING
19+
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
2020

2121
CHECK: <Meta
2222
CHECK: <Remark Num
@@ -42,9 +42,9 @@ CHECK: <Remark Num
4242
CHECK: <Remark Num
4343
CHECK-NOT: <Remark Num
4444

45-
CHECK-MISSING: warning: '/remarks/basic1.macho.remarks.x86_64.opt.bitstream': No such file or directory
45+
CHECK-MISSING: warning: '/remarks/basic1.macho.remarks.x86_64.opt.bitstream': [[MSG]]
4646
CHECK-MISSING-NEXT: note: while processing {{.*}}libbasic.a(basic1.macho.remarks.x86_64.o)
47-
CHECK-MISSING-NEXT: warning: '/remarks/basic2.macho.remarks.x86_64.opt.bitstream': No such file or directory
47+
CHECK-MISSING-NEXT: warning: '/remarks/basic2.macho.remarks.x86_64.opt.bitstream': [[MSG]]
4848
CHECK-MISSING-NEXT: note: while processing {{.*}}libbasic.a(basic2.macho.remarks.x86_64.o)
49-
CHECK-MISSING-NEXT: warning: '/remarks/basic3.macho.remarks.x86_64.opt.bitstream': No such file or directory
49+
CHECK-MISSING-NEXT: warning: '/remarks/basic3.macho.remarks.x86_64.opt.bitstream': [[MSG]]
5050
CHECK-MISSING-NEXT: note: while processing {{.*}}libbasic.a(basic3.macho.remarks.x86_64.o)

llvm/test/tools/gold/X86/stats-file-option.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ define i32 @foo() {
2121

2222
; Try to save statistics to an invalid file.
2323
; RUN: not %gold -plugin %llvmshlibdir/LLVMgold%shlibext -plugin-opt=stats-file=%t2/foo.stats \
24-
; RUN: -m elf_x86_64 -r -o %t.o %t.bc 2>&1 | FileCheck --check-prefix=ERROR %s
25-
; ERROR: LLVM gold plugin: No such file or directory
24+
; RUN: -m elf_x86_64 -r -o %t.o %t.bc 2>&1 | FileCheck -DMSG=%errc_ENOENT --check-prefix=ERROR %s
25+
; ERROR: LLVM gold plugin: [[MSG]]

llvm/test/tools/llvm-ar/read-only-archive.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
# RUN: chmod 444 %t/archive.a
1212

1313
# RUN: not llvm-ar r %t/archive.a %t/3.txt \
14-
# RUN: FileCheck %s --check-prefix=ERROR -DFILE=%t/archive.a
14+
# RUN: FileCheck %s --check-prefix=ERROR -DFILE=%t/archive.a -DMSG=%errc_ENOENT
1515

16-
# ERROR: error: [[FILE]]: no such file or directory
16+
# ERROR: error: [[FILE]]: [[MSG]]
1717

1818
# RUN: not llvm-ar q %t/archive.a %t/3.txt \
19-
# RUN: FileCheck %s --check-prefix=ERROR -DFILE=%t/archive.a
19+
# RUN: FileCheck %s --check-prefix=ERROR -DFILE=%t/archive.a -DMSG=%errc_ENOENT
2020

2121
# RUN: not llvm-ar m %t/archive.a t/1.txt \
2222
# RUN: FileCheck %s --check-prefix=ERROR-2 -DFILE=%t/archive.a

llvm/test/tools/llvm-ctxprof-util/llvm-ctxprof-util-negative.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
; RUN: not llvm-ctxprof-util nofile.json 2>&1 | FileCheck %s --check-prefix=NO_CMD
44
; RUN: not llvm-ctxprof-util invalidCmd --input nofile.json 2>&1 | FileCheck %s --check-prefix=INVALID_CMD
55
; RUN: not llvm-ctxprof-util fromJSON nofile.json 2>&1 | FileCheck %s --check-prefix=NO_FLAG
6-
; RUN: not llvm-ctxprof-util fromJSON --input nofile.json 2>&1 | FileCheck %s --check-prefix=NO_FILE
6+
; RUN: not llvm-ctxprof-util fromJSON --input nofile.json 2>&1 | FileCheck -DMSG=%errc_ENOENT %s --check-prefix=NO_FILE
77
; RUN: not llvm-ctxprof-util fromJSON --input %S/Inputs/bad.json 2>&1 | FileCheck %s --check-prefix=BAD_JSON
88
; RUN: not llvm-ctxprof-util fromJSON --input %S/Inputs/invalid-no-vector.json 2>&1 | FileCheck %s --check-prefix=NO_VECTOR
99
; 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 @@
1515
; NO_CMD: Unknown subcommand 'nofile.json'
1616
; INVALID_CMD: Unknown subcommand 'invalidCmd'
1717
; NO_FLAG: Unknown command line argument 'nofile.json'.
18-
; NO_FILE: 'nofile.json': No such file or directory
18+
; NO_FILE: 'nofile.json': [[MSG]]
1919
; BAD_JSON: Expected object key
2020
; NO_VECTOR: expected array
2121
; NO_CTX: missing value at (root)[0].Guid

0 commit comments

Comments
 (0)