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 if [ -z "$CC" ] 12 then 13 CC=clang++ 14 fi 15 16 if [ -z "$OPTIONS" ] 17 then 18 OPTIONS="-std=c++0x -stdlib=libc++" 19 fi 20 21 case $TRIPLE in 22 *-*-mingw* | *-*-cygwin* | *-*-win*) 23 TEST_EXE=test.exe 24 ;; 25 *) 26 TEST_EXE=a.out 27 ;; 28 esac 29 30 FAIL=0 31 PASS=0 32 UNIMPLEMENTED=0 33 IMPLEMENTED_FAIL=0 34 IMPLEMENTED_PASS=0 35 36 afunc() 37 { 38 fail=0 39 pass=0 40 if (ls *.fail.cpp > /dev/null 2>&1) 41 then 42 for FILE in $(ls *.fail.cpp); do 43 if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS -o ./$TEST_EXE > /dev/null 2>&1 44 then 45 rm ./$TEST_EXE 46 echo "$FILE should not compile" 47 fail=$(($fail + 1)) 48 else 49 pass=$(($pass + 1)) 50 fi 51 done 52 fi 53 54 if (ls *.cpp > /dev/null 2>&1) 55 then 56 for FILE in $(ls *.pass.cpp); do 57 if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS -o ./$TEST_EXE 58 then 59 if ./$TEST_EXE 60 then 61 rm ./$TEST_EXE 62 pass=$(($pass + 1)) 63 else 64 echo "$FILE failed at run time" 65 fail=$(($fail + 1)) 66 rm ./$TEST_EXE 67 fi 68 else 69 echo "$FILE failed to compile" 70 fail=$(($fail + 1)) 71 fi 72 done 73 fi 74 75 if [ $fail -gt 0 ] 76 then 77 echo "failed $fail tests in `pwd`" 78 IMPLEMENTED_FAIL=$(($IMPLEMENTED_FAIL + 1)) 79 fi 80 if [ $pass -gt 0 ] 81 then 82 echo "passed $pass tests in `pwd`" 83 if [ $fail -eq 0 ] 84 then 85 IMPLEMENTED_PASS=$(($IMPLEMENTED_PASS + 1)) 86 fi 87 fi 88 if [ $fail -eq 0 -a $pass -eq 0 ] 89 then 90 echo "not implemented: `pwd`" 91 UNIMPLEMENTED=$(($UNIMPLEMENTED + 1)) 92 fi 93 94 FAIL=$(($FAIL + $fail)) 95 PASS=$(($PASS + $pass)) 96 97 for FILE in * 98 do 99 if [ -d "$FILE" ]; 100 then 101 cd $FILE 102 afunc 103 cd .. 104 fi 105 done 106 } 107 108 afunc 109 110 echo "****************************************************" 111 echo "Results for `pwd`:" 112 echo "using `$CC --version`" 113 echo "with $OPTIONS $HEADER_INCLUDE $SOURCE_LIB" 114 echo "----------------------------------------------------" 115 echo "sections without tests : $UNIMPLEMENTED" 116 echo "sections with failures : $IMPLEMENTED_FAIL" 117 echo "sections without failures: $IMPLEMENTED_PASS" 118 echo " + ----" 119 echo "total number of sections : $(($UNIMPLEMENTED+$IMPLEMENTED_FAIL+$IMPLEMENTED_PASS))" 120 echo "----------------------------------------------------" 121 echo "number of tests failed : $FAIL" 122 echo "number of tests passed : $PASS" 123 echo " + ----" 124 echo "total number of tests : $(($FAIL+$PASS))" 125 echo "****************************************************" 126 127 exit $FAIL 128