14684ddb6SLionel Sambuc#!/bin/sh 24684ddb6SLionel Sambuc# //===--------------------------- testit ---------------------------------===// 34684ddb6SLionel Sambuc# // 44684ddb6SLionel Sambuc# // The LLVM Compiler Infrastructure 54684ddb6SLionel Sambuc# // 64684ddb6SLionel Sambuc# // This file is distributed under the University of Illinois Open Source 74684ddb6SLionel Sambuc# // License. See LICENSE.TXT for details. 84684ddb6SLionel Sambuc# // 94684ddb6SLionel Sambuc# //===--------------------------------------------------------------------===// 104684ddb6SLionel Sambuc 114684ddb6SLionel Sambuccurrentpath=`pwd` 124684ddb6SLionel Sambucorigpath=$currentpath 134684ddb6SLionel Sambuccurrentdir=`basename $currentpath` 144684ddb6SLionel Sambucwhile [ $currentdir != "test" ]; do 154684ddb6SLionel Sambuc if [ $currentdir = "/" ] 164684ddb6SLionel Sambuc then 174684ddb6SLionel Sambuc echo "current directory must be in or under \"test\"." 184684ddb6SLionel Sambuc exit 1 194684ddb6SLionel Sambuc fi 204684ddb6SLionel Sambuc cd .. 214684ddb6SLionel Sambuc currentpath=`pwd` 224684ddb6SLionel Sambuc currentdir=`basename $currentpath` 234684ddb6SLionel Sambucdone 244684ddb6SLionel Sambuc 254684ddb6SLionel Sambuccd .. 264684ddb6SLionel SambucLIBCXX_ROOT=`pwd` 274684ddb6SLionel Sambuccd $origpath 284684ddb6SLionel Sambuc 294684ddb6SLionel Sambucif [ -z "$CC" ] 304684ddb6SLionel Sambucthen 314684ddb6SLionel Sambuc if which xcrun >/dev/null 324684ddb6SLionel Sambuc then 334684ddb6SLionel Sambuc CC="xcrun clang++" 344684ddb6SLionel Sambuc else 354684ddb6SLionel Sambuc CC=clang++ 364684ddb6SLionel Sambuc fi 374684ddb6SLionel Sambucfi 384684ddb6SLionel Sambuc 39*0a6a1f1dSLionel Sambucif [ -z "$CXX_LANG" ] 40*0a6a1f1dSLionel Sambucthen 41*0a6a1f1dSLionel Sambuc CXX_LANG=c++11 42*0a6a1f1dSLionel Sambucfi 434684ddb6SLionel Sambucif [ -z "$OPTIONS" ] 444684ddb6SLionel Sambucthen 45*0a6a1f1dSLionel Sambuc OPTIONS="-std=${CXX_LANG} -stdlib=libc++" 464684ddb6SLionel Sambucfi 474684ddb6SLionel SambucOPTIONS="$OPTIONS -I$LIBCXX_ROOT/test/support" 484684ddb6SLionel Sambuc 494684ddb6SLionel Sambucif [ -z "$HEADER_INCLUDE" ] 504684ddb6SLionel Sambucthen 514684ddb6SLionel Sambuc HEADER_INCLUDE="-I$LIBCXX_ROOT/include" 524684ddb6SLionel Sambucfi 534684ddb6SLionel Sambuc 544684ddb6SLionel Sambucif [ -z "$SOURCE_LIB" ] 554684ddb6SLionel Sambucthen 564684ddb6SLionel Sambuc SOURCE_LIB="-L$LIBCXX_ROOT/lib" 574684ddb6SLionel Sambucfi 584684ddb6SLionel Sambuc 594684ddb6SLionel Sambuccase $TRIPLE in 604684ddb6SLionel Sambuc *-*-mingw* | *-*-cygwin* | *-*-win*) 614684ddb6SLionel Sambuc TEST_EXE=test.exe 624684ddb6SLionel Sambuc ;; 634684ddb6SLionel Sambuc *) 644684ddb6SLionel Sambuc TEST_EXE=a.out 654684ddb6SLionel Sambuc ;; 664684ddb6SLionel Sambucesac 674684ddb6SLionel Sambuc 684684ddb6SLionel Sambuccase $(uname -s) in 694684ddb6SLionel Sambuc NetBSD) 704684ddb6SLionel Sambuc THREAD_FLAGS=-lpthread 714684ddb6SLionel Sambuc ;; 724684ddb6SLionel Sambucesac 734684ddb6SLionel Sambuc 744684ddb6SLionel SambucFAIL=0 754684ddb6SLionel SambucPASS=0 764684ddb6SLionel SambucUNIMPLEMENTED=0 774684ddb6SLionel SambucIMPLEMENTED_FAIL=0 784684ddb6SLionel SambucIMPLEMENTED_PASS=0 794684ddb6SLionel Sambuc 804684ddb6SLionel Sambucafunc() { 814684ddb6SLionel Sambuc fail=0 824684ddb6SLionel Sambuc pass=0 83*0a6a1f1dSLionel Sambuc if (ls ${TEST_PREFIX}*fail.cpp > /dev/null 2>&1) 844684ddb6SLionel Sambuc then 85*0a6a1f1dSLionel Sambuc for FILE in $(ls ${TEST_PREFIX}*fail.cpp); do 864684ddb6SLionel Sambuc if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS -o ./$TEST_EXE > /dev/null 2>&1 874684ddb6SLionel Sambuc then 884684ddb6SLionel Sambuc rm ./$TEST_EXE 894684ddb6SLionel Sambuc echo "$FILE should not compile" 904684ddb6SLionel Sambuc fail=$(($fail+1)) 914684ddb6SLionel Sambuc else 924684ddb6SLionel Sambuc pass=$(($pass+1)) 934684ddb6SLionel Sambuc fi 944684ddb6SLionel Sambuc done 954684ddb6SLionel Sambuc fi 964684ddb6SLionel Sambuc 97*0a6a1f1dSLionel Sambuc if (ls ${TEST_PREFIX}*pass.cpp > /dev/null 2>&1) 984684ddb6SLionel Sambuc then 99*0a6a1f1dSLionel Sambuc for FILE in $(ls ${TEST_PREFIX}*pass.cpp); do 1004684ddb6SLionel Sambuc if [ "$VERBOSE" ] 1014684ddb6SLionel Sambuc then 1024684ddb6SLionel Sambuc echo "Running test: " $FILE 1034684ddb6SLionel Sambuc fi 1044684ddb6SLionel Sambuc if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS) -o ./$TEST_EXE 1054684ddb6SLionel Sambuc then 1064684ddb6SLionel Sambuc if ./$TEST_EXE 1074684ddb6SLionel Sambuc then 1084684ddb6SLionel Sambuc rm ./$TEST_EXE 1094684ddb6SLionel Sambuc pass=$(($pass+1)) 1104684ddb6SLionel Sambuc else 1114684ddb6SLionel Sambuc echo "`pwd`/$FILE failed at run time" 1124684ddb6SLionel Sambuc echo "Compile line was:" $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS) 1134684ddb6SLionel Sambuc fail=$(($fail+1)) 1144684ddb6SLionel Sambuc rm ./$TEST_EXE 1154684ddb6SLionel Sambuc fi 1164684ddb6SLionel Sambuc else 1174684ddb6SLionel Sambuc echo "`pwd`/$FILE failed to compile" 1184684ddb6SLionel Sambuc echo "Compile line was:" $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS) 1194684ddb6SLionel Sambuc fail=$(($fail+1)) 1204684ddb6SLionel Sambuc fi 1214684ddb6SLionel Sambuc done 1224684ddb6SLionel Sambuc fi 1234684ddb6SLionel Sambuc 1244684ddb6SLionel Sambuc if [ $fail -gt 0 ] 1254684ddb6SLionel Sambuc then 1264684ddb6SLionel Sambuc echo "failed $fail tests in `pwd`" 1274684ddb6SLionel Sambuc IMPLEMENTED_FAIL=$(($IMPLEMENTED_FAIL+1)) 1284684ddb6SLionel Sambuc fi 1294684ddb6SLionel Sambuc if [ $pass -gt 0 ] 1304684ddb6SLionel Sambuc then 1314684ddb6SLionel Sambuc echo "passed $pass tests in `pwd`" 1324684ddb6SLionel Sambuc if [ $fail -eq 0 ] 1334684ddb6SLionel Sambuc then 1344684ddb6SLionel Sambuc IMPLEMENTED_PASS=$((IMPLEMENTED_PASS+1)) 1354684ddb6SLionel Sambuc fi 1364684ddb6SLionel Sambuc fi 1374684ddb6SLionel Sambuc if [ $fail -eq 0 -a $pass -eq 0 ] 1384684ddb6SLionel Sambuc then 1394684ddb6SLionel Sambuc echo "not implemented: `pwd`" 1404684ddb6SLionel Sambuc UNIMPLEMENTED=$(($UNIMPLEMENTED+1)) 1414684ddb6SLionel Sambuc fi 1424684ddb6SLionel Sambuc 1434684ddb6SLionel Sambuc FAIL=$(($FAIL+$fail)) 1444684ddb6SLionel Sambuc PASS=$(($PASS+$pass)) 1454684ddb6SLionel Sambuc 1464684ddb6SLionel Sambuc for FILE in * 1474684ddb6SLionel Sambuc do 1484684ddb6SLionel Sambuc if [ -d "$FILE" ]; 1494684ddb6SLionel Sambuc then 1504684ddb6SLionel Sambuc cd $FILE 1514684ddb6SLionel Sambuc if [ $FILE = thread -o $1 = yes ]; then 1524684ddb6SLionel Sambuc afunc yes 1534684ddb6SLionel Sambuc else 1544684ddb6SLionel Sambuc afunc no 1554684ddb6SLionel Sambuc fi 1564684ddb6SLionel Sambuc cd .. 1574684ddb6SLionel Sambuc fi 1584684ddb6SLionel Sambuc done 1594684ddb6SLionel Sambuc} 1604684ddb6SLionel Sambuc 1614684ddb6SLionel Sambucafunc no 1624684ddb6SLionel Sambuc 1634684ddb6SLionel Sambucecho "****************************************************" 1644684ddb6SLionel Sambucecho "Results for `pwd`:" 1654684ddb6SLionel Sambucecho "using `$CC --version`" 1664684ddb6SLionel Sambucecho "with $OPTIONS $HEADER_INCLUDE $SOURCE_LIB" 1674684ddb6SLionel Sambucecho "----------------------------------------------------" 1684684ddb6SLionel Sambucecho "sections without tests : $UNIMPLEMENTED" 1694684ddb6SLionel Sambucecho "sections with failures : $IMPLEMENTED_FAIL" 1704684ddb6SLionel Sambucecho "sections without failures: $IMPLEMENTED_PASS" 1714684ddb6SLionel Sambucecho " + ----" 1724684ddb6SLionel Sambucecho "total number of sections : $(($UNIMPLEMENTED+$IMPLEMENTED_FAIL+$IMPLEMENTED_PASS))" 1734684ddb6SLionel Sambucecho "----------------------------------------------------" 1744684ddb6SLionel Sambucecho "number of tests failed : $FAIL" 1754684ddb6SLionel Sambucecho "number of tests passed : $PASS" 1764684ddb6SLionel Sambucecho " + ----" 1774684ddb6SLionel Sambucecho "total number of tests : $(($FAIL+$PASS))" 1784684ddb6SLionel Sambucecho "****************************************************" 1794684ddb6SLionel Sambuc 1804684ddb6SLionel Sambucexit $FAIL 181