Skip to content

Commit

Permalink
Fix CCACHE_MAXSIZE with filesystem compression (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-volnov authored and jrosdahl committed Jul 21, 2019
1 parent fb0864d commit 14d4371
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 41 deletions.
20 changes: 10 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
7 changes: 1 addition & 6 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
51 changes: 26 additions & 25 deletions test/suites/cleanup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 14d4371

Please sign in to comment.