full-path-option.test
3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Note: many of these tests depend on relative paths, so we have to cd to a
# test directory first.
RUN: mkdir -p %t && cd %t
RUN: rm -rf a b && mkdir a b
RUN: echo hello-a > a/foo.txt
RUN: echo hello-b > b/foo.txt
RUN: echo hello-parent > foo.txt
# Sanity test that P is accepted.
RUN: rm -f noop.a && llvm-ar rcP noop.a foo.txt
RUN: llvm-ar p noop.a | FileCheck %s --check-prefix=ACCEPT
ACCEPT: hello-parent
# Regular (non-thin) archives cannot be created with full path names as
# members, but P can still affect how lookup works (assuming we're reading an
# archive not created by GNU ar or llvm-ar).
# Looking up a/foo.txt in a regular archive will fail with P because it is
# added to the archive as foo.txt.
RUN: rm -f display.a
RUN: llvm-ar rcS display.a a/foo.txt foo.txt b/foo.txt
RUN: llvm-ar t display.a a/foo.txt | FileCheck %s --check-prefix=DISPLAY-FOUND --match-full-lines
RUN: not llvm-ar tP display.a a/foo.txt 2>&1 | FileCheck %s --check-prefix=DISPLAY-NOT-FOUND
DISPLAY-FOUND: foo.txt
DISPLAY-NOT-FOUND: 'a/foo.txt' was not found
# Deleting will fail with P because the members exist as foo.txt, not a/foo.txt.
RUN: rm -f del1.a
RUN: llvm-ar rcS del1.a foo.txt
RUN: llvm-ar dP del1.a a/foo.txt
RUN: llvm-ar t del1.a a/foo.txt | FileCheck %s --check-prefix=DISPLAY-FOUND --match-full-lines
RUN: llvm-ar d del1.a a/foo.txt
RUN: not llvm-ar t del1.a a/foo.txt 2>&1 | FileCheck %s --check-prefix=DISPLAY-NOT-FOUND
# Run several checks that P is implied when using thin archives. None of these
# checks explicitly use P.
# Creating an archive in one step.
RUN: rm -f add.a
RUN: llvm-ar rcST add.a a/foo.txt foo.txt b/foo.txt
RUN: llvm-ar t add.a | FileCheck %s --check-prefix=ADD --match-full-lines
ADD: a/foo.txt
ADD-NEXT: foo.txt
ADD-NEXT: b/foo.txt
# Create an archive incrementally.
RUN: rm -f add-inc.a
RUN: llvm-ar rcST add-inc.a a/foo.txt
RUN: llvm-ar rcST add-inc.a foo.txt
RUN: llvm-ar rcST add-inc.a b/foo.txt
RUN: llvm-ar t add-inc.a | FileCheck %s --check-prefix=ADD-INC --match-full-lines
ADD-INC: a/foo.txt
ADD-INC-NEXT: foo.txt
ADD-INC-NEXT: b/foo.txt
# Nesting a thin archive with a name conflict.
RUN: rm -f a/nested.a b/nested.a nested.a
RUN: llvm-ar rcST a/nested.a a/foo.txt
RUN: llvm-ar rcST b/nested.a b/foo.txt
RUN: llvm-ar rcST nested.a a/nested.a foo.txt b/nested.a
RUN: llvm-ar t nested.a | FileCheck %s --check-prefix=NESTED --match-full-lines
NESTED: a/foo.txt
NESTED-NEXT: foo.txt
NESTED-NEXT: b/foo.txt
# Printing members.
RUN: rm -f add.a
RUN: llvm-ar rcST add.a a/foo.txt foo.txt b/foo.txt
RUN: llvm-ar p add.a foo.txt | FileCheck %s --check-prefix=PRINT-PARENT --match-full-lines
RUN: llvm-ar p add.a a/foo.txt | FileCheck %s --check-prefix=PRINT-A --match-full-lines
RUN: llvm-ar p add.a b/foo.txt | FileCheck %s --check-prefix=PRINT-B --match-full-lines
PRINT-PARENT: hello-parent
PRINT-A: hello-a
PRINT-B: hello-b
# Listing members.
RUN: rm -f add.a
RUN: llvm-ar rcST add.a a/foo.txt foo.txt b/foo.txt
RUN: llvm-ar t add.a foo.txt | FileCheck %s --check-prefix=LIST-PARENT --match-full-lines
RUN: llvm-ar t add.a a/foo.txt | FileCheck %s --check-prefix=LIST-A --match-full-lines
RUN: llvm-ar t add.a b/foo.txt | FileCheck %s --check-prefix=LIST-B --match-full-lines
LIST-PARENT: foo.txt
LIST-PARENT-NOT: a/foo.txt
LIST-PARENT-NOT: b/foo.txt
LIST-A: a/foo.txt
LIST-B: b/foo.txt
# Deleting members.
RUN: rm -f del1.a
RUN: llvm-ar rcST del1.a a/foo.txt foo.txt b/foo.txt
RUN: llvm-ar d del1.a foo.txt
RUN: llvm-ar t del1.a | FileCheck %s --check-prefix=DEL-1 --match-full-lines
DEL-1-NOT: foo.txt
DEL-1: a/foo.txt
DEL-1-NEXT: b/foo.txt
RUN: rm -f del2.a
RUN: llvm-ar rcST del2.a a/foo.txt foo.txt b/foo.txt
RUN: llvm-ar d del2.a a/foo.txt
RUN: llvm-ar t del2.a | FileCheck %s --check-prefix=DEL-2 --match-full-lines
DEL-2-NOT: a/foo.txt
DEL-2: foo.txt
DEL-2-NEXT: b/foo.txt