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