blob: fd1ea4113c39df95b223b0c036026ca2ef684777 [file] [log] [blame]
Rafael Espindola9cef2152013-07-12 19:34:24 +00001Test the 'u' option of llvm-ar
2
Rafael Espindola9cef2152013-07-12 19:34:24 +00003RUN: cd %T
4RUN: rm -f %t.a
5
Rafael Espindola04397c12013-07-12 21:17:17 +00006Create a file named evenlen that is newer than the evenlen on the source dir.
Chandler Carruthba310c42013-07-14 10:46:51 +00007RUN: mkdir -p %t.older
8RUN: echo older > %t.older/evenlen
9
NAKAMURA Takumib4398d82015-12-07 23:15:57 +000010RUN: mkdir -p %t.newer
11
Chandler Carruthba310c42013-07-14 10:46:51 +000012Either the shell supports the 'touch' command with a flag to manually set the
Rafael Espindola4ae78432015-07-14 16:34:23 +000013mtime or we sleep for over two seconds so that the mtime is definitely
14observable.
15RUN: touch -m -t 200001010000 %t.older/evenlen || sleep 2.1
Chandler Carruthba310c42013-07-14 10:46:51 +000016
Chandler Carruthba310c42013-07-14 10:46:51 +000017RUN: echo newer > %t.newer/evenlen
18RUN: touch %t.newer/evenlen
Rafael Espindola04397c12013-07-12 21:17:17 +000019
Rafael Espindola9cef2152013-07-12 19:34:24 +000020Create an achive with the newest file
Rafael Espindola6a8e86f2015-07-13 20:38:09 +000021RUN: llvm-ar rU %t.a %t.newer/evenlen
Rafael Espindola9cef2152013-07-12 19:34:24 +000022RUN: llvm-ar p %t.a | FileCheck --check-prefix=NEWER %s
23
24Check that without the 'u' option the member is replaced with an older file.
Rafael Espindola6a8e86f2015-07-13 20:38:09 +000025RUN: llvm-ar rU %t.a %t.older/evenlen
Rafael Espindola9cef2152013-07-12 19:34:24 +000026RUN: llvm-ar p %t.a | FileCheck --check-prefix=OLDER %s
27
28Check that with the 'u' option the member is replaced with a newer file.
Rafael Espindola6a8e86f2015-07-13 20:38:09 +000029RUN: llvm-ar ruU %t.a %t.newer/evenlen
Rafael Espindola9cef2152013-07-12 19:34:24 +000030RUN: llvm-ar p %t.a | FileCheck --check-prefix=NEWER %s
31
32Check that with the 'u' option the member is not replaced with an older file.
Rafael Espindola6a8e86f2015-07-13 20:38:09 +000033RUN: llvm-ar ruU %t.a %t.older/evenlen
Rafael Espindola9cef2152013-07-12 19:34:24 +000034RUN: llvm-ar p %t.a | FileCheck --check-prefix=NEWER %s
35
36NEWER: newer
Chandler Carruthba310c42013-07-14 10:46:51 +000037OLDER: older
Rafael Espindola449208d2015-07-15 20:45:56 +000038
39RUN: rm -f %t.a
40RUN: echo foo > foo
41RUN: echo bar > bar
42RUN: llvm-ar --format=gnu rcT %t.a foo
43RUN: llvm-ar --format=gnu rcT %t.a bar
44RUN: llvm-ar t %t.a | FileCheck --check-prefix=BOTH-FILES %s
45BOTH-FILES: foo
46BOTH-FILES: bar
47
48RUN: rm -f %t.a
49RUN: llvm-ar --format=gnu rc %t.a foo
50RUN: not llvm-ar --format=gnu rcT %t.a bar 2>&1 | FileCheck --check-prefix=ERROR %s
51ERROR: Cannot convert a regular archive to a thin one.