chiark / gitweb /
Shorten all per-file copyright notices
[adns.git] / regress / m1test
1 #!/bin/bash
2 # usage: m1test <name> <initfile> [<initflags>] <queryargs>'
3 # test recording script
4 #
5 #  This file is part of adns, which is Copyright Ian Jackson
6 #  and contributors (see the file INSTALL for full details).
7 #  
8 #  This program is free software; you can redistribute it and/or modify
9 #  it under the terms of the GNU General Public License as published by
10 #  the Free Software Foundation; either version 3, or (at your option)
11 #  any later version.
12 #  
13 #  This program is distributed in the hope that it will be useful,
14 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 #  GNU General Public License for more details.
17 #  
18 #  You should have received a copy of the GNU General Public License
19 #  along with this program; if not, write to the Free Software Foundation.
20
21 set -e
22
23 : ${srcdir=.}
24 if [ $# -lt 3 ]
25 then
26         echo >&2 \
27 'usage: m1test <name> <initfile> [-<initflags>] ["<"]
28               [=<hrecord-command-args>] <queryargs>
29 ("<" means read input from case-<name>.in)'
30         exit 1
31 fi
32
33 case="$srcdir/case-$1"; shift
34 initfile="$1"; shift
35
36 hrecord="./adnstest_record"
37
38 case "$1" in
39 -*)     initflags="$1"; shift
40 esac
41
42 if test "x$1" = "x<"
43 then
44         shift; exec <"$case.in"
45 fi
46
47 case "$1" in
48 =*)     hrecord="`echo \"$1\" | sed -e 's/^=//'`"; shift
49 esac
50
51 if test ! -f "$hrecord" -a -f "${hrecord}_record"
52 then
53         case "$hrecord" in
54         /*)     program="$hrecord"      ;;
55         *)      program="./$hrecord"    ;;
56         esac
57         hrecord="${program}_record"
58 else
59         program="$(echo "$hrecord" | sed -e 's/ .*//; s/_record$//')"
60 fi
61
62 queryargs="$*"
63
64 initstring="`cat $srcdir/init-$initfile.text`"
65 xinitflagsf=$srcdir/$program-xinitflags.text
66 if test -e $xinitflagsf
67 then
68         useinitflags="$initflags $(cat $xinitflagsf)";
69 else
70         useinitflags="$initflags /"
71 fi
72
73 echo $program $initfile $initflags >"$case.sys"
74 echo "$queryargs" >>"$case.sys"
75
76 EF_DISABLE_BANNER=1
77 export EF_DISABLE_BANNER
78
79 rm -f pipe.out pipe.err
80 mknod pipe.out p
81 mknod pipe.err p
82 tee <pipe.out "$case.out" &
83 tee_out=$!
84 tee <pipe.err "$case.err" &
85 tee_err=$!
86 exec 4>pipe.out
87 exec 5>pipe.err
88
89 echo running hrecord $initflags "... $queryargs"
90 set +e
91 ADNS_TEST_OUT_FD=3 3>>"$case.sys" >&4 2>&5 \
92  $hrecord $useinitflags"$initstring" $queryargs
93 rc=$?
94 set -e
95
96 echo "rc=$rc" >&4
97 exec 4>&-
98 exec 5>&-
99
100 wait $tee_out
101 wait $tee_err
102
103 echo "exit status: $rc"