From: claudio Date: Fri, 18 Apr 2014 16:38:28 +0000 (+0000) Subject: Introduce some regress tests against our routing table. At least that way X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f42cad18709b8f08e7d0d21ef0c8fe4c4a21fda2;p=openbsd Introduce some regress tests against our routing table. At least that way there is a chance that we do not break the network stack even more. These regress tests already found a few issues. The framework is ugly and does not properly recover from failures. Somebody more skilled can come up with a better solution. mpi@, blambert@ and sthen@ support this --- diff --git a/regress/sbin/route/Makefile b/regress/sbin/route/Makefile index 167b9b9b79a..1c6a2f89552 100644 --- a/regress/sbin/route/Makefile +++ b/regress/sbin/route/Makefile @@ -1,9 +1,39 @@ -# $OpenBSD: Makefile,v 1.2 2004/12/29 04:39:17 david Exp $ +# $OpenBSD: Makefile,v 1.3 2014/04/18 16:38:28 claudio Exp $ + +RDOMAIN?= 5 NET= 192.0.3.0 MASK= 255.255.255.0 GW= 192.0.2.1 +.MAIN: all + +.ifmake !obj && !clean && !cleandir && !depend && !regress +.if (${.TARGET} != all && ! make(all)) || (${.TARGET} == all) + +.SILENT: .BEGIN .END + +.BEGIN: + -${SUDO} ifconfig lo10001 up rdomain ${RDOMAIN} 192.0.2.1/32 + -${SUDO} ifconfig lo10002 up rdomain ${RDOMAIN} 192.0.2.2/32 + -${SUDO} ifconfig lo10003 up rdomain ${RDOMAIN} 192.0.2.3/32 + -${SUDO} ifconfig lo10004 up rdomain ${RDOMAIN} 192.0.2.4/32 + +.END: + -${SUDO} ifconfig lo10001 destroy + -${SUDO} ifconfig lo10002 destroy + -${SUDO} ifconfig lo10003 destroy + -${SUDO} ifconfig lo10004 destroy + +.INTERRUPT: + -${SUDO} ifconfig lo10001 destroy + -${SUDO} ifconfig lo10002 destroy + -${SUDO} ifconfig lo10003 destroy + -${SUDO} ifconfig lo10004 destroy + +.endif +.endif + netmask: .for cmd in add delete .for mod in -net -dst @@ -12,7 +42,121 @@ netmask: .endfor .endfor -REGRESS_TARGETS=netmask +RCMD= ${SUDO} route -T ${RDOMAIN} -n + +n= 1 +RTTEST_TARGETS+:=rttest${n} +rttest${n}: + ${RCMD} add 10/8 192.0.2.1 + ${RCMD} add 10.0/16 192.0.2.4 + ${RCMD} add 10.0/10 192.0.2.4 + ${RCMD} add 10.8/16 192.0.2.3 + ${RCMD} add 10.8.0/24 192.0.2.1 + ${RCMD} add 10.8.1/24 192.0.2.2 + ${RCMD} add 10.8.3/24 192.0.2.3 + ${RCMD} add 10.8.4/24 192.0.2.4 + ${RCMD} show -inet 2>&1 | \ + diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin + +n= 2 +RTTEST_TARGETS+:=rttest${n} +rttest${n}: + ${RCMD} add -mpath 10.8.1/24 192.0.2.3 + ${RCMD} add -mpath 10.8.1/24 192.0.2.4 + ${RCMD} show -inet 2>&1 | \ + diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin + +n= 3 +RTTEST_TARGETS+:=rttest${n} +rttest${n}: + ${RCMD} add -mpath 10.8.1/24 192.0.2.3 + ${RCMD} add -mpath 10.8.1/24 192.0.2.3 && exit 1 || exit 0 + ${RCMD} show -inet 2>&1 | \ + diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin + + +n= 4 +RTTEST_TARGETS+:=rttest${n} +rttest${n}: + ${RCMD} add -priority 16 10.8.1/24 192.0.2.1 + ${RCMD} add -priority 17 10.8.1/24 192.0.2.2 + ${RCMD} add -priority 18 10.8.1/24 192.0.2.3 + ${RCMD} show -inet 2>&1 | \ + diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin + +n= 5 +RTTEST_TARGETS+:=rttest${n} +rttest${n}: + ${RCMD} add -mpath -priority 16 10.8.1/24 192.0.2.2 + ${RCMD} add -mpath -priority 17 10.8.1/24 192.0.2.2 + ${RCMD} add -mpath -priority 18 10.8.1/24 192.0.2.2 + ${RCMD} add -mpath -priority 17 10.8.1/24 192.0.2.2 && exit 1 || exit 0 + ${RCMD} show -inet 2>&1 | \ + diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin + +n= 6 +RTTEST_TARGETS+:=rttest${n} +rttest${n}: + ${RCMD} add -priority 16 10.8.1/24 192.0.2.1 + ${RCMD} add -priority 17 10.8.1/24 192.0.2.2 + ${RCMD} add -priority 18 10.8.1/24 192.0.2.3 + ${RCMD} add -priority 17 10.8.1/24 192.0.2.2 && exit 1 || exit 0 + ${RCMD} show -inet 2>&1 | \ + diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin + +n= 7 +RTTEST_TARGETS+:=rttest${n} +rttest${n}: + ${RCMD} add -priority 16 10.8.1/24 192.0.2.1 + ${RCMD} add -priority 17 10.8.1/24 192.0.2.2 + ${RCMD} add -priority 18 10.8.1/24 192.0.2.3 + ${RCMD} delete -priority 17 10.8.1/24 + ${RCMD} show -inet 2>&1 | \ + diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin + +n= 8 +RTTEST_TARGETS+:=rttest${n} +rttest${n}: + ${RCMD} add -priority 16 10.8.1/24 192.0.2.1 + ${RCMD} add -priority 17 10.8.1/24 192.0.2.2 + ${RCMD} add -priority 18 10.8.1/24 192.0.2.3 + ${SUDO} ifconfig lo10002 down + ${RCMD} add -priority 17 10.8.1/24 192.0.2.2 && exit 1 || exit 0 + ${RCMD} show -inet 2>&1 | \ + diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin + +n= 9 +RTTEST_TARGETS+:=rttest${n} +rttest${n}: + ${RCMD} add -priority 16 10.8.1/24 192.0.2.1 + ${RCMD} add -priority 17 10.8.1/24 192.0.2.2 + ${RCMD} add -priority 18 10.8.1/24 192.0.2.3 + ${SUDO} ifconfig lo10002 down + ${RCMD} delete -priority 17 10.8.1/24 + ${RCMD} show -inet 2>&1 | \ + diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin + +n= 10 +RTTEST_TARGETS+:=rttest${n} +rttest${n}: + ${SUDO} ifconfig lo10002 down + ${RCMD} add -priority 16 10.8.1/24 192.0.2.1 + ${RCMD} add -priority 17 10.8.1/24 192.0.2.2 + ${RCMD} add -priority 18 10.8.1/24 192.0.2.3 + ${RCMD} show -inet 2>&1 | \ + diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin + +n= 11 +RTTEST_TARGETS+:=rttest${n} +rttest${n}: + ${SUDO} ifconfig lo10002 down + ${RCMD} add -priority 16 10.8.1/24 192.0.2.1 + ${RCMD} add -priority 18 10.8.1/24 192.0.2.3 + ${RCMD} add -priority 17 10.8.1/24 192.0.2.2 + ${RCMD} show -inet 2>&1 | \ + diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin + +REGRESS_TARGETS=netmask ${RTTEST_TARGETS} REGRESS_ROOT_TARGETS=${REGRESS_TARGETS} .PHONY: ${REGRESS_TARGETS} diff --git a/regress/sbin/route/rttest1.ok b/regress/sbin/route/rttest1.ok new file mode 100644 index 00000000000..b8bca7a56e0 --- /dev/null +++ b/regress/sbin/route/rttest1.ok @@ -0,0 +1,16 @@ +Routing tables + +Internet: +Destination Gateway Flags Refs Use Mtu Prio Iface +10.0/16 192.0.2.4 UGS 0 0 33136 8 lo10004 +10.0/10 192.0.2.4 UGS 0 0 33136 8 lo10004 +10/8 192.0.2.1 UGS 0 0 33136 8 lo10001 +10.8.0/24 192.0.2.1 UGS 0 0 33136 8 lo10001 +10.8/16 192.0.2.3 UGS 0 0 33136 8 lo10003 +10.8.1/24 192.0.2.2 UGS 0 0 33136 8 lo10002 +10.8.3/24 192.0.2.3 UGS 0 0 33136 8 lo10003 +10.8.4/24 192.0.2.4 UGS 0 0 33136 8 lo10004 +192.0.2.1 192.0.2.1 UH 2 0 33136 4 lo10001 +192.0.2.2 192.0.2.2 UH 1 0 33136 4 lo10002 +192.0.2.3 192.0.2.3 UH 2 0 33136 4 lo10003 +192.0.2.4 192.0.2.4 UH 3 0 33136 4 lo10004 diff --git a/regress/sbin/route/rttest10.ok b/regress/sbin/route/rttest10.ok new file mode 100644 index 00000000000..8744eb42db4 --- /dev/null +++ b/regress/sbin/route/rttest10.ok @@ -0,0 +1,11 @@ +Routing tables + +Internet: +Destination Gateway Flags Refs Use Mtu Prio Iface +10.8.1/24 192.0.2.1 UGS 0 0 33136 16 lo10001 +10.8.1/24 192.0.2.3 UGS 0 0 33136 18 lo10003 +10.8.1/24 192.0.2.2 GS 0 0 33136 17 lo10002 +192.0.2.1 192.0.2.1 UH 1 0 33136 4 lo10001 +192.0.2.2 192.0.2.2 H 1 0 33136 4 lo10002 +192.0.2.3 192.0.2.3 UH 1 0 33136 4 lo10003 +192.0.2.4 192.0.2.4 UH 0 0 33136 4 lo10004 diff --git a/regress/sbin/route/rttest11.ok b/regress/sbin/route/rttest11.ok new file mode 100644 index 00000000000..8744eb42db4 --- /dev/null +++ b/regress/sbin/route/rttest11.ok @@ -0,0 +1,11 @@ +Routing tables + +Internet: +Destination Gateway Flags Refs Use Mtu Prio Iface +10.8.1/24 192.0.2.1 UGS 0 0 33136 16 lo10001 +10.8.1/24 192.0.2.3 UGS 0 0 33136 18 lo10003 +10.8.1/24 192.0.2.2 GS 0 0 33136 17 lo10002 +192.0.2.1 192.0.2.1 UH 1 0 33136 4 lo10001 +192.0.2.2 192.0.2.2 H 1 0 33136 4 lo10002 +192.0.2.3 192.0.2.3 UH 1 0 33136 4 lo10003 +192.0.2.4 192.0.2.4 UH 0 0 33136 4 lo10004 diff --git a/regress/sbin/route/rttest2.ok b/regress/sbin/route/rttest2.ok new file mode 100644 index 00000000000..97a0270d4cf --- /dev/null +++ b/regress/sbin/route/rttest2.ok @@ -0,0 +1,10 @@ +Routing tables + +Internet: +Destination Gateway Flags Refs Use Mtu Prio Iface +10.8.1/24 192.0.2.3 UGSP 0 0 33136 8 lo10003 +10.8.1/24 192.0.2.4 UGSP 0 0 33136 8 lo10004 +192.0.2.1 192.0.2.1 UH 0 0 33136 4 lo10001 +192.0.2.2 192.0.2.2 UH 0 0 33136 4 lo10002 +192.0.2.3 192.0.2.3 UH 1 0 33136 4 lo10003 +192.0.2.4 192.0.2.4 UH 1 0 33136 4 lo10004 diff --git a/regress/sbin/route/rttest3.ok b/regress/sbin/route/rttest3.ok new file mode 100644 index 00000000000..c8391c35b20 --- /dev/null +++ b/regress/sbin/route/rttest3.ok @@ -0,0 +1,9 @@ +Routing tables + +Internet: +Destination Gateway Flags Refs Use Mtu Prio Iface +10.8.1/24 192.0.2.3 UGS 0 0 33136 8 lo10003 +192.0.2.1 192.0.2.1 UH 0 0 33136 4 lo10001 +192.0.2.2 192.0.2.2 UH 0 0 33136 4 lo10002 +192.0.2.3 192.0.2.3 UH 1 0 33136 4 lo10003 +192.0.2.4 192.0.2.4 UH 0 0 33136 4 lo10004 diff --git a/regress/sbin/route/rttest4.ok b/regress/sbin/route/rttest4.ok new file mode 100644 index 00000000000..f445d7af295 --- /dev/null +++ b/regress/sbin/route/rttest4.ok @@ -0,0 +1,11 @@ +Routing tables + +Internet: +Destination Gateway Flags Refs Use Mtu Prio Iface +10.8.1/24 192.0.2.1 UGS 0 0 33136 16 lo10001 +10.8.1/24 192.0.2.2 UGS 0 0 33136 17 lo10002 +10.8.1/24 192.0.2.3 UGS 0 0 33136 18 lo10003 +192.0.2.1 192.0.2.1 UH 1 0 33136 4 lo10001 +192.0.2.2 192.0.2.2 UH 1 0 33136 4 lo10002 +192.0.2.3 192.0.2.3 UH 1 0 33136 4 lo10003 +192.0.2.4 192.0.2.4 UH 0 0 33136 4 lo10004 diff --git a/regress/sbin/route/rttest5.ok b/regress/sbin/route/rttest5.ok new file mode 100644 index 00000000000..d7bfde52bf8 --- /dev/null +++ b/regress/sbin/route/rttest5.ok @@ -0,0 +1,11 @@ +Routing tables + +Internet: +Destination Gateway Flags Refs Use Mtu Prio Iface +10.8.1/24 192.0.2.2 UGS 0 0 33136 16 lo10002 +10.8.1/24 192.0.2.2 UGS 0 0 33136 17 lo10002 +10.8.1/24 192.0.2.2 UGS 0 0 33136 18 lo10002 +192.0.2.1 192.0.2.1 UH 0 0 33136 4 lo10001 +192.0.2.2 192.0.2.2 UH 3 0 33136 4 lo10002 +192.0.2.3 192.0.2.3 UH 0 0 33136 4 lo10003 +192.0.2.4 192.0.2.4 UH 0 0 33136 4 lo10004 diff --git a/regress/sbin/route/rttest6.ok b/regress/sbin/route/rttest6.ok new file mode 100644 index 00000000000..f445d7af295 --- /dev/null +++ b/regress/sbin/route/rttest6.ok @@ -0,0 +1,11 @@ +Routing tables + +Internet: +Destination Gateway Flags Refs Use Mtu Prio Iface +10.8.1/24 192.0.2.1 UGS 0 0 33136 16 lo10001 +10.8.1/24 192.0.2.2 UGS 0 0 33136 17 lo10002 +10.8.1/24 192.0.2.3 UGS 0 0 33136 18 lo10003 +192.0.2.1 192.0.2.1 UH 1 0 33136 4 lo10001 +192.0.2.2 192.0.2.2 UH 1 0 33136 4 lo10002 +192.0.2.3 192.0.2.3 UH 1 0 33136 4 lo10003 +192.0.2.4 192.0.2.4 UH 0 0 33136 4 lo10004 diff --git a/regress/sbin/route/rttest7.ok b/regress/sbin/route/rttest7.ok new file mode 100644 index 00000000000..52712c577b7 --- /dev/null +++ b/regress/sbin/route/rttest7.ok @@ -0,0 +1,10 @@ +Routing tables + +Internet: +Destination Gateway Flags Refs Use Mtu Prio Iface +10.8.1/24 192.0.2.1 UGS 0 0 33136 16 lo10001 +10.8.1/24 192.0.2.3 UGS 0 0 33136 18 lo10003 +192.0.2.1 192.0.2.1 UH 1 0 33136 4 lo10001 +192.0.2.2 192.0.2.2 UH 0 0 33136 4 lo10002 +192.0.2.3 192.0.2.3 UH 1 0 33136 4 lo10003 +192.0.2.4 192.0.2.4 UH 0 0 33136 4 lo10004 diff --git a/regress/sbin/route/rttest8.ok b/regress/sbin/route/rttest8.ok new file mode 100644 index 00000000000..8744eb42db4 --- /dev/null +++ b/regress/sbin/route/rttest8.ok @@ -0,0 +1,11 @@ +Routing tables + +Internet: +Destination Gateway Flags Refs Use Mtu Prio Iface +10.8.1/24 192.0.2.1 UGS 0 0 33136 16 lo10001 +10.8.1/24 192.0.2.3 UGS 0 0 33136 18 lo10003 +10.8.1/24 192.0.2.2 GS 0 0 33136 17 lo10002 +192.0.2.1 192.0.2.1 UH 1 0 33136 4 lo10001 +192.0.2.2 192.0.2.2 H 1 0 33136 4 lo10002 +192.0.2.3 192.0.2.3 UH 1 0 33136 4 lo10003 +192.0.2.4 192.0.2.4 UH 0 0 33136 4 lo10004 diff --git a/regress/sbin/route/rttest9.ok b/regress/sbin/route/rttest9.ok new file mode 100644 index 00000000000..d5e53637296 --- /dev/null +++ b/regress/sbin/route/rttest9.ok @@ -0,0 +1,10 @@ +Routing tables + +Internet: +Destination Gateway Flags Refs Use Mtu Prio Iface +10.8.1/24 192.0.2.1 UGS 0 0 33136 16 lo10001 +10.8.1/24 192.0.2.3 UGS 0 0 33136 18 lo10003 +192.0.2.1 192.0.2.1 UH 1 0 33136 4 lo10001 +192.0.2.2 192.0.2.2 H 0 0 33136 4 lo10002 +192.0.2.3 192.0.2.3 UH 1 0 33136 4 lo10003 +192.0.2.4 192.0.2.4 UH 0 0 33136 4 lo10004