File: source_date_epoch.bash

package info (click to toggle)
ccache 4.13.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,420 kB
  • sloc: cpp: 50,251; asm: 28,570; sh: 9,632; ansic: 5,357; python: 834; perl: 68; makefile: 24
file content (99 lines) | stat: -rw-r--r-- 3,292 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
SUITE_source_date_epoch_PROBE() {
    echo 'char x[] = __DATE__;' >test.c
    if ! SOURCE_DATE_EPOCH=0 $COMPILER -E test.c | grep -q 1970; then
        echo "SOURCE_DATE_EPOCH not supported by compiler"
    fi
}

SUITE_source_date_epoch_SETUP() {
    echo 'char x;' >without_temporal_macros.c
    echo 'char x[] = __DATE__;' >with_date_macro.c
    echo 'char x[] = __TIME__;' >with_time_macro.c
}

SUITE_source_date_epoch() {
    # -------------------------------------------------------------------------
    TEST "Without temporal macro"

    unset CCACHE_NODIRECT

    SOURCE_DATE_EPOCH=1 $CCACHE_COMPILE -c without_temporal_macros.c
    expect_stat direct_cache_hit 0
    expect_stat preprocessed_cache_hit 0
    expect_stat cache_miss 1

    SOURCE_DATE_EPOCH=1 $CCACHE_COMPILE -c without_temporal_macros.c
    expect_stat direct_cache_hit 1
    expect_stat preprocessed_cache_hit 0
    expect_stat cache_miss 1

    SOURCE_DATE_EPOCH=2 $CCACHE_COMPILE -c without_temporal_macros.c
    expect_stat direct_cache_hit 2
    expect_stat preprocessed_cache_hit 0
    expect_stat cache_miss 1

    # -------------------------------------------------------------------------
    TEST "With __DATE__ macro"

    unset CCACHE_NODIRECT

    SOURCE_DATE_EPOCH=1 $CCACHE_COMPILE -c with_date_macro.c
    expect_stat direct_cache_hit 0
    expect_stat preprocessed_cache_hit 0
    expect_stat cache_miss 1

    SOURCE_DATE_EPOCH=1 $CCACHE_COMPILE -c with_date_macro.c
    expect_stat direct_cache_hit 1
    expect_stat preprocessed_cache_hit 0
    expect_stat cache_miss 1

    SOURCE_DATE_EPOCH=2 $CCACHE_COMPILE -c with_date_macro.c
    expect_stat direct_cache_hit 1
    expect_stat preprocessed_cache_hit 1
    expect_stat cache_miss 1

    # -------------------------------------------------------------------------
    TEST "With __TIME__ macro"

    unset CCACHE_NODIRECT

    SOURCE_DATE_EPOCH=1 $CCACHE_COMPILE -c with_time_macro.c
    expect_stat direct_cache_hit 0
    expect_stat preprocessed_cache_hit 0
    expect_stat cache_miss 1

    SOURCE_DATE_EPOCH=1 $CCACHE_COMPILE -c with_time_macro.c
    expect_stat direct_cache_hit 0
    expect_stat preprocessed_cache_hit 1
    expect_stat cache_miss 1

    SOURCE_DATE_EPOCH=2 $CCACHE_COMPILE -c with_time_macro.c
    expect_stat direct_cache_hit 0
    expect_stat preprocessed_cache_hit 1
    expect_stat cache_miss 2

    # -------------------------------------------------------------------------
    TEST "With __TIME__ and time_macros sloppiness"

    unset CCACHE_NODIRECT

    CCACHE_SLOPPINESS=time_macros SOURCE_DATE_EPOCH=1 $CCACHE_COMPILE -c with_time_macro.c
    expect_stat direct_cache_hit 0
    expect_stat preprocessed_cache_hit 0
    expect_stat cache_miss 1

    CCACHE_SLOPPINESS=time_macros SOURCE_DATE_EPOCH=1 $CCACHE_COMPILE -c with_time_macro.c
    expect_stat direct_cache_hit 1
    expect_stat preprocessed_cache_hit 0
    expect_stat cache_miss 1

    CCACHE_SLOPPINESS=time_macros SOURCE_DATE_EPOCH=2 $CCACHE_COMPILE -c with_time_macro.c
    expect_stat direct_cache_hit 2
    expect_stat preprocessed_cache_hit 0
    expect_stat cache_miss 1

    SOURCE_DATE_EPOCH=1 $CCACHE_COMPILE -c with_time_macro.c
    expect_stat direct_cache_hit 2
    expect_stat preprocessed_cache_hit 1
    expect_stat cache_miss 1
}