summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Givone <david@givone.net>2012-09-03 20:57:00 -0700
committerJoel Rosdahl <joel@rosdahl.net>2012-09-13 20:35:57 +0200
commit12934eceb31a3562d3c89187870dddd6c981e6cd (patch)
tree08117b5de5646da1a46cf123fdea08310cf6a982
parent15f9ced6a9fd24327871084e2b990199947fe732 (diff)
downloadccache-12934eceb31a3562d3c89187870dddd6c981e6cd.tar.gz
Make test suite work with clang and gcc-llvm on Mac OS X
Numerous fixes so that clang and gcc-llvm from Xcode 4 can successfully complete Various variables were also added to simplify conditional statements.
-rwxr-xr-xtest.sh122
1 files changed, 97 insertions, 25 deletions
diff --git a/test.sh b/test.sh
index f1362f81..d0eaad12 100755
--- a/test.sh
+++ b/test.sh
@@ -208,7 +208,7 @@ base_tests() {
testname="non-regular"
mkdir testd
$CCACHE_COMPILE -o testd -c test1.c > /dev/null 2>&1
- rmdir testd
+ rmdir testd > /dev/null 2>&1
checkstat 'output to a non-regular file' 1
testname="no-input"
@@ -521,7 +521,16 @@ EOF
$CCACHE -C > /dev/null
checkstat 'files in cache' 0
- if $COMPILER -c -fprofile-generate test1.c 2>/dev/null; then
+ # the profile options do not seem to work correctly with clang or gcc-llvm
+ # on darwin machines
+ darwin_llvm=0
+ if [ $HOST_OS_APPLE -eq 1 ] && \
+ [ $COMPILER_USES_LLVM -eq 1 ]; then
+ darwin_llvm=1
+ fi
+
+ $COMPILER -c -fprofile-generate test1.c 2>/dev/null
+ if [ $? -eq 0 ] && [ $darwin_llvm -eq 0 ]; then
testname="profile-generate"
$CCACHE -Cz > /dev/null
$CCACHE_COMPILE -c -fprofile-generate test1.c
@@ -777,31 +786,37 @@ EOF
##################################################################
# Check that -Wp,-MD,file.d,-P disables direct mode.
- testname="-Wp,-MD,file.d,-P"
- $CCACHE -z >/dev/null
- $CCACHE $COMPILER -c -Wp,-MD,$DEVNULL,-P test.c
- checkstat 'cache hit (direct)' 0
- checkstat 'cache hit (preprocessed)' 0
- checkstat 'cache miss' 1
+ # currently clang does not support -Wp form of options
+ if [ $COMPILER_TYPE_GCC -eq 1 ]; then
+ testname="-Wp,-MD,file.d,-P"
+ $CCACHE -z >/dev/null
+ $CCACHE $COMPILER -c -Wp,-MD,$DEVNULL,-P test.c
+ checkstat 'cache hit (direct)' 0
+ checkstat 'cache hit (preprocessed)' 0
+ checkstat 'cache miss' 1
- $CCACHE $COMPILER -c -Wp,-MD,$DEVNULL,-P test.c
- checkstat 'cache hit (direct)' 0
- checkstat 'cache hit (preprocessed)' 1
- checkstat 'cache miss' 1
+ $CCACHE $COMPILER -c -Wp,-MD,$DEVNULL,-P test.c
+ checkstat 'cache hit (direct)' 0
+ checkstat 'cache hit (preprocessed)' 1
+ checkstat 'cache miss' 1
+ fi
##################################################################
# Check that -Wp,-MMD,file.d,-P disables direct mode.
- testname="-Wp,-MDD,file.d,-P"
- $CCACHE -z >/dev/null
- $CCACHE $COMPILER -c -Wp,-MMD,$DEVNULL,-P test.c
- checkstat 'cache hit (direct)' 0
- checkstat 'cache hit (preprocessed)' 0
- checkstat 'cache miss' 1
+ # currently clang does not support -Wp form of options
+ if [ $COMPILER_TYPE_GCC -eq 1 ]; then
+ testname="-Wp,-MDD,file.d,-P"
+ $CCACHE -z >/dev/null
+ $CCACHE $COMPILER -c -Wp,-MMD,$DEVNULL,-P test.c
+ checkstat 'cache hit (direct)' 0
+ checkstat 'cache hit (preprocessed)' 0
+ checkstat 'cache miss' 1
- $CCACHE $COMPILER -c -Wp,-MMD,$DEVNULL,-P test.c
- checkstat 'cache hit (direct)' 0
- checkstat 'cache hit (preprocessed)' 1
- checkstat 'cache miss' 1
+ $CCACHE $COMPILER -c -Wp,-MMD,$DEVNULL,-P test.c
+ checkstat 'cache hit (direct)' 0
+ checkstat 'cache hit (preprocessed)' 1
+ checkstat 'cache miss' 1
+ fi
##################################################################
# Test some header modifications to get multiple objects in the manifest.
@@ -1249,7 +1264,37 @@ EOF
$CCACHE --dump-manifest $manifest |
perl -ape 's/:.*/: normalized/ if $F[0] =~ "(Hash|Size):" and ++$n > 6' \
>manifest.dump
- cat <<EOF >expected.dump
+ if [ $COMPILER_TYPE_CLANG -eq 1 ]; then
+ cat <<EOF >expected.dump
+Magic: cCmF
+Version: 0
+Hash size: 16
+Reserved field: 0
+File paths (3):
+ 0: ./test3.h
+ 1: ./test1.h
+ 2: ./test2.h
+File infos (3):
+ 0:
+ Path index: 0
+ Hash: c2f5392dbc7e8ff6138d01608445240a
+ Size: 24
+ 1:
+ Path index: 1
+ Hash: e6b009695d072974f2c4d1dd7e7ed4fc
+ Size: 95
+ 2:
+ Path index: 2
+ Hash: e94ceb9f1b196c387d098a5f1f4fe862
+ Size: 11
+Results (1):
+ 0:
+ File hash indexes: 0 1 2
+ Hash: normalized
+ Size: normalized
+EOF
+ else
+ cat <<EOF >expected.dump
Magic: cCmF
Version: 0
Hash size: 16
@@ -1277,6 +1322,8 @@ Results (1):
Hash: normalized
Size: normalized
EOF
+ fi
+
if diff expected.dump manifest.dump; then
:
else
@@ -1951,9 +1998,21 @@ if [ -z "$CCACHE" ]; then
CCACHE=`pwd`/ccache
fi
+
+# save the type of compiler because some test may not work on all compilers
+COMPILER_TYPE_CLANG=0
+COMPILER_TYPE_GCC=0
+
+COMPILER_USES_LLVM=0
+HOST_OS_APPLE=0
+
compiler_version="`$COMPILER --version 2>&1 | head -1`"
case $compiler_version in
- *gcc*|2.95*)
+ *gcc*|*g++*|2.95*)
+ COMPILER_TYPE_GCC=1
+ ;;
+ *clang*)
+ COMPILER_TYPE_CLANG=1
;;
*)
echo "WARNING: Compiler $COMPILER not supported (version: $compiler_version) -- not running tests" >&2
@@ -1961,6 +2020,20 @@ case $compiler_version in
;;
esac
+case $compiler_version in
+ *llvm*|*LLVM*)
+ COMPILER_USES_LLVM=1
+ ;;
+esac
+
+host_os="`uname -s`"
+case $host_os in
+ *Darwin*)
+ HOST_OS_APPLE=1
+ ;;
+esac
+
+
TESTDIR=testdir.$$
rm -rf $TESTDIR
mkdir $TESTDIR
@@ -1994,7 +2067,6 @@ upgrade
prefix
"
-host_os="`uname -s`"
case $host_os in
*MINGW*|*mingw*)
export CCACHE_DETECT_SHEBANG