llvm.org GIT mirror llvm / 2a4c4ba
Reapply [llvm-ar][test] Add to MRI test coverage This reapplies 363232 without mri-utf8.test due to failing on Darwin. Differential Revision: https://reviews.llvm.org/D63197 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366201 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Reynolds 2 months ago
4 changed file(s) with 139 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ## Test the ADDLIB MRI command.
1
2 # RUN: rm -rf %t && mkdir -p %t
3 # RUN: yaml2obj %s -o %t/f.o
4 # RUN: llvm-ar r %t/f.a %t/f.o
5
6 ## Merge contents of archives.
7 # RUN: echo "CREATE %t/addlib.a" > %t/addlib.mri
8 # RUN: echo "ADDLIB %t/f.a" >> %t/addlib.mri
9 # RUN: echo "SAVE" >> %t/addlib.mri
10 # RUN: llvm-ar -M < %t/addlib.mri
11 # RUN: llvm-nm --print-armap %t/addlib.a | FileCheck --check-prefix=SYMS %s
12 # RUN: llvm-ar t %t/addlib.a | FileCheck --check-prefix=FILES %s
13
14 # SYMS: f in {{.*}}
15 # FILES: f.o
16
17 ## ADDLIB with non-archive file.
18 # RUN: echo "CREATE %t/badlib.a" > %t/badlib.mri
19 # RUN: echo "ADDLIB %s" >> %t/badlib.mri
20 # RUN: echo "SAVE" >> %t/badlib.mri
21 # RUN: not llvm-ar -M < %t/badlib.mri 2>&1 | FileCheck --check-prefix=PARSE %s
22 # RUN: not ls %t/badlib.a
23
24 # PARSE: Could not parse library
25
26 ## No create command.
27 # RUN: echo "ADDLIB %t/f.a" > %t/nocreate.mri
28 # RUN: echo "SAVE" >> %t/nocreate.mri
29 # RUN: not llvm-ar -M < %t/nocreate.mri
30
31 --- !ELF
32 FileHeader:
33 Class: ELFCLASS64
34 Data: ELFDATA2LSB
35 Type: ET_REL
36 Machine: EM_X86_64
37 Sections:
38 - Name: .text
39 Type: SHT_PROGBITS
40 Symbols:
41 - Name: f
42 Binding: STB_GLOBAL
43 Section: .text
44 ...
0 ## Test the ADDMOD MRI command.
1
2 # RUN: rm -rf %t && mkdir -p %t
3 # RUN: yaml2obj %s -o %t/f.o
4
5 # RUN: echo "CREATE %t/addmod.a" > %t/addmod.mri
6 # RUN: echo "ADDMOD %t/f.o" >> %t/addmod.mri
7 # RUN: echo "SAVE" >> %t/addmod.mri
8 # RUN: llvm-ar -M < %t/addmod.mri
9 # RUN: llvm-nm --print-armap %t/addmod.a | FileCheck %s
10
11 # CHECK: f in f.o
12
13 --- !ELF
14 FileHeader:
15 Class: ELFCLASS64
16 Data: ELFDATA2LSB
17 Type: ET_REL
18 Machine: EM_X86_64
19 Sections:
20 - Name: .text
21 Type: SHT_PROGBITS
22 Symbols:
23 - Name: f
24 Binding: STB_GLOBAL
25 Section: .text
26 ...
0 # Test different MRI comment formats and white space.
1
2 RUN: rm -rf %t && mkdir -p %t
3 RUN: yaml2obj %S/Inputs/elf.yaml -o %t/elf.o
4
5 RUN: echo "create %t/mri.ar;comment" > %t/script.mri
6 RUN: echo "addmod %t/elf.o * comment" >> %t/script.mri
7 RUN: echo "; comment" >> %t/script.mri
8 RUN: echo " ;comment" >> %t/script.mri
9 RUN: echo "* comment" >> %t/script.mri
10 RUN: echo " *comment" >> %t/script.mri
11 RUN: echo "" >> %t/script.mri
12 RUN: echo " " >> %t/script.mri
13 RUN: echo " save" >> %t/script.mri
14
15 RUN: llvm-ar -M < %t/script.mri
16 RUN: llvm-ar t %t/mri.ar | FileCheck %s
17
18 CHECK: elf.o
0 # The END MRI command is optional. Scripts that omit
1 # or include END should be handled by llvm-ar.
2 RUN: rm -rf %t && mkdir -p %t
3
4 # Empty File
5 RUN: yaml2obj %S/Inputs/elf.yaml -o %t/elf.o
6
7 RUN: touch %t/empty.mri
8 RUN: llvm-ar -M < %t/empty.mri
9
10 RUN: echo "END" > %t/empty-end.mri
11 RUN: llvm-ar -M < %t/empty-end.mri
12
13 # Comment only
14 RUN: echo "; a comment" > %t/comment.mri
15 RUN: llvm-ar -M < %t/comment.mri
16
17 RUN: echo "; a comment" > %t/comment-end.mri
18 RUN: echo "END" > %t/comment-end.mri
19 RUN: llvm-ar -M < %t/comment-end.mri
20
21 # Without Save
22 RUN: echo "create %t/mri.ar" > %t/no-save.mri
23 RUN: echo "addmod %t/elf.o" >> %t/no-save.mri
24 RUN: llvm-ar -M < %t/no-save.mri
25 RUN: test ! -e %t/mri.ar
26
27 RUN: echo "create %t/mri.ar" > %t/no-save-end.mri
28 RUN: echo "addmod %t/elf.o" >> %t/no-save-end.mri
29 RUN: echo "END" > %t/no-save-end.mri
30 RUN: llvm-ar -M < %t/no-save-end.mri
31 RUN: test ! -e %t/mri.ar
32
33 # With Save
34 RUN: echo "create %t/mri.ar" > %t/save.mri
35 RUN: echo "addmod %t/elf.o" >> %t/save.mri
36 RUN: echo "save" >> %t/save.mri
37 RUN: llvm-ar -M < %t/save.mri
38 RUN: llvm-ar t %t/mri.ar | FileCheck %s
39
40 RUN: echo "create %t/mri.ar" > %t/save-end.mri
41 RUN: echo "addmod %t/elf.o" >> %t/save-end.mri
42 RUN: echo "save" >> %t/save-end.mri
43 RUN: echo "END" > %t/no-save-end.mri
44 RUN: llvm-ar -M < %t/save-end.mri
45 RUN: llvm-ar t %t/mri.ar | FileCheck %s
46
47 CHECK: elf.o