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 | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 11 | if [ -z $CC ] |
| 12 | then |
Howard Hinnant | c4cbb5b | 2011-02-14 18:06:10 +0000 | [diff] [blame] | 13 | CC=clang++ |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 14 | fi |
| 15 | |
| 16 | if [ -z "$OPTIONS" ] |
| 17 | then |
Howard Hinnant | c4cbb5b | 2011-02-14 18:06:10 +0000 | [diff] [blame] | 18 | OPTIONS="-std=c++0x -stdlib=libc++" |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 19 | fi |
| 20 | |
Howard Hinnant | 8452d21 | 2011-10-01 15:34:27 +0000 | [diff] [blame^] | 21 | case $TRIPLE in |
| 22 | *-*-mingw* | *-*-cygwin* | *-*-win*) |
| 23 | TEST_EXE=test.exe |
| 24 | ;; |
| 25 | *) |
| 26 | TEST_EXE=a.out |
| 27 | ;; |
| 28 | esac |
| 29 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 30 | FAIL=0 |
| 31 | PASS=0 |
| 32 | UNIMPLEMENTED=0 |
| 33 | IMPLEMENTED_FAIL=0 |
| 34 | IMPLEMENTED_PASS=0 |
| 35 | |
| 36 | function afunc |
| 37 | { |
| 38 | fail=0 |
| 39 | pass=0 |
| 40 | if (ls *.fail.cpp &> /dev/null) |
| 41 | then |
| 42 | for FILE in $(ls *.fail.cpp); do |
Howard Hinnant | 8452d21 | 2011-10-01 15:34:27 +0000 | [diff] [blame^] | 43 | 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] | 44 | then |
Howard Hinnant | 8452d21 | 2011-10-01 15:34:27 +0000 | [diff] [blame^] | 45 | rm ./$TEST_EXE |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 46 | echo "$FILE should not compile" |
| 47 | let "fail+=1" |
| 48 | else |
| 49 | let "pass+=1" |
| 50 | fi |
| 51 | done |
| 52 | fi |
Howard Hinnant | d2bb032 | 2010-08-22 01:04:38 +0000 | [diff] [blame] | 53 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 54 | if (ls *.pass.cpp &> /dev/null) |
| 55 | then |
| 56 | for FILE in $(ls *.pass.cpp); do |
Howard Hinnant | 8452d21 | 2011-10-01 15:34:27 +0000 | [diff] [blame^] | 57 | if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS -o ./$TEST_EXE |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 58 | then |
Howard Hinnant | 8452d21 | 2011-10-01 15:34:27 +0000 | [diff] [blame^] | 59 | if ./$TEST_EXE |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 60 | then |
Howard Hinnant | 8452d21 | 2011-10-01 15:34:27 +0000 | [diff] [blame^] | 61 | rm ./$TEST_EXE |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 62 | let "pass+=1" |
| 63 | else |
| 64 | echo "$FILE failed at run time" |
| 65 | let "fail+=1" |
Howard Hinnant | 8452d21 | 2011-10-01 15:34:27 +0000 | [diff] [blame^] | 66 | rm ./$TEST_EXE |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 67 | fi |
| 68 | else |
| 69 | echo "$FILE failed to compile" |
| 70 | let "fail+=1" |
| 71 | fi |
| 72 | done |
| 73 | fi |
| 74 | |
| 75 | if [ $fail -gt 0 ] |
| 76 | then |
| 77 | echo "failed $fail tests in `pwd`" |
| 78 | let "IMPLEMENTED_FAIL+=1" |
| 79 | fi |
| 80 | if [ $pass -gt 0 ] |
| 81 | then |
| 82 | echo "passed $pass tests in `pwd`" |
| 83 | if [ $fail -eq 0 ] |
| 84 | then |
| 85 | let "IMPLEMENTED_PASS+=1" |
| 86 | fi |
| 87 | fi |
| 88 | if [ $fail -eq 0 -a $pass -eq 0 ] |
| 89 | then |
| 90 | echo "not implemented: `pwd`" |
| 91 | let "UNIMPLEMENTED+=1" |
| 92 | fi |
| 93 | |
| 94 | let "FAIL+=$fail" |
| 95 | let "PASS+=$pass" |
| 96 | |
| 97 | for FILE in * |
| 98 | do |
| 99 | if [ -d "$FILE" ]; |
| 100 | then |
| 101 | cd $FILE |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 102 | afunc |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 103 | cd .. |
| 104 | fi |
| 105 | done |
| 106 | } |
| 107 | |
| 108 | afunc |
| 109 | |
| 110 | echo "****************************************************" |
| 111 | echo "Results for `pwd`:" |
| 112 | echo "using `$CC --version`" |
Howard Hinnant | c4cbb5b | 2011-02-14 18:06:10 +0000 | [diff] [blame] | 113 | echo "with $OPTIONS $HEADER_INCLUDE $SOURCE_LIB" |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 114 | echo "----------------------------------------------------" |
| 115 | echo "sections without tests : $UNIMPLEMENTED" |
| 116 | echo "sections with failures : $IMPLEMENTED_FAIL" |
| 117 | echo "sections without failures: $IMPLEMENTED_PASS" |
| 118 | echo " + ----" |
| 119 | echo "total number of sections : $(($UNIMPLEMENTED+$IMPLEMENTED_FAIL+$IMPLEMENTED_PASS))" |
| 120 | echo "----------------------------------------------------" |
| 121 | echo "number of tests failed : $FAIL" |
| 122 | echo "number of tests passed : $PASS" |
| 123 | echo " + ----" |
| 124 | echo "total number of tests : $(($FAIL+$PASS))" |
| 125 | echo "****************************************************" |
| 126 | |
| 127 | exit $FAIL |