gcc/
[official-gcc.git] / gcc / testsuite / ada / acats / run_all.sh
bloba084d6b3354c9d7baf7c233201f8e48eecbb8557
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 () {
16 eval $EXPECT -f $testdir/run_test.exp $*
19 # End of customization section.
21 # Perform arithmetic evaluation on the ARGs, and store the result in the
22 # global $as_val. Take advantage of shells that can avoid forks. The arguments
23 # must be portable across $(()) and expr.
24 if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
25 eval 'as_fn_arith ()
27 as_val=$(( $* ))
29 else
30 as_fn_arith ()
32 as_val=`expr "$@" || test $? -eq 1`
34 fi # as_fn_arith
36 display_noeol () {
37 printf "$@"
38 printf "$@" >> $dir/acats.sum
39 printf "$@" >> $dir/acats.log
42 display () {
43 echo "$@"
44 echo "$@" >> $dir/acats.sum
45 echo "$@" >> $dir/acats.log
48 log () {
49 echo "$@" >> $dir/acats.sum
50 echo "$@" >> $dir/acats.log
53 dir=`${PWDCMD-pwd}`
55 if [ "$testdir" = "" ]; then
56 echo You must use make check or make check-ada
57 exit 1
60 if [ "$dir" = "$testdir" ]; then
61 echo "error: srcdir must be different than objdir, exiting."
62 exit 1
65 target_gnatchop () {
66 gnatchop --GCC="$GCC_DRIVER" $*
69 target_gnatmake () {
70 echo gnatmake --GCC=\"$GCC\" $gnatflags $gccflags $* -largs $EXTERNAL_OBJECTS --GCC=\"$GCC\"
71 gnatmake --GCC="$GCC" $gnatflags $gccflags $* -largs $EXTERNAL_OBJECTS --GCC="$GCC"
74 target_gcc () {
75 $GCC $gccflags $*
78 clean_dir () {
79 rm -f "$binmain" *.o *.ali > /dev/null 2>&1
82 find_main () {
83 ls ${i}?.adb > ${i}.lst 2> /dev/null
84 ls ${i}*m.adb >> ${i}.lst 2> /dev/null
85 ls ${i}.adb >> ${i}.lst 2> /dev/null
86 main=`tail -1 ${i}.lst`
89 EXTERNAL_OBJECTS=""
90 # Global variable to communicate external objects to link with.
92 rm -f $dir/acats.sum $dir/acats.log
94 display "Test Run By $USER on `date`"
96 display " === acats configuration ==="
98 target=`$GCC -dumpmachine`
100 display target gcc is $GCC
101 display `$GCC -v 2>&1`
102 display host=`gcc -dumpmachine`
103 display target=$target
104 display `type gnatmake`
105 gnatls -v >> $dir/acats.log
106 display ""
108 if [ -n "$GCC_RUNTEST_PARALLELIZE_DIR" ]; then
109 dir_support=$dir/../acats/support
111 rm -rf $dir/run
112 mv $dir/tests $dir/tests.$$ 2> /dev/null
113 rm -rf $dir/tests.$$ &
114 mkdir -p $dir/run
116 cp -pr $dir/../acats/tests $dir/
117 else
118 dir_support=$dir/support
120 display " === acats support ==="
121 display_noeol "Generating support files..."
123 rm -rf $dir/support
124 mkdir -p $dir/support
125 cd $dir/support
127 cp $testdir/support/*.ada $testdir/support/*.a $testdir/support/*.tst $dir/support
129 # Find out the size in bit of an address on the target
130 target_gnatmake $testdir/support/impbit.adb >> $dir/acats.log 2>&1
131 target_run $dir/support/impbit > $dir/support/impbit.out 2>&1
132 target_bit=`cat $dir/support/impbit.out`
133 echo target_bit="$target_bit" >> $dir/acats.log
135 # Find out a suitable asm statement
136 # Adapted from configure.ac gcc_cv_as_dwarf2_debug_line
137 case "$target" in
138 ia64*-*-* | s390*-*-*)
139 target_insn="nop 0"
141 mmix-*-*)
142 target_insn="swym 0"
145 target_insn="nop"
147 esac
148 echo target_insn="$target_insn" >> $dir/acats.log
150 sed -e "s,ACATS4GNATDIR,$dir,g" \
151 < $testdir/support/impdef.a > $dir/support/impdef.a
152 sed -e "s,ACATS4GNATDIR,$dir,g" \
153 -e "s,ACATS4GNATBIT,$target_bit,g" \
154 -e "s,ACATS4GNATINSN,$target_insn,g" \
155 < $testdir/support/macro.dfs > $dir/support/MACRO.DFS
156 sed -e "s,ACATS4GNATDIR,$dir,g" \
157 < $testdir/support/tsttests.dat > $dir/support/TSTTESTS.DAT
159 cp $testdir/tests/cd/*.c $dir/support
160 cp $testdir/tests/cxb/*.c $dir/support
161 grep -v '^#' $testdir/norun.lst | sort > $dir/support/norun.lst
163 rm -rf $dir/run
164 mv $dir/tests $dir/tests.$$ 2> /dev/null
165 rm -rf $dir/tests.$$ &
166 mkdir -p $dir/run
168 cp -pr $testdir/tests $dir/
170 for i in $dir/support/*.ada $dir/support/*.a; do
171 host_gnatchop $i >> $dir/acats.log 2>&1
172 done
174 # These tools are used to preprocess some ACATS sources
175 # they need to be compiled native on the host.
177 host_gnatmake -q -gnatws macrosub.adb
178 if [ $? -ne 0 ]; then
179 display "**** Failed to compile macrosub"
180 exit 1
182 ./macrosub > macrosub.out 2>&1
184 gcc -c cd300051.c
185 host_gnatmake -q -gnatws widechr.adb
186 if [ $? -ne 0 ]; then
187 display "**** Failed to compile widechr"
188 exit 1
190 ./widechr > widechr.out 2>&1
192 rm -f $dir/support/macrosub
193 rm -f $dir/support/widechr
194 rm -f $dir/support/*.ali
195 rm -f $dir/support/*.o
197 display " done."
199 # From here, all compilations will be made by the target compiler
201 display_noeol "Compiling support files..."
203 target_gcc -c *.c
204 if [ $? -ne 0 ]; then
205 display "**** Failed to compile C code"
206 exit 1
209 target_gnatchop *.adt >> $dir/acats.log 2>&1
211 target_gnatmake -c -gnato -gnatE *.ads >> $dir/acats.log 2>&1
212 target_gnatmake -c -gnato -gnatE *.adb >> $dir/acats.log 2>&1
214 display " done."
215 display ""
219 display " === acats tests ==="
221 if [ $# -eq 0 ]; then
222 chapters=`cd $dir/tests; echo [a-z]*`
223 else
224 chapters=$*
227 glob_countn=0
228 glob_countok=0
229 glob_countu=0
230 par_count=0
231 par_countm=0
232 par_last=
234 for chapter in $chapters; do
235 # Used to generate support once and finish after that.
236 [ "$chapter" = "NONE" ] && continue
238 display Running chapter $chapter ...
240 if [ ! -d $dir/tests/$chapter ]; then
241 display "*** CHAPTER $chapter does not exist, skipping."
242 display ""
243 continue
246 cd $dir/tests/$chapter
247 ls *.a *.ada *.adt *.am *.dep 2> /dev/null | sed -e 's/\(.*\)\..*/\1/g' | \
248 cut -c1-7 | sort | uniq | comm -23 - $dir_support/norun.lst \
249 > $dir/tests/$chapter/${chapter}.lst
250 countn=`wc -l < $dir/tests/$chapter/${chapter}.lst`
251 as_fn_arith $glob_countn + $countn
252 glob_countn=$as_val
253 for i in `cat $dir/tests/$chapter/${chapter}.lst`; do
255 # If running multiple run_all.sh jobs in parallel, decide
256 # if we should run this test in the current instance.
257 if [ -n "$GCC_RUNTEST_PARALLELIZE_DIR" ]; then
258 case "$i" in
259 # Ugh, some tests have inter-test dependencies, those
260 # tests have to be scheduled on the same parallel instance
261 # as previous test.
262 ce2108f | ce2108h | ce3112d) ;;
263 # All others can be hopefully scheduled freely.
265 as_fn_arith $par_countm + 1
266 par_countm=$as_val
267 [ $par_countm -eq 10 ] && par_countm=0
268 if [ $par_countm -eq 1 ]; then
269 as_fn_arith $par_count + 1
270 par_count=$as_val
271 if mkdir $GCC_RUNTEST_PARALLELIZE_DIR/$par_count; then
272 par_last=1
273 else
274 par_last=
276 fi;;
277 esac
278 if [ -z "$par_last" ]; then
279 as_fn_arith $glob_countn - 1
280 glob_countn=$as_val
281 continue
285 extraflags="-gnat95"
286 grep $i $testdir/overflow.lst > /dev/null 2>&1
287 if [ $? -eq 0 ]; then
288 extraflags="$extraflags -gnato"
290 grep $i $testdir/elabd.lst > /dev/null 2>&1
291 if [ $? -eq 0 ]; then
292 extraflags="$extraflags -gnatE"
294 grep $i $testdir/floatstore.lst > /dev/null 2>&1
295 if [ $? -eq 0 ]; then
296 extraflags="$extraflags -ffloat-store"
298 grep $i $testdir/stackcheck.lst > /dev/null 2>&1
299 if [ $? -eq 0 ]; then
300 extraflags="$extraflags -fstack-check"
302 test=$dir/tests/$chapter/$i
303 mkdir $test && cd $test >> $dir/acats.log 2>&1
305 if [ $? -ne 0 ]; then
306 display "FAIL: $i"
307 failed="${failed}${i} "
308 clean_dir
309 continue
312 target_gnatchop -c -w `ls ${test}*.a ${test}*.ada ${test}*.adt ${test}*.am ${test}*.dep 2> /dev/null` >> $dir/acats.log 2>&1
313 main=""
314 find_main
315 if [ -z "$main" ]; then
316 sync
317 find_main
319 binmain=`echo $main | sed -e 's/\(.*\)\..*/\1/g'`
320 echo "BUILD $main" >> $dir/acats.log
321 EXTERNAL_OBJECTS=""
322 case $i in
323 cxb30*) EXTERNAL_OBJECTS="$dir_support/cxb30040.o $dir_support/cxb30060.o $dir_support/cxb30130.o $dir_support/cxb30131.o";;
324 ca1020e) rm -f ca1020e_func1.adb ca1020e_func2.adb ca1020e_proc1.adb ca1020e_proc2.adb > /dev/null 2>&1;;
325 ca14028) rm -f ca14028_func2.ads ca14028_func3.ads ca14028_proc1.ads ca14028_proc3.ads > /dev/null 2>&1;;
326 esac
327 if [ "$main" = "" ]; then
328 display "FAIL: $i"
329 failed="${failed}${i} "
330 clean_dir
331 continue
334 target_gnatmake $extraflags -I$dir_support $main >> $dir/acats.log 2>&1
335 if [ $? -ne 0 ]; then
336 display "FAIL: $i"
337 failed="${failed}${i} "
338 clean_dir
339 continue
342 echo "RUN $binmain" >> $dir/acats.log
343 cd $dir/run
344 if [ ! -x $dir/tests/$chapter/$i/$binmain ]; then
345 sync
347 target_run $dir/tests/$chapter/$i/$binmain > $dir/tests/$chapter/$i/${i}.log 2>&1
348 cd $dir/tests/$chapter/$i
349 cat ${i}.log >> $dir/acats.log
350 egrep -e '(==== |\+\+\+\+ |\!\!\!\! )' ${i}.log > /dev/null 2>&1
351 if [ $? -ne 0 ]; then
352 grep 'tasking not implemented' ${i}.log > /dev/null 2>&1
354 if [ $? -ne 0 ]; then
355 display "FAIL: $i"
356 failed="${failed}${i} "
357 else
358 log "UNSUPPORTED: $i"
359 as_fn_arith $glob_countn - 1
360 glob_countn=$as_val
361 as_fn_arith $glob_countu + 1
362 glob_countu=$as_val
364 else
365 log "PASS: $i"
366 as_fn_arith $glob_countok + 1
367 glob_countok=$as_val
369 clean_dir
370 done
371 done
373 display " === acats Summary ==="
374 display "# of expected passes $glob_countok"
375 display "# of unexpected failures `expr $glob_countn - $glob_countok`"
377 if [ $glob_countu -ne 0 ]; then
378 display "# of unsupported tests $glob_countu"
381 if [ $glob_countok -ne $glob_countn ]; then
382 display "*** FAILURES: $failed"
385 display "$0 completed at `date`"
387 exit 0