mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[test] Use host platform specific error message substitution in lit tests
This patch uses the errno python library to print out the correct error messages instead of hardcoding the error message per platform. Reviewed By: jhenderson, ASDenysPetrov Differential Revision: https://reviews.llvm.org/D97472
This commit is contained in:
parent
21a926deb5
commit
4a1dabde23
@ -3,7 +3,7 @@
|
|||||||
# REQUIRES: system-windows
|
# REQUIRES: system-windows
|
||||||
# RUN: touch %t.TestFile
|
# RUN: touch %t.TestFile
|
||||||
# RUN: chmod 400 %t.TestFile
|
# RUN: chmod 400 %t.TestFile
|
||||||
# RUN: not llvm-elfabi %s --output-target=elf64-little %t.TestFile 2>&1 | FileCheck %s --check-prefix=ERR
|
# RUN: not llvm-elfabi %s --output-target=elf64-little %t.TestFile 2>&1 | FileCheck -DMSG=%errc_EACCES %s --check-prefix=ERR
|
||||||
# RUN: chmod 777 %t.TestFile
|
# RUN: chmod 777 %t.TestFile
|
||||||
# RUN: rm -rf %t.TestFile
|
# RUN: rm -rf %t.TestFile
|
||||||
|
|
||||||
@ -13,4 +13,4 @@ Arch: AArch64
|
|||||||
Symbols: {}
|
Symbols: {}
|
||||||
...
|
...
|
||||||
|
|
||||||
# ERR: error: permission denied
|
# ERR: error: [[MSG]]
|
||||||
|
@ -225,7 +225,7 @@ DWARF:
|
|||||||
|
|
||||||
## h) Test that yaml2obj emits an error if 'Descriptor' is missing.
|
## h) Test that yaml2obj emits an error if 'Descriptor' is missing.
|
||||||
|
|
||||||
# RUN: not yaml2obj --docnum=8 %s -o %t8.o 2>&1 | FileCheck -DMSG=%errc_EINVAL %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
|
||||||
|
|
||||||
# MISSING-KEY: YAML:{{.*}}:9: error: missing required key 'Descriptor'
|
# MISSING-KEY: YAML:{{.*}}:9: error: missing required key 'Descriptor'
|
||||||
# MISSING-KEY-NEXT: - DieOffset: 0x12345678
|
# MISSING-KEY-NEXT: - DieOffset: 0x12345678
|
||||||
|
@ -225,12 +225,12 @@ DWARF:
|
|||||||
|
|
||||||
## h) Test that yaml2obj emits an error if 'Descriptor' is missing.
|
## 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
|
||||||
|
|
||||||
# MISSING-KEY: YAML:{{.*}}:9: error: missing required key 'Descriptor'
|
# MISSING-KEY: YAML:{{.*}}:9: error: missing required key 'Descriptor'
|
||||||
# MISSING-KEY-NEXT: - DieOffset: 0x12345678
|
# MISSING-KEY-NEXT: - DieOffset: 0x12345678
|
||||||
# MISSING-KEY-NEXT: ^
|
# 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
|
--- !ELF
|
||||||
FileHeader:
|
FileHeader:
|
||||||
|
@ -4,6 +4,7 @@ import platform
|
|||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import errno
|
||||||
|
|
||||||
import lit.util
|
import lit.util
|
||||||
from lit.llvm.subst import FindTool
|
from lit.llvm.subst import FindTool
|
||||||
@ -346,21 +347,19 @@ class LLVMConfig(object):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def add_err_msg_substitutions(self):
|
def add_err_msg_substitutions(self):
|
||||||
if (sys.platform == 'zos'):
|
host_cxx = getattr(self.config, 'host_cxx', '')
|
||||||
self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
|
# On Windows, python's os.strerror() does not emit the same spelling as the C++ std::error_code.
|
||||||
self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\''))
|
# As a workaround, hardcode the Windows error message.
|
||||||
self.config.substitutions.append(('%errc_EINVAL', '\'EDC5121I Invalid argument.\''))
|
if (sys.platform == 'win32' and 'MSYS' not in host_cxx):
|
||||||
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_ENOENT', '\'no such file or directory\''))
|
||||||
self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
|
self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
|
||||||
self.config.substitutions.append(('%errc_EINVAL', '\'invalid argument\''))
|
self.config.substitutions.append(('%errc_EINVAL', '\'invalid argument\''))
|
||||||
self.config.substitutions.append(('%errc_EACCES', '\'permission denied\''))
|
self.config.substitutions.append(('%errc_EACCES', '\'permission denied\''))
|
||||||
else:
|
else:
|
||||||
self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
|
self.config.substitutions.append(('%errc_ENOENT', '\'' + os.strerror(errno.ENOENT) + '\''))
|
||||||
self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\''))
|
self.config.substitutions.append(('%errc_EISDIR', '\'' + os.strerror(errno.EISDIR) + '\''))
|
||||||
self.config.substitutions.append(('%errc_EINVAL', '\'Invalid argument\''))
|
self.config.substitutions.append(('%errc_EINVAL', '\'' + os.strerror(errno.EINVAL) + '\''))
|
||||||
self.config.substitutions.append(('%errc_EACCES', '\'Permission denied\''))
|
self.config.substitutions.append(('%errc_EACCES', '\'' + os.strerror(errno.EACCES) + '\''))
|
||||||
|
|
||||||
def use_default_substitutions(self):
|
def use_default_substitutions(self):
|
||||||
tool_patterns = [
|
tool_patterns = [
|
||||||
|
Loading…
Reference in New Issue
Block a user