1 # Note: many of these tests depend on relative paths, so we have to cd to a
2 # test directory first.
3 RUN: mkdir -p %t && cd %t
4 RUN: rm -rf a b && mkdir a b
5 RUN: echo hello-a > a/foo.txt
6 RUN: echo hello-b > b/foo.txt
7 RUN: echo hello-parent > foo.txt
9 # Verify that P is accepted.
10 RUN: rm -f noop.a && llvm-ar rcP noop.a foo.txt
11 RUN: llvm-ar p noop.a | FileCheck %s --check-prefix=ACCEPT
15 # Regular (non-thin) archives cannot be created with full path names as
16 # members, but P can still affect how lookup works (assuming we're reading an
17 # archive not created by GNU ar or llvm-ar).
18 # Looking up a/foo.txt in a regular archive will fail with P because it is
19 # added to the archive as foo.txt.
21 RUN: llvm-ar rcS display.a a/foo.txt foo.txt b/foo.txt
22 RUN: llvm-ar t display.a a/foo.txt | FileCheck %s --check-prefix=DISPLAY-FOUND --match-full-lines
23 RUN: not llvm-ar tP display.a a/foo.txt 2>&1 | FileCheck %s --check-prefix=DISPLAY-NOT-FOUND
25 DISPLAY-FOUND: foo.txt
26 DISPLAY-NOT-FOUND: 'a/foo.txt' was not found
28 # Deleting will fail with P because the members exist as foo.txt, not a/foo.txt.
30 RUN: llvm-ar rcS del1.a foo.txt
31 RUN: llvm-ar dP del1.a a/foo.txt
32 RUN: llvm-ar t del1.a a/foo.txt | FileCheck %s --check-prefix=DISPLAY-FOUND --match-full-lines
33 RUN: llvm-ar d del1.a a/foo.txt
34 RUN: not llvm-ar t del1.a a/foo.txt 2>&1 | FileCheck %s --check-prefix=DISPLAY-NOT-FOUND
36 # Run several checks that P is implied when using thin archives. None of these
37 # checks explicitly use P.
39 # Creating an archive in one step.
41 RUN: llvm-ar rcST add.a a/foo.txt foo.txt b/foo.txt
42 RUN: llvm-ar t add.a | FileCheck %s --check-prefix=ADD --match-full-lines
48 # Create an archive incrementally.
50 RUN: llvm-ar rcST add-inc.a a/foo.txt
51 RUN: llvm-ar rcST add-inc.a foo.txt
52 RUN: llvm-ar rcST add-inc.a b/foo.txt
53 RUN: llvm-ar t add-inc.a | FileCheck %s --check-prefix=ADD-INC --match-full-lines
57 ADD-INC-NEXT: b/foo.txt
59 # Nesting a thin archive with a name conflict.
60 RUN: rm -f a/nested.a b/nested.a nested.a
61 RUN: llvm-ar rcST a/nested.a a/foo.txt
62 RUN: llvm-ar rcST b/nested.a b/foo.txt
63 RUN: llvm-ar rcST nested.a a/nested.a foo.txt b/nested.a
64 RUN: llvm-ar t nested.a | FileCheck %s --check-prefix=NESTED --match-full-lines
68 NESTED-NEXT: b/foo.txt
72 RUN: llvm-ar rcST add.a a/foo.txt foo.txt b/foo.txt
73 RUN: llvm-ar p add.a foo.txt | FileCheck %s --check-prefix=PRINT-PARENT --match-full-lines
74 RUN: llvm-ar p add.a a/foo.txt | FileCheck %s --check-prefix=PRINT-A --match-full-lines
75 RUN: llvm-ar p add.a b/foo.txt | FileCheck %s --check-prefix=PRINT-B --match-full-lines
76 PRINT-PARENT: hello-parent
82 RUN: llvm-ar rcST add.a a/foo.txt foo.txt b/foo.txt
83 RUN: llvm-ar t add.a foo.txt | FileCheck %s --check-prefix=LIST-PARENT --match-full-lines
84 RUN: llvm-ar t add.a a/foo.txt | FileCheck %s --check-prefix=LIST-A --match-full-lines
85 RUN: llvm-ar t add.a b/foo.txt | FileCheck %s --check-prefix=LIST-B --match-full-lines
87 LIST-PARENT-NOT: a/foo.txt
88 LIST-PARENT-NOT: b/foo.txt
94 RUN: llvm-ar rcST del1.a a/foo.txt foo.txt b/foo.txt
95 RUN: llvm-ar d del1.a foo.txt
96 RUN: llvm-ar t del1.a | FileCheck %s --check-prefix=DEL-1 --match-full-lines
100 DEL-1-NEXT: b/foo.txt
103 RUN: llvm-ar rcST del2.a a/foo.txt foo.txt b/foo.txt
104 RUN: llvm-ar d del2.a a/foo.txt
105 RUN: llvm-ar t del2.a | FileCheck %s --check-prefix=DEL-2 --match-full-lines
108 DEL-2-NEXT: b/foo.txt