--noskip Do not skip a test even if the .skip file matches
--outdir Use a specific output folder (default=out/)
--compdir Use a specific temporary compilation folder (default=.nit_compile)
+--node Run as a node in parallel, will not output context information
END
}
+# Run a command with a timeout and a time count.
+# Options:
+# -o file write the user time into file (REQUIRED). see `-o` in `man time`
+# -a append the time to the file (instead of overwriting it). see `-a` in `man time`
+saferun()
+{
+ local stop=false
+ local o=
+ local a=
+ while [ $stop = false ]; do
+ case $1 in
+ -o) o="$2"; shift; shift;;
+ -a) a="-a"; shift;;
+ *) stop=true
+ esac
+ done
+ if test -n "$TIME"; then
+ $TIME -o "$o" $a $TIMEOUT "$@"
+ else
+ $TIMEOUT "$@"
+ if test -n "$a"; then echo 0 >> "$o"; else echo 0 > "$o"; fi
+ fi
+}
+
+# Output a timestamp attribute for XML, or an empty line
+timestamp()
+{
+ if test -n "$TIMESTAMP"; then
+ echo "timestamp='`$TIMESTAMP`'"
+ else
+ echo ""
+ fi
+
+}
+
+# Get platform specific commands ##########################
+
+# Detect a working timeout
+if sh -c "timelimit echo" 1>/dev/null 2>&1; then
+ TIMEOUT="timelimit -t 600"
+elif sh -c "timeout 1 echo" 1>/dev/null 2>&1; then
+ TIMEOUT="timeout 600s"
+else
+ echo "No timelimit or timeout command detected. Tests may hang :("
+fi
+
+# Detect a working time command
+if env time --quiet -f%U true 2>/dev/null; then
+ TIME="env time --quiet -f%U"
+elif env time -f%U true 2>/dev/null; then
+ TIME="env time -f%U"
+else
+ TIME=
+fi
+
+# Detect a working date command
+if date -Iseconds >/dev/null 2>&1; then
+ TIMESTAMP="date -Iseconds"
+else
+ TIMESTAMP=
+fi
+
# $1 is the pattern of the test
# $2 is the file to compare to
# the result is:
OLD=""
LIST=""
FIRST=""
- echo >>$xml "<testcase classname='$pack' name='$description' time='`cat $outdir/$pattern.time.out`' timestamp='`date -Iseconds`'>"
+ echo >>$xml "<testcase classname='$pack' name='$description' time='`cat $outdir/$pattern.time.out`' `timestamp`>"
#for sav in "sav/$engine/fixme/$pattern.res" "sav/$engine/$pattern.res" "sav/fixme/$pattern.res" "sav/$pattern.res" "sav/$pattern.sav"; do
for savdir in $savdirs; do
sav=$savdir/fixme/$pattern.res
test "$noskip" = true && return 1
if echo "$1" | grep -f "$engine.skip" >/dev/null 2>&1; then
echo "=> $2: [skip]"
- echo >>$xml "<testcase classname='$3' name='$2' timestamp='`date -Iseconds`'><skipped/></testcase>"
+ echo >>$xml "<testcase classname='$3' name='$2' `timestamp`><skipped/></testcase>"
return 0
fi
if test -n "$isinterpret" && echo "$1" | grep -f "exec.skip" >/dev/null 2>&1; then
echo "=> $2: [skip exec]"
- echo >>$xml "<testcase classname='$3' name='$2' timestamp='`date -Iseconds`'><skipped/></testcase>"
+ echo >>$xml "<testcase classname='$3' name='$2' `timestamp`><skipped/></testcase>"
return 0
fi
return 1
echo "Could not find binary for engine $engine, aborting"
exit 1
fi
- echo "Find binary for engine $engine: $recent $OPT"
+ if [ "x$isnode" = "xfalse" ]; then
+ echo "Found binary for engine $engine: $recent $OPT"
+ fi
NITC=$recent
}
verbose=false
+isnode=false
stop=false
engine=nitg
noskip=
--noskip) noskip=true; shift;;
--outdir) outdir="$2"; shift; shift;;
--compdir) compdir="$2"; shift; shift;;
+ --node) isnode=true; shift;;
*) stop=true
esac
done
# Set NIT_DIR if needed
[ -z "$NIT_DIR" ] && export NIT_DIR=..
-if sh -c "timelimit echo" 1>/dev/null 2>&1; then
- TIMEOUT="timelimit -t 600"
-elif sh -c "timeout 1 echo" 1>/dev/null 2>&1; then
- TIMEOUT="timeout 600s"
-else
- echo "No timelimit or timeout command detected. Tests may hang :("
-fi
-
# Mark to distinguish files among tests
# MARK=
-# File where error tests are outputed
-# Old ERRLIST is backuped
-ERRLIST=${ERRLIST:-errlist}
-ERRLIST_TARGET=$ERRLIST
-
if [ $# = 0 ]; then
usage;
exit
fi
+# CLEAN the out directory
+rm -rf "$outdir/" 2>/dev/null
+mkdir "$outdir" 2>/dev/null
+
+# File where error tests are outputed
+# Old ERRLIST is backuped
+ERRLIST=${ERRLIST:-errlist}
+ERRLIST_TARGET=$ERRLIST
+
# Initiate new ERRLIST
if [ "x$ERRLIST" = "x" ]; then
ERRLIST=/dev/null
ok=""
nok=""
todos=""
-xml="tests-$engine.xml"
-echo >$xml "<testsuites><testsuite>"
-# CLEAN the out directory
-rm -rf "$outdir/" 2>/dev/null
-mkdir "$outdir" 2>/dev/null
+if [ "x$XMLDIR" = "x" ]; then
+ xml="tests-$engine.xml"
+else
+ xml="$XMLDIR/tests-$engine.xml"
+fi
+
+echo >$xml "<testsuites><testsuite>"
for ii in "$@"; do
if [ ! -f $ii ]; then
fi
if [ -n "$isinterpret" ]; then
- cat > "./$ff.bin" <<END
+ cat > "$ff.bin" <<END
exec $NITC --no-color $OPT "$i" $includes -- "\$@"
END
- chmod +x "./$ff.bin"
+ chmod +x "$ff.bin"
> "$ff.cmp.err"
> "$ff.compile.log"
ERR=0
echo $NITC --no-color $OPT -o "$ffout" "$i" "$includes" $nocc
fi
NIT_NO_STACK=1 JNI_LIB_PATH=$JNI_LIB_PATH JAVA_HOME=$JAVA_HOME \
- /usr/bin/time --quiet -f%U -o "$ff.time.out" $TIMEOUT $NITC --no-color $OPT -o "$ffout" "$i" $includes $nocc 2> "$ff.cmp.err" > "$ff.compile.log"
+ saferun -o "$ff.time.out" $NITC --no-color $OPT -o "$ffout" "$i" $includes $nocc 2> "$ff.cmp.err" > "$ff.compile.log"
ERR=$?
if [ "x$verbose" = "xtrue" ]; then
cat "$ff.compile.log"
fi
fi
if [ "$engine" = "emscripten" ]; then
- echo > "./$ff.bin" "nodejs $ffout \"\$@\""
+ echo > "$ff.bin" "nodejs $ffout \"\$@\""
chmod +x "$ff.bin"
if grep "Fatal Error: more than one primitive class" "$ff.compile.log" > /dev/null; then
echo " [skip] do no not imports kernel"
- echo >>$xml "<testcase classname='$pack' name='$bf' timestamp='`date -Iseconds`'><skipped/></testcase>"
+ echo >>$xml "<testcase classname='$pack' name='$bf' `timestamp`><skipped/></testcase>"
continue
fi
fi
echo -n "nocc "
> "$ff.res"
process_result $bf $bf $pack
- elif [ -x "./$ff.bin" ]; then
+ elif [ -x "$ff.bin" ]; then
if skip_exec "$bf"; then
# No exec
> "$ff.res"
args=""
if [ "x$verbose" = "xtrue" ]; then
echo ""
- echo "NIT_NO_STACK=1 ./$ff.bin" $args
- fi
+ echo "NIT_NO_STACK=1 $ff.bin" $args
+ fi
NIT_NO_STACK=1 LD_LIBRARY_PATH=$JNI_LIB_PATH \
- /usr/bin/time --quiet -f%U -a -o "$ff.time.out" $TIMEOUT "./$ff.bin" $args < "$inputs" > "$ff.res" 2>"$ff.err"
+ saferun -a -o "$ff.time.out" "$ff.bin" $args < "$inputs" > "$ff.res" 2>"$ff.err"
mv $ff.time.out $ff.times.out
awk '{ SUM += $1} END { print SUM }' $ff.times.out > $ff.time.out
rm -rf "$fff.res" "$fff.err" "$fff.write" 2> /dev/null
if [ "x$verbose" = "xtrue" ]; then
echo ""
- echo "NIT_NO_STACK=1 ./$ff.bin" $args
+ echo "NIT_NO_STACK=1 $ff.bin" $args
fi
echo -n "==> $name "
- echo "./$ff.bin $args" > "./$fff.bin"
- chmod +x "./$fff.bin"
- WRITE="$fff.write" /usr/bin/time --quiet -f%U -o "$fff.time.out" sh -c "NIT_NO_STACK=1 $TIMEOUT ./$fff.bin < $ffinputs > $fff.res 2>$fff.err"
+ echo "$ff.bin $args" > "$fff.bin"
+ chmod +x "$fff.bin"
+ WRITE="$fff.write" saferun -o "$fff.time.out" sh -c "NIT_NO_STACK=1 $fff.bin < $ffinputs > $fff.res 2>$fff.err"
if [ "x$verbose" = "xtrue" ]; then
cat "$fff.res"
cat >&2 "$fff.err"
process_result $bff " $name" $pack
done < $fargs
fi
- elif [ -f "./$ff.bin" ]; then
+ elif [ -f "$ff.bin" ]; then
#Not executable (platform?)"
> "$ff.res"
process_result $bf "$bf" $pack
done
done
-echo "engine: $engine ($enginebinname $OPT)"
-echo "ok: " `echo $ok | wc -w` "/" `echo $ok $nok $nos $todos | wc -w`
+if [ "x$isnode" = "xfalse" ]; then
+ echo "engine: $engine ($enginebinname $OPT)"
+ echo "ok: " `echo $ok | wc -w` "/" `echo $ok $nok $nos $todos | wc -w`
-if [ -n "$nok" ]; then
- echo "fail: $nok"
- echo "There were $(echo $nok | wc -w) errors ! (see file $ERRLIST)"
-fi
-if [ -n "$nos" ]; then
- echo "no sav: $nos"
-fi
-if [ -n "$todos" ]; then
- echo "todo/fixme: $todos"
-fi
-if [ -n "$remains" ]; then
- echo "sav that remains: $remains"
+ if [ -n "$nok" ]; then
+ echo "fail: $nok"
+ echo "There were $(echo $nok | wc -w) errors ! (see file $ERRLIST)"
+ fi
+ if [ -n "$nos" ]; then
+ echo "no sav: $nos"
+ fi
+ if [ -n "$todos" ]; then
+ echo "todo/fixme: $todos"
+ fi
+ if [ -n "$remains" ]; then
+ echo "sav that remains: $remains"
+ fi
fi
# write $ERRLIST