1## Test the -D and -U flags of llvm-ranlib 2## Create an archive with timestamps but without symbol table 3## Important: all `llvm-ar tv` calls must use TZ=UTC to produce identical values 4# RUN: yaml2obj %S/../llvm-ar/Inputs/add-lib1.yaml -o %t.o 5# RUN: env TZ=UTC touch -t 200001020304 %t.o 6# RUN: rm -f %t.a %t-no-index.a && llvm-ar cqSU %t-no-index.a %t.o 7 8## Check that the intial listing has real values: 9# RUN: env TZ=UTC llvm-ar tv %t-no-index.a | FileCheck %s --check-prefix=REAL-VALUES 10 11## Check that the -D flag clears the timestamps: 12# RUN: cp %t-no-index.a %t.a && llvm-ranlib -D %t.a 13# RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s --check-prefix=DETERMINISTIC-VALUES 14 15## Check that the -U flag maintains the timestamps: 16# RUN: cp %t-no-index.a %t.a && llvm-ranlib -U %t.a 17# RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s --check-prefix=REAL-VALUES 18 19## Check that we accept multiple values and the last one wins: 20# RUN: cp %t-no-index.a %t.a && llvm-ranlib -UDU %t.a 21# RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s --check-prefix=REAL-VALUES 22# RUN: cp %t-no-index.a %t.a && llvm-ranlib -UUD %t.a 23# RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s --check-prefix=DETERMINISTIC-VALUES 24 25## Check multiple archives can be specified and arguments can be specified anywhere. 26# RUN: cp %t-no-index.a %t.a && cp %t-no-index.a %t2.a 27# RUN: llvm-ranlib -U %t.a -D %t2.a -U 28# RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s --check-prefix=REAL-VALUES 29# RUN: env TZ=UTC llvm-ar tv %t2.a | FileCheck %s --check-prefix=REAL-VALUES 30 31## Check that the -D/-U option is only accepted with a single dash. This matches 32## the GNU ranlib behaviour. 33# RUN: not llvm-ranlib --D %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-D 34# BAD-OPT-D: error: Invalid option: '--D' 35# RUN: not llvm-ranlib --U %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-U 36# BAD-OPT-U: error: Invalid option: '--U' 37# RUN: not llvm-ranlib -x %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-x 38# BAD-OPT-x: error: Invalid option: '-x' 39 40## If the first argument starts with value flags, the error message only shows 41## the remainder of the parsed string: 42# RUN: not llvm-ranlib -Dx %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-x 43# RUN: not llvm-ranlib -DxD %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-xD 44# BAD-OPT-xD: error: Invalid option: '-xD' 45 46# DETERMINISTIC-VALUES: {{[-rwx]+}} 0/0 712 Jan 1 00:00 1970 D-flag.test.tmp.o 47# REAL-VALUES: {{[-rwx]+}} {{[0-9]+}}/{{[0-9]+}} 712 Jan 2 03:04 2000 D-flag.test.tmp.o 48