tests: limit the res of generated res files
[nit.git] / tests / tests.sh
1 #!/bin/bash
2 # This file is part of NIT ( http://www.nitlanguage.org ).
3 #
4 # Copyright 2004-2008 Jean Privat <jean@pryen.org>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17
18 # This shell script compile, run and verify Nit program files
19
20 # Set lang do default to avoid failed tests because of locale
21 export LANG=C
22 export LC_ALL=C
23 export NIT_TESTING=true
24 export NIT_SRAND=0
25
26 unset NIT_DIR
27
28 # Get the first Java lib available
29 shopt -s nullglob
30 JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac))))
31
32 paths=`echo $JAVA_HOME/jre/lib/*/{client,server}/libjvm.so`
33 paths=($paths)
34 JNI_LIB_PATH=`dirname ${paths[0]}`
35 shopt -u nullglob
36
37 outdir="out"
38 compdir="nit_compile"
39
40 # Real-time limit (in seconds)
41 # Is used to avoid waiting or sleeping tests.
42 # Require timeout or timelimit, or else is not used.
43 realtimelimit=300 # 5 min
44
45 # Limit (in bytes) for generated .res file.
46 # Larger ones are truncated and will fail tests
47 # Is used to avoid processing huge crappy res file (diff, xml, etc)
48 reslimit=100000 # ~100KB
49
50 usage()
51 {
52 e=`basename "$0"`
53 cat<<END
54 Usage: $e [options] modulenames
55 -o option Pass option to the engine
56 -v Verbose (show tests steps)
57 -h This help
58 --engine Use a specific engine (default=nitc)
59 --noskip Do not skip a test even if the .skip file matches
60 --outdir Use a specific output folder (default=out/)
61 --compdir Use a specific temporary compilation folder (default=$compdir)
62 --node Run as a node in parallel, will not output context information
63 --autosav Copy the .res files directly in the sav folder overriding existing .res files
64 END
65 }
66
67 # Run a command with a timeout and a time count.
68 # Options:
69 # -o file write the user time into file (REQUIRED). see `-o` in `man time`
70 # -a append the time to the file (instead of overwriting it). see `-a` in `man time`
71 saferun()
72 {
73 local stop=false
74 local o=
75 local a=
76 while [ $stop = false ]; do
77 case "$1" in
78 -o) o="$2"; shift; shift;;
79 -a) a="-a"; shift;;
80 *) stop=true
81 esac
82 done
83 if test -d "$1"; then
84 find $1 | sort
85 elif test -n "$TIME"; then
86 $TIME -o "$o" $a $TIMEOUT "$@"
87 else
88 if test -n "$a"; then echo 0 >> "$o"; else echo 0 > "$o"; fi
89 $TIMEOUT "$@"
90 fi
91 }
92
93 # Output a timestamp attribute for XML, or an empty line
94 timestamp()
95 {
96 if test -n "$TIMESTAMP"; then
97 echo "timestamp='`$TIMESTAMP`'"
98 else
99 echo ""
100 fi
101
102 }
103
104 # Get platform specific commands ##########################
105
106 # Detect a working timeout
107 if sh -c "timelimit echo" 1>/dev/null 2>&1; then
108 TIMEOUT="timelimit -t $realtimelimit"
109 elif sh -c "timeout 1 echo" 1>/dev/null 2>&1; then
110 TIMEOUT="timeout ${realtimelimit}s"
111 else
112 echo "No timelimit or timeout command detected. Tests may hang :("
113 fi
114
115 # Detect a working time command
116 if env time --quiet -f%U true 2>/dev/null; then
117 TIME="env time --quiet -f%U"
118 elif env time -f%U true 2>/dev/null; then
119 TIME="env time -f%U"
120 else
121 TIME=
122 fi
123
124 # Detect a working date command
125 if date -Iseconds >/dev/null 2>&1; then
126 TIMESTAMP="date -Iseconds"
127 else
128 TIMESTAMP=
129 fi
130
131 # $1 is the pattern of the test
132 # $2 is the file to compare to
133 # the result is:
134 # 0: if the file to compare to do not exists
135 # 1: if the file match
136 # 2: if the file match with soso
137 # 3: if the file do not match
138 function compare_to_result()
139 {
140 local pattern="$1"
141 local sav="$2"
142 if [ ! -r "$sav" ]; then return 0; fi
143 test "`cat -- "$sav"`" = "UNDEFINED" && return 1
144 diff -u -- "$sav" "$outdir/$pattern.res" > "$outdir/$pattern.diff.sav.log"
145 if [ "$?" == 0 ]; then
146 return 1
147 fi
148 sed '/[Ww]arning/d;/[Ee]rror/d' "$outdir/$pattern.res" > "$outdir/$pattern.res2"
149 sed '/[Ww]arning/d;/[Ee]rror/d' "$sav" > "$outdir/$pattern.sav2"
150 grep '[Ee]rror' "$outdir/$pattern.res" >/dev/null && echo "Error" >> "$outdir/$pattern.res2"
151 grep '[Ee]rror' "$sav" >/dev/null && echo "Error" >> "$outdir/$pattern.sav2"
152 diff -u "$outdir/$pattern.sav2" "$outdir/$pattern.res2" > "$outdir/$pattern.diff.sav.log2"
153 if [ "$?" == 0 ]; then
154 return 2
155 else
156 return 3
157 fi
158 }
159
160 function xmlesc()
161 {
162 sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g'<<EOF
163 $*
164 EOF
165 }
166
167 # As argument: the pattern used for the file
168 function process_result()
169 {
170 # Result
171 pattern=$1
172 description=$2
173 pack=$3
174 SAV=""
175 NSAV=""
176 FIXME=""
177 NFIXME=""
178 SOSO=""
179 NSOSO=""
180 SOSOF=""
181 NSOSOF=""
182 OLD=""
183 LIST=""
184 FIRST=""
185
186 # Truncate too big res file
187 size=$(wc -c < "$outdir/$pattern.res")
188 if test -n "$reslimit" -a "$size" -gt "$reslimit"; then
189 # The most portable way to truncate a file is with Perl
190 perl -e "truncate \"$outdir/$pattern.res\", $reslimit;"
191 echo "***TRUNCATED***" >> "$outdir/$pattern.res"
192 fi
193
194 echo >>$xml "<testcase classname='`xmlesc "$pack"`' name='`xmlesc "$description"`' time='`cat -- "$outdir/$pattern.time.out"`' `timestamp`>"
195 #for sav in "sav/$engine/fixme/$pattern.res" "sav/$engine/$pattern.res" "sav/fixme/$pattern.res" "sav/$pattern.res" "sav/$pattern.sav"; do
196 for savdir in $savdirs; do
197 sav=$savdir/fixme/$pattern.res
198 compare_to_result "$pattern" "$sav"
199 case "$?" in
200 0)
201 ;; # no file
202 1)
203 OLD="$LIST"
204 FIXME="$sav"
205 LIST="$LIST $sav"
206 ;;
207 2)
208 if [ -z "$FIRST" ]; then
209 SOSOF="$sav"
210 FIRST="$sav"
211 fi
212 LIST="$LIST $sav"
213 ;;
214 3)
215 if [ -z "$FIRST" ]; then
216 NFIXME="$sav"
217 FIRST="$sav"
218 fi
219 LIST="$LIST $sav"
220 ;;
221 esac
222
223 sav=$savdir/$pattern.res
224 compare_to_result "$pattern" "$sav"
225 case "$?" in
226 0)
227 ;; # no file
228 1)
229 OLD="$LIST"
230 SAV="$sav"
231 LIST="$LIST $sav"
232 ;;
233 2)
234 if [ -z "$FIRST" ]; then
235 SOSO="$sav"
236 FIRST="$sav"
237 fi
238 LIST="$LIST $sav"
239 ;;
240 3)
241 if [ -z "$FIRST" ]; then
242 NSAV="$sav"
243 FIRST="$sav"
244 fi
245 LIST="$LIST $sav"
246 ;;
247 esac
248 done
249 OLD=`echo "$OLD" | sed -e 's/ */ /g' -e 's/^ //' -e 's/ $//'`
250 grep 'NOT YET IMPLEMENTED' "$outdir/$pattern.res" >/dev/null
251 NYI="$?"
252 if [ -n "$SAV" ]; then
253 if [ -n "$OLD" ]; then
254 echo "[*ok*] $outdir/$pattern.res $SAV - but $OLD remains!"
255 echo >>$xml "<error message='`xmlesc "ok $outdir/$pattern.res - but $OLD remains"`'/>"
256 remains="$remains $OLD"
257 test "$autosav" = "true" && rm "$OLD"
258 else
259 echo "[ok] $outdir/$pattern.res $SAV"
260 fi
261 ok="$ok $pattern"
262 elif [ -n "$FIXME" ]; then
263 if [ -n "$OLD" ]; then
264 echo "[*fixme*] $outdir/$pattern.res $FIXME - but $OLD remains!"
265 echo >>$xml "<error message='`xmlesc "ok $outdir/$pattern.res - but $OLD remains"`'/>"
266 remains="$remains $OLD"
267 test "$autosav" = "true" && rm "$OLD"
268 else
269 echo "[fixme] $outdir/$pattern.res $FIXME"
270 echo >>$xml "<skipped/>"
271 fi
272 todos="$todos $pattern"
273 elif [ "x$NYI" = "x0" ]; then
274 echo "[todo] $outdir/$pattern.res -> not yet implemented"
275 echo >>$xml "<skipped/>"
276 todos="$todos $pattern"
277 elif [ -n "$SOSO" ]; then
278 echo "[======= soso $outdir/$pattern.res $SOSO =======]"
279 echo >>$xml "<error message='`xmlesc "soso $outdir/$pattern.res $SOSO"`'/>"
280 echo >>$xml "<system-out><![CDATA["
281 cat -v -- "$outdir/$pattern.diff.sav.log" | head >>$xml -n 50
282 echo >>$xml "]]></system-out>"
283 nok="$nok $pattern"
284 echo "$ii" >> "$ERRLIST"
285 test "$autosav" = "true" && cp "$outdir/$pattern.res" "$SOSO"
286 elif [ -n "$SOSOF" ]; then
287 echo "[======= fixme soso $outdir/$pattern.res $SOSOF =======]"
288 echo >>$xml "<error message='`xmlesc "soso $outdir/$pattern.res $SOSO"`'/>"
289 echo >>$xml "<system-out><![CDATA["
290 cat -v -- "$outdir/$pattern.diff.sav.log" | head >>$xml -n 50
291 echo >>$xml "]]></system-out>"
292 nok="$nok $pattern"
293 echo "$ii" >> "$ERRLIST"
294 test "$autosav" = "true" && cp "$outdir/$pattern.res" && "$SOSO"
295 elif [ -n "$NSAV" ]; then
296 echo "[======= fail $outdir/$pattern.res $NSAV =======]"
297 echo >>$xml "<error message='`xmlesc "fail $outdir/$pattern.res $NSAV"`'/>"
298 echo >>$xml "<system-out><![CDATA["
299 cat -v -- "$outdir/$pattern.diff.sav.log" | head >>$xml -n 50
300 echo >>$xml "]]></system-out>"
301 nok="$nok $pattern"
302 echo "$ii" >> "$ERRLIST"
303 test "$autosav" = "true" && cp "$outdir/$pattern.res" "$NSAV"
304 elif [ -n "$NFIXME" ]; then
305 echo "[======= changed $outdir/$pattern.res $NFIXME ======]"
306 echo >>$xml "<error message='`xmlesc "changed $outdir/$pattern.res $NFIXME"`'/>"
307 echo >>$xml "<system-out><![CDATA["
308 cat -v -- "$outdir/$pattern.diff.sav.log" | head >>$xml -n 50
309 echo >>$xml "]]></system-out>"
310 nok="$nok $pattern"
311 echo "$ii" >> "$ERRLIST"
312 test "$autosav" = "true" && cp "$outdir/$pattern.res" "$NFIXME"
313 elif [ -s "$outdir/$pattern.res" ]; then
314 echo "[=== no sav ===] $outdir/$pattern.res is not empty"
315 echo >>$xml "<error message='no sav and not empty'/>"
316 echo >>$xml "<system-out><![CDATA["
317 cat -v >>$xml -- "$outdir/$pattern.res"
318 echo >>$xml "]]></system-out>"
319 nos="$nos $pattern"
320 echo "$ii" >> "$ERRLIST"
321 test "$autosav" = "true" && cp "$outdir/$pattern.res" "sav/"
322 else
323 # no sav but empty res
324 echo "[0k] $outdir/$pattern.res is empty"
325 ok="$ok $pattern"
326 fi
327 if test -s "$outdir/$pattern.cmp.err"; then
328 echo >>$xml "<system-err><![CDATA["
329 cat -v >>$xml -- "$outdir/$pattern.cmp.err"
330 echo >>$xml "]]></system-err>"
331 fi
332 echo >>$xml "</testcase>"
333 }
334
335 need_skip()
336 {
337 test "$noskip" = true && return 1
338 if echo "$1" | grep -f "$engine.skip" >/dev/null 2>&1; then
339 echo "=> $2: [skip]"
340 echo >>$xml "<testcase classname='`xmlesc "$3"`' name='`xmlesc "$2"`' `timestamp`><skipped/></testcase>"
341 return 0
342 fi
343 if test -n "$isinterpret" && echo "$1" | grep -f "exec.skip" >/dev/null 2>&1; then
344 echo "=> $2: [skip exec]"
345 echo >>$xml "<testcase classname='`xmlesc "$3"`' name='`xmlesc "$2"`' `timestamp`><skipped/></testcase>"
346 return 0
347 fi
348
349 # Skip by OS
350 os_skip_file=`uname`.skip
351 if test -e $os_skip_file && echo "$1" | grep -f "$os_skip_file" >/dev/null 2>&1; then
352 echo "=> $2: [skip os]"
353 echo >>$xml "<testcase classname='`xmlesc "$3"`' name='`xmlesc "$2"`' `timestamp`><skipped/></testcase>"
354 return 0
355 fi
356 return 1
357 }
358
359 skip_exec()
360 {
361 test "$noskip" = true && return 1
362 if echo "$1" | grep -f "exec.skip" >/dev/null 2>&1; then
363 echo -n "_ "
364 return 0
365 fi
366 return 1
367 }
368
369 skip_cc()
370 {
371 test "$noskip" = true && return 1
372 if echo "$1" | grep -f "cc.skip" >/dev/null 2>&1; then
373 return 0
374 fi
375 return 1
376 }
377
378 find_nitc()
379 {
380 name="$enginebinname"
381 recent=`ls -t ../src/$name ../src/$name_[0-9] ../bin/$name ../c_src/$name 2>/dev/null | head -1`
382 if [[ "x$recent" == "x" ]]; then
383 echo "Could not find binary for engine $engine, aborting"
384 exit 1
385 fi
386 if [ "x$isnode" = "xfalse" ]; then
387 echo "Found binary for engine $engine: $recent $OPT"
388 fi
389 NITC=$recent
390 }
391
392 verbose=false
393 isnode=false
394 autosav=false
395 stop=false
396 engine=nitc
397 noskip=
398 savdirs=
399 while [ $stop = false ]; do
400 case $1 in
401 -o) OPT="$OPT $2"; shift; shift;;
402 -v) verbose=true; shift;;
403 -h) usage; exit;;
404 --engine) engine="$2"; shift; shift;;
405 --noskip) noskip=true; shift;;
406 --outdir) outdir="$2"; shift; shift;;
407 --compdir) compdir="$2"; shift; shift;;
408 --node) isnode=true; shift;;
409 --autosav) autosav=true; shift;;
410 *) stop=true
411 esac
412 done
413 enginebinname=$engine
414 isinterpret=
415 case $engine in
416 nitc|nitg)
417 engine=nitg-s;
418 enginebinname=nitc;
419 OPT="--separate $OPT --compile-dir $compdir"
420 savdirs="sav/nitg-common/"
421 ;;
422 nitcs|nitg-s)
423 enginebinname=nitc;
424 OPT="--separate $OPT --compile-dir $compdir"
425 savdirs="sav/nitg-common/"
426 ;;
427 nitce|nitg-e)
428 enginebinname=nitc;
429 OPT="--erasure $OPT --compile-dir $compdir"
430 savdirs="sav/nitg-common/"
431 ;;
432 nitcsg|nitg-sg)
433 enginebinname=nitc;
434 OPT="--semi-global $OPT --compile-dir $compdir"
435 savdirs="sav/nitg-common/"
436 ;;
437 nitcg|nitg-g)
438 enginebinname=nitc;
439 OPT="--global $OPT --compile-dir $compdir"
440 savdirs="sav/nitg-common/"
441 ;;
442 nit)
443 engine=niti
444 isinterpret=true
445 ;;
446 niti)
447 enginebinname=nit
448 isinterpret=true
449 ;;
450 nitvm)
451 isinterpret=true
452 enginebinname=nit
453 OPT="--vm $OPT"
454 savdirs="sav/niti/"
455 ;;
456 emscripten)
457 enginebinname=nitc
458 OPT="-m emscripten_nodejs.nit --semi-global $OPT --compile-dir $compdir"
459 savdirs="sav/nitg-sg/"
460 ;;
461 nitc)
462 echo "disabled engine $engine"
463 exit 0
464 ;;
465 *)
466 echo "unknown engine $engine"
467 exit 1
468 ;;
469 esac
470
471 savdirs="sav/$engine $savdirs sav/"
472
473 # The default nitc compiler
474 [ -z "$NITC" ] && find_nitc
475
476 # Set NIT_DIR if needed
477 [ -z "$NIT_DIR" ] && export NIT_DIR=..
478
479 # Mark to distinguish files among tests
480 # MARK=
481
482 if [ $# = 0 ]; then
483 usage;
484 exit
485 fi
486
487 # CLEAN the out directory
488 rm -rf "$outdir/" 2>/dev/null
489 mkdir "$outdir" 2>/dev/null
490
491 # File where error tests are outputed
492 # Old ERRLIST is backuped
493 ERRLIST=${ERRLIST:-errlist}
494 ERRLIST_TARGET=$ERRLIST
495
496 # Initiate new ERRLIST
497 if [ "x$ERRLIST" = "x" ]; then
498 ERRLIST=/dev/null
499 else
500 ERRLIST=$ERRLIST.tmp
501 > "$ERRLIST"
502 fi
503
504 ok=""
505 nok=""
506 todos=""
507
508 if [ "x$XMLDIR" = "x" ]; then
509 xml="tests-$engine.xml"
510 else
511 sum=`echo $@ | md5sum | cut -f1 -d " "`
512 xml="$XMLDIR/tests-$engine-$sum.xml"
513 mkdir -p "$XMLDIR"
514 fi
515
516 echo >$xml "<testsuites><testsuite>"
517
518 for ii in "$@"; do
519 if [ ! -f "$ii" ]; then
520 echo "File '$ii' does not exist."
521 continue
522 fi
523 f=`basename -- "$ii" .nit`
524
525 pack="tests.${engine}".`echo $ii | perl -p -e 's|^../([^/]*)/([a-zA-Z_]*).*|\1.\2| || s|^([a-zA-Z]*)[^_]*_([a-zA-Z]*).*|\1.\2| || s|\W*([a-zA-Z_]*).*|\1|'`
526
527 # Sould we skip the file for this engine?
528 need_skip "$f" "$f" "$pack" && continue
529
530 tmp=${ii/../AA}
531 if [ "x$tmp" = "x$ii" ]; then
532 includes="-I . -I ../lib/standard -I ../lib/standard/collection -I alt"
533 else
534 includes="-I alt"
535 fi
536
537 for i in "$ii" `./alterner.pl --start '#' --altsep '_' -- "$ii"`; do
538 bf=`basename -- "$i" .nit`
539 ff="$outdir/$bf"
540
541 # Sould we skip the alternative for this engine?
542 need_skip "$bf" "$bf" "$pack" && continue
543
544 echo -n "=> $bf: "
545
546 if [ -f "$f.inputs" ]; then
547 inputs="$f.inputs"
548 export MNIT_READ_INPUT="$f.inputs"
549 else
550 inputs=/dev/null
551 export MNIT_READ_INPUT=/dev/null
552 fi
553
554 ffout="$ff.bin"
555 if [ "$engine" = "emscripten" ]; then
556 ffout="$ff.bin.js"
557 fi
558
559 if [ -n "$isinterpret" ]; then
560 cat > "$ff.bin" <<END
561 exec $NITC --no-color $OPT $includes -- $(printf '%q' "$i") "\$@"
562 END
563 chmod +x "$ff.bin"
564 > "$ff.cmp.err"
565 > "$ff.compile.log"
566 ERR=0
567 echo 0.0 > "$ff.time.out"
568 else
569 if skip_cc "$bf"; then
570 nocc="--no-cc"
571 else
572 nocc=
573 fi
574 # Compile
575 if [ "x$verbose" = "xtrue" ]; then
576 echo ""
577 echo $NITC --no-color $OPT -o "$ffout" "$includes" $nocc "$i"
578 fi
579 NIT_NO_STACK=1 JNI_LIB_PATH=$JNI_LIB_PATH JAVA_HOME=$JAVA_HOME \
580 saferun -o "$ff.time.out" $NITC --no-color $OPT -o "$ffout" $includes $nocc "$i" 2> "$ff.cmp.err" > "$ff.compile.log"
581 ERR=$?
582 if [ "x$verbose" = "xtrue" ]; then
583 cat -- "$ff.compile.log"
584 cat >&2 -- "$ff.cmp.err"
585 fi
586 # Clean
587 rm -r "$compdir" 2>/dev/null
588 fi
589 if [ "$engine" = "emscripten" ]; then
590 echo > "$ff.bin" "nodejs $ffout \"\$@\""
591 chmod +x "$ff.bin"
592 if grep "Fatal Error: more than one primitive class" "$ff.compile.log" > /dev/null; then
593 echo " [skip] do no not imports kernel"
594 echo >>$xml "<testcase classname='`xmlesc "$pack"`' name='`xmlesc "$bf"`' `timestamp`><skipped/></testcase>"
595 continue
596 fi
597 fi
598 if [ "$ERR" != 0 ]; then
599 echo -n "! "
600 cat -- "$ff.compile.log" "$ff.cmp.err" > "$ff.res"
601 process_result "$bf" "$bf" "$pack"
602 elif [ -n "$nocc" ]; then
603 # not compiled
604 echo -n "nocc "
605 > "$ff.res"
606 process_result "$bf" "$bf" "$pack"
607 elif [ -x "$ff.bin" ]; then
608 if skip_exec "$bf"; then
609 # No exec
610 > "$ff.res"
611 process_result "$bf" "$bf" "$pack"
612 break
613 fi
614 echo -n ". "
615 # Execute
616 args=""
617 if [ "x$verbose" = "xtrue" ]; then
618 echo ""
619 echo "NIT_NO_STACK=1 $ff.bin" $args
620 fi
621 NIT_NO_STACK=1 LD_LIBRARY_PATH=$JNI_LIB_PATH \
622 saferun -a -o "$ff.time.out" "$ff.bin" $args < "$inputs" > "$ff.res" 2>"$ff.err"
623 mv "$ff.time.out" "$ff.times.out"
624 awk '{ SUM += $1} END { print SUM }' "$ff.times.out" > "$ff.time.out"
625
626 if [ "x$verbose" = "xtrue" ]; then
627 cat -- "$ff.res"
628 cat >&2 -- "$ff.err"
629 fi
630 if [ -f "$ff.write" ]; then
631 cat -- "$ff.write" >> "$ff.res"
632 elif [ -d "$ff.write" ]; then
633 LANG=C /bin/ls -F "$ff.write" >> "$ff.res"
634 fi
635 cp -- "$ff.res" "$ff.res2"
636 cat -- "$ff.cmp.err" "$ff.err" "$ff.res2" > "$ff.res"
637 process_result "$bf" "$bf" "$pack"
638
639 if [ -f "$f.args" ]; then
640 fargs=$f.args
641 cptr=0
642 while read line; do
643 ((cptr=cptr+1))
644 args="$line"
645 bff=$bf"_args"$cptr
646 fff=$ff"_args"$cptr
647 name="$bf args $cptr"
648
649 # Sould we skip the input for this engine?
650 need_skip "$bff" " $name" "$pack" && continue
651
652 # use a specific inputs file, if required
653 if [ -f "$bff.inputs" ]; then
654 ffinputs="$bff.inputs"
655 else
656 ffinputs="$inputs"
657 fi
658
659 rm -rf "$fff.res" "$fff.err" "$fff.write" 2> /dev/null
660 if [ "x$verbose" = "xtrue" ]; then
661 echo ""
662 echo "NIT_NO_STACK=1 $ff.bin" $args
663 fi
664 echo -n "==> $name "
665 echo "$ff.bin $args" > "$fff.bin"
666 chmod +x "$fff.bin"
667 WRITE="$fff.write" saferun -o "$fff.time.out" sh -c "NIT_NO_STACK=1 $fff.bin < $ffinputs > $fff.res 2>$fff.err"
668 if [ "x$verbose" = "xtrue" ]; then
669 cat -- "$fff.res"
670 cat >&2 -- "$fff.err"
671 fi
672 if [ -f "$fff.write" ]; then
673 cat -- "$fff.write" >> "$fff.res"
674 elif [ -d "$fff.write" ]; then
675 LANG=C /bin/ls -F -- "$fff.write" >> "$fff.res"
676 fi
677 if [ -s "$fff.err" ]; then
678 cp -- "$fff.res" "$fff.res2"
679 cat -- "$fff.err" "$fff.res2" > "$fff.res"
680 fi
681 process_result "$bff" " $name" "$pack"
682 done < "$fargs"
683 fi
684 elif [ -f "$ff.bin" ]; then
685 #Not executable (platform?)"
686 > "$ff.res"
687 process_result "$bf" "$bf" "$pack"
688 else
689 echo -n "! "
690 cat -- "$ff.cmp.err" > "$ff.res"
691 echo "Compilation error" > "$ff.res"
692 process_result "$bf" "$bf" "$pack"
693 fi
694 done
695 done
696
697 if [ "x$isnode" = "xfalse" ]; then
698 echo "engine: $engine ($enginebinname $OPT)"
699 echo "ok: " `echo $ok | wc -w` "/" `echo $ok $nok $nos $todos | wc -w`
700
701 if [ -n "$nok" ]; then
702 echo "fail: $nok"
703 echo "There were $(echo $nok | wc -w) errors ! (see file $ERRLIST)"
704 fi
705 if [ -n "$nos" ]; then
706 echo "no sav: $nos"
707 fi
708 if [ -n "$todos" ]; then
709 echo "todo/fixme: $todos"
710 fi
711 if [ -n "$remains" ]; then
712 echo "sav that remains: $remains"
713 fi
714 fi
715
716 # write $ERRLIST
717 if [ "x$ERRLIST" != "x" ]; then
718 if [ -f "$ERRLIST_TARGET" ]; then
719 mv "$ERRLIST_TARGET" "${ERRLIST_TARGET}.bak"
720 fi
721 uniq $ERRLIST > $ERRLIST_TARGET
722 rm $ERRLIST
723 fi
724
725 echo >>$xml "</testsuite></testsuites>"
726
727 if [ -n "$nok" ]; then
728 exit 1
729 else
730 exit 0
731 fi