tests/files tests/fairland: Check stderr and exit status
New helper run_and_cmp to automate the job: run a program capturing its standard output, standard error and exit status, then compare the actual with the expected results. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
e633597854
commit
fed6620a0b
4 changed files with 45 additions and 16 deletions
|
@ -11,13 +11,8 @@ srcdir="$1"
|
|||
|
||||
create_sandbox
|
||||
|
||||
exec 3>sandbox/fairland.out
|
||||
|
||||
$files -f >&3
|
||||
$fairland -s sandbox/newcap_script -R 1 10 30 >&3
|
||||
|
||||
exec 3>&-
|
||||
$files -f >/dev/null
|
||||
run_and_cmp fairland $fairland -s sandbox/newcap_script -R 1 10 30
|
||||
|
||||
$empdump -x >sandbox/final.xdump
|
||||
|
||||
cmp_out fairland.out final.xdump newcap_script
|
||||
cmp_out final.xdump newcap_script
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
All praise to POGO!
|
||||
Creating a planet with:
|
||||
|
||||
10 continents
|
||||
|
|
|
@ -11,12 +11,7 @@ srcdir="$1"
|
|||
|
||||
create_sandbox
|
||||
|
||||
exec 3>sandbox/files.out
|
||||
|
||||
$files -f >&3
|
||||
|
||||
exec 3>&-
|
||||
run_and_cmp files $files -f
|
||||
|
||||
$empdump -x >sandbox/final.xdump
|
||||
|
||||
cmp_out files.out final.xdump
|
||||
cmp_out final.xdump
|
||||
|
|
|
@ -49,6 +49,23 @@ EOF
|
|||
cp `git ls-files "$srcdir"/src/lib/global | uniq | grep '\.config$'` sandbox/share/empire/builtin
|
||||
}
|
||||
|
||||
run_and_cmp()
|
||||
{
|
||||
run "$@"
|
||||
cmp_run "$1"
|
||||
}
|
||||
|
||||
run()
|
||||
{
|
||||
local name=$1 ret
|
||||
shift
|
||||
set +e
|
||||
"$@" >>sandbox/$name.out 2>>sandbox/$name.err
|
||||
ret=$?
|
||||
set -e
|
||||
echo $ret >>sandbox/$name.status
|
||||
}
|
||||
|
||||
now()
|
||||
{
|
||||
# date +%s isn't portable...
|
||||
|
@ -174,6 +191,18 @@ end_test ()
|
|||
$empdump -x >sandbox/final.xdump
|
||||
}
|
||||
|
||||
cmp_run()
|
||||
{
|
||||
local i j exp
|
||||
|
||||
for i
|
||||
do
|
||||
for j in status out err
|
||||
do cmp_out "$i.$j"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
cmp_logs_xdump()
|
||||
{
|
||||
cmp_out var/empire/server.log var/empire/journal.log final.xdump
|
||||
|
@ -188,6 +217,15 @@ cmp_out()
|
|||
exp="$testdir/${i##*/}"
|
||||
act="sandbox/$i"
|
||||
nrm="sandbox/normalized-${i##*/}"
|
||||
|
||||
if [ ! -e "$exp" ]
|
||||
then
|
||||
case "$i" in
|
||||
*.status) exp=sandbox/ok.status; echo 0 >sandbox/ok.status ;;
|
||||
*) exp=/dev/null ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case "$i" in
|
||||
*/journal.log)
|
||||
perl "$srcdir"/tests/normalize.pl -j "$act" ;;
|
||||
|
@ -195,6 +233,8 @@ cmp_out()
|
|||
perl "$srcdir"/tests/normalize.pl -s "$act" ;;
|
||||
*.xdump)
|
||||
perl "$srcdir"/tests/normalize.pl "$act" ;;
|
||||
*.err)
|
||||
perl -pe 's/\s+$/\n/;' -e "s,\Q$srcdir/tests\E,tests," "$act" ;;
|
||||
*)
|
||||
perl -pe 's/\s+$/\n/;' "$act" ;;
|
||||
esac >"$nrm"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue