aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/tools/llvm-ar/mri-delete.test
blob: 37dc5a22835709c9aba9da92b8353507489f99ed (plain)
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# RUN: rm -rf %t && split-file %s %t
# RUN: cd %t

# RUN: yaml2obj %S/Inputs/elf.yaml -o elf.o
# RUN: llvm-ar -rc elf.a elf.o text.txt
# RUN: llvm-ar -rc --thin thin-elf.a elf.o text.txt

## Basic delete.
# RUN: llvm-ar -M < delete.mri
# RUN: llvm-ar tv delete.ar | FileCheck %s --check-prefixes=DELETE --implicit-check-not=elf.o

# DELETE: text.txt

## Delete so the archive is empty.
# RUN: llvm-ar -M < empty.mri
# RUN: llvm-ar tv empty.ar | FileCheck %s --check-prefixes=EMPTY --allow-empty

# EMPTY-NOT: elf.o

## Attempt to delete a file that is not in the archive.
# RUN: llvm-ar -M < bad.mri
# RUN: llvm-ar tv bad.ar | FileCheck %s --check-prefixes=BOTH

## Delete operation in a script with comments.
# RUN: llvm-ar -M < comment.mri
# RUN: llvm-ar tv comment.ar | FileCheck %s --check-prefixes=DELETE --implicit-check-not=elf.o

## Add a file that has been deleted.
# RUN: llvm-ar -M < re-add.mri
# RUN: llvm-ar tv re-add.ar | FileCheck %s --check-prefixes=BOTH

# BOTH-DAG: text.txt
# BOTH-DAG: elf.o

## Add the same file twice and delete them. It is expected behaviour
## that one delete command deletes all matching members.
# RUN: llvm-ar -M < duplicate.mri
# RUN: llvm-ar tv duplicate.ar | FileCheck %s --check-prefixes=DELETE --implicit-check-not=elf.o

## Add and delete the same file twice.
# RUN: llvm-ar -M < duplicate-re-add.mri
# RUN: llvm-ar tv duplicate-re-add.ar | FileCheck %s --check-prefixes=DELETE --implicit-check-not=elf.o

## Attempt to delete the same file twice.
# RUN: llvm-ar -M < extra-delete.mri
# RUN: llvm-ar tv extra-delete.ar | FileCheck %s --check-prefixes=DELETE --implicit-check-not=elf.o

## Add the same file to a thin archive twice.
# RUN: llvm-ar -M < thin-duplicate.mri
# RUN: llvm-ar tv thin-duplicate.ar | FileCheck %s --check-prefixes=DELETE --implicit-check-not=elf.o

## Delete a file after it was added via ADDLIB.
# RUN: llvm-ar -M < addlib.mri
# RUN: llvm-ar tv addlib.ar | FileCheck %s --check-prefixes=DELETE --implicit-check-not=elf.o

## Attempt to delete an archive after it was added via ADDLIB.
# RUN: llvm-ar -M < addlib-deletelib.mri
# RUN: llvm-ar tv addlib-deletelib.ar | FileCheck %s --check-prefixes=BOTH

## Add the same archive twice to a thin archive and then delete some members.
# RUN: llvm-ar -M < addlib-thin-duplicate.mri
# RUN: llvm-ar tv addlib-thin-duplicate.ar | FileCheck %s --check-prefixes=DELETE --implicit-check-not=elf.o

#--- text.txt
I AM A TEXT FILE

#--- delete.mri
create delete.ar
addmod text.txt
addmod elf.o
delete elf.o
save
end

#--- empty.mri
create empty.ar
addmod elf.o
delete elf.o
save
end

#--- bad.mri
create bad.ar
addmod text.txt
addmod elf.o
delete bad.o
save
end

#--- comment.mri
create comment.ar
addmod elf.o
; comment
addmod text.txt
 ;comment
delete elf.o
* comment
save
 *comment
end

#--- re-add.mri
create re-add.ar
addmod elf.o
addmod text.txt
delete elf.o
addmod elf.o
save
end

#--- duplicate.mri
create duplicate.ar
addmod elf.o
addmod elf.o
addmod text.txt
delete elf.o
save
end

#--- duplicate-re-add.mri
create duplicate-re-add.ar
addmod elf.o
delete elf.o
addmod text.txt
addmod elf.o
delete elf.o
save
end

#--- extra-delete.mri
create extra-delete.ar
addmod elf.o
addmod text.txt
delete elf.o
delete elf.o
save
end

#--- thin-duplicate.mri
createthin thin-duplicate.ar
addmod elf.o
addmod elf.o
addmod text.txt
delete elf.o
save
end

#--- addlib.mri
create addlib.ar
addlib elf.a
delete elf.o
save
end

#--- addlib-deletelib.mri
create addlib-deletelib.ar
addlib elf.a
delete elf.a
save
end

#--- addlib-thin-duplicate.mri
createthin addlib-thin-duplicate.ar
addlib thin-elf.a
addlib thin-elf.a
delete elf.o
save
end