blob: 219fc7f894a7f6c0ad5c336ce45afe1b0d14ffe8 [file] [log] [blame]
Rafael Espindola0aac01b2013-07-13 04:14:13 +00001Test the exact archive format. In particular, test which file names use the
2string table or not.
3
Rafael Espindola0aac01b2013-07-13 04:14:13 +00004RUN: mkdir -p %t
5RUN: cd %t
6
Rui Ueyama2241b842016-10-26 01:07:26 +00007RUN: printf bar. > 0123456789abcde
8RUN: printf zed. > 0123456789abcdef
Rafael Espindola57c05252015-07-15 23:15:33 +00009RUN: mkdir -p foo
Rui Ueyama2241b842016-10-26 01:07:26 +000010RUN: printf bar2 > foo/0123456789abcde
11RUN: printf zed2 > foo/0123456789abcdef
Rafael Espindola0aac01b2013-07-13 04:14:13 +000012
Rafael Espindola6a8e86f2015-07-13 20:38:09 +000013RUN: rm -f %t.a
Rafael Espindola57c05252015-07-15 23:15:33 +000014RUN: llvm-ar --format=gnu rc %t.a 0123456789abcde 0123456789abcdef foo/0123456789abcde foo/0123456789abcdef
Rafael Espindola6a8e86f2015-07-13 20:38:09 +000015RUN: cat %t.a | FileCheck -strict-whitespace %s
Rafael Espindola0aac01b2013-07-13 04:14:13 +000016
17CHECK: !<arch>
Rafael Espindola57c05252015-07-15 23:15:33 +000018CHECK-NEXT: // 36 `
19CHECK-NEXT: 0123456789abcdef/
Rafael Espindola0aac01b2013-07-13 04:14:13 +000020CHECK-NEXT: 0123456789abcdef/
Rafael Espindola6a8e86f2015-07-13 20:38:09 +000021CHECK-NEXT: 0123456789abcde/0 0 0 644 4 `
Rafael Espindola57c05252015-07-15 23:15:33 +000022CHECK-NEXT: bar.
23CHECK-SAME: /0 0 0 0 644 4 `
NAKAMURA Takumi10d576d2015-03-03 15:54:48 +000024CHECK-NEXT: zed.
Rafael Espindola57c05252015-07-15 23:15:33 +000025CHECK-SAME: 0123456789abcde/0 0 0 644 4 `
26CHECK-NEXT: bar2
27CHECK-SAME: /18 0 0 0 644 4 `
28CHECK-NEXT: zed2
Rafael Espindolaa2ed0b02015-07-08 20:47:32 +000029
Rafael Espindola6a8e86f2015-07-13 20:38:09 +000030RUN: 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
Rafael Espindolaa2ed0b02015-07-08 20:47:32 +000033
34BSD: !<arch>
Rafael Espindola23a76be2017-02-21 20:40:54 +000035BSD-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 `
Saleem Abdulrasool111cd662017-02-09 19:29:35 +000046Each [[:space:]] matches a newline. We explicitly match 3 newlines, as the
47fourth newline is implicitly consumed by FileCheck and cannot be matched.
Rafael Espindola23a76be2017-02-21 20:40:54 +000048DARWIN-NEXT: 0123456789abcde{{.....}}bar.{{[[:space:]][[:space:]][[:space:]]}}
49DARWIN-NEXT: #1/20 0 0 0 644 28 `
50DARWIN-NEXT: 0123456789abcdef{{....}}zed.
51
Rafael Espindolae6492582015-07-15 05:47:46 +000052
Rafael Espindola06d6d192015-07-16 00:14:49 +000053RUN: 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
Rafael Espindolae6492582015-07-15 05:47:46 +000056THIN: !<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 `
Rafael Espindola06d6d192015-07-16 00:14:49 +000063
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 `
Rafael Espindolae79b62d2015-07-16 00:38:34 +000070THIN-PATH-NEXT: ..{{/|\\}}0123456789abcde/
71THIN-PATH-NEXT: ..{{/|\\}}0123456789abcdef/
72THIN-PATH-NEXT: ..{{/|\\}}foo{{/|\\}}0123456789abcde/
73THIN-PATH-NEXT: ..{{/|\\}}foo{{/|\\}}0123456789abcdef/
Rafael Espindola06d6d192015-07-16 00:14:49 +000074THIN-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 `
Rafael Espindola21507a42016-05-02 21:06:57 +000078
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.
Rafael Espindola8f2dd7c2017-03-14 19:57:13 +000081
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/