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