blob: 18b0814536048b9239cc6bf4d23c7b2d78325faa [file] [log] [blame]
Joerg Sonnenbergerc5e6aa52013-04-23 19:53:24 +00001#!/bin/sh
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002# //===--------------------------- testit ---------------------------------===//
3# //
Howard Hinnantf5256e12010-05-11 21:36:01 +00004# // The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00005# //
6# // This file is distributed under the University of Illinois Open Source
7# // License. See LICENSE.TXT for details.
8# //
9# //===--------------------------------------------------------------------===//
10
Howard Hinnant7fa77a72012-12-09 00:12:14 +000011currentpath=`pwd`
12origpath=$currentpath
13currentdir=`basename $currentpath`
14while [ $currentdir != "test" ]; do
Joerg Sonnenberger4dca0442013-07-04 15:11:10 +000015 if [ $currentdir = "/" ]
Howard Hinnant7fa77a72012-12-09 00:12:14 +000016 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`
23done
24
25cd ..
26LIBCXX_ROOT=`pwd`
27cd $origpath
28
Richard Smith9efdc0b2012-04-19 00:50:47 +000029if [ -z "$CC" ]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000030then
Dave Zarzyckib9344c22012-02-22 00:20:30 +000031 if which xcrun >/dev/null
32 then
33 CC="xcrun clang++"
34 else
35 CC=clang++
36 fi
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000037fi
38
39if [ -z "$OPTIONS" ]
40then
Howard Hinnant7a6b7ce2013-06-22 15:21:29 +000041 OPTIONS="-std=c++11 -stdlib=libc++"
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000042fi
Marshall Clow83e2c4d2013-01-05 03:21:01 +000043OPTIONS="$OPTIONS -I$LIBCXX_ROOT/test/support"
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000044
Howard Hinnant7fa77a72012-12-09 00:12:14 +000045if [ -z "$HEADER_INCLUDE" ]
46then
47 HEADER_INCLUDE="-I$LIBCXX_ROOT/include"
48fi
49
50if [ -z "$SOURCE_LIB" ]
51then
52 SOURCE_LIB="-L$LIBCXX_ROOT/lib"
53fi
54
Howard Hinnant8452d212011-10-01 15:34:27 +000055case $TRIPLE in
56 *-*-mingw* | *-*-cygwin* | *-*-win*)
57 TEST_EXE=test.exe
58 ;;
59 *)
60 TEST_EXE=a.out
61 ;;
62esac
63
Joerg Sonnenberger34cb0662013-05-02 19:21:36 +000064case $(uname -s) in
65 NetBSD)
66 THREAD_FLAGS=-lpthread
67 ;;
68esac
69
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000070FAIL=0
71PASS=0
72UNIMPLEMENTED=0
73IMPLEMENTED_FAIL=0
74IMPLEMENTED_PASS=0
75
Joerg Sonnenbergerc5e6aa52013-04-23 19:53:24 +000076afunc() {
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000077 fail=0
78 pass=0
Joerg Sonnenbergerc5e6aa52013-04-23 19:53:24 +000079 if (ls *.fail.cpp > /dev/null 2>&1)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000080 then
81 for FILE in $(ls *.fail.cpp); do
Joerg Sonnenbergerc5e6aa52013-04-23 19:53:24 +000082 if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS -o ./$TEST_EXE > /dev/null 2>&1
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000083 then
Howard Hinnant8452d212011-10-01 15:34:27 +000084 rm ./$TEST_EXE
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000085 echo "$FILE should not compile"
Joerg Sonnenbergerc5e6aa52013-04-23 19:53:24 +000086 fail=$(($fail+1))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000087 else
Joerg Sonnenbergerc5e6aa52013-04-23 19:53:24 +000088 pass=$(($pass+1))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000089 fi
90 done
91 fi
Howard Hinnantd2bb0322010-08-22 01:04:38 +000092
Joerg Sonnenbergerc5e6aa52013-04-23 19:53:24 +000093 if (ls *.pass.cpp > /dev/null 2>&1)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000094 then
95 for FILE in $(ls *.pass.cpp); do
Marshall Clowc3a9b812013-03-26 15:28:33 +000096 if [ "$VERBOSE" ]
97 then
98 echo "Running test: " $FILE
99 fi
Joerg Sonnenberger34cb0662013-05-02 19:21:36 +0000100 if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS) -o ./$TEST_EXE
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000101 then
Howard Hinnant8452d212011-10-01 15:34:27 +0000102 if ./$TEST_EXE
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000103 then
Howard Hinnant8452d212011-10-01 15:34:27 +0000104 rm ./$TEST_EXE
Joerg Sonnenbergerc5e6aa52013-04-23 19:53:24 +0000105 pass=$(($pass+1))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000106 else
David Chisnallf2b2cc62012-02-29 13:00:44 +0000107 echo "`pwd`/$FILE failed at run time"
Joerg Sonnenberger34cb0662013-05-02 19:21:36 +0000108 echo "Compile line was:" $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS)
Joerg Sonnenbergerc5e6aa52013-04-23 19:53:24 +0000109 fail=$(($fail+1))
Howard Hinnant8452d212011-10-01 15:34:27 +0000110 rm ./$TEST_EXE
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000111 fi
112 else
David Chisnallf2b2cc62012-02-29 13:00:44 +0000113 echo "`pwd`/$FILE failed to compile"
Joerg Sonnenberger34cb0662013-05-02 19:21:36 +0000114 echo "Compile line was:" $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS)
Joerg Sonnenbergerc5e6aa52013-04-23 19:53:24 +0000115 fail=$(($fail+1))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000116 fi
117 done
118 fi
119
120 if [ $fail -gt 0 ]
121 then
122 echo "failed $fail tests in `pwd`"
Joerg Sonnenbergerc5e6aa52013-04-23 19:53:24 +0000123 IMPLEMENTED_FAIL=$(($IMPLEMENTED_FAIL+1))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000124 fi
125 if [ $pass -gt 0 ]
126 then
127 echo "passed $pass tests in `pwd`"
128 if [ $fail -eq 0 ]
129 then
Joerg Sonnenbergerc5e6aa52013-04-23 19:53:24 +0000130 IMPLEMENTED_PASS=$((IMPLEMENTED_PASS+1))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000131 fi
132 fi
133 if [ $fail -eq 0 -a $pass -eq 0 ]
134 then
135 echo "not implemented: `pwd`"
Joerg Sonnenbergerc5e6aa52013-04-23 19:53:24 +0000136 UNIMPLEMENTED=$(($UNIMPLEMENTED+1))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000137 fi
138
Joerg Sonnenbergerc5e6aa52013-04-23 19:53:24 +0000139 FAIL=$(($FAIL+$fail))
140 PASS=$(($PASS+$pass))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000141
142 for FILE in *
143 do
144 if [ -d "$FILE" ];
145 then
146 cd $FILE
Joerg Sonnenberger34cb0662013-05-02 19:21:36 +0000147 if [ $FILE = thread -o $1 = yes ]; then
148 afunc yes
149 else
150 afunc no
151 fi
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000152 cd ..
153 fi
154 done
155}
156
Joerg Sonnenberger34cb0662013-05-02 19:21:36 +0000157afunc no
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000158
159echo "****************************************************"
160echo "Results for `pwd`:"
161echo "using `$CC --version`"
Howard Hinnantc4cbb5b2011-02-14 18:06:10 +0000162echo "with $OPTIONS $HEADER_INCLUDE $SOURCE_LIB"
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000163echo "----------------------------------------------------"
164echo "sections without tests : $UNIMPLEMENTED"
165echo "sections with failures : $IMPLEMENTED_FAIL"
166echo "sections without failures: $IMPLEMENTED_PASS"
167echo " + ----"
168echo "total number of sections : $(($UNIMPLEMENTED+$IMPLEMENTED_FAIL+$IMPLEMENTED_PASS))"
169echo "----------------------------------------------------"
170echo "number of tests failed : $FAIL"
171echo "number of tests passed : $PASS"
172echo " + ----"
173echo "total number of tests : $(($FAIL+$PASS))"
174echo "****************************************************"
175
176exit $FAIL