Source-Changes-HG archive

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

[src/trunk]: src/tests/net/ipsec Introduce check_sa_entries to remove lots of...



details:   https://anonhg.NetBSD.org/src/rev/2ad98fe7cded
branches:  trunk
changeset: 823808:2ad98fe7cded
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Wed May 10 04:46:13 2017 +0000

description:
Introduce check_sa_entries to remove lots of duplicated codes

diffstat:

 tests/net/ipsec/common.sh            |  19 ++++++++++++++-
 tests/net/ipsec/t_ipsec_gif.sh       |  46 ++++-------------------------------
 tests/net/ipsec/t_ipsec_l2tp.sh      |  46 ++++-------------------------------
 tests/net/ipsec/t_ipsec_transport.sh |  30 +++-------------------
 tests/net/ipsec/t_ipsec_tunnel.sh    |  42 +++++++-------------------------
 5 files changed, 44 insertions(+), 139 deletions(-)

diffs (truncated from 352 to 300 lines):

diff -r 13c2050cf51e -r 2ad98fe7cded tests/net/ipsec/common.sh
--- a/tests/net/ipsec/common.sh Wed May 10 03:26:33 2017 +0000
+++ b/tests/net/ipsec/common.sh Wed May 10 04:46:13 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: common.sh,v 1.1 2017/05/09 04:25:28 ozaki-r Exp $
+#      $NetBSD: common.sh,v 1.2 2017/05/10 04:46:13 ozaki-r Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -36,3 +36,20 @@
        atf_check -s exit:0 -o match:"No SAD entries." $HIJACKING setkey -D -a
        atf_check -s exit:0 -o match:"No SPD entries." $HIJACKING setkey -D -P
 }
+
+check_sa_entries()
+{
+       local sock=$1
+       local local_addr=$2
+       local remote_addr=$3
+
+       export RUMP_SERVER=$sock
+
+       $DEBUG && $HIJACKING setkey -D
+
+       atf_check -s exit:0 -o match:"$local_addr $rmote_addr" \
+           $HIJACKING setkey -D
+       atf_check -s exit:0 -o match:"$remote_addr $local_addr" \
+           $HIJACKING setkey -D
+       # TODO: more detail checks
+}
diff -r 13c2050cf51e -r 2ad98fe7cded tests/net/ipsec/t_ipsec_gif.sh
--- a/tests/net/ipsec/t_ipsec_gif.sh    Wed May 10 03:26:33 2017 +0000
+++ b/tests/net/ipsec/t_ipsec_gif.sh    Wed May 10 04:46:13 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: t_ipsec_gif.sh,v 1.3 2017/05/09 04:25:28 ozaki-r Exp $
+#      $NetBSD: t_ipsec_gif.sh,v 1.4 2017/05/10 04:46:13 ozaki-r Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -161,12 +161,6 @@
                EOF
                $DEBUG && cat $tmpfile
                atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
-               $DEBUG && $HIJACKING setkey -D
-               atf_check -s exit:0 -o match:"$ip_gwlo_tun $ip_gwre_tun" \
-                   $HIJACKING setkey -D
-               atf_check -s exit:0 -o match:"$ip_gwre_tun $ip_gwlo_tun" \
-                   $HIJACKING setkey -D
-               # TODO: more detail checks
 
                export RUMP_SERVER=$SOCK_TUN_REMOTE
                cat > $tmpfile <<-EOF
@@ -179,12 +173,6 @@
                EOF
                $DEBUG && cat $tmpfile
                atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
-               $DEBUG && $HIJACKING setkey -D
-               atf_check -s exit:0 -o match:"$ip_gwlo_tun $ip_gwre_tun" \
-                   $HIJACKING setkey -D
-               atf_check -s exit:0 -o match:"$ip_gwre_tun $ip_gwlo_tun" \
-                   $HIJACKING setkey -D
-               # TODO: more detail checks
        else # transport mode
                export RUMP_SERVER=$SOCK_TUN_LOCAL
                # from https://www.netbsd.org/docs/network/ipsec/
@@ -198,12 +186,6 @@
                EOF
                $DEBUG && cat $tmpfile
                atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
-               $DEBUG && $HIJACKING setkey -D
-               atf_check -s exit:0 -o match:"$ip_gwlo_tun $ip_gwre_tun" \
-                   $HIJACKING setkey -D
-               atf_check -s exit:0 -o match:"$ip_gwre_tun $ip_gwlo_tun" \
-                   $HIJACKING setkey -D
-               # TODO: more detail checks
 
                export RUMP_SERVER=$SOCK_TUN_REMOTE
                cat > $tmpfile <<-EOF
@@ -216,14 +198,11 @@
                EOF
                $DEBUG && cat $tmpfile
                atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
-               $DEBUG && $HIJACKING setkey -D
-               atf_check -s exit:0 -o match:"$ip_gwlo_tun $ip_gwre_tun" \
-                   $HIJACKING setkey -D
-               atf_check -s exit:0 -o match:"$ip_gwre_tun $ip_gwlo_tun" \
-                   $HIJACKING setkey -D
-               # TODO: more detail checks
        fi
 
+       check_sa_entries $SOCK_TUN_LOCAL $ip_gwlo_tun $ip_gwre_tun
+       check_sa_entries $SOCK_TUN_REMOTE $ip_gwlo_tun $ip_gwre_tun
+
        export RUMP_SERVER=$SOCK_LOCAL
        atf_check -s exit:0 -o ignore rump.ping -c 1 -n -w 3 $ip_remote
 
@@ -378,21 +357,8 @@
                atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
        fi
 
-       export RUMP_SERVER=$SOCK_TUN_LOCAL
-       $DEBUG && $HIJACKING setkey -D
-       atf_check -s exit:0 -o match:"$ip_gwlo_tun $ip_gwre_tun" \
-           $HIJACKING setkey -D
-       atf_check -s exit:0 -o match:"$ip_gwre_tun $ip_gwlo_tun" \
-           $HIJACKING setkey -D
-       # TODO: more detail checks
-
-       export RUMP_SERVER=$SOCK_TUN_REMOTE
-       $DEBUG && $HIJACKING setkey -D
-       atf_check -s exit:0 -o match:"$ip_gwlo_tun $ip_gwre_tun" \
-           $HIJACKING setkey -D
-       atf_check -s exit:0 -o match:"$ip_gwre_tun $ip_gwlo_tun" \
-           $HIJACKING setkey -D
-       # TODO: more detail checks
+       check_sa_entries $SOCK_TUN_LOCAL $ip_gwlo_tun $ip_gwre_tun
+       check_sa_entries $SOCK_TUN_REMOTE $ip_gwlo_tun $ip_gwre_tun
 
        export RUMP_SERVER=$SOCK_LOCAL
        atf_check -s exit:0 -o ignore rump.ping6 -c 1 -n -X 3 $ip_remote
diff -r 13c2050cf51e -r 2ad98fe7cded tests/net/ipsec/t_ipsec_l2tp.sh
--- a/tests/net/ipsec/t_ipsec_l2tp.sh   Wed May 10 03:26:33 2017 +0000
+++ b/tests/net/ipsec/t_ipsec_l2tp.sh   Wed May 10 04:46:13 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: t_ipsec_l2tp.sh,v 1.3 2017/05/09 04:25:28 ozaki-r Exp $
+#      $NetBSD: t_ipsec_l2tp.sh,v 1.4 2017/05/10 04:46:13 ozaki-r Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -196,21 +196,8 @@
                atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
        fi
 
-       export RUMP_SERVER=$SOCK_TUN_LOCAL
-       $DEBUG && $HIJACKING setkey -D
-       atf_check -s exit:0 -o match:"$ip_gwlo_tun $ip_gwre_tun" \
-           $HIJACKING setkey -D
-       atf_check -s exit:0 -o match:"$ip_gwre_tun $ip_gwlo_tun" \
-           $HIJACKING setkey -D
-       # TODO: more detail checks
-
-       export RUMP_SERVER=$SOCK_TUN_REMOTE
-       $DEBUG && $HIJACKING setkey -D
-       atf_check -s exit:0 -o match:"$ip_gwlo_tun $ip_gwre_tun" \
-           $HIJACKING setkey -D
-       atf_check -s exit:0 -o match:"$ip_gwre_tun $ip_gwlo_tun" \
-           $HIJACKING setkey -D
-       # TODO: more detail checks
+       check_sa_entries $SOCK_TUN_LOCAL $ip_gwlo_tun $ip_gwre_tun
+       check_sa_entries $SOCK_TUN_REMOTE $ip_gwlo_tun $ip_gwre_tun
 
        export RUMP_SERVER=$SOCK_LOCAL
        atf_check -s exit:0 -o ignore rump.ping -c 1 -n -w 3 $ip_remote
@@ -319,12 +306,6 @@
                EOF
                $DEBUG && cat $tmpfile
                atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
-               $DEBUG && $HIJACKING setkey -D
-               atf_check -s exit:0 -o match:"$ip_gwlo_tun $ip_gwre_tun" \
-                   $HIJACKING setkey -D
-               atf_check -s exit:0 -o match:"$ip_gwre_tun $ip_gwlo_tun" \
-                   $HIJACKING setkey -D
-               # TODO: more detail checks
 
                export RUMP_SERVER=$SOCK_TUN_REMOTE
                cat > $tmpfile <<-EOF
@@ -337,12 +318,6 @@
                EOF
                $DEBUG && cat $tmpfile
                atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
-               $DEBUG && $HIJACKING setkey -D
-               atf_check -s exit:0 -o match:"$ip_gwlo_tun $ip_gwre_tun" \
-                   $HIJACKING setkey -D
-               atf_check -s exit:0 -o match:"$ip_gwre_tun $ip_gwlo_tun" \
-                   $HIJACKING setkey -D
-               # TODO: more detail checks
        else # transport mode
                export RUMP_SERVER=$SOCK_TUN_LOCAL
                # from https://www.netbsd.org/docs/network/ipsec/
@@ -356,12 +331,6 @@
                EOF
                $DEBUG && cat $tmpfile
                atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
-               $DEBUG && $HIJACKING setkey -D
-               atf_check -s exit:0 -o match:"$ip_gwlo_tun $ip_gwre_tun" \
-                   $HIJACKING setkey -D
-               atf_check -s exit:0 -o match:"$ip_gwre_tun $ip_gwlo_tun" \
-                   $HIJACKING setkey -D
-               # TODO: more detail checks
 
                export RUMP_SERVER=$SOCK_TUN_REMOTE
                cat > $tmpfile <<-EOF
@@ -374,14 +343,11 @@
                EOF
                $DEBUG && cat $tmpfile
                atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
-               $DEBUG && $HIJACKING setkey -D
-               atf_check -s exit:0 -o match:"$ip_gwlo_tun $ip_gwre_tun" \
-                   $HIJACKING setkey -D
-               atf_check -s exit:0 -o match:"$ip_gwre_tun $ip_gwlo_tun" \
-                   $HIJACKING setkey -D
-               # TODO: more detail checks
        fi
 
+       check_sa_entries $SOCK_TUN_LOCAL $ip_gwlo_tun $ip_gwre_tun
+       check_sa_entries $SOCK_TUN_REMOTE $ip_gwlo_tun $ip_gwre_tun
+
        export RUMP_SERVER=$SOCK_LOCAL
        atf_check -s exit:0 -o ignore rump.ping6 -c 1 -n -X 3 $ip_remote
 
diff -r 13c2050cf51e -r 2ad98fe7cded tests/net/ipsec/t_ipsec_transport.sh
--- a/tests/net/ipsec/t_ipsec_transport.sh      Wed May 10 03:26:33 2017 +0000
+++ b/tests/net/ipsec/t_ipsec_transport.sh      Wed May 10 04:46:13 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: t_ipsec_transport.sh,v 1.2 2017/05/09 04:25:28 ozaki-r Exp $
+#      $NetBSD: t_ipsec_transport.sh,v 1.3 2017/05/10 04:46:13 ozaki-r Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -84,12 +84,7 @@
        EOF
        $DEBUG && cat $tmpfile
        atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
-       $DEBUG && $HIJACKING setkey -D
-       atf_check -s exit:0 -o match:"$ip_local $ip_peer" \
-           $HIJACKING setkey -D
-       atf_check -s exit:0 -o match:"$ip_peer $ip_local" \
-           $HIJACKING setkey -D
-       # TODO: more detail checks
+       check_sa_entries $SOCK_LOCAL $ip_local $ip_peer
 
        export RUMP_SERVER=$SOCK_PEER
        cat > $tmpfile <<-EOF
@@ -99,12 +94,7 @@
        EOF
        $DEBUG && cat $tmpfile
        atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
-       $DEBUG && $HIJACKING setkey -D
-       atf_check -s exit:0 -o match:"$ip_local $ip_peer" \
-           $HIJACKING setkey -D
-       atf_check -s exit:0 -o match:"$ip_peer $ip_local" \
-           $HIJACKING setkey -D
-       # TODO: more detail checks
+       check_sa_entries $SOCK_PEER $ip_local $ip_peer
 
        export RUMP_SERVER=$SOCK_LOCAL
        atf_check -s exit:0 -o ignore rump.ping -c 1 -n -w 3 $ip_peer
@@ -172,12 +162,7 @@
        EOF
        $DEBUG && cat $tmpfile
        atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
-       $DEBUG && $HIJACKING setkey -D
-       atf_check -s exit:0 -o match:"$ip_local $ip_peer" \
-           $HIJACKING setkey -D
-       atf_check -s exit:0 -o match:"$ip_peer $ip_local" \
-           $HIJACKING setkey -D
-       # TODO: more detail checks
+       check_sa_entries $SOCK_LOCAL $ip_local $ip_peer
 
        export RUMP_SERVER=$SOCK_PEER
        cat > $tmpfile <<-EOF
@@ -187,12 +172,7 @@
        EOF
        $DEBUG && cat $tmpfile
        atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
-       $DEBUG && $HIJACKING setkey -D
-       atf_check -s exit:0 -o match:"$ip_local $ip_peer" \
-           $HIJACKING setkey -D
-       atf_check -s exit:0 -o match:"$ip_peer $ip_local" \
-           $HIJACKING setkey -D
-       # TODO: more detail checks
+       check_sa_entries $SOCK_PEER $ip_local $ip_peer
 
        export RUMP_SERVER=$SOCK_LOCAL
        atf_check -s exit:0 -o ignore rump.ping6 -c 1 -n -X 3 $ip_peer
diff -r 13c2050cf51e -r 2ad98fe7cded tests/net/ipsec/t_ipsec_tunnel.sh
--- a/tests/net/ipsec/t_ipsec_tunnel.sh Wed May 10 03:26:33 2017 +0000
+++ b/tests/net/ipsec/t_ipsec_tunnel.sh Wed May 10 04:46:13 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: t_ipsec_tunnel.sh,v 1.4 2017/05/09 04:25:28 ozaki-r Exp $
+#      $NetBSD: t_ipsec_tunnel.sh,v 1.5 2017/05/10 04:46:13 ozaki-r Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -124,14 +124,8 @@
        EOF
        $DEBUG && cat $tmpfile
        atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
-       $DEBUG && $HIJACKING setkey -D
-       atf_check -s exit:0 \
-           -o match:"$ip_gw_local_tunnel $ip_gw_remote_tunnel" \
-           $HIJACKING setkey -D
-       atf_check -s exit:0 \
-           -o match:"$ip_gw_remote_tunnel $ip_gw_local_tunnel" \
-           $HIJACKING setkey -D
-       # TODO: more detail checks
+       check_sa_entries $SOCK_TUNNEL_LOCAL $ip_gw_local_tunnel \
+           $ip_gw_remote_tunnel
 
        export RUMP_SERVER=$SOCK_TUNNEL_REMOTE



Home | Main Index | Thread Index | Old Index