We were getting different results when converting "float" to
integers, on 32-bit versus 64-bit platforms. So use "roundf".
Also exposed a typo in another testsuite, where we only cleaned
files as a result of roundoff... Make cleaning explicit again.
#include "ccache.h"
+#include <float.h>
+#include <math.h>
+
static struct files {
char *fname;
time_t mtime;
// When "max files" or "max cache size" is reached, one of the 16 cache
// subdirectories is cleaned up. When doing so, files are deleted (in LRU
// order) until the levels are below limit_multiple.
- cache_size_threshold = conf->max_size * limit_multiple / 16;
- files_in_cache_threshold = conf->max_files * limit_multiple / 16;
+ cache_size_threshold = roundf(conf->max_size * limit_multiple / 16);
+ files_in_cache_threshold = roundf(conf->max_files * limit_multiple / 16);
num_files = 0;
cache_size = 0;
TEST ".o file is removed before .stderr"
prepare_cleanup_test_dir $CCACHE_DIR/a
- $CCACHE -F 474 -M 0 >/dev/null
+ $CCACHE -F 464 -M 0 >/dev/null
backdate 0 $CCACHE_DIR/a/result9-4017.stderr
$CCACHE -c >/dev/null
expect_file_missing $CCACHE_DIR/a/result9-4017.stderr
TEST ".stderr file is not removed before .o"
prepare_cleanup_test_dir $CCACHE_DIR/a
- $CCACHE -F 474 -M 0 >/dev/null
+ $CCACHE -F 464 -M 0 >/dev/null
backdate 0 $CCACHE_DIR/a/result9-4017.o
$CCACHE -c >/dev/null
expect_file_exists $CCACHE_DIR/a/result9-4017.stderr