close(fd);
return 0;
}
+ if (st.st_size == 0) {
+ close(fd);
+ return 1;
+ }
data = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
close(fd);
if (data == (void *)-1) {
checkstat 'cache hit (preprocessed)' 0
checkstat 'cache miss' 2
+ ##################################################################
+ # Check that it's possible to compile and cache an empty source code file.
+ testname="empty source file"
+ $CCACHE -Cz >/dev/null
+ cp /dev/null empty.c
+ $CCACHE_COMPILE -c empty.c
+ checkstat 'cache hit (direct)' 0
+ checkstat 'cache hit (preprocessed)' 0
+ checkstat 'cache miss' 1
+ $CCACHE_COMPILE -c empty.c
+ checkstat 'cache hit (direct)' 1
+ checkstat 'cache hit (preprocessed)' 0
+ checkstat 'cache miss' 1
+
##################################################################
# Reset things.
CCACHE_NODIRECT=1