1 #!/bin/sh 2 # //===--------------------------- testit ---------------------------------===// 3 # // 4 # // The LLVM Compiler Infrastructure 5 # // 6 # // This file is distributed under the University of Illinois Open Source 7 # // License. See LICENSE.TXT for details. 8 # // 9 # //===--------------------------------------------------------------------===// 10 11 currentpath=`pwd` 12 origpath=$currentpath 13 currentdir=`basename $currentpath` 14 while [ $currentdir != "test" ]; do 15 if [ $currentdir = "/" ] 16 then 17 echo "current directory must be in or under \"test\"." 18 exit 1 19 fi 20 cd .. 21 currentpath=`pwd` 22 currentdir=`basename $currentpath` 23 done 24 25 cd .. 26 LIBCXX_ROOT=`pwd` 27 cd $origpath 28 29 if [ -z "$CC" ] 30 then 31 if which xcrun >/dev/null 32 then 33 CC="xcrun clang++" 34 else 35 CC=clang++ 36 fi 37 fi 38 39 if [ -z "$OPTIONS" ] 40 then 41 OPTIONS="-std=c++11 -stdlib=libc++" 42 fi 43 OPTIONS="$OPTIONS -I$LIBCXX_ROOT/test/support" 44 45 if [ -z "$HEADER_INCLUDE" ] 46 then 47 HEADER_INCLUDE="-I$LIBCXX_ROOT/include" 48 fi 49 50 if [ -z "$SOURCE_LIB" ] 51 then 52 SOURCE_LIB="-L$LIBCXX_ROOT/lib" 53 fi 54 55 case $TRIPLE in 56 *-*-mingw* | *-*-cygwin* | *-*-win*) 57 TEST_EXE=test.exe 58 ;; 59 *) 60 TEST_EXE=a.out 61 ;; 62 esac 63 64 case $(uname -s) in 65 NetBSD) 66 THREAD_FLAGS=-lpthread 67 ;; 68 esac 69 70 FAIL=0 71 PASS=0 72 UNIMPLEMENTED=0 73 IMPLEMENTED_FAIL=0 74 IMPLEMENTED_PASS=0 75 76 afunc() { 77 fail=0 78 pass=0 79 if (ls *.fail.cpp > /dev/null 2>&1) 80 then 81 for FILE in $(ls *.fail.cpp); do 82 if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS -o ./$TEST_EXE > /dev/null 2>&1 83 then 84 rm ./$TEST_EXE 85 echo "$FILE should not compile" 86 fail=$(($fail+1)) 87 else 88 pass=$(($pass+1)) 89 fi 90 done 91 fi 92 93 if (ls *.pass.cpp > /dev/null 2>&1) 94 then 95 for FILE in $(ls *.pass.cpp); do 96 if [ "$VERBOSE" ] 97 then 98 echo "Running test: " $FILE 99 fi 100 if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS) -o ./$TEST_EXE 101 then 102 if ./$TEST_EXE 103 then 104 rm ./$TEST_EXE 105 pass=$(($pass+1)) 106 else 107 echo "`pwd`/$FILE failed at run time" 108 echo "Compile line was:" $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS) 109 fail=$(($fail+1)) 110 rm ./$TEST_EXE 111 fi 112 else 113 echo "`pwd`/$FILE failed to compile" 114 echo "Compile line was:" $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS) 115 fail=$(($fail+1)) 116 fi 117 done 118 fi 119 120 if [ $fail -gt 0 ] 121 then 122 echo "failed $fail tests in `pwd`" 123 IMPLEMENTED_FAIL=$(($IMPLEMENTED_FAIL+1)) 124 fi 125 if [ $pass -gt 0 ] 126 then 127 echo "passed $pass tests in `pwd`" 128 if [ $fail -eq 0 ] 129 then 130 IMPLEMENTED_PASS=$((IMPLEMENTED_PASS+1)) 131 fi 132 fi 133 if [ $fail -eq 0 -a $pass -eq 0 ] 134 then 135 echo "not implemented: `pwd`" 136 UNIMPLEMENTED=$(($UNIMPLEMENTED+1)) 137 fi 138 139 FAIL=$(($FAIL+$fail)) 140 PASS=$(($PASS+$pass)) 141 142 for FILE in * 143 do 144 if [ -d "$FILE" ]; 145 then 146 cd $FILE 147 if [ $FILE = thread -o $1 = yes ]; then 148 afunc yes 149 else 150 afunc no 151 fi 152 cd .. 153 fi 154 done 155 } 156 157 afunc no 158 159 echo "****************************************************" 160 echo "Results for `pwd`:" 161 echo "using `$CC --version`" 162 echo "with $OPTIONS $HEADER_INCLUDE $SOURCE_LIB" 163 echo "----------------------------------------------------" 164 echo "sections without tests : $UNIMPLEMENTED" 165 echo "sections with failures : $IMPLEMENTED_FAIL" 166 echo "sections without failures: $IMPLEMENTED_PASS" 167 echo " + ----" 168 echo "total number of sections : $(($UNIMPLEMENTED+$IMPLEMENTED_FAIL+$IMPLEMENTED_PASS))" 169 echo "----------------------------------------------------" 170 echo "number of tests failed : $FAIL" 171 echo "number of tests passed : $PASS" 172 echo " + ----" 173 echo "total number of tests : $(($FAIL+$PASS))" 174 echo "****************************************************" 175 176 exit $FAIL 177