Support building the library on Mac OS X 10.4.x Tiger.
[blocksruntime.git] / checktests
blobc60dae02bb9fc679aea6fdfe6f6b9acf7728e4d6
1 #!/bin/sh
2 : ${CC:=clang}
3 : ${CXX:=$CC}
4 CFLAGS='-Wno-unused -include testprefix.h -IBlocksRuntime'
5 CCFLAGS='-std=c99'
6 LIB=libBlocksRuntime.a
7 TESTDIR=testbin
8 rm -rf $TESTDIR
9 mkdir $TESTDIR
10 if ! "$CC" --version >/dev/null 2>&1; then
11 echo "$CC" not installed
12 exit 1
13 else
14 if ("$CC" -fblocks -c -o /dev/null -x c - < /dev/null 2>&1 || echo '-fblocks') 2>&1 | grep -q -- -fblocks; then
15 echo "$CC" does not support the -fblocks option
16 exit 1
19 if "$CXX" --version >/dev/null 2>&1; then
20 dopp=1
21 if ("$CXX" -fblocks -c -o /dev/null -x c - < /dev/null 2>&1 || echo '-fblocks') | grep -q -- -fblocks; then
22 echo "$CXX" does not support the -fblocks option
23 exit 1
25 else
26 echo "$CXX" not installed -- skipping C++ tests
28 if [ ! -r "$LIB" ]; then
29 echo "No $LIB file found, try running $(dirname "$0")/buildlib first"
30 exit 1
32 failcount=0
33 testsfailed=
34 for test in BlocksRuntime/tests/*.[cC]; do
35 skip=
36 skipdoze=
37 extra=
38 stub=
39 println=
40 xfail=
41 pmsg='should PASS'
42 fmsg='should FAIL'
43 case $test in
44 */rdar6405500.c | \
45 */rdar6414583.c | \
46 */objectRRGC.c | \
47 */dispatch_async.c) skip=1;;
48 */fail.c) skipdoze=1;;
49 */macro.c) stub='void foo(); int main(){foo(); printf("success");}'; println=1;;
50 */cast.c | \
51 */voidarg.c) println=1;;
52 */varargs-bad-assign.c | \
53 */rettypepromotion.c | \
54 */shorthandexpression.c | \
55 */k-and-r.c | \
56 */sizeof.c | \
57 */orbars.c | \
58 */constassign.c) xfail=1;;
59 esac
60 ext=.c
61 cpp=
62 USECC="$CC"
63 USEFLAGS="$CCFLAGS $CFLAGS"
64 USELIB="$LIB"
65 case $test in
66 *.C) cpp=1; ext=.C;;
67 *.cpp) cpp=1; ext=.cpp;;
68 *.cp) cpp=1; ext=.cp;;
69 *.c++) cpp=1; ext=.c++;;
70 esac
71 if [ -n "$cpp" ]; then
72 USECC="$CXX"
73 USEFLAGS="$CFLAGS"
74 USELIB="$LIB -lstdc++"
76 if [ -n "$COMSPEC" -a -n "$skipdoze" ]; then
77 skip=1
79 if [ -z "$skip" -a -n "$cpp" -a -z "$dopp" ]; then
80 echo "skipping $test ("$CXX" not installed)"
81 else
82 if [ -n "$skip" ]; then
83 echo skipping $test
84 else
85 if [ -n "$xfail" ]; then
86 echo "--- $(basename $test) ($fmsg) ---"
87 else
88 echo "--- $(basename $test) ($pmsg) ---"
90 if [ -n "$stub" ]; then
91 "$USECC" -c $USEFLAGS $extra -o $TESTDIR/$(basename $test $ext).o -fblocks $test && \
92 echo "$stub" | "$USECC" $USEFLAGS $extra -o $TESTDIR/$(basename $test $ext) -fblocks \
93 $TESTDIR/$(basename $test $ext).o $USELIB -x c - && \
94 $TESTDIR/$(basename $test $ext)
95 else
96 "$USECC" -c $USEFLAGS $extra -o $TESTDIR/$(basename $test $ext).o -fblocks $test && \
97 "$USECC" -o $TESTDIR/$(basename $test $ext) -fblocks $TESTDIR/$(basename $test $ext).o $USELIB && \
98 $TESTDIR/$(basename $test $ext)
100 result=$?
101 if [ -n "$println" ]; then
102 echo ''
104 if [ $result = 0 -a -n "$xfail" ]; then
105 echo ''
106 echo "*"
107 echo "**"
108 echo "*** ^FAILURE: expect FAIL test PASSED! ***"
109 echo "**"
110 echo "*"
111 echo ''
112 testsfailed=1
113 failcount=$(($failcount + 1))
115 if [ $result != 0 -a -z "$xfail" ]; then
116 echo ''
117 echo "*"
118 echo "**"
119 echo "*** ^FAILURE: expect PASS test FAILED! ***"
120 echo "**"
121 echo "*"
122 echo ''
123 testsfailed=1
124 failcount=$(($failcount + 1))
128 done
129 if [ -n "$testsfailed" ]; then
130 echo ''
131 echo "*"
132 echo "**"
133 echo "*** WARNING: Some failures($failcount) occurred, look for '*** ^FAILURE:' lines above"
134 echo "**"
135 echo "*"
136 echo ''
137 exit 1
139 echo "*** All tests passed ***"
140 exit 0