1 #!/bin/bash 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++0x -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 FAIL=0 65 PASS=0 66 UNIMPLEMENTED=0 67 IMPLEMENTED_FAIL=0 68 IMPLEMENTED_PASS=0 69 70 function afunc 71 { 72 fail=0 73 pass=0 74 if (ls *.fail.cpp &> /dev/null) 75 then 76 for FILE in $(ls *.fail.cpp); do 77 if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS -o ./$TEST_EXE &> /dev/null 78 then 79 rm ./$TEST_EXE 80 echo "$FILE should not compile" 81 let "fail+=1" 82 else 83 let "pass+=1" 84 fi 85 done 86 fi 87 88 if (ls *.pass.cpp &> /dev/null) 89 then 90 for FILE in $(ls *.pass.cpp); do 91 if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS -o ./$TEST_EXE 92 then 93 if ./$TEST_EXE 94 then 95 rm ./$TEST_EXE 96 let "pass+=1" 97 else 98 echo "`pwd`/$FILE failed at run time" 99 echo "Compile line was:" $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS 100 let "fail+=1" 101 rm ./$TEST_EXE 102 fi 103 else 104 echo "`pwd`/$FILE failed to compile" 105 echo "Compile line was:" $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS 106 let "fail+=1" 107 fi 108 done 109 fi 110 111 if [ $fail -gt 0 ] 112 then 113 echo "failed $fail tests in `pwd`" 114 let "IMPLEMENTED_FAIL+=1" 115 fi 116 if [ $pass -gt 0 ] 117 then 118 echo "passed $pass tests in `pwd`" 119 if [ $fail -eq 0 ] 120 then 121 let "IMPLEMENTED_PASS+=1" 122 fi 123 fi 124 if [ $fail -eq 0 -a $pass -eq 0 ] 125 then 126 echo "not implemented: `pwd`" 127 let "UNIMPLEMENTED+=1" 128 fi 129 130 let "FAIL+=$fail" 131 let "PASS+=$pass" 132 133 for FILE in * 134 do 135 if [ -d "$FILE" ]; 136 then 137 cd $FILE 138 afunc 139 cd .. 140 fi 141 done 142 } 143 144 afunc 145 146 echo "****************************************************" 147 echo "Results for `pwd`:" 148 echo "using `$CC --version`" 149 echo "with $OPTIONS $HEADER_INCLUDE $SOURCE_LIB" 150 echo "----------------------------------------------------" 151 echo "sections without tests : $UNIMPLEMENTED" 152 echo "sections with failures : $IMPLEMENTED_FAIL" 153 echo "sections without failures: $IMPLEMENTED_PASS" 154 echo " + ----" 155 echo "total number of sections : $(($UNIMPLEMENTED+$IMPLEMENTED_FAIL+$IMPLEMENTED_PASS))" 156 echo "----------------------------------------------------" 157 echo "number of tests failed : $FAIL" 158 echo "number of tests passed : $PASS" 159 echo " + ----" 160 echo "total number of tests : $(($FAIL+$PASS))" 161 echo "****************************************************" 162 163 exit $FAIL 164