diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2017-10-18 19:41:32 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2017-10-18 19:41:32 +0000 |
commit | c0bec954d9847e2af3c95e2560a9fa69b639883c (patch) | |
tree | ebede816fc5f43071388707599490f0deb7c40e1 /regress/sys | |
parent | 521143e1814efe7eb68da58d9bde3c6bb6fd7698 (diff) |
Move the test implementation into the Makefile. Then we have only
one place to look at. Make prints the commands it executes to
assist debugging and analysis. If the test fails, there are simple
regress targets that can be run to reproduce the error easily.
Diffstat (limited to 'regress/sys')
-rw-r--r-- | regress/sys/net/etherip/Makefile | 78 | ||||
-rw-r--r-- | regress/sys/net/etherip/etherip_1.sh | 84 | ||||
-rw-r--r-- | regress/sys/net/etherip/etherip_subr | 79 |
3 files changed, 71 insertions, 170 deletions
diff --git a/regress/sys/net/etherip/Makefile b/regress/sys/net/etherip/Makefile index f36edc0590a..17070d2fe54 100644 --- a/regress/sys/net/etherip/Makefile +++ b/regress/sys/net/etherip/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.2 2016/10/10 18:25:26 bluhm Exp $ +# $OpenBSD: Makefile,v 1.3 2017/10/18 19:41:31 bluhm Exp $ SYSCTL_ETHERIP != sysctl net.inet.etherip.allow @@ -9,13 +9,77 @@ regress: @echo SKIPPED .endif -REGRESS_TARGETS= etherip_1 -REGRESS_ROOT_TARGETS= etherip_1 +# configure interface numbers and routing domains +N1 = 11 +N2 = 12 +NUMS = ${N1} ${N2} +IFS = bridge vether etherip pair -RDOMAINS= 11 12 -IFACE_NUMS= 11 12 +CLEANFILES = stamp-* -etherip_1: - ${SUDO} ksh ${.CURDIR}/$@.sh -R "${RDOMAINS}" -I "${IFACE_NUMS}" +.PHONY: check-interfaces check-rdomains ifconfig unconfig + +check-interfaces: + # check if interfaces are busy +.for i in ${IFS} +.for n in ${NUMS} + @if ! /sbin/ifconfig ${i}${n} 2>&1 | grep -q "no such interface"; then\ + echo interface ${i}${n} is already used >&2; exit 1; fi +.endfor +.endfor + +check-rdomains: + # check if rdomains are busy +.for n in ${NUMS} + @if /sbin/ifconfig | grep -v '^lo${n}:' | grep ' rdomain ${n} '; then\ + echo routing domain ${n} is already used >&2; exit 1; fi +.endfor + +ifconfig: check-interfaces check-rdomains + # create and configure interfaces +.for i in ${IFS} +.for n in ${NUMS} + ${SUDO} /sbin/ifconfig ${i}${n} create rdomain ${n} +.endfor +.endfor + ${SUDO} /sbin/ifconfig pair${N1} 172.31.0.1/24 + ${SUDO} /sbin/ifconfig pair${N2} 172.31.0.2/24 patch pair${N1} + ${SUDO} /sbin/ifconfig vether${N1} 192.168.0.1 + ${SUDO} /sbin/ifconfig vether${N2} 192.168.0.2 + ${SUDO} /sbin/ifconfig etherip${N1} tunneldomain ${N1} + ${SUDO} /sbin/ifconfig etherip${N2} tunneldomain ${N2} + ${SUDO} /sbin/ifconfig bridge${N1} add vether${N1} add etherip${N1} up + ${SUDO} /sbin/ifconfig bridge${N2} add vether${N2} add etherip${N2} up + ${SUDO} /sbin/ifconfig etherip${N1} tunnel 172.31.0.1 172.31.0.2 up + ${SUDO} /sbin/ifconfig etherip${N2} tunnel 172.31.0.2 172.31.0.1 up + +unconfig: + # destroy interfaces +.for i in ${IFS} +.for n in ${NUMS} + -${SUDO} /sbin/ifconfig ${i}${n} destroy +.endfor +.endfor + rm -f stamp-setup + +stamp-setup: + @echo '\n======== $@ ========' + ${.MAKE} -C ${.CURDIR} ifconfig + date >$@ + +REGRESS_TARGETS += run-regress-ping-1-2 +run-regress-ping-1-2: stamp-setup + @echo '\n======== $@ ========' + /sbin/ping -w 1 -c 1 -V ${N1} 192.168.0.2 + +REGRESS_TARGETS += run-regress-ping-2-1 +run-regress-ping-2-1: stamp-setup + @echo '\n======== $@ ========' + /sbin/ping -w 1 -c 1 -V ${N2} 192.168.0.1 + +REGRESS_TARGETS += run-regress-cleanup +run-regress-cleanup: stamp-setup + @echo '\n======== $@ ========' + ${.MAKE} -C ${.CURDIR} unconfig .include <bsd.regress.mk> diff --git a/regress/sys/net/etherip/etherip_1.sh b/regress/sys/net/etherip/etherip_1.sh deleted file mode 100644 index 53bc0c2f149..00000000000 --- a/regress/sys/net/etherip/etherip_1.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/ksh -# $OpenBSD: etherip_1.sh,v 1.2 2016/10/10 18:25:26 bluhm Exp $ - - -cleanup() -{ - for if in $ALL_IFS; do - ifconfig $if destroy 2>/dev/null - done -} - -CURDIR=$(cd $(dirname $0); pwd) - -. ${CURDIR}/etherip_subr - -# rdomains -set -- $RDOMAINS -if [ $# -lt 2 ]; then - echo "2 rdomain(-R option) is required" >&2 - exit 64 -fi -RD1=$1 -RD2=$2 - -# interface minor numbers -set -- $IFACE_NUMS -if [ $# -lt 2 ]; then - echo "2 interface numbers(-I option) is required" >&2 - exit 64 -fi -IFNO1=$1 -IFNO2=$2 - -ALL_IFS="bridge$IFNO2 bridge$IFNO1 vether$IFNO2 vether$IFNO1 etherip$IFNO2 - etherip$IFNO1 pair$IFNO2 pair$IFNO1" - -[ $CLEANUP -gt 0 ] && cleanup -# -# Check pre-conditions -# -# interfaces are busy? -for if in $ALL_IFS; do - if iface_exists $if; then - echo "Aborted. interface \`$if' is used already." >&2 - exit 255 - fi -done -# rdomains are busy? -for rt in $RD1 $RD2; do - if ! rdomain_is_used $rt; then - echo "Aborted. rdomain \`$rt' is used already." >&2 - exit 255 - fi -done - -# -# Prepeare the test -# -[ $VERBOSE -gt 0 ] && set -x -ifconfig pair$IFNO1 rdomain $RD1 172.31.0.1/24 -ifconfig pair$IFNO2 rdomain $RD2 172.31.0.2/24 patch pair$IFNO1 -ifconfig vether$IFNO1 rdomain $RD1 192.168.0.1 -ifconfig vether$IFNO2 rdomain $RD2 192.168.0.2 -ifconfig etherip$IFNO1 rdomain $RD1 tunneldomain $RD1 || abort_test -ifconfig etherip$IFNO2 rdomain $RD2 tunneldomain $RD2 || abort_test -ifconfig bridge$IFNO1 rdomain $RD1 add vether$IFNO1 add etherip$IFNO1 up -ifconfig bridge$IFNO2 rdomain $RD2 add vether$IFNO2 add etherip$IFNO2 up - -# -# Test config -# -ifconfig etherip$IFNO1 tunnel 172.31.0.1 172.31.0.2 up || abort_test -ifconfig etherip$IFNO2 tunnel 172.31.0.2 172.31.0.1 up || abort_test - -# -# Test behavior -# -test ping -w 1 -c 1 -V $RD1 192.168.0.2 -test ping -w 1 -c 1 -V $RD2 192.168.0.1 -set +x - -# Done -cleanup -exit $FAILS diff --git a/regress/sys/net/etherip/etherip_subr b/regress/sys/net/etherip/etherip_subr deleted file mode 100644 index fb86ca6b67c..00000000000 --- a/regress/sys/net/etherip/etherip_subr +++ /dev/null @@ -1,79 +0,0 @@ -# -# Copyright (c) 2015 Vincent Gross <vgross@openbsd.org> -# -# Permission to use, copy, modify, and distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -CLEANUP=0 -VERBOSE=0 -FAILS=0 - -iface_exists() -{ - ifconfig_out=`ifconfig "$1" 2>&1` - [ "${ifconfig_out}" != "$1: no such interface" ] -} - -rdomain_is_used() -{ - _rdomains=$(ifconfig |grep -v ^lo$1 | \ - sed -n '/^[a-z].* rdomain \([0-9]*\).*/s//\1/p' | sort | uniq) - for _r in $_rdomains; do - if [ $_r = $1 ]; then - return 1 - fi - done - return 0 -} - -abort_test() -{ - echo "** Aborted" >&2 - [ $# -ge 0 ] && echo "$1" >&2 - cleanup - exit 1 -} - -test() -{ - if [ $VERBOSE -gt 0 ]; then - "$@" - else - "$@" > /dev/null 2>&1 - fi - if [ $? -ne 0 ]; then - FAILS=$((FAILS + 1)) - fi -} - -RDOMAINS="" -IFACE_NUMS="" -while getopts 'cvR:I:' ch "$@"; do - case $ch in - c) - CLEANUP=1 - ;; - v) - VERBOSE=$((VERBOSE + 1)) - ;; - R) - RDOMAINS="$RDOMAINS $OPTARG" - ;; - I) - IFACE_NUMS="$IFACE_NUMS $OPTARG" - ;; - *) - echo "usage: $(basename $0) [-cv][-R rodmains][-I iface_nums]" - exit 64 - ;; - esac -done |