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 -fomit-frame-pointer -funroll-all-loops -finline-functions" 10# gnatflags="-gnatN" 11 12gccflags="-O2" 13gnatflags="-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. 20if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : 21 eval 'as_fn_arith () 22 { 23 as_val=$(( $* )) 24 }' 25else 26 as_fn_arith () 27 { 28 as_val=`expr "$@" || test $? -eq 1` 29 } 30fi # as_fn_arith 31 32display_noeol () { 33 printf "$@" 34 printf "$@" >> $dir/acats.sum 35 printf "$@" >> $dir/acats.log 36} 37 38display () { 39 echo "$@" 40 echo "$@" >> $dir/acats.sum 41 echo "$@" >> $dir/acats.log 42} 43 44log () { 45 echo "$@" >> $dir/acats.sum 46 echo "$@" >> $dir/acats.log 47} 48 49dir=`${PWDCMD-pwd}` 50 51if [ "$dir" = "$testdir" ]; then 52 echo "error: srcdir must be different than objdir, exiting." 53 exit 1 54fi 55 56GCC="$BASE/xgcc -B$BASE/" 57 58target_gnatchop () { 59 $BASE/gnatchop --GCC="$BASE/xgcc" $* 60} 61 62target_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 67target_gcc () { 68 $GCC $gccflags $* 69} 70 71target_run () { 72 eval $EXPECT -f $testdir/run_test.exp $* 73} 74 75clean_dir () { 76 rm -f "$binmain" *.o *.ali > /dev/null 2>&1 77} 78 79find_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 86EXTERNAL_OBJECTS="" 87# Global variable to communicate external objects to link with. 88 89rm -f $dir/acats.sum $dir/acats.log 90 91display "Test Run By $USER on `date`" 92 93display " === acats configuration ===" 94 95target=`$GCC -dumpmachine` 96 97display target gcc is $GCC 98display `$GCC -v 2>&1` 99display host=`gcc -dumpmachine` 100display target=$target 101display `type gnatmake` 102gnatls -v >> $dir/acats.log 103display "" 104 105if [ -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/ 114else 115 dir_support=$dir/support 116 117display " === acats support ===" 118display_noeol "Generating support files..." 119 120rm -rf $dir/support 121mkdir -p $dir/support 122cd $dir/support 123 124cp $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 127target_gnatmake $testdir/support/impbit.adb >> $dir/acats.log 2>&1 128if [ $? -ne 0 ]; then 129 display "**** Failed to compile impbit" 130 exit 1 131fi 132target_run $dir/support/impbit > $dir/support/impbit.out 2>&1 133target_bit=`cat $dir/support/impbit.out` 134echo target_bit="$target_bit" >> $dir/acats.log 135 136# Find out a suitable asm statement 137# Adapted from configure.ac gcc_cv_as_dwarf2_debug_line 138case "$target" in 139 ia64*-*-* | s390*-*-*) 140 target_insn="nop 0" 141 ;; 142 mmix-*-*) 143 target_insn="swym 0" 144 ;; 145 *) 146 target_insn="nop" 147 ;; 148esac 149echo target_insn="$target_insn" >> $dir/acats.log 150 151sed -e "s,ACATS4GNATDIR,$dir,g" \ 152 < $testdir/support/impdef.a > $dir/support/impdef.a 153sed -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 157sed -e "s,ACATS4GNATDIR,$dir,g" \ 158 < $testdir/support/tsttests.dat > $dir/support/TSTTESTS.DAT 159 160cp $testdir/tests/cd/*.c $dir/support 161cp $testdir/tests/cxb/*.c $dir/support 162grep -v '^#' $testdir/norun.lst | sort > $dir/support/norun.lst 163 164rm -rf $dir/run 165mv $dir/tests $dir/tests.$$ 2> /dev/null 166rm -rf $dir/tests.$$ & 167mkdir -p $dir/run 168 169cp -pr $testdir/tests $dir/ 170 171for i in $dir/support/*.ada $dir/support/*.a; do 172 host_gnatchop $i >> $dir/acats.log 2>&1 173done 174 175# These tools are used to preprocess some ACATS sources 176# they need to be compiled native on the host. 177 178host_gnatmake -q -gnatws macrosub.adb 179if [ $? -ne 0 ]; then 180 display "**** Failed to compile macrosub" 181 exit 1 182fi 183./macrosub > macrosub.out 2>&1 184 185gcc -c cd300051.c 186host_gnatmake -q -gnatws widechr.adb 187if [ $? -ne 0 ]; then 188 display "**** Failed to compile widechr" 189 exit 1 190fi 191./widechr > widechr.out 2>&1 192 193rm -f $dir/support/macrosub 194rm -f $dir/support/widechr 195rm -f $dir/support/*.ali 196rm -f $dir/support/*.o 197 198display " done." 199 200# From here, all compilations will be made by the target compiler 201 202display_noeol "Compiling support files..." 203 204target_gcc -c *.c 205if [ $? -ne 0 ]; then 206 display "**** Failed to compile C code" 207 exit 1 208fi 209 210target_gnatchop *.adt >> $dir/acats.log 2>&1 211 212target_gnatmake -c -gnato -gnatE *.ads >> $dir/acats.log 2>&1 213target_gnatmake -c -gnato -gnatE *.adb >> $dir/acats.log 2>&1 214 215display " done." 216display "" 217 218fi 219 220display " === acats tests ===" 221 222if [ $# -eq 0 ]; then 223 chapters=`cd $dir/tests; echo [a-z]*` 224else 225 chapters=$* 226fi 227 228glob_countn=0 229glob_countok=0 230glob_countu=0 231par_count=0 232par_countm=0 233par_last= 234 235for chapter in $chapters; do 236 # Used to generate support once and finish after that. 237 [ "$chapter" = "NONE" ] && continue 238 239 display Running chapter $chapter ... 240 241 if [ ! -d $dir/tests/$chapter ]; then 242 display "*** CHAPTER $chapter does not exist, skipping." 243 display "" 244 continue 245 fi 246 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 255 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. 265 *) 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= 276 fi 277 fi;; 278 esac 279 if [ -z "$par_last" ]; then 280 as_fn_arith $glob_countn - 1 281 glob_countn=$as_val 282 continue 283 fi 284 fi 285 286 extraflags="-gnat95" 287 grep $i $testdir/overflow.lst > /dev/null 2>&1 288 if [ $? -eq 0 ]; then 289 extraflags="$extraflags -gnato" 290 fi 291 grep $i $testdir/elabd.lst > /dev/null 2>&1 292 if [ $? -eq 0 ]; then 293 extraflags="$extraflags -gnatE" 294 fi 295 grep $i $testdir/floatstore.lst > /dev/null 2>&1 296 if [ $? -eq 0 ]; then 297 extraflags="$extraflags -ffloat-store" 298 fi 299 grep $i $testdir/stackcheck.lst > /dev/null 2>&1 300 if [ $? -eq 0 ]; then 301 extraflags="$extraflags -fstack-check" 302 fi 303 test=$dir/tests/$chapter/$i 304 mkdir $test && cd $test >> $dir/acats.log 2>&1 305 306 if [ $? -ne 0 ]; then 307 display "FAIL: $i" 308 failed="${failed}${i} " 309 clean_dir 310 continue 311 fi 312 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 319 fi 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 333 fi 334 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 341 fi 342 343 echo "RUN $binmain" >> $dir/acats.log 344 cd $dir/run 345 if [ ! -x $dir/tests/$chapter/$i/$binmain ]; then 346 sync 347 fi 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 354 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 364 fi 365 else 366 log "PASS: $i" 367 as_fn_arith $glob_countok + 1 368 glob_countok=$as_val 369 fi 370 clean_dir 371 done 372done 373 374display " === acats Summary ===" 375display "# of expected passes $glob_countok" 376display "# of unexpected failures `expr $glob_countn - $glob_countok`" 377 378if [ $glob_countu -ne 0 ]; then 379 display "# of unsupported tests $glob_countu" 380fi 381 382if [ $glob_countok -ne $glob_countn ]; then 383 display "*** FAILURES: $failed" 384fi 385 386display "$0 completed at `date`" 387 388exit 0 389