diff options
author | David Givone <david@givone.net> | 2012-09-09 16:55:37 -0700 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2012-10-08 21:05:32 +0200 |
commit | 6cca82a5bacfeee5952062388e33a1d5997d04a3 (patch) | |
tree | 6e9271139e55889ffd60249bb254a3642c88bd51 /test.sh | |
parent | a46c996deeea228bba5c52405ad0b98875da1076 (diff) | |
download | ccache-6cca82a5bacfeee5952062388e33a1d5997d04a3.tar.gz |
Add object file comparison check for numerous tests
Comparing the output of ccache and direct compilation is a useful check to
make sure we are creating the same object file. It is especially useful
when performing 2 stage compilation like ccache does when CCACHE_CPP2 is
not set.
Diffstat (limited to 'test.sh')
-rwxr-xr-x | test.sh | 54 |
1 files changed, 54 insertions, 0 deletions
@@ -80,6 +80,15 @@ checkstat() { fi } +compare_file() { + cmp -s "$1" "$2" + if [ $? -eq 0 ]; then + : + else + test_failed "Files differ: $1 != $2" + fi +} + checkfile() { if [ ! -f $1 ]; then test_failed "$1 not found" @@ -140,17 +149,21 @@ base_tests() { j=`expr $j + 1` done + $DIRECT_COMPILE -c -o compiler_direct_test1.o test1.c + testname="BASIC" $CCACHE_COMPILE -c test1.c checkstat 'cache hit (preprocessed)' 0 checkstat 'cache miss' 1 checkstat 'files in cache' 1 + compare_file compiler_direct_test1.o test1.o testname="BASIC2" $CCACHE_COMPILE -c test1.c checkstat 'cache hit (preprocessed)' 1 checkstat 'cache miss' 1 checkstat 'files in cache' 1 + compare_file compiler_direct_test1.o test1.o testname="debug" $CCACHE_COMPILE -c test1.c -g @@ -167,6 +180,7 @@ base_tests() { $CCACHE_COMPILE -c test1.c -o foo.o checkstat 'cache hit (preprocessed)' 3 checkstat 'cache miss' 2 + compare_file compiler_direct_test1.o foo.o testname="link" $CCACHE_COMPILE test1.c -o test 2> /dev/null @@ -225,10 +239,13 @@ base_tests() { CCACHE_CPP2=1 $CCACHE_COMPILE -c test1.c -O -O checkstat 'cache hit (preprocessed)' 4 checkstat 'cache miss' 3 + $DIRECT_COMPILE -c test1.c -o compiler_direct_test1.o -O -O + compare_file compiler_direct_test1.o test1.o CCACHE_CPP2=1 $CCACHE_COMPILE -c test1.c -O -O checkstat 'cache hit (preprocessed)' 5 checkstat 'cache miss' 3 + compare_file compiler_direct_test1.o test1.o testname="CCACHE_NOSTATS" CCACHE_NOSTATS=1 $CCACHE_COMPILE -c test1.c -O -O @@ -239,6 +256,7 @@ base_tests() { CCACHE_RECACHE=1 $CCACHE_COMPILE -c test1.c -O -O checkstat 'cache hit (preprocessed)' 5 checkstat 'cache miss' 4 + compare_file compiler_direct_test1.o test1.o # strictly speaking should be 3 - RECACHE causes a double counting! checkstat 'files in cache' 4 @@ -249,11 +267,13 @@ base_tests() { CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -O -O checkstat 'cache hit (preprocessed)' 5 checkstat 'cache miss' 5 + compare_file compiler_direct_test1.o test1.o CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -O -O checkstat 'cache hit (preprocessed)' 6 checkstat 'cache miss' 5 checkstat 'files in cache' 4 + compare_file compiler_direct_test1.o test1.o testname="comments" echo '/* a silly comment */' > test1-comment.c @@ -274,6 +294,9 @@ base_tests() { mv test1-saved.c test1.c checkstat 'cache hit (preprocessed)' 7 checkstat 'cache miss' 7 + $DIRECT_COMPILE -c test1.c -o compiler_direct_test1.o + compare_file compiler_direct_test1.o test1.o + testname="cache-size" for f in *.c; do @@ -752,6 +775,8 @@ EOF checkstat 'cache hit (preprocessed)' 0 checkstat 'cache miss' 1 checkfile other.d "test.o: test.c test1.h test3.h test2.h" + $DIRECT_COMPILE -c -Wp,-MD,other.d test.c -o compiler_direct_test.o + compare_file compiler_direct_test.o test.o rm -f other.d @@ -760,6 +785,7 @@ EOF checkstat 'cache hit (preprocessed)' 0 checkstat 'cache miss' 1 checkfile other.d "test.o: test.c test1.h test3.h test2.h" + compare_file compiler_direct_test.o test.o rm -f other.d @@ -773,6 +799,8 @@ EOF checkstat 'cache hit (preprocessed)' 0 checkstat 'cache miss' 1 checkfile other.d "test.o: test.c test1.h test3.h test2.h" + $DIRECT_COMPILE -c -Wp,-MMD,other.d test.c -o compiler_direct_test.o + compare_file compiler_direct_test.o test.o rm -f other.d @@ -781,6 +809,7 @@ EOF checkstat 'cache hit (preprocessed)' 0 checkstat 'cache miss' 1 checkfile other.d "test.o: test.c test1.h test3.h test2.h" + compare_file compiler_direct_test.o test.o rm -f other.d @@ -794,11 +823,14 @@ EOF checkstat 'cache hit (direct)' 0 checkstat 'cache hit (preprocessed)' 0 checkstat 'cache miss' 1 + $DIRECT_COMPILE -c -Wp,-MD,$DEVNULL,-P test.c -o compiler_direct_test.o + compare_file compiler_direct_test.o test.o $CCACHE $COMPILER -c -Wp,-MD,$DEVNULL,-P test.c checkstat 'cache hit (direct)' 0 checkstat 'cache hit (preprocessed)' 1 checkstat 'cache miss' 1 + compare_file compiler_direct_test.o test.o fi ################################################################## @@ -811,11 +843,14 @@ EOF checkstat 'cache hit (direct)' 0 checkstat 'cache hit (preprocessed)' 0 checkstat 'cache miss' 1 + $DIRECT_COMPILE -c -Wp,-MMD,$DEVNULL,-P test.c -o compiler_direct_test.o + compare_file compiler_direct_test.o test.o $CCACHE $COMPILER -c -Wp,-MMD,$DEVNULL,-P test.c checkstat 'cache hit (direct)' 0 checkstat 'cache hit (preprocessed)' 1 checkstat 'cache miss' 1 + compare_file compiler_direct_test.o test.o fi ################################################################## @@ -841,6 +876,9 @@ EOF checkstat 'cache hit (preprocessed)' 0 checkstat 'cache miss' 1 checkfile test.d "test.o: test.c test1.h test3.h test2.h" + $DIRECT_COMPILE -c -MD test.c -o compiler_direct_test.o + compare_file compiler_direct_test.o test.o + rm -f test.d @@ -849,6 +887,7 @@ EOF checkstat 'cache hit (preprocessed)' 0 checkstat 'cache miss' 1 checkfile test.d "test.o: test.c test1.h test3.h test2.h" + compare_file compiler_direct_test.o test.o ################################################################## # Check the scenario of running a ccache with direct mode on a cache @@ -861,6 +900,8 @@ EOF checkstat 'cache hit (preprocessed)' 0 checkstat 'cache miss' 1 checkfile test.d "test.o: test.c test1.h test3.h test2.h" + $DIRECT_COMPILE -c -MD test.c -o compiler_direct_test.o + compare_file compiler_direct_test.o test.o rm -f test.d @@ -869,6 +910,7 @@ EOF checkstat 'cache hit (preprocessed)' 1 checkstat 'cache miss' 1 checkfile test.d "test.o: test.c test1.h test3.h test2.h" + compare_file compiler_direct_test.o test.o rm -f test.d @@ -877,6 +919,7 @@ EOF checkstat 'cache hit (preprocessed)' 2 checkstat 'cache miss' 1 checkfile test.d "test.o: test.c test1.h test3.h test2.h" + compare_file compiler_direct_test.o test.o rm -f test.d @@ -885,6 +928,7 @@ EOF checkstat 'cache hit (preprocessed)' 2 checkstat 'cache miss' 1 checkfile test.d "test.o: test.c test1.h test3.h test2.h" + compare_file compiler_direct_test.o test.o ################################################################## # Check that -MF works. @@ -896,6 +940,8 @@ EOF checkstat 'cache hit (preprocessed)' 0 checkstat 'cache miss' 1 checkfile other.d "test.o: test.c test1.h test3.h test2.h" + $DIRECT_COMPILE -c -MD -MF other.d test.c -o compiler_direct_test.o + compare_file compiler_direct_test.o test.o rm -f other.d @@ -904,6 +950,7 @@ EOF checkstat 'cache hit (preprocessed)' 0 checkstat 'cache miss' 1 checkfile other.d "test.o: test.c test1.h test3.h test2.h" + compare_file compiler_direct_test.o test.o ################################################################## # Check that a missing .d file in the cache is handled correctly. @@ -916,12 +963,15 @@ EOF checkstat 'cache hit (preprocessed)' 0 checkstat 'cache miss' 1 checkfile other.d "test.o: test.c test1.h test3.h test2.h" + $DIRECT_COMPILE -c -MD test.c -o compiler_direct_test.o + compare_file compiler_direct_test.o test.o $CCACHE $COMPILER -c -MD test.c checkstat 'cache hit (direct)' 1 checkstat 'cache hit (preprocessed)' 0 checkstat 'cache miss' 1 checkfile other.d "test.o: test.c test1.h test3.h test2.h" + compare_file compiler_direct_test.o test.o find $CCACHE_DIR -name '*.d' -exec rm -f '{}' \; @@ -930,6 +980,7 @@ EOF checkstat 'cache hit (preprocessed)' 1 checkstat 'cache miss' 1 checkfile other.d "test.o: test.c test1.h test3.h test2.h" + compare_file compiler_direct_test.o test.o ################################################################## # Check that stderr from both the preprocessor and the compiler is emitted @@ -2052,6 +2103,9 @@ CCACHE_CONFIGPATH=`pwd`/ccache.conf export CCACHE_CONFIGPATH touch $CCACHE_CONFIGPATH +# comand used to bypass ccache +DIRECT_COMPILE=`which $COMPILER` + # --------------------------------------- all_suites=" |