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