blob: eb68e8dca481688b721a585c10f3df8b858e2eee [file] [log] [blame]
Rafael Espindola94803592013-07-12 19:34:24 +00001Test the 'u' option of llvm-ar
2
Kuba Mracek6965d512017-08-20 18:18:44 +00003RUN: rm -rf %t && mkdir -p %t && cd %t
Kuba Mracek3ef5d9d2017-08-20 18:31:30 +00004RUN: rm -f %t/tmp.a
Rafael Espindola94803592013-07-12 19:34:24 +00005
Rafael Espindola0878d702013-07-12 21:17:17 +00006Create a file named evenlen that is newer than the evenlen on the source dir.
Kuba Mracek3ef5d9d2017-08-20 18:31:30 +00007RUN: mkdir -p %t/tmp.older
8RUN: echo older > %t/tmp.older/evenlen
Chandler Carruth3c0e8fb2013-07-14 10:46:51 +00009
Kuba Mracek3ef5d9d2017-08-20 18:31:30 +000010RUN: mkdir -p %t/tmp.newer
NAKAMURA Takumib69b6b52015-12-07 23:15:57 +000011
Chandler Carruth3c0e8fb2013-07-14 10:46:51 +000012Either the shell supports the 'touch' command with a flag to manually set the
Rafael Espindola52ed7742015-07-14 16:34:23 +000013mtime or we sleep for over two seconds so that the mtime is definitely
14observable.
Kuba Mracek3ef5d9d2017-08-20 18:31:30 +000015RUN: touch -m -t 200001010000 %t/tmp.older/evenlen || sleep 2.1
Chandler Carruth3c0e8fb2013-07-14 10:46:51 +000016
Kuba Mracek3ef5d9d2017-08-20 18:31:30 +000017RUN: echo newer > %t/tmp.newer/evenlen
18RUN: touch %t/tmp.newer/evenlen
Rafael Espindola0878d702013-07-12 21:17:17 +000019
Rafael Espindola94803592013-07-12 19:34:24 +000020Create an achive with the newest file
Kuba Mracek3ef5d9d2017-08-20 18:31:30 +000021RUN: llvm-ar rU %t/tmp.a %t/tmp.newer/evenlen
22RUN: llvm-ar p %t/tmp.a | FileCheck --check-prefix=NEWER %s
Rafael Espindola94803592013-07-12 19:34:24 +000023
24Check that without the 'u' option the member is replaced with an older file.
Kuba Mracek3ef5d9d2017-08-20 18:31:30 +000025RUN: llvm-ar rU %t/tmp.a %t/tmp.older/evenlen
26RUN: llvm-ar p %t/tmp.a | FileCheck --check-prefix=OLDER %s
Rafael Espindola94803592013-07-12 19:34:24 +000027
28Check that with the 'u' option the member is replaced with a newer file.
Kuba Mracek3ef5d9d2017-08-20 18:31:30 +000029RUN: llvm-ar ruU %t/tmp.a %t/tmp.newer/evenlen
30RUN: llvm-ar p %t/tmp.a | FileCheck --check-prefix=NEWER %s
Rafael Espindola94803592013-07-12 19:34:24 +000031
32Check that with the 'u' option the member is not replaced with an older file.
Kuba Mracek3ef5d9d2017-08-20 18:31:30 +000033RUN: llvm-ar ruU %t/tmp.a %t/tmp.older/evenlen
34RUN: llvm-ar p %t/tmp.a | FileCheck --check-prefix=NEWER %s
Rafael Espindola94803592013-07-12 19:34:24 +000035
36NEWER: newer
Chandler Carruth3c0e8fb2013-07-14 10:46:51 +000037OLDER: older
Rafael Espindola8d1daf62015-07-15 20:45:56 +000038
Kuba Mracek3ef5d9d2017-08-20 18:31:30 +000039RUN: rm -f %t/tmp.a
Rafael Espindola8d1daf62015-07-15 20:45:56 +000040RUN: echo foo > foo
41RUN: echo bar > bar
Kuba Mracek3ef5d9d2017-08-20 18:31:30 +000042RUN: llvm-ar --format=gnu rcT %t/tmp.a foo
43RUN: llvm-ar --format=gnu rcT %t/tmp.a bar
44RUN: llvm-ar t %t/tmp.a | FileCheck --check-prefix=BOTH-FILES %s
Rafael Espindola8d1daf62015-07-15 20:45:56 +000045BOTH-FILES: foo
46BOTH-FILES: bar
47
Kuba Mracek3ef5d9d2017-08-20 18:31:30 +000048RUN: rm -f %t/tmp.a
49RUN: llvm-ar --format=gnu rc %t/tmp.a foo
50RUN: not llvm-ar --format=gnu rcT %t/tmp.a bar 2>&1 | FileCheck --check-prefix=ERROR %s
Rafael Espindola8d1daf62015-07-15 20:45:56 +000051ERROR: Cannot convert a regular archive to a thin one.