Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 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 |
| 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` |
| 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 | c4cbb5b | 2011-02-14 18:06:10 +0000 | [diff] [blame] | 41 | OPTIONS="-std=c++0x -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 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 64 | FAIL=0 |
| 65 | PASS=0 |
| 66 | UNIMPLEMENTED=0 |
| 67 | IMPLEMENTED_FAIL=0 |
| 68 | IMPLEMENTED_PASS=0 |
| 69 | |
| 70 | function afunc |
| 71 | { |
| 72 | fail=0 |
| 73 | pass=0 |
| 74 | if (ls *.fail.cpp &> /dev/null) |
| 75 | then |
| 76 | for FILE in $(ls *.fail.cpp); do |
Howard Hinnant | 8452d21 | 2011-10-01 15:34:27 +0000 | [diff] [blame] | 77 | if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS -o ./$TEST_EXE &> /dev/null |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 78 | then |
Howard Hinnant | 8452d21 | 2011-10-01 15:34:27 +0000 | [diff] [blame] | 79 | rm ./$TEST_EXE |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 80 | echo "$FILE should not compile" |
| 81 | let "fail+=1" |
| 82 | else |
| 83 | let "pass+=1" |
| 84 | fi |
| 85 | done |
| 86 | fi |
Howard Hinnant | d2bb032 | 2010-08-22 01:04:38 +0000 | [diff] [blame] | 87 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 88 | if (ls *.pass.cpp &> /dev/null) |
| 89 | then |
| 90 | for FILE in $(ls *.pass.cpp); do |
Howard Hinnant | 8452d21 | 2011-10-01 15:34:27 +0000 | [diff] [blame] | 91 | if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS -o ./$TEST_EXE |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 92 | then |
Howard Hinnant | 8452d21 | 2011-10-01 15:34:27 +0000 | [diff] [blame] | 93 | if ./$TEST_EXE |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 94 | then |
Howard Hinnant | 8452d21 | 2011-10-01 15:34:27 +0000 | [diff] [blame] | 95 | rm ./$TEST_EXE |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 96 | let "pass+=1" |
| 97 | else |
David Chisnall | f2b2cc6 | 2012-02-29 13:00:44 +0000 | [diff] [blame] | 98 | echo "`pwd`/$FILE failed at run time" |
| 99 | echo "Compile line was:" $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 100 | let "fail+=1" |
Howard Hinnant | 8452d21 | 2011-10-01 15:34:27 +0000 | [diff] [blame] | 101 | rm ./$TEST_EXE |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 102 | fi |
| 103 | else |
David Chisnall | f2b2cc6 | 2012-02-29 13:00:44 +0000 | [diff] [blame] | 104 | echo "`pwd`/$FILE failed to compile" |
| 105 | echo "Compile line was:" $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 106 | let "fail+=1" |
| 107 | fi |
| 108 | done |
| 109 | fi |
| 110 | |
| 111 | if [ $fail -gt 0 ] |
| 112 | then |
| 113 | echo "failed $fail tests in `pwd`" |
| 114 | let "IMPLEMENTED_FAIL+=1" |
| 115 | fi |
| 116 | if [ $pass -gt 0 ] |
| 117 | then |
| 118 | echo "passed $pass tests in `pwd`" |
| 119 | if [ $fail -eq 0 ] |
| 120 | then |
| 121 | let "IMPLEMENTED_PASS+=1" |
| 122 | fi |
| 123 | fi |
| 124 | if [ $fail -eq 0 -a $pass -eq 0 ] |
| 125 | then |
| 126 | echo "not implemented: `pwd`" |
| 127 | let "UNIMPLEMENTED+=1" |
| 128 | fi |
| 129 | |
| 130 | let "FAIL+=$fail" |
| 131 | let "PASS+=$pass" |
| 132 | |
| 133 | for FILE in * |
| 134 | do |
| 135 | if [ -d "$FILE" ]; |
| 136 | then |
| 137 | cd $FILE |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 138 | afunc |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 139 | cd .. |
| 140 | fi |
| 141 | done |
| 142 | } |
| 143 | |
| 144 | afunc |
| 145 | |
| 146 | echo "****************************************************" |
| 147 | echo "Results for `pwd`:" |
| 148 | echo "using `$CC --version`" |
Howard Hinnant | c4cbb5b | 2011-02-14 18:06:10 +0000 | [diff] [blame] | 149 | echo "with $OPTIONS $HEADER_INCLUDE $SOURCE_LIB" |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 150 | echo "----------------------------------------------------" |
| 151 | echo "sections without tests : $UNIMPLEMENTED" |
| 152 | echo "sections with failures : $IMPLEMENTED_FAIL" |
| 153 | echo "sections without failures: $IMPLEMENTED_PASS" |
| 154 | echo " + ----" |
| 155 | echo "total number of sections : $(($UNIMPLEMENTED+$IMPLEMENTED_FAIL+$IMPLEMENTED_PASS))" |
| 156 | echo "----------------------------------------------------" |
| 157 | echo "number of tests failed : $FAIL" |
| 158 | echo "number of tests passed : $PASS" |
| 159 | echo " + ----" |
| 160 | echo "total number of tests : $(($FAIL+$PASS))" |
| 161 | echo "****************************************************" |
| 162 | |
| 163 | exit $FAIL |