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));
}
}
# 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"