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