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