diff options
author | Thomas Preud'homme <thomasp@graphcore.ai> | 2019-10-10 11:48:30 +0000 |
---|---|---|
committer | Thomas Preud'homme <thomasp@graphcore.ai> | 2019-11-04 15:25:45 +0000 |
commit | 0bab0538d8cc0de242ed2936a4766930cfc934d2 (patch) | |
tree | 6388d72db9836571e3928b8efc0820dbb583aafe /llvm/test/tools/llvm-ar | |
parent | bf6744dfb244dbd2a4abe635f57e45218292743f (diff) | |
download | bcm5719-llvm-0bab0538d8cc0de242ed2936a4766930cfc934d2.tar.gz bcm5719-llvm-0bab0538d8cc0de242ed2936a4766930cfc934d2.zip |
[test] Use system locale for mri-utf8.test
Summary:
llvm-ar's mri-utf8.test test relies on the en_US.UTF-8 locale to be
installed for its last RUN line to work. If not installed, the unicode
string gets encoded (interpreted) as ascii which fails since the most
significant byte is non zero. This commit changes the test to only rely
on the system being able to encode the pound sign in its default
encoding (e.g. UTF-16 for Microsoft Windows) by always opening the file
via input/output redirection. This avoids forcing a given locale to be
present and supported. A Byte Order Mark is also added to help
recognizing the encoding of the file and its endianness. Finally the
XFAIL on system-darwin is removed since the test actually passes fine on
Mac OS X and XFAIL was only added because it failed before.
Reviewers: gbreynoo, MaskRay, rupprecht, JamesNagurne, jfb
Subscribers: dexonsmith, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D68472
Diffstat (limited to 'llvm/test/tools/llvm-ar')
-rw-r--r-- | llvm/test/tools/llvm-ar/mri-nonascii.test | 21 | ||||
-rw-r--r-- | llvm/test/tools/llvm-ar/mri-utf8.test | 23 |
2 files changed, 21 insertions, 23 deletions
diff --git a/llvm/test/tools/llvm-ar/mri-nonascii.test b/llvm/test/tools/llvm-ar/mri-nonascii.test new file mode 100644 index 00000000000..2a688874756 --- /dev/null +++ b/llvm/test/tools/llvm-ar/mri-nonascii.test @@ -0,0 +1,21 @@ +# Test non-ascii archive members + +RUN: rm -rf %t && mkdir -p %t/extracted + +# Note: lit's Python will read this UTF-8 encoded mri-nonascii.txt file, +# decode it to unicode. The filename in the redirection below will then +# be encoded in the system's filename encoding (e.g. UTF-16 for +# Microsoft Windows). +RUN: echo "contents" > %t/£.txt + +RUN: echo "CREATE %t/mri.ar" > %t/script.mri +RUN: echo "ADDMOD %t/£.txt" >> %t/script.mri +RUN: echo "SAVE" >> %t/script.mri + +RUN: llvm-ar -M < %t/script.mri +RUN: cd %t/extracted && llvm-ar x %t/mri.ar + +# Same as above. +RUN: FileCheck --strict-whitespace %s <£.txt +CHECK:{{^}} +CHECK-SAME:{{^}}contents{{$}} diff --git a/llvm/test/tools/llvm-ar/mri-utf8.test b/llvm/test/tools/llvm-ar/mri-utf8.test deleted file mode 100644 index e297dce8d8a..00000000000 --- a/llvm/test/tools/llvm-ar/mri-utf8.test +++ /dev/null @@ -1,23 +0,0 @@ -# Test non-ascii archive members -# XFAIL: system-darwin - -RUN: rm -rf %t && mkdir -p %t/extracted - -RUN: echo "contents" > %t/£.txt - -RUN: echo "CREATE %t/mri.ar" > %t/script.mri -RUN: echo "ADDMOD %t/£.txt" >> %t/script.mri -RUN: echo "SAVE" >> %t/script.mri - -RUN: llvm-ar -M < %t/script.mri -RUN: cd %t/extracted && llvm-ar x %t/mri.ar - -# This works around problems launching processess that -# include arguments with non-ascii characters. -# Python on Linux defaults to ASCII encoding unless the -# environment specifies otherwise, so it is explicitly set. -# The reliance the test has on this locale is not ideal, -# however alternate solutions have been difficult due to -# behaviour differences with python 2 vs python 3, -# and linux vs windows. -RUN: env LANG=en_US.UTF-8 %python -c "assert open(u'\U000000A3.txt', 'rb').read() == b'contents\n'" |