File: trim_dir.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 (42 lines) | stat: -rw-r--r-- 1,215 bytes parent folder | download | duplicates (3)
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
SUITE_trim_dir() {
    # -------------------------------------------------------------------------
    TEST "Trim remote cache directory"

    if $HOST_OS_APPLE; then
        one_mb=1m
    else
        one_mb=1M
    fi
    for subdir in aa bb cc; do
        mkdir -p remote/$subdir
        dd if=/dev/zero of=remote/$subdir/1 count=1 bs=$one_mb 2>/dev/null
        dd if=/dev/zero of=remote/$subdir/2 count=1 bs=$one_mb 2>/dev/null
    done

    backdate remote/bb/2 remote/cc/1
    $CCACHE --trim-dir remote --trim-max-size 4.5M --trim-method mtime \
            >/dev/null

    expect_exists remote/aa/1
    expect_exists remote/aa/2
    expect_exists remote/bb/1
    expect_missing remote/bb/2
    expect_missing remote/cc/1
    expect_exists remote/cc/2

    # -------------------------------------------------------------------------
    TEST "Trim local cache directory"

    mkdir -p local/0
    touch local/0/stats
    if $CCACHE --trim-dir local --trim-max-size 0 &>/dev/null; then
        test_failed "Expected failure"
    fi

    rm -rf local
    mkdir local
    touch local/ccache.conf
    if $CCACHE --trim-dir local --trim-max-size 0 &>/dev/null; then
        test_failed "Expected failure"
    fi
}