Merge from mainline
[official-gcc.git] / gcc / testsuite / ada / acats / run_all.sh
blob8a097936cf1b1c8a1229956e67bb7a3d17d48428
1 #!/bin/sh
2 # Run ACATS with the GNU Ada compiler
4 # The following functions are to be customized if you run in cross
5 # environment or want to change compilation flags. Note that for
6 # tests requiring checks not turned on by default, this script
7 # automatically adds the needed flags to pass (ie: -gnato or -gnatE).
9 # gccflags="-O3 -fomit-frame-pointer -funroll-all-loops -finline-functions"
10 # gnatflags="-gnatN"
12 gccflags="-O2"
13 gnatflags="-gnatws"
15 target_run () {
19 # End of customization section.
21 display_noeol () {
22 printf "$@"
23 printf "$@" >> $dir/acats.sum
24 printf "$@" >> $dir/acats.log
27 display () {
28 echo "$@"
29 echo "$@" >> $dir/acats.sum
30 echo "$@" >> $dir/acats.log
33 log () {
34 echo "$@" >> $dir/acats.sum
35 echo "$@" >> $dir/acats.log
38 dir=`${PWDCMD-pwd}`
40 if [ "$testdir" = "" ]; then
41 echo You must use make check or make check-ada
42 exit 1
45 if [ "$dir" = "$testdir" ]; then
46 echo "error: srcdir must be different than objdir, exiting."
47 exit 1
50 target_gnatchop () {
51 gnatchop --GCC="$GCC_DRIVER" $*
54 target_gnatmake () {
55 echo gnatmake --GCC=\"$GCC\" $gnatflags $gccflags $* -largs $EXTERNAL_OBJECTS --GCC=\"$GCC\"
56 gnatmake --GCC="$GCC" $gnatflags $gccflags $* -largs $EXTERNAL_OBJECTS --GCC="$GCC"
59 target_gcc () {
60 $GCC $gccflags $*
63 clean_dir () {
64 rm -f "$binmain" *.o *.ali > /dev/null 2>&1
67 EXTERNAL_OBJECTS=""
68 # Global variable to communicate external objects to link with.
70 rm -f $dir/acats.sum $dir/acats.log
72 display " === acats configuration ==="
74 target=`$GCC -dumpmachine`
76 display target gcc is $GCC
77 display `$GCC -v 2>&1`
78 display host=`gcc -dumpmachine`
79 display target=$target
80 display `type gnatmake`
81 gnatls -v >> $dir/acats.log
82 display ""
84 display " === acats support ==="
85 display_noeol "Generating support files..."
87 rm -rf $dir/support
88 mkdir -p $dir/support
89 cd $dir/support
91 cp $testdir/support/*.ada $testdir/support/*.a $testdir/support/*.tst $dir/support
93 # Find out the size in bit of an address on the target
94 target_gnatmake $testdir/support/impbit.adb >> $dir/acats.log 2>&1
95 target_run $dir/support/impbit > $dir/support/impbit.out 2>&1
96 target_bit=`cat $dir/support/impbit.out`
97 echo target_bit="$target_bit" >> $dir/acats.log
99 # Find out a suitable asm statement
100 # Adapted from configure.ac gcc_cv_as_dwarf2_debug_line
101 case "$target" in
102 ia64*-*-* | s390*-*-*)
103 target_insn="nop 0"
105 mmix-*-*)
106 target_insn="swym 0"
109 target_insn="nop"
111 esac
112 echo target_insn="$target_insn" >> $dir/acats.log
114 sed -e "s,ACATS4GNATDIR,$dir,g" \
115 < $testdir/support/impdef.a > $dir/support/impdef.a
116 sed -e "s,ACATS4GNATDIR,$dir,g" \
117 -e "s,ACATS4GNATBIT,$target_bit,g" \
118 -e "s,ACATS4GNATINSN,$target_insn,g" \
119 < $testdir/support/macro.dfs > $dir/support/MACRO.DFS
120 sed -e "s,ACATS4GNATDIR,$dir,g" \
121 < $testdir/support/tsttests.dat > $dir/support/TSTTESTS.DAT
123 cp $testdir/tests/cd/*.c $dir/support
124 cp $testdir/tests/cxb/*.c $dir/support
126 rm -rf $dir/run
127 mv $dir/tests $dir/tests.$$ 2> /dev/null
128 rm -rf $dir/tests.$$ &
129 mkdir -p $dir/run
131 cp -pr $testdir/tests $dir/
133 for i in $dir/support/*.ada $dir/support/*.a; do
134 host_gnatchop $i >> $dir/acats.log 2>&1
135 done
137 # These tools are used to preprocess some ACATS sources
138 # they need to be compiled native on the host.
140 host_gnatmake -q -gnatws macrosub.adb
141 if [ $? -ne 0 ]; then
142 display "**** Failed to compile macrosub"
143 exit 1
145 ./macrosub > macrosub.out 2>&1
147 gcc -c cd300051.c
148 host_gnatmake -q -gnatws widechr.adb
149 if [ $? -ne 0 ]; then
150 display "**** Failed to compile widechr"
151 exit 1
153 ./widechr > widechr.out 2>&1
155 rm -f $dir/support/macrosub
156 rm -f $dir/support/widechr
157 rm -f $dir/support/*.ali
158 rm -f $dir/support/*.o
160 display " done."
162 # From here, all compilations will be made by the target compiler
164 display_noeol "Compiling support files..."
166 target_gcc -c *.c
167 if [ $? -ne 0 ]; then
168 display "**** Failed to compile C code"
169 exit 1
172 target_gnatchop *.adt >> $dir/acats.log 2>&1
174 target_gnatmake -c -gnato -gnatE *.ads >> $dir/acats.log 2>&1
175 target_gnatmake -c -gnato -gnatE *.adb >> $dir/acats.log 2>&1
177 display " done."
178 display ""
179 display " === acats tests ==="
181 if [ $# -eq 0 ]; then
182 chapters=`cd $dir/tests; echo [a-z]*`
183 else
184 chapters=$*
187 glob_countn=0
188 glob_countok=0
189 glob_countu=0
191 for chapter in $chapters; do
192 display Running chapter $chapter ...
194 if [ ! -d $dir/tests/$chapter ]; then
195 display "*** CHAPTER $chapter does not exist, skipping."
196 display ""
197 continue
200 cd $dir/tests/$chapter
201 ls *.a *.ada *.adt *.am *.dep 2> /dev/null | sed -e 's/\(.*\)\..*/\1/g' | \
202 cut -c1-7 | sort | uniq | comm -23 - $testdir/norun.lst \
203 > $dir/tests/$chapter/${chapter}.lst
204 countn=`wc -l < $dir/tests/$chapter/${chapter}.lst`
205 glob_countn=`expr $glob_countn + $countn`
206 counti=0
207 for i in `cat $dir/tests/$chapter/${chapter}.lst`; do
208 counti=`expr $counti + 1`
209 extraflags=""
210 grep $i $testdir/overflow.lst > /dev/null 2>&1
211 if [ $? -eq 0 ]; then
212 extraflags="$extraflags -gnato"
214 grep $i $testdir/elabd.lst > /dev/null 2>&1
215 if [ $? -eq 0 ]; then
216 extraflags="$extraflags -gnatE"
218 grep $i $testdir/stackcheck.lst > /dev/null 2>&1
219 if [ $? -eq 0 ]; then
220 extraflags="$extraflags -fstack-check"
222 test=$dir/tests/$chapter/$i
223 mkdir $test && cd $test >> $dir/acats.log 2>&1
225 if [ $? -ne 0 ]; then
226 display "FAIL: $i"
227 failed="${failed}${i} "
228 clean_dir
229 continue
232 target_gnatchop -c -w `ls ${test}*.a ${test}*.ada ${test}*.adt ${test}*.am ${test}*.dep 2> /dev/null` >> $dir/acats.log 2>&1
233 ls ${i}?.adb > ${i}.lst 2> /dev/null
234 ls ${i}*m.adb >> ${i}.lst 2> /dev/null
235 ls ${i}.adb >> ${i}.lst 2> /dev/null
236 main=`tail -1 ${i}.lst`
237 binmain=`echo $main | sed -e 's/\(.*\)\..*/\1/g'`
238 echo "BUILD $main" >> $dir/acats.log
239 EXTERNAL_OBJECTS=""
240 case $i in
241 cxb30*) EXTERNAL_OBJECTS="$dir/support/cxb30040.o $dir/support/cxb30060.o $dir/support/cxb30130.o $dir/support/cxb30131.o";;
242 ca1020e) rm -f ca1020e_func1.adb ca1020e_func2.adb ca1020e_proc1.adb ca1020e_proc2.adb > /dev/null 2>&1;;
243 ca14028) rm -f ca14028_func2.ads ca14028_func3.ads ca14028_proc1.ads ca14028_proc3.ads > /dev/null 2>&1;;
244 cxh1001) extraflags="-a -f"; echo "pragma Normalize_Scalars;" > gnat.adc
245 esac
246 if [ "$main" = "" ]; then
247 display "FAIL: $i"
248 failed="${failed}${i} "
249 clean_dir
250 continue
253 target_gnatmake $extraflags -I$dir/support $main >> $dir/acats.log 2>&1
254 if [ $? -ne 0 ]; then
255 display "FAIL: $i"
256 failed="${failed}${i} "
257 clean_dir
258 continue
261 echo "RUN $binmain" >> $dir/acats.log
262 cd $dir/run
263 if [ ! -x $dir/tests/$chapter/$i/$binmain ]; then
264 sync
266 target_run $dir/tests/$chapter/$i/$binmain > $dir/tests/$chapter/$i/${i}.log 2>&1
267 cd $dir/tests/$chapter/$i
268 cat ${i}.log >> $dir/acats.log
269 egrep -e '(==== |\+\+\+\+ |\!\!\!\! )' ${i}.log > /dev/null 2>&1
270 if [ $? -ne 0 ]; then
271 grep 'Tasking not implemented' ${i}.log > /dev/null 2>&1
273 if [ $? -ne 0 ]; then
274 display "FAIL: $i"
275 failed="${failed}${i} "
276 else
277 log "UNSUPPORTED: $i"
278 glob_countn=`expr $glob_countn - 1`
279 glob_countu=`expr $glob_countu + 1`
281 else
282 log "PASS: $i"
283 glob_countok=`expr $glob_countok + 1`
285 clean_dir
286 done
287 done
289 display " === acats Summary ==="
290 display "# of expected passes $glob_countok"
291 display "# of unexpected failures `expr $glob_countn - $glob_countok`"
293 if [ $glob_countu -ne 0 ]; then
294 display "# of unsupported tests $glob_countu"
297 if [ $glob_countok -ne $glob_countn ]; then
298 display "*** FAILURES: $failed"
301 exit 0