Debian Codegraph @

gcc/testsuite/ada/acats/run_all.sh

raw
1 #!/bin/sh
2 # Run ACATS with the GNU Ada compiler
3
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).
8
9 # gccflags="-O3 -funroll-loops"
10 # gnatflags="-gnatn"
11
12 gccflags="-O2"
13 gnatflags="-gnatws"
14
15 # End of customization section.
16
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 ()
22 {
23 as_val=$(( $* ))
24 }'
25 else
26 as_fn_arith ()
27 {
28 as_val=`expr "$@" || test $? -eq 1`
29 }
30 fi # as_fn_arith
31
32 display_noeol () {
33 printf "$@"
34 printf "$@" >> $dir/acats.sum
35 printf "$@" >> $dir/acats.log
36 }
37
38 display () {
39 echo "$@"
40 echo "$@" >> $dir/acats.sum
41 echo "$@" >> $dir/acats.log
42 }
43
44 log () {
45 echo "$@" >> $dir/acats.sum
46 echo "$@" >> $dir/acats.log
47 }
48
49 dir=`${PWDCMD-pwd}`
50
51 if [ "$dir" = "$testdir" ]; then
52 echo "error: srcdir must be different than objdir, exiting."
53 exit 1
54 fi
55
56 GCC="$BASE/xgcc -B$BASE/"
57
58 target_gnatchop () {
59 $BASE/gnatchop --GCC="$BASE/xgcc" $*
60 }
61
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"
65 }
66
67 target_gcc () {
68 $GCC $gccflags $*
69 }
70
71 target_run () {
72 eval $EXPECT -f $testdir/run_test.exp $*
73 }
74
75 clean_dir () {
76 rm -f "$binmain" *.o *.ali > /dev/null 2>&1
77 }
78
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`
84 }
85
86 EXTERNAL_OBJECTS=""
87 # Global variable to communicate external objects to link with.
88
89 rm -f $dir/acats.sum $dir/acats.log
90
91 display "Test Run By $USER on `date`"
92
93 display " === acats configuration ==="
94
95 target=`$GCC -dumpmachine`
96
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 ""
104
105 if [ -n "$GCC_RUNTEST_PARALLELIZE_DIR" ]; then
106 dir_support=$dir/../acats/support
107
108 rm -rf $dir/run
109 mv $dir/tests $dir/tests.$$ 2> /dev/null
110 rm -rf $dir/tests.$$ &
111 mkdir -p $dir/run
112
113 cp -pr $dir/../acats/tests $dir/
114 else
115 dir_support=$dir/support
116
117 display " === acats support ==="
118 display_noeol "Generating support files..."
119
120 rm -rf $dir/support
121 mkdir -p $dir/support
122 cd $dir/support
123
124 cp $testdir/support/*.ada $testdir/support/*.a $testdir/support/*.tst $dir/support
125
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
131 fi
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
135
136 case "$target_bit" in
137 *32*)
138 target_max_int="9223372036854775807"
139 target_min_int="-9223372036854775808"
140 ;;
141 *64*)
142 target_max_int="170141183460469231731687303715884105727"
143 target_min_int="-170141183460469231731687303715884105728"
144 ;;
145 *)
146 display "**** Unsupported bits per word"
147 exit 1
148 esac
149
150 echo target_max_insn="$target_max_int" >> $dir/acats.log
151 echo target_min_insn="$target_min_int" >> $dir/acats.log
152
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"
158 ;;
159 mmix-*-*)
160 target_insn="swym 0"
161 ;;
162 *)
163 target_insn="nop"
164 ;;
165 esac
166 echo target_insn="$target_insn" >> $dir/acats.log
167
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
178
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
182
183 rm -rf $dir/run
184 mv $dir/tests $dir/tests.$$ 2> /dev/null
185 rm -rf $dir/tests.$$ &
186 mkdir -p $dir/run
187
188 cp -pr $testdir/tests $dir/
189
190 for i in $dir/support/*.ada $dir/support/*.a; do
191 host_gnatchop $i >> $dir/acats.log 2>&1
192 done
193
194 # These tools are used to preprocess some ACATS sources
195 # they need to be compiled native on the host.
196
197 host_gnatmake -q -gnatws macrosub.adb
198 if [ $? -ne 0 ]; then
199 display "**** Failed to compile macrosub"
200 exit 1
201 fi
202 ./macrosub > macrosub.out 2>&1
203
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
209 fi
210 ./widechr > widechr.out 2>&1
211
212 rm -f $dir/support/macrosub
213 rm -f $dir/support/widechr
214 rm -f $dir/support/*.ali
215 rm -f $dir/support/*.o
216
217 display " done."
218
219 # From here, all compilations will be made by the target compiler
220
221 display_noeol "Compiling support files..."
222
223 target_gcc -c *.c
224 if [ $? -ne 0 ]; then
225 display "**** Failed to compile C code"
226 exit 1
227 fi
228
229 target_gnatchop *.adt >> $dir/acats.log 2>&1
230
231 target_gnatmake -c -gnato -gnatE *.ads >> $dir/acats.log 2>&1
232 target_gnatmake -c -gnato -gnatE *.adb >> $dir/acats.log 2>&1
233
234 display " done."
235 display ""
236
237 fi
238
239 display " === acats tests ==="
240
241 if [ $# -eq 0 ]; then
242 chapters=`cd $dir/tests; echo [a-z]*`
243 else
244 chapters=$*
245 fi
246
247 glob_countn=0
248 glob_countok=0
249 glob_countu=0
250 par_count=0
251 par_countm=0
252 par_last=
253
254 for chapter in $chapters; do
255 # Used to generate support once and finish after that.
256 [ "$chapter" = "NONE" ] && continue
257
258 display Running chapter $chapter ...
259
260 if [ ! -d $dir/tests/$chapter ]; then
261 display "*** CHAPTER $chapter does not exist, skipping."
262 display ""
263 continue
264 fi
265
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
274
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.
284 *)
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=
295 fi
296 fi;;
297 esac
298 if [ -z "$par_last" ]; then
299 as_fn_arith $glob_countn - 1
300 glob_countn=$as_val
301 continue
302 fi
303 fi
304
305 extraflags="-gnat95"
306 grep $i $testdir/overflow.lst > /dev/null 2>&1
307 if [ $? -eq 0 ]; then
308 extraflags="$extraflags -gnato"
309 fi
310 grep $i $testdir/elabd.lst > /dev/null 2>&1
311 if [ $? -eq 0 ]; then
312 extraflags="$extraflags -gnatE"
313 fi
314 grep $i $testdir/floatstore.lst > /dev/null 2>&1
315 if [ $? -eq 0 ]; then
316 extraflags="$extraflags -ffloat-store"
317 fi
318 grep $i $testdir/stackcheck.lst > /dev/null 2>&1
319 if [ $? -eq 0 ]; then
320 extraflags="$extraflags -fstack-check"
321 fi
322 test=$dir/tests/$chapter/$i
323 mkdir $test && cd $test >> $dir/acats.log 2>&1
324
325 if [ $? -ne 0 ]; then
326 display "FAIL: $i"
327 failed="${failed}${i} "
328 clean_dir
329 continue
330 fi
331
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
338 fi
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
352 fi
353
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
360 fi
361
362 echo "RUN $binmain" >> $dir/acats.log
363 cd $dir/run
364 if [ ! -x $dir/tests/$chapter/$i/$binmain ]; then
365 sync
366 fi
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
373
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
383 fi
384 else
385 log "PASS: $i"
386 as_fn_arith $glob_countok + 1
387 glob_countok=$as_val
388 fi
389 clean_dir
390 done
391 done
392
393 display " === acats Summary ==="
394 display "# of expected passes $glob_countok"
395 display "# of unexpected failures `expr $glob_countn - $glob_countok`"
396
397 if [ $glob_countu -ne 0 ]; then
398 display "# of unsupported tests $glob_countu"
399 fi
400
401 if [ $glob_countok -ne $glob_countn ]; then
402 display "*** FAILURES: $failed"
403 fi
404
405 display "$0 completed at `date`"
406
407 exit 0