1Test the exact archive format. In particular, test which file names use the
2string table or not.
3
4RUN: mkdir -p %t
5RUN: cd %t
6
7RUN: printf bar. > 0123456789abcde
8RUN: printf zed. > 0123456789abcdef
9RUN: mkdir -p foo
10RUN: printf bar2 > foo/0123456789abcde
11RUN: printf zed2 > foo/0123456789abcdef
12
13RUN: rm -f %t.a
14RUN: llvm-ar --format=gnu rc %t.a 0123456789abcde 0123456789abcdef foo/0123456789abcde foo/0123456789abcdef
15RUN: cat %t.a | FileCheck -strict-whitespace %s
16
17CHECK:      !<arch>
18CHECK-NEXT: //                                              18        `
19CHECK-NEXT: 0123456789abcdef/
20CHECK-NEXT: 0123456789abcde/0           0     0     644     4         `
21CHECK-NEXT: bar.
22CHECK-SAME: /0              0           0     0     644     4         `
23CHECK-NEXT: zed.
24CHECK-SAME: 0123456789abcde/0           0     0     644     4         `
25CHECK-NEXT: bar2
26CHECK-SAME: /0              0           0     0     644     4         `
27CHECK-NEXT: zed2
28
29RUN: rm -f %t.a
30RUN: llvm-ar --format=bsd rc %t.a 0123456789abcde 0123456789abcdef
31RUN: cat %t.a | FileCheck -strict-whitespace --check-prefix=BSD %s
32
33BSD:      !<arch>
34BSD-NEXT: #1/20           0           0     0     644     24        `
35BSD-NEXT: 0123456789abcde{{.....}}bar.
36BSD-SAME: #1/16           0           0     0     644     20        `
37BSD-NEXT: 0123456789abcdefzed.
38
39RUN: rm -f %t.a
40RUN: llvm-ar --format=darwin rcS %t.a 0123456789abcde 0123456789abcdef
41RUN: cat %t.a | FileCheck -strict-whitespace --check-prefix=DARWIN %s
42
43DARWIN:      !<arch>
44DARWIN-NEXT: #1/20           0           0     0     644     28        `
45Each [[:space:]] matches a newline.  We explicitly match 3 newlines, as the
46fourth newline is implicitly consumed by FileCheck and cannot be matched.
47DARWIN-NEXT: 0123456789abcde{{.....}}bar.{{[[:space:]][[:space:]][[:space:]]}}
48DARWIN-NEXT: #1/20           0           0     0     644     28        `
49DARWIN-NEXT: 0123456789abcdef{{....}}zed.
50
51
52RUN: rm -f test.a
53RUN: llvm-ar --format=gnu rcT test.a 0123456789abcde 0123456789abcdef
54RUN: cat test.a | FileCheck -strict-whitespace --check-prefix=THIN %s
55THIN: !<thin>
56THIN-NEXT: //                                              36        `
57THIN-NEXT: 0123456789abcde/
58THIN-NEXT: 0123456789abcdef/{{$}}
59THIN: {{^$}}
60THIN: /0              0           0     0     644     4         `
61THIN-NEXT: /17             0           0     0     644     4         `
62
63RUN: mkdir -p bar
64RUN: rm -f bar/test.a
65RUN: llvm-ar --format=gnu rcT bar/test.a 0123456789abcde 0123456789abcdef foo/0123456789abcde foo/0123456789abcdef
66RUN: cat bar/test.a | FileCheck -strict-whitespace --check-prefix=THIN-PATH %s
67THIN-PATH: !<thin>
68THIN-PATH-NEXT: //                                              90        `
69THIN-PATH-NEXT: ..{{/|\\}}0123456789abcde/
70THIN-PATH-NEXT: ..{{/|\\}}0123456789abcdef/
71THIN-PATH-NEXT: ..{{/|\\}}foo{{/|\\}}0123456789abcde/
72THIN-PATH-NEXT: ..{{/|\\}}foo{{/|\\}}0123456789abcdef/
73THIN-PATH-NEXT: /0              0           0     0     644     4         `
74THIN-PATH-NEXT: /20             0           0     0     644     4         `
75THIN-PATH-NEXT: /41             0           0     0     644     4         `
76THIN-PATH-NEXT: /65             0           0     0     644     4         `
77
78RUN: not llvm-ar --format=bsd rcT bad.a 0123456789abcde 0123456789abcdef 2>&1 | FileCheck --check-prefix=BSD-THIN %s
79BSD-THIN: error: only the gnu format has a thin mode
80
81If an archive has an object with no symbols, the linker and some other
82tools on some versions of Solaris will abort operations if there is no
83symbol table.  Create such an object, put it into an archive, and check to
84see that there is an empty symbol table.
85RUN: mkdir -p %t
86RUN: yaml2obj %S/Inputs/solaris-nosymbols.yaml -o %t/foo.o
87RUN: llvm-ar rs %t/foo.a %t/foo.o
88RUN: cat -v %t/foo.a | FileCheck -strict-whitespace --check-prefix=SOLARIS %s
89SOLARIS:      !<arch>
90SOLARIS-NEXT: /               0           0     0     0       8         `
91SOLARIS-NEXT: ^@^@^@^@^@^@^@^@foo.o/
92