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