PERFORCE change 197825 for review

Catalin Nicutar cnicutar at FreeBSD.org
Thu Aug 18 17:11:15 UTC 2011


http://p4web.freebsd.org/@@197825?ac=10

Change 197825 by cnicutar at cnicutar_cronos on 2011/08/18 17:10:17

	Clean up tests and remove duplicate code.

Affected files ...

.. //depot/projects/soc2011/cnicutar_tcputo_9/src/tools/regression/netinet/tcputo/Makefile.generic_uto#1 add
.. //depot/projects/soc2011/cnicutar_tcputo_9/src/tools/regression/netinet/tcputo/Makefile.long_uto#2 delete
.. //depot/projects/soc2011/cnicutar_tcputo_9/src/tools/regression/netinet/tcputo/Makefile.short_uto#2 delete
.. //depot/projects/soc2011/cnicutar_tcputo_9/src/tools/regression/netinet/tcputo/generic_uto.c#1 add
.. //depot/projects/soc2011/cnicutar_tcputo_9/src/tools/regression/netinet/tcputo/long_uto.c#3 delete
.. //depot/projects/soc2011/cnicutar_tcputo_9/src/tools/regression/netinet/tcputo/runtest.sh#2 edit
.. //depot/projects/soc2011/cnicutar_tcputo_9/src/tools/regression/netinet/tcputo/short_uto.c#2 delete

Differences ...

==== //depot/projects/soc2011/cnicutar_tcputo_9/src/tools/regression/netinet/tcputo/runtest.sh#2 (text+ko) ====

@@ -1,5 +1,6 @@
 #!/bin/sh
 
+
 # Bring down two loopback interfaces
 lo_down()
 {
@@ -7,7 +8,7 @@
         ifconfig lo3 destroy
 }
 
-# Create two loopback interfaces and assign example addresses
+# Create two loopback interfaces and assign addresses
 lo_up()
 {
 	# Just in case they are still around
@@ -38,8 +39,6 @@
 # Run a test and display results
 runtest()
 {
-	args=$1			# Test arguments
-
 	killall "$bin" > /dev/null 2>&1
 
 	if ! make -f "Makefile.${bin}" > /dev/null 2>&1
@@ -47,9 +46,11 @@
 		echo "not ok $no - $name # make failed"
 		exit 1
 	fi
-	
+
 	# Finally run the test
-	if ./$bin  > /dev/null 2>&1 $args
+	./$bin $testargs >/dev/null 2>&1
+
+	if [ "$?" -eq "$expect" ]
 	then
 		echo "ok $no - $name"
 	else
@@ -58,77 +59,143 @@
 	lo_down > /dev/null 2>&1
 }
 
+# Setup loopback interfaces before starting the test program and bring them
+# down afterwards.
 test_with_loopback()
 {
-	lo1=$1
-	lo2=$2
-
 	# Make sure we run as root
 	needroot 
 
 	# Create loopback interfaces
-	lo_up $lo1 $lo2 > /dev/null 2>&1
+	lo_up $client $server > /dev/null 2>&1
 	
 	# Run the atual test
-	runtest "$lo1 $lo2 $PORT"
+	runtest
 
 	# Destroy loopback interfaces
 	lo_down > /dev/null 2>&1
 }
 
-PORT="1296"
-
 no=$1
 case "$no" in
+	# The test passes if the UTO values are correctly exchanged.
 	"1")
-		name="Send UTO"
+		name="Send UTO IPv4"
 		bin="send_uto"
 		addr="127.0.0.1"
-
-		runtest "$addr $PORT"
+		port="1296"
+		expect=0		# Normal exit
+		
+		testargs="$addr $port"
+		runtest
 	;;
+	# In this scenario the server imposes a very small timeout. After the
+	# handshake the connection is broken and the client can't receive data
+ 	# (and thus can't acknowledge it). *
+	# The server wait a period longer than UTO before trying to write again;
+	# this triggers an EPIPE error which means the connection is broken.
+	#
+	# The test passes if the program exits abnormally with EX_IOERR.
 	"2")
-		name="short_uto"
-		bin="short_uto"
+		name="Short UTO IPv4"
+		bin="generic_uto"
+		expect=74		# EX_IOERR
+
+		# Test arguments
 		client="192.0.2.2"
 		server="192.0.2.3"
+		port="1296"
+		client_snd="0"
+		client_rcv="1"
+		server_snd="10"
+		server_rcv="1"
+		downtime="20"
 
-		test_with_loopback $client $server
+		testargs="$client $server $port $client_snd $client_rcv
+		$server_snd $server_rcv $downtime"
+
+		test_with_loopback
 	;;
+
+	# In this scenario the client requests a large UTO value and the server
+	# accepts it. The network is unavailable for a period < UTO. After the
+	# network picks up, the client should eventually receive the data and
+	# acknowledge it.
+	#
+	# The test passes if the program exits normally.
 	"3")
-		name="long_uto"
-		bin="long_uto"
+		name="Long UTO IPv4"
+		bin="generic_uto"
+		expect=0		# Normal exit
+
+		# Test arguments
 		client="192.0.2.2"
 		server="192.0.2.3"
+		port="1296"
+		client_snd="1200"	# 20 minutes UTO
+		client_rcv="1"
+		server_snd="0"
+		server_rcv="1"
+		downtime="300"		# 5 minutes downtime
 
-		test_with_loopback $client $server
+		testargs="$client $server $port $client_snd $client_rcv
+		$server_snd $server_rcv $downtime"
+
+		test_with_loopback
 	;;
+	# Same as test 1, with IPv6
 	"4")
-		name="send_uto_ipv6"
+		name="Send UTO IPv6"
 		bin="send_uto"
-		addr="127.0.0.1"
+		addr="::1"
+		port="1296"
+		expect=0		# Normal exit
 
-		runtest "$addr $PORT"
+		testargs="$addr $port"
+		runtest
 	;;
+	# Same as test 2, with IPv6
 	"5")
-		name="short_utov6"
-		bin="short_uto"
+		name="Short UTO IPv6"
+		bin="generic_uto"
+		ipv6="yes"
+		expect=74		# EX_IOERR
+
+		# Test arguments
 		client="2001:db80:5::2"
 		server="2001:db80:5::3"
-		ipv6="yes"
+		port="1296"
+		client_snd="0"
+		client_rcv="1"
+		server_snd="10"
+		server_rcv="1"
+		downtime="20"
+
+		testargs="$client $server $port $client_snd $client_rcv
+		$server_snd $server_rcv $downtime"
 
-		test_with_loopback $client $server
+		test_with_loopback
 	;;
+	# Same as test 3, with IPv6
 	"6")
-		name="long_utov6"
-		bin="long_uto"
+		name="Long UTO IPv6"
+		bin="generic_uto"
+		ipv6="yes"
+		expect=0		# Normal exit
+
+		# Test arguments
 		client="2001:db80:5::2"
 		server="2001:db80:5::3"
-		ipv6="yes"
+		port="1296"
+		client_snd="1200"	# 20 minutes UTO
+		client_rcv="1"
+		server_snd="0"
+		server_rcv="1"
+		downtime="300"		# 5 minutes downtime
+
+		testargs="$client $server $port $client_snd $client_rcv
+		$server_snd $server_rcv $downtime"
 
-		test_with_loopback $client $server
+		test_with_loopback
 	;;
-
 esac
-
-


More information about the p4-projects mailing list