Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # //===--------------------------- testit ---------------------------------===// |
| 3 | # // |
Howard Hinnant | c566dc3 | 2010-05-11 21:36:01 +0000 | [diff] [blame^] | 4 | # // The LLVM Compiler Infrastructure |
Howard Hinnant | c51e102 | 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 | |
| 11 | BACKUP="../" |
| 12 | |
| 13 | currentpath=`pwd` |
| 14 | origpath=$currentpath |
| 15 | currentdir=`basename $currentpath` |
| 16 | while [ $currentdir != "test" ]; do |
| 17 | if [ $currentdir == "/" ] |
| 18 | then |
| 19 | echo "current directory must be in or under \"test\"." |
| 20 | exit 1 |
| 21 | fi |
| 22 | cd .. |
| 23 | currentpath=`pwd` |
| 24 | currentdir=`basename $currentpath` |
| 25 | BACKUP="../"$BACKUP |
| 26 | done |
| 27 | cd $origpath |
| 28 | |
| 29 | if [ -z $CC ] |
| 30 | then |
| 31 | CC=g++ |
| 32 | fi |
| 33 | |
| 34 | auto_header=0 |
| 35 | |
| 36 | if [ -z $HEADER_INCLUDE ] |
| 37 | then |
| 38 | HEADER_INCLUDE=$BACKUP"include" |
| 39 | let "auto_header+=1" |
| 40 | fi |
| 41 | |
| 42 | auto_lib=0 |
| 43 | |
| 44 | SOURCE_LIB=/usr/lib/libc++.dylib |
| 45 | #SOURCE_LIB=/Users/hinnant/Development/libcpp/lib/libc++.a |
| 46 | |
| 47 | if [ -z $SOURCE_LIB ] |
| 48 | then |
| 49 | SOURCE_LIB=$BACKUP"lib/libc++.dylib" |
| 50 | let "auto_lib+=1" |
| 51 | fi |
| 52 | |
| 53 | if [ -z "$OPTIONS" ] |
| 54 | then |
| 55 | OPTIONS="-nostdinc++ -nodefaultlibs /usr/lib/libSystem.B.dylib -arch `arch`" |
| 56 | fi |
| 57 | |
| 58 | FAIL=0 |
| 59 | PASS=0 |
| 60 | UNIMPLEMENTED=0 |
| 61 | IMPLEMENTED_FAIL=0 |
| 62 | IMPLEMENTED_PASS=0 |
| 63 | |
| 64 | function afunc |
| 65 | { |
| 66 | fail=0 |
| 67 | pass=0 |
| 68 | if (ls *.fail.cpp &> /dev/null) |
| 69 | then |
| 70 | for FILE in $(ls *.fail.cpp); do |
| 71 | if $CC $OPTIONS -I$HEADER_INCLUDE $SOURCE_LIB $FILE &> /dev/null |
| 72 | then |
| 73 | rm ./a.out |
| 74 | echo "$FILE should not compile" |
| 75 | let "fail+=1" |
| 76 | else |
| 77 | let "pass+=1" |
| 78 | fi |
| 79 | done |
| 80 | fi |
| 81 | |
| 82 | if (ls *.pass.cpp &> /dev/null) |
| 83 | then |
| 84 | for FILE in $(ls *.pass.cpp); do |
| 85 | if $CC $OPTIONS -I$HEADER_INCLUDE $SOURCE_LIB $FILE |
| 86 | then |
| 87 | if ./a.out |
| 88 | then |
| 89 | rm ./a.out |
| 90 | let "pass+=1" |
| 91 | else |
| 92 | echo "$FILE failed at run time" |
| 93 | let "fail+=1" |
| 94 | rm ./a.out |
| 95 | fi |
| 96 | else |
| 97 | echo "$FILE failed to compile" |
| 98 | let "fail+=1" |
| 99 | fi |
| 100 | done |
| 101 | fi |
| 102 | |
| 103 | if [ $fail -gt 0 ] |
| 104 | then |
| 105 | echo "failed $fail tests in `pwd`" |
| 106 | let "IMPLEMENTED_FAIL+=1" |
| 107 | fi |
| 108 | if [ $pass -gt 0 ] |
| 109 | then |
| 110 | echo "passed $pass tests in `pwd`" |
| 111 | if [ $fail -eq 0 ] |
| 112 | then |
| 113 | let "IMPLEMENTED_PASS+=1" |
| 114 | fi |
| 115 | fi |
| 116 | if [ $fail -eq 0 -a $pass -eq 0 ] |
| 117 | then |
| 118 | echo "not implemented: `pwd`" |
| 119 | let "UNIMPLEMENTED+=1" |
| 120 | fi |
| 121 | |
| 122 | let "FAIL+=$fail" |
| 123 | let "PASS+=$pass" |
| 124 | |
| 125 | for FILE in * |
| 126 | do |
| 127 | if [ -d "$FILE" ]; |
| 128 | then |
| 129 | cd $FILE |
| 130 | if [ $auto_header -eq 1 ] |
| 131 | then |
| 132 | SAVE_HEADER_INCLUDE=$HEADER_INCLUDE |
| 133 | HEADER_INCLUDE="../"$HEADER_INCLUDE |
| 134 | fi |
| 135 | if [ $auto_lib -eq 1 ] |
| 136 | then |
| 137 | SAVE_SOURCE_LIB=$SOURCE_LIB |
| 138 | SOURCE_LIB="../"$SOURCE_LIB |
| 139 | fi |
| 140 | |
| 141 | afunc |
| 142 | |
| 143 | if [ $auto_header -eq 1 ] |
| 144 | then |
| 145 | HEADER_INCLUDE=${HEADER_INCLUDE:3} |
| 146 | fi |
| 147 | if [ $auto_lib -eq 1 ] |
| 148 | then |
| 149 | SOURCE_LIB=${SOURCE_LIB:3} |
| 150 | fi |
| 151 | cd .. |
| 152 | fi |
| 153 | done |
| 154 | } |
| 155 | |
| 156 | afunc |
| 157 | |
| 158 | echo "****************************************************" |
| 159 | echo "Results for `pwd`:" |
| 160 | echo "using `$CC --version`" |
| 161 | echo "with $OPTIONS -I$HEADER_INCLUDE $SOURCE_LIB" |
| 162 | echo "----------------------------------------------------" |
| 163 | echo "sections without tests : $UNIMPLEMENTED" |
| 164 | echo "sections with failures : $IMPLEMENTED_FAIL" |
| 165 | echo "sections without failures: $IMPLEMENTED_PASS" |
| 166 | echo " + ----" |
| 167 | echo "total number of sections : $(($UNIMPLEMENTED+$IMPLEMENTED_FAIL+$IMPLEMENTED_PASS))" |
| 168 | echo "----------------------------------------------------" |
| 169 | echo "number of tests failed : $FAIL" |
| 170 | echo "number of tests passed : $PASS" |
| 171 | echo " + ----" |
| 172 | echo "total number of tests : $(($FAIL+$PASS))" |
| 173 | echo "****************************************************" |
| 174 | |
| 175 | exit $FAIL |