OSDN Git Service

* ada/acats/run_all.sh: Add more verbose output in acats.log
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / ada / acats / run_all.sh
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
12 gccflags=""
13 gnatflags="-gnatws"
14
15 target_run () {
16 $*
17 }
18
19 # End of customization section.
20
21 display_noeol () {
22   printf "$@"
23   printf "$@" >> $dir/acats.sum
24   printf "$@" >> $dir/acats.log
25 }
26
27 display () {
28   echo "$@"
29   echo "$@" >> $dir/acats.sum
30   echo "$@" >> $dir/acats.log
31 }
32
33 log () {
34   echo "$@" >> $dir/acats.sum
35   echo "$@" >> $dir/acats.log
36 }
37
38 dir=`${PWDCMD-pwd}`
39
40 if [ "$testdir" = "" ]; then
41    echo You must use make check or make check-ada
42    exit 1
43 fi
44
45 if [ "$dir" = "$testdir" ]; then
46   echo "error: srcdir must be different than objdir, exiting."
47   exit 1
48 fi
49
50 target_gnatchop () {
51   gnatchop --GCC="$GCC_DRIVER" $*
52 }
53
54 target_gnatmake () {
55   echo gnatmake --GCC="$GCC" $gnatflags $gccflags $* -largs $EXTERNAL_OBJECTS --GCC="$GCC"
56   gnatmake --GCC="$GCC" $gnatflags $gccflags $* -largs $EXTERNAL_OBJECTS --GCC="$GCC"
57 }
58
59 target_gcc () {
60   $GCC $gccflags $*
61 }
62
63 clean_dir () {
64   rm -f "$binmain" *.o *.ali > /dev/null 2>&1
65 }
66
67 EXTERNAL_OBJECTS=""
68 # Global variable to communicate external objects to link with.
69
70 rm -f $dir/acats.sum $dir/acats.log
71
72 display "               === acats configuration ==="
73
74 display target gcc is $GCC
75 display `$GCC -v 2>&1`
76 display host=`gcc -dumpmachine`
77 display target=`$GCC -dumpmachine`
78 display `type gnatmake`
79 gnatls -v >> $dir/acats.log
80 display ""
81
82 display "               === acats support ==="
83 display_noeol "Generating support files..."
84
85 rm -rf $dir/support
86 mkdir -p $dir/support
87 cd $dir/support
88
89 cp $testdir/support/*.ada $testdir/support/*.a $testdir/support/*.tst $dir/support
90
91 sed -e "s,ACATS4GNATDIR,$dir,g" \
92   < $testdir/support/impdef.a > $dir/support/impdef.a
93 sed -e "s,ACATS4GNATDIR,$dir,g" \
94   < $testdir/support/macro.dfs > $dir/support/MACRO.DFS
95 sed -e "s,ACATS4GNATDIR,$dir,g" \
96   < $testdir/support/tsttests.dat > $dir/support/TSTTESTS.DAT
97
98 cp $testdir/tests/cd/*.c $dir/support
99 cp $testdir/tests/cxb/*.c $dir/support
100
101 rm -rf $dir/run
102 mv $dir/tests $dir/tests.$$ 2> /dev/null
103 rm -rf $dir/tests.$$ &
104 mkdir -p $dir/run
105
106 cp -pr $testdir/tests $dir/
107
108 for i in $dir/support/*.ada $dir/support/*.a; do 
109    host_gnatchop $i >> $dir/acats.log 2>&1
110 done
111
112 # These tools are used to preprocess some ACATS sources
113 # they need to be compiled native on the host.
114
115 host_gnatmake -q -gnatws macrosub.adb
116 if [ $? -ne 0 ]; then
117    display "**** Failed to compile macrosub"
118    exit 1
119 fi
120 ./macrosub > macrosub.out 2>&1
121
122 gcc -c cd300051.c
123 host_gnatmake -q -gnatws widechr.adb
124 if [ $? -ne 0 ]; then
125    display "**** Failed to compile widechr"
126    exit 1
127 fi
128 ./widechr > widechr.out 2>&1
129
130 rm -f $dir/support/macrosub
131 rm -f $dir/support/widechr
132 rm -f $dir/support/*.ali
133 rm -f $dir/support/*.o
134
135 display " done."
136
137 # From here, all compilations will be made by the target compiler
138
139 display_noeol "Compiling support files..."
140
141 target_gcc -c *.c
142 if [ $? -ne 0 ]; then
143    display "**** Failed to compile C code"
144    exit 1
145 fi
146
147 target_gnatchop *.adt >> $dir/acats.log 2>&1
148
149 target_gnatmake -c -gnato -gnatE *.ads >> $dir/acats.log 2>&1
150 target_gnatmake -c -gnato -gnatE *.adb >> $dir/acats.log 2>&1
151
152 display " done."
153 display ""
154 display "               === acats tests ==="
155
156 if [ $# -eq 0 ]; then
157    chapters=`cd $dir/tests; echo [a-z]*`
158 else
159    chapters=$*
160 fi
161
162 glob_countn=0
163 glob_countok=0
164 glob_countu=0
165
166 for chapter in $chapters; do
167    display Running chapter $chapter ...
168
169    if [ ! -d $dir/tests/$chapter ]; then
170       display "*** CHAPTER $chapter does not exist, skipping."
171       display ""
172       continue
173    fi
174
175    cd $dir/tests/$chapter
176    ls *.a *.ada *.adt *.am *.dep 2> /dev/null | sed -e 's/\(.*\)\..*/\1/g' | \
177    cut -c1-7 | sort | uniq | comm -23 - $testdir/norun.lst \
178      > $dir/tests/$chapter/${chapter}.lst 
179    countn=`wc -l < $dir/tests/$chapter/${chapter}.lst`
180    glob_countn=`expr $glob_countn + $countn`
181    counti=0
182    for i in `cat $dir/tests/$chapter/${chapter}.lst`; do 
183       counti=`expr $counti + 1`
184       extraflags=""
185       grep $i $testdir/overflow.lst > /dev/null 2>&1
186       if [ $? -eq 0 ]; then
187          extraflags="$extraflags -gnato"
188       fi
189       grep $i $testdir/elabd.lst > /dev/null 2>&1
190       if [ $? -eq 0 ]; then
191          extraflags="$extraflags -gnatE"
192       fi
193       test=$dir/tests/$chapter/$i
194       mkdir $test
195       cd $test
196       target_gnatchop -c -w `ls ${test}*.a ${test}*.ada ${test}*.adt ${test}*.am ${test}*.dep 2> /dev/null` >> $dir/acats.log 2>&1
197       ls ${i}?.adb > ${i}.lst 2> /dev/null
198       ls ${i}*m.adb >> ${i}.lst 2> /dev/null
199       ls ${i}.adb >> ${i}.lst 2> /dev/null
200       main=`tail -1 ${i}.lst`
201       binmain=`echo $main | sed -e 's/\(.*\)\..*/\1/g'`
202       echo "BUILD $main" >> $dir/acats.log
203       EXTERNAL_OBJECTS=""
204       case $i in
205         cxb30*) EXTERNAL_OBJECTS="$dir/support/cxb30040.o $dir/support/cxb30060.o $dir/support/cxb30130.o $dir/support/cxb30131.o";;
206         ca1020e) rm -f ca1020e_func1.adb ca1020e_func2.adb ca1020e_proc1.adb ca1020e_proc2.adb > /dev/null 2>&1;;
207         ca14028) rm -f ca14028_func2.ads ca14028_func3.ads ca14028_proc1.ads ca14028_proc3.ads > /dev/null 2>&1;;
208         cxh1001) extraflags="-a -f"; echo "pragma Normalize_Scalars;" > gnat.adc
209       esac
210       if [ "$main" = "" ]; then
211          display "FAIL: $i"
212          failed="${failed}${i} "
213          clean_dir
214          continue
215       fi
216
217       target_gnatmake $extraflags -I$dir/support $main >> $dir/acats.log 2>&1
218       if [ $? -ne 0 ]; then
219          display "FAIL: $i"
220          failed="${failed}${i} "
221          clean_dir
222          continue
223       fi
224
225       echo "RUN $binmain" >> $dir/acats.log
226       cd $dir/run
227       target_run $dir/tests/$chapter/$i/$binmain > $dir/tests/$chapter/$i/${i}.log 2>&1
228       cd $dir/tests/$chapter/$i
229       cat ${i}.log >> $dir/acats.log
230       egrep -e '(==== |\+\+\+\+ |\!\!\!\! )' ${i}.log > /dev/null 2>&1
231       if [ $? -ne 0 ]; then
232          grep 'Tasking not implemented' ${i}.log > /dev/null 2>&1
233
234          if [ $? -ne 0 ]; then
235             display "FAIL:      $i"
236             failed="${failed}${i} "
237          else
238             log "UNSUPPORTED:   $i"
239             glob_countn=`expr $glob_countn - 1`
240             glob_countu=`expr $glob_countu + 1`
241          fi
242       else
243          log "PASS:     $i"
244          glob_countok=`expr $glob_countok + 1`
245       fi
246       clean_dir
247    done
248 done
249
250 display "               === acats Summary ==="
251 display "# of expected passes           $glob_countok"
252 display "# of unexpected failures       `expr $glob_countn - $glob_countok`"
253
254 if [ $glob_countu -ne 0 ]; then
255    display "# of unsupported tests              $glob_countu"
256 fi
257
258 if [ $glob_countok -ne $glob_countn ]; then
259    display "*** FAILURES: $failed"
260 fi
261
262 exit 0