Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/net/ipsec Dedup some checks
details: https://anonhg.NetBSD.org/src/rev/82d6621be890
branches: trunk
changeset: 827693:82d6621be890
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Thu Nov 09 04:51:07 2017 +0000
description:
Dedup some checks
And the change a bit optimizes checks of SA expirations, which
may shorten testing time.
diffstat:
tests/net/ipsec/t_ipsec_misc.sh | 80 ++++++++++++++++++++++------------------
1 files changed, 43 insertions(+), 37 deletions(-)
diffs (124 lines):
diff -r 1742be55bd28 -r 82d6621be890 tests/net/ipsec/t_ipsec_misc.sh
--- a/tests/net/ipsec/t_ipsec_misc.sh Thu Nov 09 04:50:37 2017 +0000
+++ b/tests/net/ipsec/t_ipsec_misc.sh Thu Nov 09 04:51:07 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_ipsec_misc.sh,v 1.21 2017/11/09 04:50:37 ozaki-r Exp $
+# $NetBSD: t_ipsec_misc.sh,v 1.22 2017/11/09 04:51:07 ozaki-r Exp $
#
# Copyright (c) 2017 Internet Initiative Japan Inc.
# All rights reserved.
@@ -78,6 +78,42 @@
#check_sa_entries $SOCK_PEER $ip_local $ip_peer
}
+test_sad_disapper_until()
+{
+ local time=$1
+ local check_dead_sa=$2
+ local setkey_opts=
+ local n=$time
+ local tmpfile=./__tmp
+ local sock= ok=
+
+ if $check_dead_sa; then
+ setkey_opts="-D -a"
+ else
+ setkey_opts="-D"
+ fi
+
+ while [ $n -ne 0 ]; do
+ ok=0
+ sleep 1
+ for sock in $SOCK_LOCAL $SOCK_PEER; do
+ export RUMP_SERVER=$sock
+ $HIJACKING setkey $setkey_opts > $tmpfile
+ $DEBUG && cat $tmpfile
+ if grep -q 'No SAD entries.' $tmpfile; then
+ ok=$((ok + 1))
+ fi
+ done
+ if [ $ok -eq 2 ]; then
+ return
+ fi
+
+ n=$((n - 1))
+ done
+
+ atf_fail "SAs didn't disappear after $time sec."
+}
+
test_ipsec4_lifetime()
{
local proto=$1
@@ -119,16 +155,8 @@
# Set up SAs with lifetime 1 sec.
setup_sasp $proto "$algo_args" $ip_local $ip_peer 1
- # Wait for the SAs to be expired
- atf_check -s exit:0 sleep $((1 + $buffertime))
-
# Check the SAs have been expired
- export RUMP_SERVER=$SOCK_LOCAL
- $DEBUG && $HIJACKING setkey -D
- atf_check -s exit:0 -o match:'No SAD entries.' $HIJACKING setkey -D
- export RUMP_SERVER=$SOCK_PEER
- $DEBUG && $HIJACKING setkey -D
- atf_check -s exit:0 -o match:'No SAD entries.' $HIJACKING setkey -D
+ test_sad_disapper_until $((1 + $buffertime)) false
# Clean up SPs
export RUMP_SERVER=$SOCK_LOCAL
@@ -149,15 +177,8 @@
atf_check -s exit:0 -o match:"$ip_peer > $ip_local: $proto_cap" \
cat $outfile
- atf_check -s exit:0 sleep $((lifetime + $buffertime))
-
- export RUMP_SERVER=$SOCK_LOCAL
- $DEBUG && $HIJACKING setkey -D
- atf_check -s exit:0 -o match:'No SAD entries.' $HIJACKING setkey -D -a
-
- export RUMP_SERVER=$SOCK_PEER
- $DEBUG && $HIJACKING setkey -D
- atf_check -s exit:0 -o match:'No SAD entries.' $HIJACKING setkey -D -a
+ # Check the SAs have been expired
+ test_sad_disapper_until $((lifetime + $buffertime)) true
export RUMP_SERVER=$SOCK_LOCAL
atf_check -s not-exit:0 -o match:'0 packets received' \
@@ -206,16 +227,8 @@
# Set up SAs with lifetime 1 sec.
setup_sasp $proto "$algo_args" $ip_local $ip_peer 1
- # Wait for the SAs to be expired
- atf_check -s exit:0 sleep $((1 + $buffertime))
-
# Check the SAs have been expired
- export RUMP_SERVER=$SOCK_LOCAL
- $DEBUG && $HIJACKING setkey -D
- atf_check -s exit:0 -o match:'No SAD entries.' $HIJACKING setkey -D
- export RUMP_SERVER=$SOCK_PEER
- $DEBUG && $HIJACKING setkey -D
- atf_check -s exit:0 -o match:'No SAD entries.' $HIJACKING setkey -D
+ test_sad_disapper_until $((1 + $buffertime)) false
# Clean up SPs
export RUMP_SERVER=$SOCK_LOCAL
@@ -236,15 +249,8 @@
atf_check -s exit:0 -o match:"$ip_peer > $ip_local: $proto_cap" \
cat $outfile
- atf_check -s exit:0 sleep $((lifetime + $buffertime))
-
- export RUMP_SERVER=$SOCK_LOCAL
- $DEBUG && $HIJACKING setkey -D
- atf_check -s exit:0 -o match:'No SAD entries.' $HIJACKING setkey -D -a
-
- export RUMP_SERVER=$SOCK_PEER
- $DEBUG && $HIJACKING setkey -D
- atf_check -s exit:0 -o match:'No SAD entries.' $HIJACKING setkey -D -a
+ # Check the SAs have been expired
+ test_sad_disapper_until $((lifetime + $buffertime)) true
export RUMP_SERVER=$SOCK_LOCAL
atf_check -s not-exit:0 -o match:'0 packets received' \
Home |
Main Index |
Thread Index |
Old Index