Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/net/mpls factor out common code and set the path.



details:   https://anonhg.NetBSD.org/src/rev/3a9f44f7c307
branches:  trunk
changeset: 746437:3a9f44f7c307
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Apr 01 01:49:26 2020 +0000

description:
factor out common code and set the path.

diffstat:

 tests/net/mpls/Makefile       |   7 +++-
 tests/net/mpls/mpls_common.sh |  55 +++++++++++++++++++++++++++++++++++++++++++
 tests/net/mpls/t_ldp_regen.sh |  24 +++--------------
 tests/net/mpls/t_mpls_fw.sh   |  34 ++------------------------
 tests/net/mpls/t_mpls_fw6.sh  |  33 ++-----------------------
 tests/net/mpls/t_mpls_fw64.sh |  33 ++-----------------------
 tests/net/mpls/t_rfc4182.sh   |  31 +----------------------
 7 files changed, 76 insertions(+), 141 deletions(-)

diffs (truncated from 409 to 300 lines):

diff -r cb624a05cb54 -r 3a9f44f7c307 tests/net/mpls/Makefile
--- a/tests/net/mpls/Makefile   Wed Apr 01 00:49:04 2020 +0000
+++ b/tests/net/mpls/Makefile   Wed Apr 01 01:49:26 2020 +0000
@@ -1,10 +1,13 @@
-# $NetBSD: Makefile,v 1.6 2015/05/27 18:13:14 kefren Exp $
+# $NetBSD: Makefile,v 1.7 2020/04/01 01:49:26 christos Exp $
 #
 
 .include <bsd.own.mk>
 
 TESTSDIR=      ${TESTSBASE}/net/mpls
 
-TESTS_SH=      t_mpls_fw t_mpls_fw6 t_mpls_fw64 t_rfc4182 t_ldp_regen
+.for name in t_mpls_fw t_mpls_fw6 t_mpls_fw64 t_rfc4182 t_ldp_regen
+TESTS_SH+=              ${name}
+TESTS_SH_SRC_${name}= mpls_common.sh ${name}.sh
+.endfor
 
 .include <bsd.test.mk>
diff -r cb624a05cb54 -r 3a9f44f7c307 tests/net/mpls/mpls_common.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/net/mpls/mpls_common.sh     Wed Apr 01 01:49:26 2020 +0000
@@ -0,0 +1,55 @@
+# $NetBSD: mpls_common.sh,v 1.1 2020/04/01 01:49:26 christos Exp $
+#
+# Copyright (c) 2020 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+export PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+RUMP_SERVER1=unix://./r1
+RUMP_SERVER2=unix://./r2
+RUMP_SERVER3=unix://./r3
+RUMP_SERVER4=unix://./r4
+
+RUMP_FLAGS6="-lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6 \
+             -lrumpnet_shmif -lrumpnet_netmpls"
+
+dostart()
+{
+
+       ulimit -r 400
+       atf_check -s exit:0 rump_server ${RUMP_FLAGS6} ${RUMP_SERVER1}
+       atf_check -s exit:0 rump_server ${RUMP_FLAGS6} ${RUMP_SERVER2}
+       atf_check -s exit:0 rump_server ${RUMP_FLAGS6} ${RUMP_SERVER3}
+       atf_check -s exit:0 rump_server ${RUMP_FLAGS6} ${RUMP_SERVER4}
+}
+
+docleanup()
+{
+
+       RUMP_SERVER=${RUMP_SERVER1} rump.halt
+       RUMP_SERVER=${RUMP_SERVER2} rump.halt
+       RUMP_SERVER=${RUMP_SERVER3} rump.halt
+       RUMP_SERVER=${RUMP_SERVER4} rump.halt
+}
diff -r cb624a05cb54 -r 3a9f44f7c307 tests/net/mpls/t_ldp_regen.sh
--- a/tests/net/mpls/t_ldp_regen.sh     Wed Apr 01 00:49:04 2020 +0000
+++ b/tests/net/mpls/t_ldp_regen.sh     Wed Apr 01 01:49:26 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_ldp_regen.sh,v 1.8 2019/05/13 17:55:09 bad Exp $
+# $NetBSD: t_ldp_regen.sh,v 1.9 2020/04/01 01:49:26 christos Exp $
 #
 # Copyright (c) 2013 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -35,6 +35,7 @@
 # Now: * R4 should install label IMPLNULL for that prefix
 #      * R3 should realloc the target label from IMPLNULL to something else
 
+export PATH=/sbin:/usr/sbin:/bin:/usr/bin
 
 RUMP_SERVER1=unix://./r1
 RUMP_SERVER2=unix://./r2
@@ -68,15 +69,7 @@
                rump.ping -n -o -w 5 10.0.5.1
 }
 
-create_servers() {
-
-       # allows us to run as normal user
-       ulimit -r 400
-
-       atf_check -s exit:0 rump_server ${RUMP_LIBS} ${RUMP_SERVER1}
-       atf_check -s exit:0 rump_server ${RUMP_LIBS} ${RUMP_SERVER2}
-       atf_check -s exit:0 rump_server ${RUMP_LIBS} ${RUMP_SERVER3}
-       atf_check -s exit:0 rump_server ${RUMP_LIBS} ${RUMP_SERVER4}
+configservers() {
 
        # LDP HIJACK
        export RUMPHIJACK=path=/rump,socket=all,sysctl=yes
@@ -153,21 +146,14 @@
                rump.ping -o -w 60 10.0.4.1
 }
 
-docleanup() {
-
-       RUMP_SERVER=${RUMP_SERVER1} rump.halt
-       RUMP_SERVER=${RUMP_SERVER2} rump.halt
-       RUMP_SERVER=${RUMP_SERVER3} rump.halt
-       RUMP_SERVER=${RUMP_SERVER4} rump.halt
-}
-
 ldp_regen_body() {
 
         if sysctl machdep.cpu_brand 2>/dev/null | grep QEMU >/dev/null 2>&1
        then
            atf_skip "unreliable under qemu, skip until PR kern/43997 fixed"
        fi
-       create_servers
+       dostart
+       configservers
        wait_ldp_ok
        newaddr_and_ping
 }
diff -r cb624a05cb54 -r 3a9f44f7c307 tests/net/mpls/t_mpls_fw.sh
--- a/tests/net/mpls/t_mpls_fw.sh       Wed Apr 01 00:49:04 2020 +0000
+++ b/tests/net/mpls/t_mpls_fw.sh       Wed Apr 01 01:49:26 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_mpls_fw.sh,v 1.6 2019/05/13 17:55:09 bad Exp $
+# $NetBSD: t_mpls_fw.sh,v 1.7 2020/04/01 01:49:26 christos Exp $
 #
 # Copyright (c) 2013 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -36,15 +36,6 @@
 # Do the same for the reverse direction (R4 to R1)
 # ping from R1 to R4 right hand side interface
 
-
-RUMP_SERVER1=unix://./r1
-RUMP_SERVER2=unix://./r2
-RUMP_SERVER3=unix://./r3
-RUMP_SERVER4=unix://./r4
-
-RUMP_FLAGS="-lrumpnet -lrumpnet_net -lrumpnet_netinet  \
-            -lrumpnet_netmpls -lrumpnet_shmif"
-
 atf_test_case mplsfw4 cleanup
 mplsfw4_head()
 {
@@ -53,16 +44,6 @@
        atf_set "require.progs" "rump_server"
 }
 
-startservers()
-{
-
-       ulimit -r 300
-       atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER1}
-       atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER2}
-       atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER3}
-       atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER4}
-}
-
 configservers()
 {
 
@@ -133,19 +114,10 @@
        unset RUMP_SERVER
 }
 
-docleanup()
-{
-
-       RUMP_SERVER=${RUMP_SERVER1} rump.halt
-       RUMP_SERVER=${RUMP_SERVER2} rump.halt
-       RUMP_SERVER=${RUMP_SERVER3} rump.halt
-       RUMP_SERVER=${RUMP_SERVER4} rump.halt
-}
-
 mplsfw4_body()
 {
 
-       startservers
+       dostart
        configservers 3
        doping
 }
@@ -168,7 +140,7 @@
 mplsfw4_expl_body()
 {
 
-       startservers
+       dostart
        configservers 0
        doping
 }
diff -r cb624a05cb54 -r 3a9f44f7c307 tests/net/mpls/t_mpls_fw6.sh
--- a/tests/net/mpls/t_mpls_fw6.sh      Wed Apr 01 00:49:04 2020 +0000
+++ b/tests/net/mpls/t_mpls_fw6.sh      Wed Apr 01 01:49:26 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_mpls_fw6.sh,v 1.4 2019/05/13 17:55:09 bad Exp $
+# $NetBSD: t_mpls_fw6.sh,v 1.5 2020/04/01 01:49:26 christos Exp $
 #
 # Copyright (c) 2015 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -38,14 +38,6 @@
 #
 # redo the test using IPv6 explicit null label
 
-RUMP_SERVER1=unix://./r1
-RUMP_SERVER2=unix://./r2
-RUMP_SERVER3=unix://./r3
-RUMP_SERVER4=unix://./r4
-
-RUMP_FLAGS6="-lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6 \
-             -lrumpnet_shmif -lrumpnet_netmpls"
-
 atf_test_case mplsfw6 cleanup
 mplsfw6_head()
 {
@@ -54,16 +46,6 @@
        atf_set "require.progs" "rump_server"
 }
 
-startservers()
-{
-
-       ulimit -r 300
-       atf_check -s exit:0 rump_server ${RUMP_FLAGS6} ${RUMP_SERVER1}
-       atf_check -s exit:0 rump_server ${RUMP_FLAGS6} ${RUMP_SERVER2}
-       atf_check -s exit:0 rump_server ${RUMP_FLAGS6} ${RUMP_SERVER3}
-       atf_check -s exit:0 rump_server ${RUMP_FLAGS6} ${RUMP_SERVER4}
-}
-
 configservers()
 {
 
@@ -163,19 +145,10 @@
        unset RUMP_SERVER
 }
 
-docleanup()
-{
-
-       RUMP_SERVER=${RUMP_SERVER1} rump.halt
-       RUMP_SERVER=${RUMP_SERVER2} rump.halt
-       RUMP_SERVER=${RUMP_SERVER3} rump.halt
-       RUMP_SERVER=${RUMP_SERVER4} rump.halt
-}
-
 mplsfw6_body()
 {
 
-       startservers
+       dostart
        configservers 3
        do_check_route
        doping
@@ -199,7 +172,7 @@
 mplsfw6_expl_body()
 {
 
-       startservers
+       dostart
        configservers 2
        do_check_route
        doping
diff -r cb624a05cb54 -r 3a9f44f7c307 tests/net/mpls/t_mpls_fw64.sh
--- a/tests/net/mpls/t_mpls_fw64.sh     Wed Apr 01 00:49:04 2020 +0000
+++ b/tests/net/mpls/t_mpls_fw64.sh     Wed Apr 01 01:49:26 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_mpls_fw64.sh,v 1.4 2019/05/13 17:55:09 bad Exp $
+# $NetBSD: t_mpls_fw64.sh,v 1.5 2020/04/01 01:49:26 christos Exp $
 #
 # Copyright (c) 2015 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -42,24 +42,6 @@
 # ping6 from R1 to R4 right hand side interface
 
 
-RUMP_SERVER1=unix://./r1
-RUMP_SERVER2=unix://./r2
-RUMP_SERVER3=unix://./r3
-RUMP_SERVER4=unix://./r4
-
-RUMP_FLAGS6="-lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6 \
-             -lrumpnet_shmif -lrumpnet_netmpls"
-



Home | Main Index | Thread Index | Old Index