2016-12-07 Thomas Preud'homme <thomas.preudhomme@arm.com>
[official-gcc.git] / gcc / testsuite / ada / acats / run_all.sh
blob764598398a28561d42812f31b45fc5a8d97e7fa3
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 # End of customization section.
17 # Perform arithmetic evaluation on the ARGs, and store the result in the
18 # global $as_val. Take advantage of shells that can avoid forks. The arguments
19 # must be portable across $(()) and expr.
20 if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
21 eval 'as_fn_arith ()
23 as_val=$(( $* ))
25 else
26 as_fn_arith ()
28 as_val=`expr "$@" || test $? -eq 1`
30 fi # as_fn_arith
32 display_noeol () {
33 printf "$@"
34 printf "$@" >> $dir/acats.sum
35 printf "$@" >> $dir/acats.log
38 display () {
39 echo "$@"
40 echo "$@" >> $dir/acats.sum
41 echo "$@" >> $dir/acats.log
44 log () {
45 echo "$@" >> $dir/acats.sum
46 echo "$@" >> $dir/acats.log
49 dir=`${PWDCMD-pwd}`
51 if [ "$dir" = "$testdir" ]; then
52 echo "error: srcdir must be different than objdir, exiting."
53 exit 1
56 GCC="$BASE/xgcc -B$BASE/"
58 target_gnatchop () {
59 $BASE/gnatchop --GCC="$BASE/xgcc" $*
62 target_gnatmake () {
63 echo $BASE/gnatmake --GNATBIND=$BASE/gnatbind --GNATLINK=$BASE/gnatlink --GCC="$GCC" $gnatflags $gccflags $* -largs $EXTERNAL_OBJECTS --GCC="$GCC"
64 $BASE/gnatmake --GNATBIND=$BASE/gnatbind --GNATLINK=$BASE/gnatlink --GCC="$GCC" $gnatflags $gccflags $* -largs $EXTERNAL_OBJECTS --GCC="$GCC"
67 target_gcc () {
68 $GCC $gccflags $*
71 target_run () {
72 eval $EXPECT -f $testdir/run_test.exp $*
75 clean_dir () {
76 rm -f "$binmain" *.o *.ali > /dev/null 2>&1
79 find_main () {
80 ls ${i}?.adb > ${i}.lst 2> /dev/null
81 ls ${i}*m.adb >> ${i}.lst 2> /dev/null
82 ls ${i}.adb >> ${i}.lst 2> /dev/null
83 main=`tail -1 ${i}.lst`
86 EXTERNAL_OBJECTS=""
87 # Global variable to communicate external objects to link with.
89 rm -f $dir/acats.sum $dir/acats.log
91 display "Test Run By $USER on `date`"
93 display " === acats configuration ==="
95 target=`$GCC -dumpmachine`
97 display target gcc is $GCC
98 display `$GCC -v 2>&1`
99 display host=`gcc -dumpmachine`
100 display target=$target
101 display `type gnatmake`
102 gnatls -v >> $dir/acats.log
103 display ""
105 if [ -n "$GCC_RUNTEST_PARALLELIZE_DIR" ]; then
106 dir_support=$dir/../acats/support
108 rm -rf $dir/run
109 mv $dir/tests $dir/tests.$$ 2> /dev/null
110 rm -rf $dir/tests.$$ &
111 mkdir -p $dir/run
113 cp -pr $dir/../acats/tests $dir/
114 else
115 dir_support=$dir/support
117 display " === acats support ==="
118 display_noeol "Generating support files..."
120 rm -rf $dir/support
121 mkdir -p $dir/support
122 cd $dir/support
124 cp $testdir/support/*.ada $testdir/support/*.a $testdir/support/*.tst $dir/support
126 # Find out the size in bit of an address on the target
127 target_gnatmake $testdir/support/impbit.adb >> $dir/acats.log 2>&1
128 if [ $? -ne 0 ]; then
129 display "**** Failed to compile impbit"
130 exit 1
132 target_run $dir/support/impbit > $dir/support/impbit.out 2>&1
133 target_bit=`cat $dir/support/impbit.out`
134 echo target_bit="$target_bit" >> $dir/acats.log
136 # Find out a suitable asm statement
137 # Adapted from configure.ac gcc_cv_as_dwarf2_debug_line
138 case "$target" in
139 ia64*-*-* | s390*-*-*)
140 target_insn="nop 0"
142 mmix-*-*)
143 target_insn="swym 0"
146 target_insn="nop"
148 esac
149 echo target_insn="$target_insn" >> $dir/acats.log
151 sed -e "s,ACATS4GNATDIR,$dir,g" \
152 < $testdir/support/impdef.a > $dir/support/impdef.a
153 sed -e "s,ACATS4GNATDIR,$dir,g" \
154 -e "s,ACATS4GNATBIT,$target_bit,g" \
155 -e "s,ACATS4GNATINSN,$target_insn,g" \
156 < $testdir/support/macro.dfs > $dir/support/MACRO.DFS
157 sed -e "s,ACATS4GNATDIR,$dir,g" \
158 < $testdir/support/tsttests.dat > $dir/support/TSTTESTS.DAT
160 cp $testdir/tests/cd/*.c $dir/support
161 cp $testdir/tests/cxb/*.c $dir/support
162 grep -v '^#' $testdir/norun.lst | sort > $dir/support/norun.lst
164 rm -rf $dir/run
165 mv $dir/tests $dir/tests.$$ 2> /dev/null
166 rm -rf $dir/tests.$$ &
167 mkdir -p $dir/run
169 cp -pr $testdir/tests $dir/
171 for i in $dir/support/*.ada $dir/support/*.a; do
172 host_gnatchop $i >> $dir/acats.log 2>&1
173 done
175 # These tools are used to preprocess some ACATS sources
176 # they need to be compiled native on the host.
178 host_gnatmake -q -gnatws macrosub.adb
179 if [ $? -ne 0 ]; then
180 display "**** Failed to compile macrosub"
181 exit 1
183 ./macrosub > macrosub.out 2>&1
185 gcc -c cd300051.c
186 host_gnatmake -q -gnatws widechr.adb
187 if [ $? -ne 0 ]; then
188 display "**** Failed to compile widechr"
189 exit 1
191 ./widechr > widechr.out 2>&1
193 rm -f $dir/support/macrosub
194 rm -f $dir/support/widechr
195 rm -f $dir/support/*.ali
196 rm -f $dir/support/*.o
198 display " done."
200 # From here, all compilations will be made by the target compiler
202 display_noeol "Compiling support files..."
204 target_gcc -c *.c
205 if [ $? -ne 0 ]; then
206 display "**** Failed to compile C code"
207 exit 1
210 target_gnatchop *.adt >> $dir/acats.log 2>&1
212 target_gnatmake -c -gnato -gnatE *.ads >> $dir/acats.log 2>&1
213 target_gnatmake -c -gnato -gnatE *.adb >> $dir/acats.log 2>&1
215 display " done."
216 display ""
220 display " === acats tests ==="
222 if [ $# -eq 0 ]; then
223 chapters=`cd $dir/tests; echo [a-z]*`
224 else
225 chapters=$*
228 glob_countn=0
229 glob_countok=0
230 glob_countu=0
231 par_count=0
232 par_countm=0
233 par_last=
235 for chapter in $chapters; do
236 # Used to generate support once and finish after that.
237 [ "$chapter" = "NONE" ] && continue
239 display Running chapter $chapter ...
241 if [ ! -d $dir/tests/$chapter ]; then
242 display "*** CHAPTER $chapter does not exist, skipping."
243 display ""
244 continue
247 cd $dir/tests/$chapter
248 ls *.a *.ada *.adt *.am *.dep 2> /dev/null | sed -e 's/\(.*\)\..*/\1/g' | \
249 cut -c1-7 | sort | uniq | comm -23 - $dir_support/norun.lst \
250 > $dir/tests/$chapter/${chapter}.lst
251 countn=`wc -l < $dir/tests/$chapter/${chapter}.lst`
252 as_fn_arith $glob_countn + $countn
253 glob_countn=$as_val
254 for i in `cat $dir/tests/$chapter/${chapter}.lst`; do
256 # If running multiple run_all.sh jobs in parallel, decide
257 # if we should run this test in the current instance.
258 if [ -n "$GCC_RUNTEST_PARALLELIZE_DIR" ]; then
259 case "$i" in
260 # Ugh, some tests have inter-test dependencies, those
261 # tests have to be scheduled on the same parallel instance
262 # as previous test.
263 ce2108f | ce2108h | ce3112d) ;;
264 # All others can be hopefully scheduled freely.
266 as_fn_arith $par_countm + 1
267 par_countm=$as_val
268 [ $par_countm -eq 10 ] && par_countm=0
269 if [ $par_countm -eq 1 ]; then
270 as_fn_arith $par_count + 1
271 par_count=$as_val
272 if mkdir $GCC_RUNTEST_PARALLELIZE_DIR/$par_count 2>/dev/null; then
273 par_last=1
274 else
275 par_last=
277 fi;;
278 esac
279 if [ -z "$par_last" ]; then
280 as_fn_arith $glob_countn - 1
281 glob_countn=$as_val
282 continue
286 extraflags="-gnat95"
287 grep $i $testdir/overflow.lst > /dev/null 2>&1
288 if [ $? -eq 0 ]; then
289 extraflags="$extraflags -gnato"
291 grep $i $testdir/elabd.lst > /dev/null 2>&1
292 if [ $? -eq 0 ]; then
293 extraflags="$extraflags -gnatE"
295 grep $i $testdir/floatstore.lst > /dev/null 2>&1
296 if [ $? -eq 0 ]; then
297 extraflags="$extraflags -ffloat-store"
299 grep $i $testdir/stackcheck.lst > /dev/null 2>&1
300 if [ $? -eq 0 ]; then
301 extraflags="$extraflags -fstack-check"
303 test=$dir/tests/$chapter/$i
304 mkdir $test && cd $test >> $dir/acats.log 2>&1
306 if [ $? -ne 0 ]; then
307 display "FAIL: $i"
308 failed="${failed}${i} "
309 clean_dir
310 continue
313 target_gnatchop -c -w `ls ${test}*.a ${test}*.ada ${test}*.adt ${test}*.am ${test}*.dep 2> /dev/null` >> $dir/acats.log 2>&1
314 main=""
315 find_main
316 if [ -z "$main" ]; then
317 sync
318 find_main
320 binmain=`echo $main | sed -e 's/\(.*\)\..*/\1/g'`
321 echo "BUILD $main" >> $dir/acats.log
322 EXTERNAL_OBJECTS=""
323 case $i in
324 cxb30*) EXTERNAL_OBJECTS="$dir_support/cxb30040.o $dir_support/cxb30060.o $dir_support/cxb30130.o $dir_support/cxb30131.o";;
325 ca1020e) rm -f ca1020e_func1.adb ca1020e_func2.adb ca1020e_proc1.adb ca1020e_proc2.adb > /dev/null 2>&1;;
326 ca14028) rm -f ca14028_func2.ads ca14028_func3.ads ca14028_proc1.ads ca14028_proc3.ads > /dev/null 2>&1;;
327 esac
328 if [ "$main" = "" ]; then
329 display "FAIL: $i"
330 failed="${failed}${i} "
331 clean_dir
332 continue
335 target_gnatmake $extraflags -I$dir_support $main >> $dir/acats.log 2>&1
336 if [ $? -ne 0 ]; then
337 display "FAIL: $i"
338 failed="${failed}${i} "
339 clean_dir
340 continue
343 echo "RUN $binmain" >> $dir/acats.log
344 cd $dir/run
345 if [ ! -x $dir/tests/$chapter/$i/$binmain ]; then
346 sync
348 target_run $dir/tests/$chapter/$i/$binmain > $dir/tests/$chapter/$i/${i}.log 2>&1
349 cd $dir/tests/$chapter/$i
350 cat ${i}.log >> $dir/acats.log
351 egrep -e '(==== |\+\+\+\+ |\!\!\!\! )' ${i}.log > /dev/null 2>&1
352 if [ $? -ne 0 ]; then
353 grep 'tasking not implemented' ${i}.log > /dev/null 2>&1
355 if [ $? -ne 0 ]; then
356 display "FAIL: $i"
357 failed="${failed}${i} "
358 else
359 log "UNSUPPORTED: $i"
360 as_fn_arith $glob_countn - 1
361 glob_countn=$as_val
362 as_fn_arith $glob_countu + 1
363 glob_countu=$as_val
365 else
366 log "PASS: $i"
367 as_fn_arith $glob_countok + 1
368 glob_countok=$as_val
370 clean_dir
371 done
372 done
374 display " === acats Summary ==="
375 display "# of expected passes $glob_countok"
376 display "# of unexpected failures `expr $glob_countn - $glob_countok`"
378 if [ $glob_countu -ne 0 ]; then
379 display "# of unsupported tests $glob_countu"
382 if [ $glob_countok -ne $glob_countn ]; then
383 display "*** FAILURES: $failed"
386 display "$0 completed at `date`"
388 exit 0