2012-05-30 18:02:14 +03:00
|
|
|
#!/bin/bash -x
|
|
|
|
#
|
|
|
|
# Common - Elements shared by all regression tests for BOOM
|
|
|
|
#
|
|
|
|
# Written 2012 by Werner Almesberger
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
run_boom()
|
|
|
|
{
|
2012-06-03 16:18:37 +03:00
|
|
|
if [ "`sed -n '/^!-/p;q' _in`" -o ! -s _in ]; then
|
|
|
|
args="-N dummy <(echo ';')"
|
2012-06-03 02:42:49 +03:00
|
|
|
else
|
|
|
|
args="-N h <(sed -n '/^!-/q;p' _in)"
|
|
|
|
fi
|
2012-06-02 19:58:33 +03:00
|
|
|
for n in c x p i s b X; do
|
2012-06-02 11:50:07 +03:00
|
|
|
for m in "" 1 2 3; do
|
|
|
|
if grep ^!-$n$m\$ _in >/dev/null; then
|
|
|
|
args="$args -N $n$m"
|
|
|
|
args="$args -$n \
|
2012-06-03 02:42:49 +03:00
|
|
|
<(sed -n '0,/^!-$n$m/d;/^!-/q;p' _in)"
|
2012-06-02 11:50:07 +03:00
|
|
|
fi
|
|
|
|
done
|
2012-05-30 18:02:14 +03:00
|
|
|
done
|
2012-06-02 11:24:50 +03:00
|
|
|
eval $VALGRIND ../boom "$args" "$@"
|
2012-05-30 18:02:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tst()
|
|
|
|
{
|
|
|
|
echo -n "$1: " 1>&2
|
|
|
|
shift
|
|
|
|
cat >_in
|
|
|
|
run_boom "$@" >_out 2>&1 || {
|
|
|
|
echo FAILED "($SCRIPT)" 1>&2
|
|
|
|
cat _out
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tst_fail()
|
|
|
|
{
|
|
|
|
echo -n "$1: " 1>&2
|
|
|
|
shift
|
|
|
|
cat >_in
|
|
|
|
run_boom "$@" >_out 2>&1 && {
|
|
|
|
echo FAILED "($SCRIPT)" 1>&2
|
|
|
|
cat _out
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
rm -f _in
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
expect()
|
|
|
|
{
|
|
|
|
diff -u - "$@" _out >_diff || {
|
|
|
|
echo FAILED "($SCRIPT)" 1>&2
|
|
|
|
cat _diff 1>&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
echo PASSED 1>&2
|
|
|
|
rm -f _in _out _diff
|
|
|
|
passed=`expr ${passed:-0} + 1`
|
|
|
|
}
|