Licensing: Update copyright dates for Ian Jackson
[adns] / regress / r1test
CommitLineData
12c5b204 1#!/bin/sh
2# usage: r1test <testcasename>
3d5cde09 3# test execution script, for running one test
4#
ae8cc977 5# This file is part of adns, which is
26e1c3d6 6# Copyright (C) 1997-2000,2003,2006,2014 Ian Jackson
ae8cc977 7# Copyright (C) 1999-2000,2003,2006 Tony Finch
8# Copyright (C) 1991 Massachusetts Institute of Technology
9# (See the file INSTALL for full details.)
3d5cde09 10#
11# This program is free software; you can redistribute it and/or modify
12# it under the terms of the GNU General Public License as published by
7f8bbe29 13# the Free Software Foundation; either version 3, or (at your option)
3d5cde09 14# any later version.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
8c09a4c6 22# along with this program; if not, write to the Free Software Foundation.
12c5b204 23
24set -e
2dee2b7a 25: ${srcdir=.}
4ac46883 26mrc=1
27trap 'exit $mrc' 0
28
39196d5f 29casename="$1"
2dee2b7a 30case="$srcdir/case-$casename"
98b6d5b4 31ocase="output-$casename"
12c5b204 32
67a57aae 33exec 4<"$case.sys"
34read <&4 program initfile initflags
35read <&4 queryargs
1c957fda 36
2dee2b7a
MW
37initstring="`cat $srcdir/init-$initfile.text`"
38xinitflagsf=$srcdir/$program-xinitflags.text
0ebff22d 39if test -f $xinitflagsf
40then
8e26a971 41 initflags="$initflags `cat $xinitflagsf`";
0ebff22d 42else
43 initflags="$initflags /"
44fi
1c957fda 45
98b6d5b4 46rm -f $ocase.*
47
1671459c 48EF_DISABLE_BANNER=1
49export EF_DISABLE_BANNER
50
67a57aae 51if test -f "$case.in"
52then
53 exec <"$case.in"
54else
55 exec </dev/null
56fi
57
a069d77f 58playback=./${program}_playback
59if test ! -f $playback
60then
61 printf "SKIPPED-$casename "
62 mrc=5
63 exit
64fi
65
1c957fda 66set +e
a069d77f 67ADNS_TEST_REPORT_FD=3 ADNS_TEST_IN_FD=4 \
e16c09ea 68 3>>"$ocase.report" 4<&4 >"$ocase.out" 2>"$ocase.err" \
1da660af 69 $ADNS_TEST_DEBUG $playback $initflags"$initstring" $queryargs
1c957fda 70rc=$?
71set -e
72
4ac46883 73if [ "$rc" = 5 ]
74then
5a0be244 75 printf "SKIPPED-$casename "
4ac46883 76 mrc=5
77 exit
78fi
79
78bcc172 80echo "rc=$rc" >>$ocase.out
1c957fda 81
73c4c523 82failed=false
83for part in err out
1c957fda 84do
78bcc172 85 if diff -u -- "$case.$part" "$ocase.$part"
1c957fda 86 then
87 :
88 else
4fad263d 89 failwhy="$failwhy WRONG OUTPUT"
1c957fda 90 fi
91done
92
a069d77f 93cat <&4 >"$ocase.leftover"
4fad263d 94if egrep . /dev/null "$ocase.leftover"
73c4c523 95then
4fad263d 96 failwhy="$failwhy EXITED EARLY"
97fi
98
99if [ "x$failwhy" != x ]
100then
101 scremain="`wc -l <\"$ocase.leftover\"`"
102 echo >&2 "FAILED $case -$failwhy - lines of syscall remaining $scremain"
4ac46883 103 mrc=2
104 exit
73c4c523 105fi
106
5a0be244 107printf "$casename "
4ac46883 108mrc=0