]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
test: Add safeguard against running test.sh in directories with spacy names
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 10 Nov 2012 10:27:51 +0000 (11:27 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 10 Nov 2012 10:27:51 +0000 (11:27 +0100)
test.sh

diff --git a/test.sh b/test.sh
index 924b635000a0cc464632a83f476fdf9c5a5df7d3..09b6d5bbc5b6bb1e52b856279d381b761c707e71 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -64,7 +64,6 @@ randcode() {
     ) >> "$outfile"
 }
 
-
 getstat() {
     stat="$1"
     value=`$CCACHE -s | grep "$stat" | cut -c34-`
@@ -295,7 +294,6 @@ base_tests() {
     CCACHE_DISABLE=1 $COMPILER -c test1.c -o reference_test1.o
     compare_file reference_test1.o test1.o
 
-
     testname="cache-size"
     for f in *.c; do
         $CCACHE_COMPILE -c $f
@@ -867,7 +865,6 @@ EOF
     CCACHE_DISABLE=1 $COMPILER -c -MD test.c -o reference_test.o
     compare_file reference_test.o test.o
 
-
     rm -f test.d
 
     $CCACHE $COMPILER -c -MD test.c
@@ -2041,6 +2038,14 @@ b"
 ######################################################################
 # main program
 
+if pwd | grep '[^A-Za-z0-9/.,=_%+-]' >/dev/null 2>&1; then
+    cat <<EOF
+Error: The test suite doesn't work in directories with whitespace or other
+funny characters in the name. Sorry.
+EOF
+    exit 1
+fi
+
 suites="$*"
 if [ -n "$CC" ]; then
     COMPILER="$CC"
@@ -2051,7 +2056,6 @@ 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
@@ -2086,7 +2090,6 @@ case $host_os in
         ;;
 esac
 
-
 TESTDIR=testdir.$$
 rm -rf $TESTDIR
 mkdir $TESTDIR