[llvm] r363232 - [llvm-ar][test] Add to MRI test coverage
Owen Reynolds via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 13 00:45:12 PDT 2019
Author: gbreynoo
Date: Thu Jun 13 00:45:12 2019
New Revision: 363232
URL: http://llvm.org/viewvc/llvm-project?rev=363232&view=rev
Log:
[llvm-ar][test] Add to MRI test coverage
This change adds tests to cover existing MRI script functionality.
Differential Revision: https://reviews.llvm.org/D63197
Added:
llvm/trunk/test/tools/llvm-ar/mri-addlib.test
llvm/trunk/test/tools/llvm-ar/mri-addmod.test
llvm/trunk/test/tools/llvm-ar/mri-comments.test
llvm/trunk/test/tools/llvm-ar/mri-end.test
llvm/trunk/test/tools/llvm-ar/mri-utf8.test
Added: llvm/trunk/test/tools/llvm-ar/mri-addlib.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-ar/mri-addlib.test?rev=363232&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-ar/mri-addlib.test (added)
+++ llvm/trunk/test/tools/llvm-ar/mri-addlib.test Thu Jun 13 00:45:12 2019
@@ -0,0 +1,45 @@
+## Test the ADDLIB MRI command.
+
+# RUN: rm -rf %t && mkdir -p %t
+# RUN: yaml2obj %s -o %t/f.o
+# RUN: llvm-ar r %t/f.a %t/f.o
+
+## Merge contents of archives.
+# RUN: echo "CREATE %t/addlib.a" > %t/addlib.mri
+# RUN: echo "ADDLIB %t/f.a" >> %t/addlib.mri
+# RUN: echo "SAVE" >> %t/addlib.mri
+# RUN: llvm-ar -M < %t/addlib.mri
+# RUN: llvm-nm --print-armap %t/addlib.a | FileCheck --check-prefix=SYMS %s
+# RUN: llvm-ar t %t/addlib.a | FileCheck --check-prefix=FILES %s
+
+# SYMS: f in {{.*}}
+# FILES: f.o
+
+## ADDLIB with non-archive file.
+# RUN: echo "CREATE %t/badlib.a" > %t/badlib.mri
+# RUN: echo "ADDLIB %s" >> %t/badlib.mri
+# RUN: echo "SAVE" >> %t/badlib.mri
+# RUN: not llvm-ar -M < %t/badlib.mri 2>&1 | FileCheck --check-prefix=PARSE %s
+# RUN: not ls %t/badlib.a
+
+# PARSE: Could not parse library
+
+## No create command.
+# RUN: echo "ADDLIB %t/f.a" > %t/nocreate.mri
+# RUN: echo "SAVE" >> %t/nocreate.mri
+# RUN: not llvm-ar -M < %t/nocreate.mri
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+Symbols:
+ - Name: f
+ Binding: STB_GLOBAL
+ Section: .text
+...
Added: llvm/trunk/test/tools/llvm-ar/mri-addmod.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-ar/mri-addmod.test?rev=363232&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-ar/mri-addmod.test (added)
+++ llvm/trunk/test/tools/llvm-ar/mri-addmod.test Thu Jun 13 00:45:12 2019
@@ -0,0 +1,27 @@
+## Test the ADDMOD MRI command.
+
+# RUN: rm -rf %t && mkdir -p %t
+# RUN: yaml2obj %s -o %t/f.o
+
+# RUN: echo "CREATE %t/addmod.a" > %t/addmod.mri
+# RUN: echo "ADDMOD %t/f.o" >> %t/addmod.mri
+# RUN: echo "SAVE" >> %t/addmod.mri
+# RUN: llvm-ar -M < %t/addmod.mri
+# RUN: llvm-nm --print-armap %t/addmod.a | FileCheck %s
+
+# CHECK: f in f.o
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+Symbols:
+ - Name: f
+ Binding: STB_GLOBAL
+ Section: .text
+...
Added: llvm/trunk/test/tools/llvm-ar/mri-comments.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-ar/mri-comments.test?rev=363232&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-ar/mri-comments.test (added)
+++ llvm/trunk/test/tools/llvm-ar/mri-comments.test Thu Jun 13 00:45:12 2019
@@ -0,0 +1,19 @@
+# Test different MRI comment formats and white space.
+
+RUN: rm -rf %t && mkdir -p %t
+RUN: yaml2obj %S/Inputs/elf.yaml -o %t/elf.o
+
+RUN: echo "create %t/mri.ar;comment" > %t/script.mri
+RUN: echo "addmod %t/elf.o * comment" >> %t/script.mri
+RUN: echo "; comment" >> %t/script.mri
+RUN: echo " ;comment" >> %t/script.mri
+RUN: echo "* comment" >> %t/script.mri
+RUN: echo " *comment" >> %t/script.mri
+RUN: echo "" >> %t/script.mri
+RUN: echo " " >> %t/script.mri
+RUN: echo " save" >> %t/script.mri
+
+RUN: llvm-ar -M < %t/script.mri
+RUN: llvm-ar t %t/mri.ar | FileCheck %s
+
+CHECK: elf.o
Added: llvm/trunk/test/tools/llvm-ar/mri-end.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-ar/mri-end.test?rev=363232&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-ar/mri-end.test (added)
+++ llvm/trunk/test/tools/llvm-ar/mri-end.test Thu Jun 13 00:45:12 2019
@@ -0,0 +1,48 @@
+# The END MRI command is optional. Scripts that omit
+# or include END should be handled by llvm-ar.
+RUN: rm -rf %t && mkdir -p %t
+
+# Empty File
+RUN: yaml2obj %S/Inputs/elf.yaml -o %t/elf.o
+
+RUN: touch %t/empty.mri
+RUN: llvm-ar -M < %t/empty.mri
+
+RUN: echo "END" > %t/empty-end.mri
+RUN: llvm-ar -M < %t/empty-end.mri
+
+# Comment only
+RUN: echo "; a comment" > %t/comment.mri
+RUN: llvm-ar -M < %t/comment.mri
+
+RUN: echo "; a comment" > %t/comment-end.mri
+RUN: echo "END" > %t/comment-end.mri
+RUN: llvm-ar -M < %t/comment-end.mri
+
+# Without Save
+RUN: echo "create %t/mri.ar" > %t/no-save.mri
+RUN: echo "addmod %t/elf.o" >> %t/no-save.mri
+RUN: llvm-ar -M < %t/no-save.mri
+RUN: test ! -e %t/mri.ar
+
+RUN: echo "create %t/mri.ar" > %t/no-save-end.mri
+RUN: echo "addmod %t/elf.o" >> %t/no-save-end.mri
+RUN: echo "END" > %t/no-save-end.mri
+RUN: llvm-ar -M < %t/no-save-end.mri
+RUN: test ! -e %t/mri.ar
+
+# With Save
+RUN: echo "create %t/mri.ar" > %t/save.mri
+RUN: echo "addmod %t/elf.o" >> %t/save.mri
+RUN: echo "save" >> %t/save.mri
+RUN: llvm-ar -M < %t/save.mri
+RUN: llvm-ar t %t/mri.ar | FileCheck %s
+
+RUN: echo "create %t/mri.ar" > %t/save-end.mri
+RUN: echo "addmod %t/elf.o" >> %t/save-end.mri
+RUN: echo "save" >> %t/save-end.mri
+RUN: echo "END" > %t/no-save-end.mri
+RUN: llvm-ar -M < %t/save-end.mri
+RUN: llvm-ar t %t/mri.ar | FileCheck %s
+
+CHECK: elf.o
Added: llvm/trunk/test/tools/llvm-ar/mri-utf8.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-ar/mri-utf8.test?rev=363232&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-ar/mri-utf8.test (added)
+++ llvm/trunk/test/tools/llvm-ar/mri-utf8.test Thu Jun 13 00:45:12 2019
@@ -0,0 +1,18 @@
+# Test non-ascii archive members
+
+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.
+RUN: env LANG=en_US.UTF-8 %python -c "assert open(u'\U000000A3.txt', 'rb').read() == b'contents\n'"
More information about the llvm-commits
mailing list