xref: /aosp_15_r20/external/llvm/test/Object/archive-update.test (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard WorkerTest the 'u' option of llvm-ar
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard WorkerRUN: cd %T
4*9880d681SAndroid Build Coastguard WorkerRUN: rm -f %t.a
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard WorkerCreate a file named evenlen that is newer than the evenlen on the source dir.
7*9880d681SAndroid Build Coastguard WorkerRUN: mkdir -p %t.older
8*9880d681SAndroid Build Coastguard WorkerRUN: echo older > %t.older/evenlen
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard WorkerRUN: mkdir -p %t.newer
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard WorkerEither the shell supports the 'touch' command with a flag to manually set the
13*9880d681SAndroid Build Coastguard Workermtime or we sleep for over two seconds so that the mtime is definitely
14*9880d681SAndroid Build Coastguard Workerobservable.
15*9880d681SAndroid Build Coastguard WorkerRUN: touch -m -t 200001010000 %t.older/evenlen || sleep 2.1
16*9880d681SAndroid Build Coastguard Worker
17*9880d681SAndroid Build Coastguard WorkerRUN: echo newer > %t.newer/evenlen
18*9880d681SAndroid Build Coastguard WorkerRUN: touch %t.newer/evenlen
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard WorkerCreate an achive with the newest file
21*9880d681SAndroid Build Coastguard WorkerRUN: llvm-ar rU %t.a %t.newer/evenlen
22*9880d681SAndroid Build Coastguard WorkerRUN: llvm-ar p %t.a | FileCheck --check-prefix=NEWER %s
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard WorkerCheck that without the 'u' option the member is replaced with an older file.
25*9880d681SAndroid Build Coastguard WorkerRUN: llvm-ar rU %t.a %t.older/evenlen
26*9880d681SAndroid Build Coastguard WorkerRUN: llvm-ar p %t.a | FileCheck --check-prefix=OLDER %s
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard WorkerCheck that with the 'u' option the member is replaced with a newer file.
29*9880d681SAndroid Build Coastguard WorkerRUN: llvm-ar ruU %t.a %t.newer/evenlen
30*9880d681SAndroid Build Coastguard WorkerRUN: llvm-ar p %t.a | FileCheck --check-prefix=NEWER %s
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard WorkerCheck that with the 'u' option the member is not replaced with an older file.
33*9880d681SAndroid Build Coastguard WorkerRUN: llvm-ar ruU %t.a %t.older/evenlen
34*9880d681SAndroid Build Coastguard WorkerRUN: llvm-ar p %t.a | FileCheck --check-prefix=NEWER %s
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard WorkerNEWER: newer
37*9880d681SAndroid Build Coastguard WorkerOLDER: older
38*9880d681SAndroid Build Coastguard Worker
39*9880d681SAndroid Build Coastguard WorkerRUN: rm -f %t.a
40*9880d681SAndroid Build Coastguard WorkerRUN: echo foo > foo
41*9880d681SAndroid Build Coastguard WorkerRUN: echo bar > bar
42*9880d681SAndroid Build Coastguard WorkerRUN: llvm-ar --format=gnu rcT %t.a foo
43*9880d681SAndroid Build Coastguard WorkerRUN: llvm-ar --format=gnu rcT %t.a bar
44*9880d681SAndroid Build Coastguard WorkerRUN: llvm-ar t %t.a | FileCheck --check-prefix=BOTH-FILES %s
45*9880d681SAndroid Build Coastguard WorkerBOTH-FILES: foo
46*9880d681SAndroid Build Coastguard WorkerBOTH-FILES: bar
47*9880d681SAndroid Build Coastguard Worker
48*9880d681SAndroid Build Coastguard WorkerRUN: rm -f %t.a
49*9880d681SAndroid Build Coastguard WorkerRUN: llvm-ar --format=gnu rc %t.a foo
50*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-ar --format=gnu rcT %t.a bar 2>&1 | FileCheck --check-prefix=ERROR %s
51*9880d681SAndroid Build Coastguard WorkerERROR: Cannot convert a regular archive to a thin one.
52