From: Joel Rosdahl Date: Sun, 4 Nov 2012 10:38:13 +0000 (+0100) Subject: Don't create cache subdirectories in read-only mode X-Git-Tag: v3.1.9~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd408e28e62c08011686f18ca41951f551d67873;p=thirdparty%2Fccache.git Don't create cache subdirectories in read-only mode --- diff --git a/ccache.c b/ccache.c index 738c022f3..50137d398 100644 --- a/ccache.c +++ b/ccache.c @@ -266,7 +266,7 @@ get_path_in_cache(const char *name, const char *suffix) char *p = format("%s/%c", path, name[i]); free(path); path = p; - if (create_dir(path) != 0) { + if (!getenv("CCACHE_READONLY") && create_dir(path) != 0) { fatal("Failed to create %s: %s", path, strerror(errno)); } } diff --git a/test.sh b/test.sh index afd73a40e..3ed90697b 100755 --- a/test.sh +++ b/test.sh @@ -1387,17 +1387,26 @@ readonly_suite() { # Make the cache readonly # Check that readonly mode finds the result. testname="cache hit" - rm -f test.o + rm -f test.o test2.o chmod -R a-w $CCACHE_DIR - CCACHE_READONLY=1 CCACHE_TEMPDIR=/tmp CCACHE_PREFIX=false $CCACHE $COMPILER -c test.c -o test.o - status=$? + CCACHE_READONLY=1 CCACHE_TEMPDIR=/tmp CCACHE_PREFIX=false $CCACHE $COMPILER -c test.c -o test.o >/dev/null 2>&1 + status1=$? + # Check that fallback to the real compiler works for a cache miss. + CCACHE_READONLY=1 CCACHE_TEMPDIR=/tmp $CCACHE $COMPILER -c test2.c -o test2.o >/dev/null 2>&1 + status2=$? chmod -R a+w $CCACHE_DIR - if [ $status -ne 0 ]; then + if [ $status1 -ne 0 ]; then test_failed "failure when compiling test.c readonly" fi + if [ $status2 -ne 0 ]; then + test_failed "failure when compiling test2.c readonly" + fi if [ ! -f test.o ]; then test_failed "test.o missing" fi + if [ ! -f test2.o ]; then + test_failed "test2.o missing" + fi # Check that readonly mode doesn't try to store new results. testname="cache miss"