• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
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 $CXX ]
12then
13	CXX=clang++
14fi
15
16if [ -z "$OPTIONS" ]
17then
18	OPTIONS="-std=c++0x -stdlib=libc++"
19fi
20
21if [ -z "$QEMU" ]
22then
23    QEMU=qemu-system-arm
24fi
25
26case $TRIPLE in
27  *-*-mingw* | *-*-cygwin* | *-*-win*)
28    TEST_EXE_SUFFIX=.exe
29    ;;
30  *)
31    TEST_EXE_SUFFIX=.out
32    ;;
33esac
34
35FAIL=0
36PASS=0
37UNIMPLEMENTED=0
38IMPLEMENTED_FAIL=0
39IMPLEMENTED_PASS=0
40
41function compile
42{
43  echo "  [COMPILE] $1"
44  echo $CXX $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $LIBS -o $1$TEST_EXE_SUFFIX $1 test_wrapper.cc
45  $CXX $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $LIBS -o $1$TEST_EXE_SUFFIX $1 test_wrapper.cc
46}
47
48function run
49{
50  echo "  [RUN    ] $1"
51  case $TRIPLE in
52    armv4-none-eabi)
53      echo $QEMU -semihosting -M integratorcp -cpu arm1026 -kernel $1
54      $QEMU -semihosting -M integratorcp -cpu arm1026 -kernel $1 | awk 'BEGIN { f=0; } /PASS/ { next } /FAIL/ { f=1; print; next } { print } END { exit f }'
55      ;;
56    thumbv4t-none-eabi)
57      echo $QEMU -semihosting -M integratorcp -cpu arm926 -kernel $1
58      $QEMU -semihosting -M integratorcp -cpu arm1026 -kernel $1 | awk 'BEGIN { f=0; } /PASS/ { next } /FAIL/ { f=1; print; next } { print } END { exit f }'
59      ;;
60    thumbv6m-none-eabi)
61      echo $QEMU -semihosting -M integratorcp -cpu cortex-m3 -kernel $1
62      $QEMU -semihosting -M integratorcp -cpu cortex-m3 -kernel $1 | awk 'BEGIN { f=0; } /PASS/ { next } /FAIL/ { f=1; print; next } { print } END { exit f }'
63      ;;
64    thumbv7t-none-eabi)
65      echo $QEMU -semihosting -M integratorcp -cpu cortex-a8 -kernel $1
66      $QEMU -semihosting -M integratorcp -cpu cortex-a8 -kernel $1 | awk 'BEGIN { f=0; } /PASS/ { next } /FAIL/ { f=1; print; next } { print } END { exit f }'
67      ;;
68    *)
69      $1
70      ;;
71  esac
72}
73
74function afunc
75{
76	fail=0
77	pass=0
78	if (ls *.fail.cpp &> /dev/null)
79	then
80		for FILE in $(ls *.fail.cpp); do
81			if compile $FILE &> /dev/null
82			then
83				rm $FILE$TEST_EXE_SUFFIX
84				echo "  [FAIL   ] $FILE should not compile"
85				let "fail+=1"
86			else
87				let "pass+=1"
88			fi
89		done
90	fi
91
92	if (ls *.cpp &> /dev/null)
93	then
94		for FILE in $(ls *.cpp); do
95			if compile $FILE
96			then
97				if run $FILE$TEST_EXE_SUFFIX
98				then
99					let "pass+=1"
100				else
101					echo "  [FAIL   ] $FILE failed at run time"
102					let "fail+=1"
103				fi
104			else
105				echo "  [FAIL   ] $FILE failed to compile"
106				let "fail+=1"
107			fi
108		done
109	fi
110
111	if [ $fail -gt 0 ]
112	then
113		echo "failed $fail tests in `pwd`"
114		let "IMPLEMENTED_FAIL+=1"
115	fi
116	if [ $pass -gt 0 ]
117	then
118		echo "passed $pass tests in `pwd`"
119		if [ $fail -eq 0 ]
120		then
121			let "IMPLEMENTED_PASS+=1"
122		fi
123	fi
124	if [ $fail -eq 0 -a $pass -eq 0 ]
125	then
126		echo "not implemented:  `pwd`"
127		let "UNIMPLEMENTED+=1"
128	fi
129
130	let "FAIL+=$fail"
131	let "PASS+=$pass"
132
133	for FILE in *
134	do
135		if [ -d "$FILE" ];
136		then
137			cd $FILE
138			afunc
139			cd ..
140		fi
141	done
142}
143
144afunc
145
146echo "****************************************************"
147echo "Results for `pwd`:"
148echo "using `$CXX --version`"
149echo "with $OPTIONS $HEADER_INCLUDE $SOURCE_LIB"
150echo "----------------------------------------------------"
151echo "sections without tests   : $UNIMPLEMENTED"
152echo "sections with failures   : $IMPLEMENTED_FAIL"
153echo "sections without failures: $IMPLEMENTED_PASS"
154echo "                       +   ----"
155echo "total number of sections : $(($UNIMPLEMENTED+$IMPLEMENTED_FAIL+$IMPLEMENTED_PASS))"
156echo "----------------------------------------------------"
157echo "number of tests failed   : $FAIL"
158echo "number of tests passed   : $PASS"
159echo "                       +   ----"
160echo "total number of tests    : $(($FAIL+$PASS))"
161echo "****************************************************"
162
163exit $FAIL
164