1 ## Test the replace command without modifiers replaces the relevant members.
3 # RUN: rm -rf %t && mkdir -p %t/new/other
4 # RUN: yaml2obj %s -o %t/1.o --docnum=1
5 # RUN: yaml2obj %s -o %t/2.o --docnum=2
6 # RUN: yaml2obj %s -o %t/3.o --docnum=3
8 # RUN: yaml2obj %s -o %t/new/1.o --docnum=4
9 # RUN: yaml2obj %s -o %t/new/3.o --docnum=5
11 # RUN: yaml2obj %s -o %t/new/other/1.o --docnum=6
13 ## Replace single member:
14 # RUN: llvm-ar rc %t/single.a %t/1.o %t/2.o %t/3.o
15 # RUN: llvm-ar r %t/single.a %t/new/1.o
16 # RUN: llvm-ar t %t/single.a \
17 # RUN: | FileCheck %s --check-prefix=SINGLE --implicit-check-not {{.}}
23 # RUN: llvm-nm --print-armap %t/single.a \
24 # RUN: | FileCheck %s --check-prefix=SINGLE-SYM
26 # SINGLE-SYM: symbolnew1
27 # SINGLE-SYM-NEXT: symbol2
28 # SINGLE-SYM-NEXT: symbol3
30 ## Replace multiple members:
31 # RUN: llvm-ar rc %t/multiple.a %t/1.o %t/2.o %t/3.o
32 # RUN: llvm-ar r %t/multiple.a %t/new/1.o %t/new/3.o
33 # RUN: llvm-ar t %t/multiple.a \
34 # RUN: | FileCheck %s --check-prefix=MULTIPLE --implicit-check-not {{.}}
40 # RUN: llvm-nm --print-armap %t/multiple.a \
41 # RUN: | FileCheck %s --check-prefix=MULTIPLE-SYM
43 # MULTIPLE-SYM: symbolnew1
44 # MULTIPLE-SYM-NEXT: symbol2
45 # MULTIPLE-SYM-NEXT: symbolnew3
47 ## Replace same member:
48 # RUN: llvm-ar rc %t/same.a %t/1.o %t/2.o %t/3.o
49 # RUN: llvm-ar r %t/same.a %t/new/1.o %t/new/other/1.o
50 # RUN: llvm-ar t %t/same.a \
51 # RUN: | FileCheck %s --check-prefix=SAME --implicit-check-not {{.}}
58 # RUN: llvm-nm --print-armap %t/same.a \
59 # RUN: | FileCheck %s --check-prefix=SAME-SYM
61 # SAME-SYM: symbolnew1
62 # SAME-SYM-NEXT: symbol2
63 # SAME-SYM-NEXT: symbol3
64 # SAME-SYM-NEXT: symbolother1
66 ## Replace without member:
67 # RUN: llvm-ar rc %t/without.a %t/1.o %t/2.o %t/3.o
68 # RUN: llvm-ar r %t/without.a
69 # RUN: llvm-ar t %t/without.a \
70 # RUN: | FileCheck %s --check-prefix=WITHOUT --implicit-check-not {{.}}
76 # RUN: llvm-nm --print-armap %t/without.a \
77 # RUN: | FileCheck %s --check-prefix=WITHOUT-SYM
79 # WITHOUT-SYM: symbol1
80 # WITHOUT-SYM-NEXT: symbol2
81 # WITHOUT-SYM-NEXT: symbol3
84 # RUN: not llvm-ar r 2>&1 \
85 # RUN: | FileCheck %s --check-prefix=NO-ARCHIVE
87 # NO-ARCHIVE: error: an archive name must be specified
89 ## Member does not exist:
90 # RUN: llvm-ar rc %t/missing.a %t/1.o %t/2.o %t/3.o
91 # RUN: not llvm-ar r %t/missing.a %t/missing.txt 2>&1 \
92 # RUN: | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt -DMSG=%errc_ENOENT
94 # MISSING-FILE: error: [[FILE]]: [[MSG]]
96 ## Create and Replace member of thin archive:
97 # RUN: llvm-ar rcT %t/thin.a %t/1.o %t/2.o %t/3.o
98 # RUN: yaml2obj %s -o %t/1.o --docnum=4
99 # RUN: llvm-ar rT %t/thin.a %t/1.o
100 # RUN: llvm-ar t %t/thin.a | FileCheck %s --check-prefix=SINGLE
102 # RUN: llvm-nm --print-armap %t/thin.a \
103 # RUN: | FileCheck %s --check-prefix=SINGLE-SYM