summaryrefslogtreecommitdiff
path: root/src/regress/lib/libc/asr/regress.subr
diff options
context:
space:
mode:
authoreric <>2012-07-13 17:49:54 +0000
committereric <>2012-07-13 17:49:54 +0000
commit9204e59073bcf27e1487ec4ac46e981902ddd904 (patch)
treec9d57f5a2812d08f0e504c69deb162dc89ae78a9 /src/regress/lib/libc/asr/regress.subr
parent1cb24e474ab651a39f96d1b0c7582a081ea8c2b8 (diff)
downloadopenbsd-9204e59073bcf27e1487ec4ac46e981902ddd904.tar.gz
openbsd-9204e59073bcf27e1487ec4ac46e981902ddd904.tar.bz2
openbsd-9204e59073bcf27e1487ec4ac46e981902ddd904.zip
import regression suite for asr
Diffstat (limited to 'src/regress/lib/libc/asr/regress.subr')
-rw-r--r--src/regress/lib/libc/asr/regress.subr114
1 files changed, 114 insertions, 0 deletions
diff --git a/src/regress/lib/libc/asr/regress.subr b/src/regress/lib/libc/asr/regress.subr
new file mode 100644
index 0000000000..dafb7ddf75
--- /dev/null
+++ b/src/regress/lib/libc/asr/regress.subr
@@ -0,0 +1,114 @@
1#!/bin/sh
2# $OpenBSD: regress.subr,v 1.1.1.1 2012/07/13 17:49:53 eric Exp $
3
4TOTAL=0
5FAIL=0
6OK=0
7
8EXT0=.std
9EXT1=.asr
10EFLAG=-ee
11
12set -e
13
14fail()
15{
16 echo "*** ERROR: $@"
17 exit 1
18}
19
20regress()
21{
22 local out;
23 local _cmd=$1;
24 local _bin0=/bin/$_cmd$EXT0
25 local _bin1=/bin/$_cmd$EXT1
26 shift;
27
28 TOTAL=$((TOTAL+1))
29
30 # XXX with user "bin"
31 test -x $_RUNDIR$_bin0 || fail $_RUNDIR$_bin0 not executable
32 test -x $_RUNDIR$_bin1 || fail $_RUNDIR$_bin1 not executable
33
34 out=/tmp/asr_regress
35
36 echo -n $_cmd $EFLAG $@ "."
37
38 set +e
39 chroot -u bin "$_RUNDIR" $_bin0 $EFLAG $@ > $out.0
40 echo -n .
41 chroot -u bin "$_RUNDIR" $_bin1 $EFLAG $@ > $out.1
42 echo -n ". "
43
44 diff -u $out.0 $out.1 > $out.diff
45 set -e
46 if test -s $out.diff; then
47 FAIL=$((FAIL+1))
48 echo fail
49 echo "*** FAIL (env=$REGRESSENV)" $_cmd $EFLAG $@ >> $REG
50 tail -n +3 $out.diff >> $REG
51 echo >> $REG
52 else
53 OK=$((OK+1))
54 echo ok
55 echo "OK (env=$REGRESSENV)" $_cmd $EFLAG $@ >> $OUT
56 cat $out.0 >> $OUT
57 echo >> $OUT
58 fi
59 rm $out.diff $out.0 $out.1
60}
61
62regress_setenv()
63{
64 local _name="$1"
65
66 echo "===> using env $_name"
67
68 cp /etc/hosts $_RUNDIR/etc/
69 cp /etc/resolv.conf $_RUNDIR/etc/
70 cp /etc/protocols $_RUNDIR/etc/
71 cp /etc/networks $_RUNDIR/etc/
72
73 case $_name in
74 empty)
75 rm -f $_RUNDIR/etc/*
76 ;;
77 local)
78 ;;
79 file)
80 grep -v lookup /etc/resolv.conf > $_RUNDIR/etc/resolv.conf
81 echo "lookup file" >> $_RUNDIR/etc/resolv.conf
82 ;;
83 bind)
84 grep -v lookup /etc/resolv.conf > $_RUNDIR/etc/resolv.conf
85 echo "lookup bind" >> $_RUNDIR/etc/resolv.conf
86 ;;
87 *)
88 fail unknown env $_name
89 ;;
90 esac
91 REGRESSENV=$_name
92}
93
94regress_digest()
95{
96 echo
97 cat $REG
98 echo "===>" run=$TOTAL fail=$FAIL
99}
100
101
102# needed for chroot
103test "$(id -u)" -ne 0 && fail need root privileges to run this script
104
105# we really really want to avoid erasing /etc later
106test "$RUNDIR" || fail RUNDIR is not set
107_RUNDIR=$(readlink -fn ${RUNDIR})
108test "$_RUNDIR" == / && fail RUNDIR is root dir: $RUNDIR
109
110OUT=$_RUNDIR/output.log
111REG=$_RUNDIR/regress.log
112
113echo -n > $REG
114echo -n > $OUT