diff options
author | eric <> | 2017-03-10 17:23:48 +0000 |
---|---|---|
committer | eric <> | 2017-03-10 17:23:48 +0000 |
commit | c5f5042dd06a784caa9d40d27d1c3ac7a1c1fe89 (patch) | |
tree | bc911250953712efd150e9aff3bac633b0d119da /src/regress/lib/libc/asr | |
parent | efcbc859d153bd2908ab9c32fb042c03eb84d265 (diff) | |
download | openbsd-c5f5042dd06a784caa9d40d27d1c3ac7a1c1fe89.tar.gz openbsd-c5f5042dd06a784caa9d40d27d1c3ac7a1c1fe89.tar.bz2 openbsd-c5f5042dd06a784caa9d40d27d1c3ac7a1c1fe89.zip |
refresh the test infrastructure a bit.
Diffstat (limited to 'src/regress/lib/libc/asr')
-rw-r--r-- | src/regress/lib/libc/asr/Makefile | 59 | ||||
-rw-r--r-- | src/regress/lib/libc/asr/regress.sh | 4 | ||||
-rw-r--r-- | src/regress/lib/libc/asr/regress.subr | 120 |
3 files changed, 93 insertions, 90 deletions
diff --git a/src/regress/lib/libc/asr/Makefile b/src/regress/lib/libc/asr/Makefile index 76891ec176..12e59536e0 100644 --- a/src/regress/lib/libc/asr/Makefile +++ b/src/regress/lib/libc/asr/Makefile | |||
@@ -1,53 +1,52 @@ | |||
1 | # $OpenBSD: Makefile,v 1.3 2013/04/01 10:18:28 eric Exp $ | 1 | # $OpenBSD: Makefile,v 1.4 2017/03/10 17:23:48 eric Exp $ |
2 | 2 | ||
3 | # | 3 | # |
4 | # Note on building and running the regress tests: | 4 | # Notes on building and running the regression tests |
5 | # | 5 | # |
6 | # The regress suite builds two sets of static executables: one linked | 6 | # The regress suite builds two sets of static executables: the former linked |
7 | # against the current libc, and one linked against a libc with the resolver | 7 | # against the system libc, and the latter against the libc found in /usr/obj |
8 | # replaced. The idea is to compare the output of all programs in both cases. | 8 | # The idea is to compare the output of all programs with internal changes in |
9 | # the libc (more specifically the resolver). They will be run in a chrooted | ||
10 | # environment to test various /etc configurations without touching the local | ||
11 | # machine config files. | ||
9 | # | 12 | # |
10 | # So before building the regression test programs, you need to have two | 13 | # First, build a libc that needs testing, then: |
11 | # static libc: the system libc.a in /usr/lib/ which is assumed to be built | ||
12 | # with asr, and a pre-asr libc.a in the "./lib/" directory (you can build | ||
13 | # one by commenting out the ".include "${LIBCSRCDIR}/asr/Makefile.inc" | ||
14 | # line from the /usr/src/lib/libc/Makefile.in and rebuild the libc). | ||
15 | # | ||
16 | # When done, run "make && make install". This builds and installs the two sets | ||
17 | # of programs in REGRESSDIR. They will run chrooted there to allow testing with | ||
18 | # various /etc environment without messing up the local machine config files. | ||
19 | # | 14 | # |
20 | # When you are sure everything is in place, run "make regress". This will | 15 | # $ make |
21 | # create two files: $REGRESSDIR/output.log with the output of all tests, | 16 | # $ doas make install |
22 | # and $REGRESSDIR/regress.log with the diffs for those that "failed". | 17 | # $ doas make regress |
23 | # | 18 | # |
24 | # Note that the "install" and "regress" targets need to be run as root. | 19 | # Tests output goes into a $REGRESSDIR/tmp.XXXXXXXXXX directory, and a digest |
20 | # is displayed at the end. | ||
25 | # | 21 | # |
26 | 22 | ||
27 | LIBCDIRSTD?= ${.CURDIR}/lib | 23 | REGRESSDIR?= /tmp/regress-asr |
28 | LIBCDIRASR?= /usr/lib | ||
29 | |||
30 | REGRESSDIR?= /tmp/regress | ||
31 | REGRESS?= regress.sh | 24 | REGRESS?= regress.sh |
32 | 25 | ||
26 | A?= .a | ||
27 | B?= .b | ||
28 | |||
29 | DIRA?= /usr/lib | ||
30 | DIRB?= /usr/obj/lib/libc | ||
31 | |||
32 | |||
33 | all: build | 33 | all: build |
34 | 34 | ||
35 | build: | 35 | build: |
36 | cd bin && EXT=.asr LDFLAGS=-L${LIBCDIRASR} make | 36 | cd bin && EXT=${A} LDFLAGS=-L${DIRA} make |
37 | cd bin && EXT=.std LDFLAGS=-L${LIBCDIRSTD} make | 37 | cd bin && EXT=${B} LDFLAGS=-L${DIRB} make |
38 | 38 | ||
39 | clean: | 39 | clean: |
40 | cd bin && EXT=.std make clean | 40 | cd bin && EXT=${A} make clean |
41 | cd bin && EXT=.asr make clean | 41 | cd bin && EXT=${B} make clean |
42 | 42 | ||
43 | install: | 43 | install: |
44 | mkdir -p ${REGRESSDIR}/etc | ||
45 | mkdir -p ${REGRESSDIR}/bin | 44 | mkdir -p ${REGRESSDIR}/bin |
46 | cd bin && BINDIR=${REGRESSDIR}/bin EXT=.std make install | 45 | cd bin && BINDIR=${REGRESSDIR}/bin EXT=${A} make install |
47 | cd bin && BINDIR=${REGRESSDIR}/bin EXT=.asr make install | 46 | cd bin && BINDIR=${REGRESSDIR}/bin EXT=${B} make install |
48 | 47 | ||
49 | uninstall: | 48 | uninstall: |
50 | rm -rf ${REGRESSDIR} | 49 | rm -rf ${REGRESSDIR} |
51 | 50 | ||
52 | regress: | 51 | regress: |
53 | RUNDIR=${REGRESSDIR} sh ${.CURDIR}/${REGRESS} | 52 | RUNDIR=${REGRESSDIR} A=${A} B=${B} sh ${.CURDIR}/${REGRESS} |
diff --git a/src/regress/lib/libc/asr/regress.sh b/src/regress/lib/libc/asr/regress.sh index 3388f0dd2c..a0950cefde 100644 --- a/src/regress/lib/libc/asr/regress.sh +++ b/src/regress/lib/libc/asr/regress.sh | |||
@@ -1,9 +1,7 @@ | |||
1 | # $OpenBSD: regress.sh,v 1.6 2013/04/01 10:17:45 eric Exp $ | 1 | # $OpenBSD: regress.sh,v 1.7 2017/03/10 17:23:48 eric Exp $ |
2 | 2 | ||
3 | . regress.subr | 3 | . regress.subr |
4 | 4 | ||
5 | EFLAG= | ||
6 | |||
7 | test_res_mkquery() | 5 | test_res_mkquery() |
8 | { | 6 | { |
9 | for i in $@; do | 7 | for i in $@; do |
diff --git a/src/regress/lib/libc/asr/regress.subr b/src/regress/lib/libc/asr/regress.subr index 3e8cc0ebd5..43b7280158 100644 --- a/src/regress/lib/libc/asr/regress.subr +++ b/src/regress/lib/libc/asr/regress.subr | |||
@@ -1,13 +1,5 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # $OpenBSD: regress.subr,v 1.2 2013/03/28 09:36:03 eric Exp $ | 2 | # $OpenBSD: regress.subr,v 1.3 2017/03/10 17:23:48 eric Exp $ |
3 | |||
4 | TOTAL=0 | ||
5 | FAIL=0 | ||
6 | OK=0 | ||
7 | |||
8 | EXT0=.std | ||
9 | EXT1=.asr | ||
10 | EFLAG=-ee | ||
11 | 3 | ||
12 | set -e | 4 | set -e |
13 | 5 | ||
@@ -19,70 +11,75 @@ fail() | |||
19 | 11 | ||
20 | regress() | 12 | regress() |
21 | { | 13 | { |
22 | local out; | 14 | local cmd="$1" |
23 | local _cmd=$1; | 15 | local bin0="/bin/${cmd}${A}" |
24 | local _bin0=/bin/$_cmd$EXT0 | 16 | local bin1="/bin/${cmd}${B}" |
25 | local _bin1=/bin/$_cmd$EXT1 | 17 | local out="${OUTDIR}/test-${COUNT}.out" |
26 | shift; | 18 | local out0="${OUTDIR}/test-${COUNT}${A}.out" |
27 | 19 | local out1="${OUTDIR}/test-${COUNT}${B}.out" | |
28 | TOTAL=$((TOTAL+1)) | 20 | local err0="${OUTDIR}/test-${COUNT}${A}.err" |
29 | 21 | local err1="${OUTDIR}/test-${COUNT}${B}.err" | |
30 | # XXX with user "bin" | 22 | local outdiff="${OUTDIR}/test-${COUNT}${A}${B}.diff" |
31 | test -x $_RUNDIR$_bin0 || fail $_RUNDIR$_bin0 not executable | 23 | shift |
32 | test -x $_RUNDIR$_bin1 || fail $_RUNDIR$_bin1 not executable | 24 | |
33 | 25 | test -x "${ROOTDIR}${bin0}" || fail "${ROOTDIR}${bin0}" not executable | |
34 | out=/tmp/asr_regress | 26 | test -x "${ROOTDIR}${bin1}" || fail "${ROOTDIR}${bin1}" not executable |
35 | 27 | ||
36 | echo -n $_cmd $EFLAG $@ "." | 28 | echo -n "${cmd} $@ ." |
37 | 29 | ||
38 | set +e | 30 | set +e |
39 | chroot -u bin "$_RUNDIR" $_bin0 $EFLAG $@ > $out.0 | 31 | chroot -u bin "${ROOTDIR}" ${bin0} $@ > ${out0} |
40 | echo -n . | 32 | echo -n . |
41 | chroot -u bin "$_RUNDIR" $_bin1 $EFLAG $@ > $out.1 | 33 | chroot -u bin "${ROOTDIR}" ${bin1} $@ > ${out1} |
42 | echo -n ". " | 34 | echo -n "." |
43 | 35 | ||
44 | diff -u $out.0 $out.1 > $out.diff | 36 | diff -u ${out0} ${out1} > ${outdiff} |
45 | set -e | 37 | set -e |
46 | if test -s $out.diff; then | 38 | if test -s ${outdiff}; then |
47 | FAIL=$((FAIL+1)) | 39 | FAIL=$((FAIL+1)) |
48 | echo fail | 40 | echo fail |
49 | echo "*** FAIL (env=$REGRESSENV)" $_cmd $EFLAG $@ >> $REG | 41 | echo "### FAIL [#${COUNT} env=${REGRESSENV}] ${cmd} $@" >> $ERR |
50 | tail -n +3 $out.diff >> $REG | 42 | cat ${outdiff} >> $ERR |
51 | echo >> $REG | 43 | echo >> $ERR |
52 | else | 44 | else |
45 | rm ${outdiff} | ||
46 | rm ${out1} | ||
47 | mv ${out0} ${out} | ||
53 | OK=$((OK+1)) | 48 | OK=$((OK+1)) |
54 | echo ok | 49 | echo ok |
55 | echo "OK (env=$REGRESSENV)" $_cmd $EFLAG $@ >> $OUT | 50 | echo "### OK [#${COUNT} env=$REGRESSENV] ${cmd} $@" >> $OUT |
56 | cat $out.0 >> $OUT | 51 | cat ${out} >> $OUT |
57 | echo >> $OUT | 52 | echo >> $OUT |
58 | fi | 53 | fi |
59 | rm $out.diff $out.0 $out.1 | 54 | |
55 | COUNT=$((COUNT+1)) | ||
60 | } | 56 | } |
61 | 57 | ||
62 | regress_setenv() | 58 | regress_setenv() |
63 | { | 59 | { |
64 | local _name="$1" | 60 | local _name="$1" |
65 | 61 | ||
66 | echo "===> using env $_name" | 62 | echo "==> using env $_name" |
67 | 63 | ||
68 | cp /etc/hosts $_RUNDIR/etc/ | 64 | mkdir -p "${ROOTDIR}/etc/" |
69 | cp /etc/resolv.conf $_RUNDIR/etc/ | 65 | cp /etc/hosts "${ROOTDIR}/etc/" |
70 | cp /etc/protocols $_RUNDIR/etc/ | 66 | cp /etc/resolv.conf "${ROOTDIR}/etc/" |
71 | cp /etc/networks $_RUNDIR/etc/ | 67 | cp /etc/protocols "${ROOTDIR}/etc/" |
68 | cp /etc/networks "${ROOTDIR}/etc/" | ||
72 | 69 | ||
73 | case $_name in | 70 | case $_name in |
74 | empty) | 71 | empty) |
75 | rm -f $_RUNDIR/etc/* | 72 | rm -f "${ROOTDIR}/etc/*" |
76 | ;; | 73 | ;; |
77 | local) | 74 | local) |
78 | ;; | 75 | ;; |
79 | file) | 76 | file) |
80 | grep -v lookup /etc/resolv.conf > $_RUNDIR/etc/resolv.conf | 77 | grep -v lookup /etc/resolv.conf > "${ROOTDIR}/etc/resolv.conf" |
81 | echo "lookup file" >> $_RUNDIR/etc/resolv.conf | 78 | echo "lookup file" >> "${ROOTDIR}/etc/resolv.conf" |
82 | ;; | 79 | ;; |
83 | bind) | 80 | bind) |
84 | grep -v lookup /etc/resolv.conf > $_RUNDIR/etc/resolv.conf | 81 | grep -v lookup /etc/resolv.conf > "${ROOTDIR}/etc/resolv.conf" |
85 | echo "lookup bind" >> $_RUNDIR/etc/resolv.conf | 82 | echo "lookup bind" >> "${ROOTDIR}/etc/resolv.conf" |
86 | ;; | 83 | ;; |
87 | *) | 84 | *) |
88 | fail unknown env $_name | 85 | fail unknown env $_name |
@@ -93,23 +90,32 @@ regress_setenv() | |||
93 | 90 | ||
94 | regress_digest() | 91 | regress_digest() |
95 | { | 92 | { |
96 | echo | 93 | echo "===> done" |
97 | cat $REG | 94 | test -f $ERR && (echo; cat $ERR; echo "===> errfile=$ERR") |
98 | echo "===>" run=$TOTAL fail=$FAIL | 95 | echo "===> logfile=$OUT" |
99 | } | 96 | echo "===> run=$COUNT ok=$OK fail=$FAIL error=$ERROR" |
100 | 97 | ||
98 | } | ||
101 | 99 | ||
102 | # needed for chroot | 100 | # needed for chroot |
103 | test "$(id -u)" -ne 0 && fail need root privileges to run this script | 101 | test "$(id -u)" -ne 0 && fail need root privileges to run this script |
104 | 102 | ||
105 | # we really really want to avoid erasing /etc later | 103 | # we really really want to avoid erasing /etc later |
106 | test "$RUNDIR" || fail RUNDIR is not set | 104 | test "${RUNDIR}" || fail RUNDIR is not set |
107 | _RUNDIR=$(readlink -fn ${RUNDIR}) | 105 | |
108 | test "$_RUNDIR" == / && fail RUNDIR is root dir: $RUNDIR | 106 | ROOTDIR=$(readlink -fn ${RUNDIR}) |
107 | test "${ROOTDIR}" == "/" && fail RUNDIR is root dir: ${RUNDIR} | ||
108 | |||
109 | COUNT=0 | ||
110 | OK=0 | ||
111 | FAIL=0 | ||
112 | ERROR=0 | ||
113 | A=${A:=.a} | ||
114 | B=${B:=.b} | ||
109 | 115 | ||
110 | OUT=$_RUNDIR/output.log | 116 | OUTDIR=$(mktemp -d -p $ROOTDIR) |
111 | REG=$_RUNDIR/regress.log | 117 | chmod a+rx ${OUTDIR} |
112 | ETC=$_RUNDIR/etc | 118 | echo "===> ${OUTDIR}" |
113 | 119 | ||
114 | echo -n > $REG | 120 | OUT=$OUTDIR/regress.log |
115 | echo -n > $OUT | 121 | ERR=$OUTDIR/regress.err |