]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Fix CCACHE_MAXSIZE with filesystem compression (#444)
authorIvan Volnov <51086293+ivan-volnov@users.noreply.github.com>
Sun, 21 Jul 2019 20:57:51 +0000 (04:57 +0800)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 21 Jul 2019 20:57:51 +0000 (22:57 +0200)
.travis.yml
src/util.c
test/suites/cleanup.bash

index f2f2959088c75c12cf359d65710781fb05280630..42d20186241b1f06984e8d6ee4db99126d592ef3 100644 (file)
@@ -13,7 +13,7 @@ matrix:
   # Job 1: Linux native GCC
   - os: linux
     compiler: gcc
-    env: V=1
+    env: V=1 ENABLE_CACHE_CLEANUP_TESTS=1
     addons:
       apt:
         packages:
@@ -24,7 +24,7 @@ matrix:
   # Job 2: Linux native Clang
   - os: linux
     compiler: clang
-    env: V=1
+    env: V=1 ENABLE_CACHE_CLEANUP_TESTS=1
     addons:
       apt:
         packages:
@@ -35,12 +35,12 @@ matrix:
   # Job 3: Mac OS X native Clang
   - os: osx
     compiler: clang
-    env: V=1 CONFIGURE="--with-libzstd-from-internet"
+    env: V=1 CONFIGURE="--with-libzstd-from-internet" ENABLE_CACHE_CLEANUP_TESTS=1
 
   # Job 4: Linux 32-bit native
   - os: linux
     compiler: gcc
-    env: V=1 CFLAGS="-m32 -g -O2" LDFLAGS="-m32" CONFIGURE="--host=i386-linux-gnu --with-libzstd-from-internet"
+    env: V=1 CFLAGS="-m32 -g -O2" LDFLAGS="-m32" CONFIGURE="--host=i386-linux-gnu --with-libzstd-from-internet" ENABLE_CACHE_CLEANUP_TESTS=1
     addons:
       apt:
         packages:
@@ -50,7 +50,7 @@ matrix:
   # Job 5: Linux cross-compiled 32-bit MinGW
   - os: linux
     compiler: i686-w64-mingw32-gcc
-    env: V=1 CONFIGURE="--host=i686-w64-mingw32 --with-libzstd-from-internet" TEST="unittest/run.exe"
+    env: V=1 CONFIGURE="--host=i686-w64-mingw32 --with-libzstd-from-internet" TEST="unittest/run.exe" ENABLE_CACHE_CLEANUP_TESTS=1
     addons:
       apt:
         packages:
@@ -60,7 +60,7 @@ matrix:
   # Job 6: Linux cross-compiled 64-bit MinGW
   - os: linux
     compiler: x86_64-w64-mingw32-gcc
-    env: V=1 CONFIGURE="--host=x86_64-w64-mingw32 --with-libzstd-from-internet" TEST="unittest/run.exe"
+    env: V=1 CONFIGURE="--host=x86_64-w64-mingw32 --with-libzstd-from-internet" TEST="unittest/run.exe" ENABLE_CACHE_CLEANUP_TESTS=1
     addons:
       apt:
         packages:
@@ -70,7 +70,7 @@ matrix:
   # Job 7: Clang's undefined behavior sanitizer (UBSan)
   - os: linux
     compiler: clang
-    env: V=1 CFLAGS="-fsanitize=undefined" LDFLAGS="-fsanitize=undefined" ASAN_OPTIONS="detect_leaks=0"
+    env: V=1 CFLAGS="-fsanitize=undefined" LDFLAGS="-fsanitize=undefined" ASAN_OPTIONS="detect_leaks=0" ENABLE_CACHE_CLEANUP_TESTS=1
     addons:
       apt:
         packages:
@@ -81,7 +81,7 @@ matrix:
   # Job 8: Clang's address sanitizer
   - os: linux
     compiler: clang
-    env: V=1 CFLAGS="-fsanitize=address -g" LDFLAGS="-fsanitize=address" ASAN_OPTIONS="detect_leaks=0"
+    env: V=1 CFLAGS="-fsanitize=address -g" LDFLAGS="-fsanitize=address" ASAN_OPTIONS="detect_leaks=0" ENABLE_CACHE_CLEANUP_TESTS=1
     addons:
       apt:
         packages:
@@ -92,7 +92,7 @@ matrix:
   # Job 9: Clang static analyzer
   - os: linux
     compiler: clang
-    env: V=1 PATH="/usr/bin:$PATH" TEST=analyze
+    env: V=1 PATH="/usr/bin:$PATH" TEST=analyze ENABLE_CACHE_CLEANUP_TESTS=1
     addons:
       apt:
         packages:
@@ -103,7 +103,7 @@ matrix:
   # Job 10: Linux GCC with CUDA compiler
   - os: linux
     compiler: gcc
-    env: V=1 CUDA=8.0.61-1
+    env: V=1 CUDA=8.0.61-1 ENABLE_CACHE_CLEANUP_TESTS=1
     sudo: required
     addons:
       apt:
index 9b7520a561269484afd63f341f5cc20811ebf007..2e5d5d41e4cb93900378bc24b4083da80e1bccc6 100644 (file)
@@ -972,12 +972,7 @@ file_size(struct stat *st)
 #ifdef _WIN32
        return (st->st_size + 1023) & ~1023;
 #else
-       size_t size = st->st_blocks * 512;
-       if ((size_t)st->st_size > size) {
-               // Probably a broken stat() call...
-               size = (st->st_size + 1023) & ~1023;
-       }
-       return size;
+       return st->st_blocks * 512;
 #endif
 }
 
index cc3ca42ebf569a2596fa83b3e2e3d0747aef54ec..af2f4f7afc20c98dae411bc3901076dd2dcbad10 100644 (file)
@@ -65,31 +65,32 @@ SUITE_cleanup() {
     done
 
     # -------------------------------------------------------------------------
-    TEST "Forced cache cleanup, size limit"
-
-    # NOTE: This test is known to fail on filesystems that have unusual block
-    # sizes, including ecryptfs. The workaround is to place the test directory
-    # elsewhere:
-    #
-    #     cd /tmp
-    #     CCACHE=$DIR/ccache $DIR/test.sh
-
-    prepare_cleanup_test_dir $CCACHE_DIR/a
-
-    $CCACHE -F 0 -M 256K >/dev/null
-    $CCACHE -c >/dev/null
-    expect_file_count 3 '*.result' $CCACHE_DIR
-    expect_stat 'files in cache' 3
-    expect_stat 'cleanups performed' 1
-    for i in 0 1 2 3 4 5 6; do
-        file=$CCACHE_DIR/a/result$i-4017.result
-        expect_file_missing $file
-    done
-    for i in 7 8 9; do
-        file=$CCACHE_DIR/a/result$i-4017.result
-        expect_file_exists $file
-    done
-
+    if [ -n "$ENABLE_CACHE_CLEANUP_TESTS" ]; then
+        TEST "Forced cache cleanup, size limit"
+
+        # NOTE: This test is known to fail on filesystems that have unusual block
+        # sizes, including ecryptfs. The workaround is to place the test directory
+        # elsewhere:
+        #
+        #     cd /tmp
+        #     CCACHE=$DIR/ccache $DIR/test.sh
+
+        prepare_cleanup_test_dir $CCACHE_DIR/a
+
+        $CCACHE -F 0 -M 256K >/dev/null
+        $CCACHE -c >/dev/null
+        expect_file_count 3 '*.result' $CCACHE_DIR
+        expect_stat 'files in cache' 3
+        expect_stat 'cleanups performed' 1
+        for i in 0 1 2 3 4 5 6; do
+            file=$CCACHE_DIR/a/result$i-4017.result
+            expect_file_missing $file
+        done
+        for i in 7 8 9; do
+            file=$CCACHE_DIR/a/result$i-4017.result
+            expect_file_exists $file
+        done
+    fi
     # -------------------------------------------------------------------------
     TEST "Automatic cache cleanup, limit_multiple 0.9"