Rafael Espindola | 9480359 | 2013-07-12 19:34:24 +0000 | [diff] [blame] | 1 | Test the 'u' option of llvm-ar |
| 2 | |
Kuba Mracek | 6965d51 | 2017-08-20 18:18:44 +0000 | [diff] [blame] | 3 | RUN: rm -rf %t && mkdir -p %t && cd %t |
Kuba Mracek | 3ef5d9d | 2017-08-20 18:31:30 +0000 | [diff] [blame] | 4 | RUN: rm -f %t/tmp.a |
Rafael Espindola | 9480359 | 2013-07-12 19:34:24 +0000 | [diff] [blame] | 5 | |
Rafael Espindola | 0878d70 | 2013-07-12 21:17:17 +0000 | [diff] [blame] | 6 | Create a file named evenlen that is newer than the evenlen on the source dir. |
Kuba Mracek | 3ef5d9d | 2017-08-20 18:31:30 +0000 | [diff] [blame] | 7 | RUN: mkdir -p %t/tmp.older |
| 8 | RUN: echo older > %t/tmp.older/evenlen |
Chandler Carruth | 3c0e8fb | 2013-07-14 10:46:51 +0000 | [diff] [blame] | 9 | |
Kuba Mracek | 3ef5d9d | 2017-08-20 18:31:30 +0000 | [diff] [blame] | 10 | RUN: mkdir -p %t/tmp.newer |
NAKAMURA Takumi | b69b6b5 | 2015-12-07 23:15:57 +0000 | [diff] [blame] | 11 | |
Chandler Carruth | 3c0e8fb | 2013-07-14 10:46:51 +0000 | [diff] [blame] | 12 | Either the shell supports the 'touch' command with a flag to manually set the |
Rafael Espindola | 52ed774 | 2015-07-14 16:34:23 +0000 | [diff] [blame] | 13 | mtime or we sleep for over two seconds so that the mtime is definitely |
| 14 | observable. |
Kuba Mracek | 3ef5d9d | 2017-08-20 18:31:30 +0000 | [diff] [blame] | 15 | RUN: touch -m -t 200001010000 %t/tmp.older/evenlen || sleep 2.1 |
Chandler Carruth | 3c0e8fb | 2013-07-14 10:46:51 +0000 | [diff] [blame] | 16 | |
Kuba Mracek | 3ef5d9d | 2017-08-20 18:31:30 +0000 | [diff] [blame] | 17 | RUN: echo newer > %t/tmp.newer/evenlen |
| 18 | RUN: touch %t/tmp.newer/evenlen |
Rafael Espindola | 0878d70 | 2013-07-12 21:17:17 +0000 | [diff] [blame] | 19 | |
Rafael Espindola | 9480359 | 2013-07-12 19:34:24 +0000 | [diff] [blame] | 20 | Create an achive with the newest file |
Kuba Mracek | 3ef5d9d | 2017-08-20 18:31:30 +0000 | [diff] [blame] | 21 | RUN: llvm-ar rU %t/tmp.a %t/tmp.newer/evenlen |
| 22 | RUN: llvm-ar p %t/tmp.a | FileCheck --check-prefix=NEWER %s |
Rafael Espindola | 9480359 | 2013-07-12 19:34:24 +0000 | [diff] [blame] | 23 | |
| 24 | Check that without the 'u' option the member is replaced with an older file. |
Kuba Mracek | 3ef5d9d | 2017-08-20 18:31:30 +0000 | [diff] [blame] | 25 | RUN: llvm-ar rU %t/tmp.a %t/tmp.older/evenlen |
| 26 | RUN: llvm-ar p %t/tmp.a | FileCheck --check-prefix=OLDER %s |
Rafael Espindola | 9480359 | 2013-07-12 19:34:24 +0000 | [diff] [blame] | 27 | |
| 28 | Check that with the 'u' option the member is replaced with a newer file. |
Kuba Mracek | 3ef5d9d | 2017-08-20 18:31:30 +0000 | [diff] [blame] | 29 | RUN: llvm-ar ruU %t/tmp.a %t/tmp.newer/evenlen |
| 30 | RUN: llvm-ar p %t/tmp.a | FileCheck --check-prefix=NEWER %s |
Rafael Espindola | 9480359 | 2013-07-12 19:34:24 +0000 | [diff] [blame] | 31 | |
| 32 | Check that with the 'u' option the member is not replaced with an older file. |
Kuba Mracek | 3ef5d9d | 2017-08-20 18:31:30 +0000 | [diff] [blame] | 33 | RUN: llvm-ar ruU %t/tmp.a %t/tmp.older/evenlen |
| 34 | RUN: llvm-ar p %t/tmp.a | FileCheck --check-prefix=NEWER %s |
Rafael Espindola | 9480359 | 2013-07-12 19:34:24 +0000 | [diff] [blame] | 35 | |
| 36 | NEWER: newer |
Chandler Carruth | 3c0e8fb | 2013-07-14 10:46:51 +0000 | [diff] [blame] | 37 | OLDER: older |
Rafael Espindola | 8d1daf6 | 2015-07-15 20:45:56 +0000 | [diff] [blame] | 38 | |
Kuba Mracek | 3ef5d9d | 2017-08-20 18:31:30 +0000 | [diff] [blame] | 39 | RUN: rm -f %t/tmp.a |
Rafael Espindola | 8d1daf6 | 2015-07-15 20:45:56 +0000 | [diff] [blame] | 40 | RUN: echo foo > foo |
| 41 | RUN: echo bar > bar |
Kuba Mracek | 3ef5d9d | 2017-08-20 18:31:30 +0000 | [diff] [blame] | 42 | RUN: llvm-ar --format=gnu rcT %t/tmp.a foo |
| 43 | RUN: llvm-ar --format=gnu rcT %t/tmp.a bar |
| 44 | RUN: llvm-ar t %t/tmp.a | FileCheck --check-prefix=BOTH-FILES %s |
Rafael Espindola | 8d1daf6 | 2015-07-15 20:45:56 +0000 | [diff] [blame] | 45 | BOTH-FILES: foo |
| 46 | BOTH-FILES: bar |
| 47 | |
Kuba Mracek | 3ef5d9d | 2017-08-20 18:31:30 +0000 | [diff] [blame] | 48 | RUN: rm -f %t/tmp.a |
| 49 | RUN: llvm-ar --format=gnu rc %t/tmp.a foo |
| 50 | RUN: not llvm-ar --format=gnu rcT %t/tmp.a bar 2>&1 | FileCheck --check-prefix=ERROR %s |
Rafael Espindola | 8d1daf6 | 2015-07-15 20:45:56 +0000 | [diff] [blame] | 51 | ERROR: Cannot convert a regular archive to a thin one. |