• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# //===--------------------------- testit ---------------------------------===//
3# //
4# //                     The LLVM Compiler Infrastructure
5# //
6# // This file is distributed under the University of Illinois Open Source
7# // License. See LICENSE.TXT for details.
8# //
9# //===--------------------------------------------------------------------===//
10
11if [ -z "$CC" ]
12then
13	CC=clang++
14fi
15
16if [ -z "$OPTIONS" ]
17then
18	OPTIONS="-std=c++0x -stdlib=libc++"
19fi
20
21case $TRIPLE in
22  *-*-mingw* | *-*-cygwin* | *-*-win*)
23	TEST_EXE=test.exe
24    ;;
25  *)
26    TEST_EXE=a.out
27    ;;
28esac
29
30FAIL=0
31PASS=0
32UNIMPLEMENTED=0
33IMPLEMENTED_FAIL=0
34IMPLEMENTED_PASS=0
35
36afunc()
37{
38	fail=0
39	pass=0
40	if (ls *.fail.cpp > /dev/null 2>&1)
41	then
42		for FILE in $(ls *.fail.cpp); do
43			if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS -o ./$TEST_EXE > /dev/null 2>&1
44			then
45				rm ./$TEST_EXE
46				echo "$FILE should not compile"
47				fail=$(($fail + 1))
48			else
49				pass=$(($pass + 1))
50			fi
51		done
52	fi
53
54	if (ls *.cpp > /dev/null 2>&1)
55	then
56		for FILE in $(ls *.pass.cpp); do
57			if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS -o ./$TEST_EXE
58			then
59				if ./$TEST_EXE
60				then
61					rm ./$TEST_EXE
62					pass=$(($pass + 1))
63				else
64					echo "$FILE failed at run time"
65					fail=$(($fail + 1))
66					rm ./$TEST_EXE
67				fi
68			else
69				echo "$FILE failed to compile"
70				fail=$(($fail + 1))
71			fi
72		done
73	fi
74
75	if [ $fail -gt 0 ]
76	then
77		echo "failed $fail tests in `pwd`"
78		IMPLEMENTED_FAIL=$(($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			IMPLEMENTED_PASS=$(($IMPLEMENTED_PASS + 1))
86		fi
87	fi
88	if [ $fail -eq 0 -a $pass -eq 0 ]
89	then
90		echo "not implemented:  `pwd`"
91		UNIMPLEMENTED=$(($UNIMPLEMENTED + 1))
92	fi
93
94	FAIL=$(($FAIL + $fail))
95	PASS=$(($PASS + $pass))
96
97	for FILE in *
98	do
99		if [ -d "$FILE" ];
100		then
101			cd $FILE
102			afunc
103			cd ..
104		fi
105	done
106}
107
108afunc
109
110echo "****************************************************"
111echo "Results for `pwd`:"
112echo "using `$CC --version`"
113echo "with $OPTIONS $HEADER_INCLUDE $SOURCE_LIB"
114echo "----------------------------------------------------"
115echo "sections without tests   : $UNIMPLEMENTED"
116echo "sections with failures   : $IMPLEMENTED_FAIL"
117echo "sections without failures: $IMPLEMENTED_PASS"
118echo "                       +   ----"
119echo "total number of sections : $(($UNIMPLEMENTED+$IMPLEMENTED_FAIL+$IMPLEMENTED_PASS))"
120echo "----------------------------------------------------"
121echo "number of tests failed   : $FAIL"
122echo "number of tests passed   : $PASS"
123echo "                       +   ----"
124echo "total number of tests    : $(($FAIL+$PASS))"
125echo "****************************************************"
126
127exit $FAIL
128