Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/net Improve test stability
details: https://anonhg.NetBSD.org/src/rev/ce19de9b4cb4
branches: trunk
changeset: 339911:ce19de9b4cb4
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Mon Aug 17 07:06:58 2015 +0000
description:
Improve test stability
- Take a diff between packet dumps and use it for packet checking
- it's resistant against packet reorder
- Seep 2 sec to make sure a NS message is sent
- Disable tentative state check for now
- it's too ephemeral to check robustly
diffstat:
tests/net/arp/t_dad.sh | 49 +++++++++++++++++++++++++++++++++++--------------
tests/net/ndp/t_dad.sh | 49 +++++++++++++++++++++++++++++++++++--------------
2 files changed, 70 insertions(+), 28 deletions(-)
diffs (192 lines):
diff -r 25f519bee6c2 -r ce19de9b4cb4 tests/net/arp/t_dad.sh
--- a/tests/net/arp/t_dad.sh Mon Aug 17 06:50:03 2015 +0000
+++ b/tests/net/arp/t_dad.sh Mon Aug 17 07:06:58 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_dad.sh,v 1.3 2015/07/31 00:23:54 ozaki-r Exp $
+# $NetBSD: t_dad.sh,v 1.4 2015/08/17 07:06:58 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -73,6 +73,21 @@
echo $pkt
}
+extract_new_packets()
+{
+ local old=./old
+
+ if [ ! -f $old ]; then
+ old=/dev/null
+ fi
+
+ shmif_dumpbus -p - bus1 2>/dev/null| \
+ tcpdump -n -e -r - 2>/dev/null > ./new
+ diff -u $old ./new |grep '^+' |cut -d '+' -f 2 > ./diff
+ mv -f ./new ./old
+ cat ./diff
+}
+
dad_basic_body()
{
local pkt=
@@ -84,17 +99,21 @@
atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.1/24
atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.2/24 alias
- atf_check -s exit:0 rump.ifconfig shmif0 up
$DEBUG && rump.ifconfig shmif0
- atf_check -s exit:0 sleep 1
+ atf_check -s exit:0 rump.ifconfig shmif0 up
+ rump.ifconfig shmif0 > ./out
+ $DEBUG && cat ./out
- # The primary address is not tentative from the beginning
- atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.1 |grep -q tentative"
- # The alias address is still tentative
- atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.2 |grep -q tentative"
+ # The primary address doesn't start with tentative state
+ atf_check -s not-exit:0 -x "cat ./out |grep 10.0.0.1 |grep -q tentative"
+ # The alias address starts with tentative state
+ # XXX we have no stable way to check this, so skip for now
+ #atf_check -s exit:0 -x "cat ./out |grep 10.0.0.2 |grep -q tentative"
- shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - > ./out
+ atf_check -s exit:0 sleep 2
+ extract_new_packets > ./out
+ $DEBUG && cat ./out
# Check DAD probe packets
pkt=$(make_pkt_str 10.0.0.2 0.0.0.0)
@@ -105,7 +124,8 @@
# Waiting for DAD complete
atf_check -s exit:0 rump.ifconfig -w 10
- shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - |tail -1 > ./out
+ extract_new_packets > ./out
+ $DEBUG && cat ./out
# Check the DAD announce packet
pkt=$(make_pkt_str 10.0.0.2 10.0.0.2)
@@ -118,19 +138,20 @@
#
atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.3/24 alias
- atf_check -s exit:0 sleep 1
-
- # The new address is still tentative
+ # The new address starts with tentative state
atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -q tentative"
# Check DAD probe packets
- shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - |tail -1 > ./out
+ atf_check -s exit:0 sleep 2
+ extract_new_packets > ./out
+ $DEBUG && cat ./out
pkt=$(make_pkt_str 10.0.0.3 0.0.0.0)
atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'"
# Waiting for DAD complete
atf_check -s exit:0 rump.ifconfig -w 10
- shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - |tail -1 > ./out
+ extract_new_packets > ./out
+ $DEBUG && cat ./out
# Check the DAD announce packet
pkt=$(make_pkt_str 10.0.0.3 10.0.0.3)
diff -r 25f519bee6c2 -r ce19de9b4cb4 tests/net/ndp/t_dad.sh
--- a/tests/net/ndp/t_dad.sh Mon Aug 17 06:50:03 2015 +0000
+++ b/tests/net/ndp/t_dad.sh Mon Aug 17 07:06:58 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_dad.sh,v 1.2 2015/08/10 09:31:13 ozaki-r Exp $
+# $NetBSD: t_dad.sh,v 1.3 2015/08/17 07:06:58 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -75,6 +75,21 @@
echo $pkt
}
+extract_new_packets()
+{
+ local old=./old
+
+ if [ ! -f $old ]; then
+ old=/dev/null
+ fi
+
+ shmif_dumpbus -p - bus1 2>/dev/null| \
+ tcpdump -n -e -r - 2>/dev/null > ./new
+ diff -u $old ./new |grep '^+' |cut -d '+' -f 2 > ./diff
+ mv -f ./new ./old
+ cat ./diff
+}
+
dad_basic_body()
{
local pkt=
@@ -89,17 +104,21 @@
atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
atf_check -s exit:0 rump.ifconfig shmif0 inet6 $localip1
atf_check -s exit:0 rump.ifconfig shmif0 inet6 $localip2
- atf_check -s exit:0 rump.ifconfig shmif0 up
$DEBUG && rump.ifconfig shmif0
- #atf_check -s exit:0 sleep 1
+ atf_check -s exit:0 rump.ifconfig shmif0 up
+ rump.ifconfig shmif0 > ./out
+ $DEBUG && cat ./out
- # The primary address is not tentative from the beginning
- atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip1 |grep -q tentative"
- # The alias address is still tentative
- atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep $localip2 |grep -q tentative"
+ # The primary address doesn't start with tentative state
+ atf_check -s not-exit:0 -x "cat ./out |grep $localip1 |grep -q tentative"
+ # The alias address starts with tentative state
+ # XXX we have no stable way to check this, so skip for now
+ #atf_check -s exit:0 -x "cat ./out |grep $localip2 |grep -q tentative"
- shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - > ./out
+ atf_check -s exit:0 sleep 2
+ extract_new_packets > ./out
+ $DEBUG && cat ./out
# Check DAD probe packets (Neighbor Solicitation Message)
pkt=$(make_ns_pkt_str 2 $localip2)
@@ -110,7 +129,8 @@
# Waiting for DAD complete
atf_check -s exit:0 rump.ifconfig -w 10
- shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - |tail -1 > ./out
+ extract_new_packets > ./out
+ $DEBUG && cat ./out
# IPv6 DAD doesn't announce (Neighbor Advertisement Message)
@@ -122,19 +142,20 @@
#
atf_check -s exit:0 rump.ifconfig shmif0 inet6 $localip3
- #atf_check -s exit:0 sleep 1
-
- # The new address is still tentative
+ # The new address starts with tentative state
atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep $localip3 |grep -q tentative"
# Check DAD probe packets (Neighbor Solicitation Message)
- shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - |tail -1 > ./out
+ atf_check -s exit:0 sleep 2
+ extract_new_packets > ./out
+ $DEBUG && cat ./out
pkt=$(make_ns_pkt_str 3 $localip3)
atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'"
# Waiting for DAD complete
atf_check -s exit:0 rump.ifconfig -w 10
- shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - |tail -1 > ./out
+ extract_new_packets > ./out
+ $DEBUG && cat ./out
# IPv6 DAD doesn't announce (Neighbor Advertisement Message)
Home |
Main Index |
Thread Index |
Old Index