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