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