Module Name:    src
Committed By:   ozaki-r
Date:           Mon Aug 17 07:06:58 UTC 2015

Modified Files:
        src/tests/net/arp: t_dad.sh
        src/tests/net/ndp: t_dad.sh

Log Message:
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


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/net/arp/t_dad.sh
cvs rdiff -u -r1.2 -r1.3 src/tests/net/ndp/t_dad.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/arp/t_dad.sh
diff -u src/tests/net/arp/t_dad.sh:1.3 src/tests/net/arp/t_dad.sh:1.4
--- src/tests/net/arp/t_dad.sh:1.3	Fri Jul 31 00:23:54 2015
+++ src/tests/net/arp/t_dad.sh	Mon Aug 17 07:06:58 2015
@@ -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 @@ make_pkt_str()
 	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 @@ dad_basic_body()
 	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
-
-	# 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"
+	atf_check -s exit:0 rump.ifconfig shmif0 up
+	rump.ifconfig shmif0 > ./out
+	$DEBUG && cat ./out
 
-	shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - > ./out
+	# 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"
+
+	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 @@ dad_basic_body()
 
 	# 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 @@ dad_basic_body()
 	#
 	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)

Index: src/tests/net/ndp/t_dad.sh
diff -u src/tests/net/ndp/t_dad.sh:1.2 src/tests/net/ndp/t_dad.sh:1.3
--- src/tests/net/ndp/t_dad.sh:1.2	Mon Aug 10 09:31:13 2015
+++ src/tests/net/ndp/t_dad.sh	Mon Aug 17 07:06:58 2015
@@ -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 @@ make_ns_pkt_str()
 	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 @@ dad_basic_body()
 	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
-
-	# 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"
+	atf_check -s exit:0 rump.ifconfig shmif0 up
+	rump.ifconfig shmif0 > ./out
+	$DEBUG && cat ./out
 
-	shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - > ./out
+	# 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"
+
+	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 @@ dad_basic_body()
 
 	# 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 @@ dad_basic_body()
 	#
 	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)
 

Reply via email to