blob: 6ce645bc334c9652d213d17d86059a1337b00481 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
#!/bin/sh
# $OpenBSD: regress.subr,v 1.4 2017/03/14 20:22:06 eric Exp $
set -e
fail()
{
echo "*** ERROR: $@"
exit 1
}
regress()
{
local cmd="$1"
local bin0="/bin/${cmd}${A}"
local bin1="/bin/${cmd}${B}"
local out="${OUTDIR}/test-${COUNT}.out"
local out0="${OUTDIR}/test-${COUNT}${A}.out"
local out1="${OUTDIR}/test-${COUNT}${B}.out"
local err0="${OUTDIR}/test-${COUNT}${A}.err"
local err1="${OUTDIR}/test-${COUNT}${B}.err"
local outdiff="${OUTDIR}/test-${COUNT}${A}${B}.diff"
shift
test -x "${ROOTDIR}${bin0}" || fail "${ROOTDIR}${bin0}" not executable
test -x "${ROOTDIR}${bin1}" || fail "${ROOTDIR}${bin1}" not executable
echo -n "${cmd} $@ ."
set +e
chroot -u bin "${ROOTDIR}" ${bin0} $@ > ${out0}
echo -n .
chroot -u bin "${ROOTDIR}" ${bin1} $@ > ${out1}
echo -n "."
diff -u ${out0} ${out1} > ${outdiff}
set -e
if test -s ${outdiff}; then
FAIL=$((FAIL+1))
echo fail
echo "### FAIL [#${COUNT} env=${REGRESSENV}] ${cmd} $@" >> $ERR
cat ${outdiff} >> $ERR
echo >> $ERR
else
rm ${outdiff}
rm ${out1}
mv ${out0} ${out}
OK=$((OK+1))
echo ok
echo "### OK [#${COUNT} env=$REGRESSENV] ${cmd} $@" >> $OUT
cat ${out} >> $OUT
echo >> $OUT
fi
COUNT=$((COUNT+1))
}
regress_setenv()
{
local _name="$1"
echo "==> using env $_name"
mkdir -p "${ROOTDIR}/etc/"
cp /etc/hosts "${ROOTDIR}/etc/"
cp /etc/resolv.conf "${ROOTDIR}/etc/"
cp /etc/protocols "${ROOTDIR}/etc/"
cp /etc/networks "${ROOTDIR}/etc/"
cp /etc/services "${ROOTDIR}/etc/"
case $_name in
empty)
rm -f "${ROOTDIR}/etc/*"
;;
local)
;;
file)
grep -v lookup /etc/resolv.conf > "${ROOTDIR}/etc/resolv.conf"
echo "lookup file" >> "${ROOTDIR}/etc/resolv.conf"
;;
bind)
grep -v lookup /etc/resolv.conf > "${ROOTDIR}/etc/resolv.conf"
echo "lookup bind" >> "${ROOTDIR}/etc/resolv.conf"
;;
*)
fail unknown env $_name
;;
esac
REGRESSENV=$_name
}
regress_digest()
{
echo "===> done"
test -f $ERR && (echo; cat $ERR; echo "===> errfile=$ERR")
echo "===> logfile=$OUT"
echo "===> run=$COUNT ok=$OK fail=$FAIL error=$ERROR"
}
# needed for chroot
test "$(id -u)" -ne 0 && fail need root privileges to run this script
# we really really want to avoid erasing /etc later
test "${RUNDIR}" || fail RUNDIR is not set
ROOTDIR=$(readlink -fn ${RUNDIR})
test "${ROOTDIR}" == "/" && fail RUNDIR is root dir: ${RUNDIR}
COUNT=0
OK=0
FAIL=0
ERROR=0
A=${A:=.a}
B=${B:=.b}
OUTDIR=$(mktemp -d -p $ROOTDIR)
chmod a+rx ${OUTDIR}
echo "===> ${OUTDIR}"
OUT=$OUTDIR/regress.log
ERR=$OUTDIR/regress.err
|