From e6f220185d26db04e31df637480a52fa5fa67c7d Mon Sep 17 00:00:00 2001 From: Abhina Sreeskantharajan Date: Wed, 3 Feb 2021 09:52:43 -0500 Subject: [PATCH] [test] Use host platform specific error message substitution in lit tests - continued On z/OS, other error messages are not matched correctly in lit tests. ``` EDC5121I Invalid argument. EDC5111I Permission denied. ``` This patch adds a lit substitution to fix it. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D95808 --- docs/TestingGuide.rst | 3 ++- test/tools/llvm-ar/error-opening-permission.test | 4 ++-- test/tools/llvm-elfabi/fail-file-write.test | 4 ++-- test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml | 4 ++-- utils/lit/lit/llvm/config.py | 6 ++++++ 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/docs/TestingGuide.rst b/docs/TestingGuide.rst index d87b8d50d45..dd8601f3062 100644 --- a/docs/TestingGuide.rst +++ b/docs/TestingGuide.rst @@ -542,7 +542,8 @@ RUN lines: Some error messages may be substituted to allow different spellings based on the host platform. - The following error codes are currently supported: ENOENT, EISDIR. + The following error codes are currently supported: + ENOENT, EISDIR, EINVAL, EACCES. Example: ``Linux %errc_ENOENT: No such file or directory`` diff --git a/test/tools/llvm-ar/error-opening-permission.test b/test/tools/llvm-ar/error-opening-permission.test index d8d0cbfd355..4107bdfc044 100644 --- a/test/tools/llvm-ar/error-opening-permission.test +++ b/test/tools/llvm-ar/error-opening-permission.test @@ -9,6 +9,6 @@ # RUN: llvm-ar rc %t/permission.b %t/1.txt # RUN: chmod 100 %t/permission.b # RUN: not llvm-ar p %t/permission.b 2>&1 | \ -# RUN: FileCheck %s --check-prefix=NO-PERMISSION -DARCHIVE=%t/permission.b +# RUN: FileCheck %s --check-prefix=NO-PERMISSION -DARCHIVE=%t/permission.b -DMSG=%errc_EACCES -# NO-PERMISSION: error: unable to open '[[ARCHIVE]]': {{.*}}{{[pP]}}ermission denied +# NO-PERMISSION: error: unable to open '[[ARCHIVE]]': [[MSG]] diff --git a/test/tools/llvm-elfabi/fail-file-write.test b/test/tools/llvm-elfabi/fail-file-write.test index c3c479e7388..928528d16c6 100644 --- a/test/tools/llvm-elfabi/fail-file-write.test +++ b/test/tools/llvm-elfabi/fail-file-write.test @@ -5,7 +5,7 @@ # RUN: mkdir %t.TestDir # RUN: touch %t.TestDir/Output.TestFile # RUN: chmod 400 %t.TestDir -# RUN: not llvm-elfabi %s --output-target=elf64-little %t.TestDir/Output.TestFile 2>&1 | FileCheck %s --check-prefix=ERR +# RUN: not llvm-elfabi %s --output-target=elf64-little %t.TestDir/Output.TestFile 2>&1 | FileCheck -DMSG=%errc_EACCES %s --check-prefix=ERR # RUN: chmod 777 %t.TestDir # RUN: rm -rf %t.TestDir @@ -15,4 +15,4 @@ Arch: AArch64 Symbols: {} ... -# ERR: {{.*}}Permission denied{{.*}} when trying to open `{{.*}}.TestDir/Output.TestFile` for writing +# ERR: [[MSG]] when trying to open `{{.*}}.TestDir/Output.TestFile` for writing diff --git a/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml b/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml index 57a6c60d01c..610609c17b2 100644 --- a/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml +++ b/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml @@ -225,12 +225,12 @@ DWARF: ## h) Test that yaml2obj emits an error if 'Descriptor' is missing. -# RUN: not yaml2obj --docnum=8 %s -o %t8.o 2>&1 | FileCheck %s --check-prefix=MISSING-KEY --ignore-case +# RUN: not yaml2obj --docnum=8 %s -o %t8.o 2>&1 | FileCheck -DMSG=%errc_EINVAL %s --check-prefix=MISSING-KEY --ignore-case # MISSING-KEY: YAML:{{.*}}:9: error: missing required key 'Descriptor' # MISSING-KEY-NEXT: - DieOffset: 0x12345678 # MISSING-KEY-NEXT: ^ -# MISSING-KEY-NEXT: yaml2obj: error: failed to parse YAML input: Invalid argument +# MISSING-KEY-NEXT: yaml2obj: error: failed to parse YAML input: [[MSG]] --- !ELF FileHeader: diff --git a/utils/lit/lit/llvm/config.py b/utils/lit/lit/llvm/config.py index d4cd3e9dee5..81b2b2a194d 100644 --- a/utils/lit/lit/llvm/config.py +++ b/utils/lit/lit/llvm/config.py @@ -349,12 +349,18 @@ class LLVMConfig(object): if (sys.platform == 'zos'): self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\'')) self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\'')) + self.config.substitutions.append(('%errc_EINVAL', '\'EDC5121I Invalid argument.\'')) + self.config.substitutions.append(('%errc_EACCES', '\'EDC5111I Permission denied.\'')) elif (sys.platform == 'win32'): self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\'')) self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\'')) + self.config.substitutions.append(('%errc_EINVAL', '\'invalid argument\'')) + self.config.substitutions.append(('%errc_EACCES', '\'permission denied\'')) else: self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\'')) self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\'')) + self.config.substitutions.append(('%errc_EINVAL', '\'Invalid argument\'')) + self.config.substitutions.append(('%errc_EACCES', '\'Permission denied\'')) def use_default_substitutions(self): tool_patterns = [