xref: /llvm-project/llvm/test/tools/llvm-libtool-darwin/deterministic-library.test (revision bd0bddc1ea72183813d49508c8b4e73920869ea5)
1## This test checks that timestamps are set to 0 by default or when the -D
2## option is specified, and that they are preserved when the -U option is
3## specified.
4## We only test timestamps as a proxy for full deterministic writing; i.e. we
5## assume UID/GIDs are preserved if timestamps are preserved.
6
7# RUN: yaml2obj %S/Inputs/input1.yaml -o %t-input1.o
8# RUN: touch -t 199505050555.55 %t-input1.o
9
10## Test values are set to 0 (by default):
11# RUN: llvm-libtool-darwin -static -o %t.lib %t-input1.o
12# RUN: env TZ=GMT llvm-ar tv %t.lib | FileCheck %s --check-prefix=CHECK-DETERMINISTIC
13
14## Test values are set to 0 (with -D):
15# RUN: llvm-libtool-darwin -static -o %t.lib -D %t-input1.o
16# RUN: env TZ=GMT llvm-ar tv %t.lib | FileCheck %s --check-prefix=CHECK-DETERMINISTIC
17
18# CHECK-DETERMINISTIC: {{[[:space:]]1970[[:space:]]}}
19
20## Test values are preserved (with -U):
21# RUN: llvm-libtool-darwin -static -o %t.lib -U %t-input1.o
22# RUN: env TZ=GMT llvm-ar tv %t.lib | FileCheck %s --check-prefix=CHECK-NONDETERMINISTIC
23
24# CHECK-NONDETERMINISTIC:  {{[[:space:]]1995[[:space:]]}}
25
26## D Flag specified more than once:
27# RUN: llvm-libtool-darwin -static -o %t.lib %t-input1.o -D -D 2>&1 | count 0
28# RUN: env TZ=GMT llvm-ar tv %t.lib | FileCheck %s --check-prefix=CHECK-DETERMINISTIC
29
30## U Flag specified more than once:
31# RUN: llvm-libtool-darwin -static -o %t.lib %t-input1.o -U -U 2>&1 | count 0
32# RUN: env TZ=GMT llvm-ar tv %t.lib | FileCheck %s --check-prefix=CHECK-NONDETERMINISTIC
33
34## Both D and U flags specified:
35# RUN: not llvm-libtool-darwin -static -o %t.lib %t-input1.o -D -U 2>&1 | \
36# RUN:   FileCheck %s --check-prefix=CHECK-ERROR-BOTH
37
38# CHECK-ERROR-BOTH: error: cannot specify both -D and -U flags
39