ef1a71f60f435ff6062878477db69ed51152d53e
[oota-llvm.git] / test / Object / archive-update.test
1 Test the 'u' option of llvm-ar
2
3 RUN: cd %T
4 RUN: rm -f %t.a
5
6 Create a file named evenlen that is newer than the evenlen on the source dir.
7 RUN: mkdir -p %t.older
8 RUN: echo older > %t.older/evenlen
9
10 Either the shell supports the 'touch' command with a flag to manually set the
11 mtime or we sleep for over two seconds so that the mtime is definitely
12 observable.
13 RUN: touch -m -t 200001010000 %t.older/evenlen || sleep 2.1
14
15 RUN: mkdir -p %t.newer
16 RUN: echo newer > %t.newer/evenlen
17 RUN: touch %t.newer/evenlen
18
19 Create an achive with the newest file
20 RUN: llvm-ar rU %t.a %t.newer/evenlen
21 RUN: llvm-ar p %t.a | FileCheck --check-prefix=NEWER %s
22
23 Check that without the 'u' option the member is replaced with an older file.
24 RUN: llvm-ar rU %t.a %t.older/evenlen
25 RUN: llvm-ar p %t.a | FileCheck --check-prefix=OLDER %s
26
27 Check that with the 'u' option the member is replaced with a newer file.
28 RUN: llvm-ar ruU %t.a %t.newer/evenlen
29 RUN: llvm-ar p %t.a | FileCheck --check-prefix=NEWER %s
30
31 Check that with the 'u' option the member is not replaced with an older file.
32 RUN: llvm-ar ruU %t.a %t.older/evenlen
33 RUN: llvm-ar p %t.a | FileCheck --check-prefix=NEWER %s
34
35 NEWER: newer
36 OLDER: older
37
38 RUN: rm -f %t.a
39 RUN: echo foo > foo
40 RUN: echo bar > bar
41 RUN: llvm-ar --format=gnu rcT %t.a foo
42 RUN: llvm-ar --format=gnu rcT %t.a bar
43 RUN: llvm-ar t %t.a | FileCheck --check-prefix=BOTH-FILES %s
44 BOTH-FILES: foo
45 BOTH-FILES: bar
46
47 RUN: rm -f %t.a
48 RUN: llvm-ar --format=gnu rc %t.a foo
49 RUN: not llvm-ar --format=gnu rcT %t.a bar 2>&1 | FileCheck --check-prefix=ERROR %s
50 ERROR: Cannot convert a regular archive to a thin one.