Adjust example of compiler options for ACATS
[official-gcc.git] / gcc / testsuite / ada / acats / run_all.sh
blob38ec4692899715a5038bf54392330340e31633e7
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 -funroll-loops"
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 case "$target_bit" in
137 *32*)
138 target_max_int="9223372036854775807"
139 target_min_int="-9223372036854775808"
141 *64*)
142 target_max_int="170141183460469231731687303715884105727"
143 target_min_int="-170141183460469231731687303715884105728"
146 display "**** Unsupported bits per word"
147 exit 1
148 esac
150 echo target_max_insn="$target_max_int" >> $dir/acats.log
151 echo target_min_insn="$target_min_int" >> $dir/acats.log
153 # Find out a suitable asm statement
154 # Adapted from configure.ac gcc_cv_as_dwarf2_debug_line
155 case "$target" in
156 ia64*-*-* | s390*-*-*)
157 target_insn="nop 0"
159 mmix-*-*)
160 target_insn="swym 0"
163 target_insn="nop"
165 esac
166 echo target_insn="$target_insn" >> $dir/acats.log
168 sed -e "s,ACATS4GNATDIR,$dir,g" \
169 < $testdir/support/impdef.a > $dir/support/impdef.a
170 sed -e "s,ACATS4GNATDIR,$dir,g" \
171 -e "s,ACATS4GNATBIT,$target_bit,g" \
172 -e "s,ACATS4GNATINSN,$target_insn,g" \
173 -e "s,ACATS4GNATMAXINT,$target_max_int,g" \
174 -e "s,ACATS4GNATMININT,$target_min_int,g" \
175 < $testdir/support/macro.dfs > $dir/support/MACRO.DFS
176 sed -e "s,ACATS4GNATDIR,$dir,g" \
177 < $testdir/support/tsttests.dat > $dir/support/TSTTESTS.DAT
179 cp $testdir/tests/cd/*.c $dir/support
180 cp $testdir/tests/cxb/*.c $dir/support
181 grep -v '^#' $testdir/norun.lst | sort > $dir/support/norun.lst
183 rm -rf $dir/run
184 mv $dir/tests $dir/tests.$$ 2> /dev/null
185 rm -rf $dir/tests.$$ &
186 mkdir -p $dir/run
188 cp -pr $testdir/tests $dir/
190 for i in $dir/support/*.ada $dir/support/*.a; do
191 host_gnatchop $i >> $dir/acats.log 2>&1
192 done
194 # These tools are used to preprocess some ACATS sources
195 # they need to be compiled native on the host.
197 host_gnatmake -q -gnatws macrosub.adb
198 if [ $? -ne 0 ]; then
199 display "**** Failed to compile macrosub"
200 exit 1
202 ./macrosub > macrosub.out 2>&1
204 gcc -c cd300051.c
205 host_gnatmake -q -gnatws widechr.adb
206 if [ $? -ne 0 ]; then
207 display "**** Failed to compile widechr"
208 exit 1
210 ./widechr > widechr.out 2>&1
212 rm -f $dir/support/macrosub
213 rm -f $dir/support/widechr
214 rm -f $dir/support/*.ali
215 rm -f $dir/support/*.o
217 display " done."
219 # From here, all compilations will be made by the target compiler
221 display_noeol "Compiling support files..."
223 target_gcc -c *.c
224 if [ $? -ne 0 ]; then
225 display "**** Failed to compile C code"
226 exit 1
229 target_gnatchop *.adt >> $dir/acats.log 2>&1
231 target_gnatmake -c -gnato -gnatE *.ads >> $dir/acats.log 2>&1
232 target_gnatmake -c -gnato -gnatE *.adb >> $dir/acats.log 2>&1
234 display " done."
235 display ""
239 display " === acats tests ==="
241 if [ $# -eq 0 ]; then
242 chapters=`cd $dir/tests; echo [a-z]*`
243 else
244 chapters=$*
247 glob_countn=0
248 glob_countok=0
249 glob_countu=0
250 par_count=0
251 par_countm=0
252 par_last=
254 for chapter in $chapters; do
255 # Used to generate support once and finish after that.
256 [ "$chapter" = "NONE" ] && continue
258 display Running chapter $chapter ...
260 if [ ! -d $dir/tests/$chapter ]; then
261 display "*** CHAPTER $chapter does not exist, skipping."
262 display ""
263 continue
266 cd $dir/tests/$chapter
267 ls *.a *.ada *.adt *.am *.dep 2> /dev/null | sed -e 's/\(.*\)\..*/\1/g' | \
268 cut -c1-7 | sort | uniq | comm -23 - $dir_support/norun.lst \
269 > $dir/tests/$chapter/${chapter}.lst
270 countn=`wc -l < $dir/tests/$chapter/${chapter}.lst`
271 as_fn_arith $glob_countn + $countn
272 glob_countn=$as_val
273 for i in `cat $dir/tests/$chapter/${chapter}.lst`; do
275 # If running multiple run_all.sh jobs in parallel, decide
276 # if we should run this test in the current instance.
277 if [ -n "$GCC_RUNTEST_PARALLELIZE_DIR" ]; then
278 case "$i" in
279 # Ugh, some tests have inter-test dependencies, those
280 # tests have to be scheduled on the same parallel instance
281 # as previous test.
282 ce2108f | ce2108h | ce3112d) ;;
283 # All others can be hopefully scheduled freely.
285 as_fn_arith $par_countm + 1
286 par_countm=$as_val
287 [ $par_countm -eq 10 ] && par_countm=0
288 if [ $par_countm -eq 1 ]; then
289 as_fn_arith $par_count + 1
290 par_count=$as_val
291 if mkdir $GCC_RUNTEST_PARALLELIZE_DIR/$par_count 2>/dev/null; then
292 par_last=1
293 else
294 par_last=
296 fi;;
297 esac
298 if [ -z "$par_last" ]; then
299 as_fn_arith $glob_countn - 1
300 glob_countn=$as_val
301 continue
305 extraflags="-gnat95"
306 grep $i $testdir/overflow.lst > /dev/null 2>&1
307 if [ $? -eq 0 ]; then
308 extraflags="$extraflags -gnato"
310 grep $i $testdir/elabd.lst > /dev/null 2>&1
311 if [ $? -eq 0 ]; then
312 extraflags="$extraflags -gnatE"
314 grep $i $testdir/floatstore.lst > /dev/null 2>&1
315 if [ $? -eq 0 ]; then
316 extraflags="$extraflags -ffloat-store"
318 grep $i $testdir/stackcheck.lst > /dev/null 2>&1
319 if [ $? -eq 0 ]; then
320 extraflags="$extraflags -fstack-check"
322 test=$dir/tests/$chapter/$i
323 mkdir $test && cd $test >> $dir/acats.log 2>&1
325 if [ $? -ne 0 ]; then
326 display "FAIL: $i"
327 failed="${failed}${i} "
328 clean_dir
329 continue
332 target_gnatchop -c -w `ls ${test}*.a ${test}*.ada ${test}*.adt ${test}*.am ${test}*.dep 2> /dev/null` >> $dir/acats.log 2>&1
333 main=""
334 find_main
335 if [ -z "$main" ]; then
336 sync
337 find_main
339 binmain=`echo $main | sed -e 's/\(.*\)\..*/\1/g'`
340 echo "BUILD $main" >> $dir/acats.log
341 EXTERNAL_OBJECTS=""
342 case $i in
343 cxb30*) EXTERNAL_OBJECTS="$dir_support/cxb30040.o $dir_support/cxb30060.o $dir_support/cxb30130.o $dir_support/cxb30131.o";;
344 ca1020e) rm -f ca1020e_func1.adb ca1020e_func2.adb ca1020e_proc1.adb ca1020e_proc2.adb > /dev/null 2>&1;;
345 ca14028) rm -f ca14028_func2.ads ca14028_func3.ads ca14028_proc1.ads ca14028_proc3.ads > /dev/null 2>&1;;
346 esac
347 if [ "$main" = "" ]; then
348 display "FAIL: $i"
349 failed="${failed}${i} "
350 clean_dir
351 continue
354 target_gnatmake $extraflags -I$dir_support $main >> $dir/acats.log 2>&1
355 if [ $? -ne 0 ]; then
356 display "FAIL: $i"
357 failed="${failed}${i} "
358 clean_dir
359 continue
362 echo "RUN $binmain" >> $dir/acats.log
363 cd $dir/run
364 if [ ! -x $dir/tests/$chapter/$i/$binmain ]; then
365 sync
367 target_run $dir/tests/$chapter/$i/$binmain > $dir/tests/$chapter/$i/${i}.log 2>&1
368 cd $dir/tests/$chapter/$i
369 cat ${i}.log >> $dir/acats.log
370 egrep -e '(==== |\+\+\+\+ |\!\!\!\! )' ${i}.log > /dev/null 2>&1
371 if [ $? -ne 0 ]; then
372 grep 'tasking not implemented' ${i}.log > /dev/null 2>&1
374 if [ $? -ne 0 ]; then
375 display "FAIL: $i"
376 failed="${failed}${i} "
377 else
378 log "UNSUPPORTED: $i"
379 as_fn_arith $glob_countn - 1
380 glob_countn=$as_val
381 as_fn_arith $glob_countu + 1
382 glob_countu=$as_val
384 else
385 log "PASS: $i"
386 as_fn_arith $glob_countok + 1
387 glob_countok=$as_val
389 clean_dir
390 done
391 done
393 display " === acats Summary ==="
394 display "# of expected passes $glob_countok"
395 display "# of unexpected failures `expr $glob_countn - $glob_countok`"
397 if [ $glob_countu -ne 0 ]; then
398 display "# of unsupported tests $glob_countu"
401 if [ $glob_countok -ne $glob_countn ]; then
402 display "*** FAILURES: $failed"
405 display "$0 completed at `date`"
407 exit 0