PERFORCE change 197883 for review
Catalin Nicutar
cnicutar at FreeBSD.org
Fri Aug 19 19:55:54 UTC 2011
http://p4web.freebsd.org/@@197883?ac=10
Change 197883 by cnicutar at cnicutar_cronos on 2011/08/19 19:55:28
Add 2 new UTO tests and README. Make stylistic changes & add comments.
Affected files ...
.. //depot/projects/soc2011/cnicutar_tcputo_9/src/tools/regression/netinet/tcputo/README#1 add
.. //depot/projects/soc2011/cnicutar_tcputo_9/src/tools/regression/netinet/tcputo/runtest.sh#3 edit
.. //depot/projects/soc2011/cnicutar_tcputo_9/src/tools/regression/netinet/tcputo/test_utils.c#2 edit
Differences ...
==== //depot/projects/soc2011/cnicutar_tcputo_9/src/tools/regression/netinet/tcputo/runtest.sh#3 (text+ko) ====
@@ -1,5 +1,8 @@
#!/bin/sh
+EX_OK=0;
+EX_IOERR=74
+
# Bring down two loopback interfaces
lo_down()
@@ -8,7 +11,7 @@
ifconfig lo3 destroy
}
-# Create two loopback interfaces and assign addresses
+# Create two loopback interfaces and assign example addresses
lo_up()
{
# Just in case they are still around
@@ -99,7 +102,7 @@
"2")
name="Short UTO IPv4"
bin="generic_uto"
- expect=74 # EX_IOERR
+ expect=$EX_IOERR
# Test arguments
client="192.0.2.2"
@@ -107,9 +110,9 @@
port="1296"
client_snd="0"
client_rcv="1"
- server_snd="10"
+ server_snd="10" # Server imposes 10 seconds timeout
server_rcv="1"
- downtime="20"
+ downtime="20" # Downtime lasts 20 seconds
testargs="$client $server $port $client_snd $client_rcv
$server_snd $server_rcv $downtime"
@@ -135,7 +138,7 @@
client_snd="1200" # 20 minutes UTO
client_rcv="1"
server_snd="0"
- server_rcv="1"
+ server_rcv="1" # Server accepts UTO suggestion
downtime="300" # 5 minutes downtime
testargs="$client $server $port $client_snd $client_rcv
@@ -159,7 +162,7 @@
name="Short UTO IPv6"
bin="generic_uto"
ipv6="yes"
- expect=74 # EX_IOERR
+ expect=$EX_IOERR
# Test arguments
client="2001:db80:5::2"
@@ -167,9 +170,9 @@
port="1296"
client_snd="0"
client_rcv="1"
- server_snd="10"
+ server_snd="10" # Server imposes 10 seconds timeout
server_rcv="1"
- downtime="20"
+ downtime="20" # Downtime lasts 20 seconds
testargs="$client $server $port $client_snd $client_rcv
$server_snd $server_rcv $downtime"
@@ -187,10 +190,10 @@
client="2001:db80:5::2"
server="2001:db80:5::3"
port="1296"
- client_snd="1200" # 20 minutes UTO
+ client_snd="1200" # Client requests 20 minutes UTO
client_rcv="1"
server_snd="0"
- server_rcv="1"
+ server_rcv="1" # Server accepts UTO suggestions
downtime="300" # 5 minutes downtime
testargs="$client $server $port $client_snd $client_rcv
@@ -198,4 +201,53 @@
test_with_loopback
;;
+ # In this scenario the server doesn't accept the suggestion of the
+ # client so the connection should fail.
+ #
+ # The test passes if the program exits abnormally with EX_IOERR.
+ "7")
+ name="Refused UTO"
+ bin="generic_uto"
+ expect=$EX_IOERR
+
+ # Test arguments
+ client="192.0.2.2"
+ server="192.0.2.3"
+ port="1296"
+ client_snd="3600" # Client requests 1 hour
+ client_rcv="1"
+ server_snd="0"
+ server_rcv="0" # Server refuses UTO
+ downtime="600" # 10 minutes downtime
+
+ testargs="$client $server $port $client_snd $client_rcv
+ $server_snd $server_rcv $downtime"
+
+ test_with_loopback
+ ;;
+ # In this scenario the client requests one hour of UTO but the
+ # server accepts only 300 seconds.
+ #
+ # The test passes if the program exits with EX_IOERR.
+ "8")
+ name="Partial UTO IPv6"
+ bin="generic_uto"
+ ipv6="yes"
+ expect=$EX_IOERR
+
+ # Test arguments
+ client="2001:db80:5::2"
+ server="2001:db80:5::3"
+ port="1296"
+ client_snd="3600" # Client requests 1 hour
+ client_rcv="1"
+ server_snd="0"
+ server_rcv="300" # Server accepts max 5 minutes
+ downtime="600" # 10 minutes downtime
+
+ testargs="$client $server $port $client_snd $client_rcv
+ $server_snd $server_rcv $downtime"
+
+ test_with_loopback
+ ;;
esac
==== //depot/projects/soc2011/cnicutar_tcputo_9/src/tools/regression/netinet/tcputo/test_utils.c#2 (text+ko) ====
@@ -15,11 +15,16 @@
#include "test_utils.h"
+/*
+ * These are utility functions used by UTO tests.
+ */
+
/*
* Bind a socket to an address, using the SO_REUSEADDR socket option.
*/
-int tcp_bind(char *addr, char *port)
+int
+tcp_bind(char *addr, char *port)
{
int s, rc, yes = 1;
struct addrinfo hints;
@@ -64,8 +69,11 @@
return (rp == NULL) ? -1 : s;
}
-
-int tcp_connect(int s, char *addr, char *port)
+/*
+ * Try to connect an existing socket to and address.
+ */
+int
+tcp_connect(int s, char *addr, char *port)
{
int rc;
struct addrinfo hints;
@@ -169,6 +177,10 @@
/*
* Simulate broken connectivity by diverting the traffic to an unlistened
* port.
+ *
+ * XXX-CN This is a hack. The problem is that there's no easy way to filter
+ * the traffic on loopback devices in a way that doesn't interfere with
+ * syscalls.
*/
void
port_down(char *port)
@@ -182,7 +194,7 @@
}
/*
- * Remove the rule added by port_down.
+ * Remove the rule added by port_down, thus ending the downtime.
*/
void
port_up()
@@ -214,7 +226,7 @@
if (sock < 0)
err(EX_UNAVAILABLE, "accept");
- /* Take the route down and then attempt to send data. */
+ /* Take the link down and then attempt to send data. */
if (downtime)
port_down(lport);
@@ -222,7 +234,7 @@
if (bytes < 0)
err(EX_IOERR, "send");
- /* Sleep through downtime and then bring the route back up. */
+ /* Sleep through downtime and then bring the link back up. */
if (downtime) {
sleep(downtime);
port_up();
More information about the p4-projects
mailing list