xref: /llvm-project/llvm/test/tools/llvm-ar/mri-create-overwrite.test (revision 52ddae132f8ccd646e93d42b69f1efd902ecb4f2)
1## Show that CREATE/CREATETHIN overwrite existing files appropriately.
2
3# RUN: rm -rf %t
4# RUN: split-file %s %t
5# RUN: cd %t
6
7## Show that an existing file that is not an archive is overwritten by CREATE.
8# RUN: touch test.a
9# RUN: llvm-ar -M < create.mri
10# RUN: FileCheck --input-file=test.a %s --check-prefixes=ARCH,TWO
11
12## Show that an existing file that is not an archive is overwritten by CREATETHIN.
13# RUN: rm -f test.a
14# RUN: touch test.a
15# RUN: llvm-ar --format=gnu -M < createthin.mri
16# RUN: FileCheck --input-file=test.a %s --check-prefixes=THIN,TWO
17
18## Show that an existing regular archive is overwritten by CREATE.
19# RUN: rm -f test.a
20# RUN: llvm-ar cr test.a 1.txt
21# RUN: llvm-ar -M < create.mri
22# RUN: llvm-ar tv test.a
23# RUN: FileCheck --input-file=test.a %s --check-prefixes=ARCH,TWO --implicit-check-not=1.txt
24
25## Show that an existing regular archive is overwritten by CREATETHIN.
26# RUN: rm -f test.a
27# RUN: llvm-ar --format=gnu cr test.a 1.txt
28# RUN: llvm-ar --format=gnu -M < createthin.mri
29# RUN: FileCheck --input-file=test.a %s --check-prefixes=THIN,TWO --implicit-check-not=1.txt
30
31## Show that an existing thin archive is overwritten by CREATE.
32# RUN: rm -f test.a
33# RUN: llvm-ar --format=gnu crT test.a 1.txt
34# RUN: llvm-ar --format=gnu -M < create.mri
35# RUN: FileCheck --input-file=test.a %s --check-prefixes=ARCH,TWO --implicit-check-not=1.txt
36
37## Show that an existing thin archive is overwritten by CREATETHIN.
38# RUN: rm -f test.a
39# RUN: llvm-ar --format=gnu crT test.a 1.txt
40# RUN: llvm-ar --format=gnu -M < createthin.mri
41# RUN: FileCheck --input-file=test.a %s --check-prefixes=THIN,TWO --implicit-check-not=1.txt
42
43## Show that the output is not overwritten without a SAVE.
44# RUN: rm -f test.a
45# RUN: llvm-ar --format=gnu crT test.a 1.txt
46# RUN: llvm-ar --format=gnu -M < nosave.mri
47# RUN: FileCheck --input-file=test.a %s --check-prefixes=THIN,ONE --implicit-check-not=2.txt
48
49# ARCH: {{!<arch>|<bigaf>}}
50# THIN: !<thin>
51# ONE:  1.txt
52# TWO:  2.txt
53
54#--- 1.txt
55
56#--- 2.txt
57
58#--- create.mri
59CREATE test.a
60ADDMOD 2.txt
61SAVE
62
63#--- createthin.mri
64CREATETHIN test.a
65ADDMOD 2.txt
66SAVE
67
68#--- nosave.mri
69CREATE test.a
70ADDMOD 2.txt
71