svn commit: r294647 - head/tools/regression/sockets/zerosend

Garrett Cooper ngie at FreeBSD.org
Sat Jan 23 22:51:24 UTC 2016


Author: ngie
Date: Sat Jan 23 22:51:22 2016
New Revision: 294647
URL: https://svnweb.freebsd.org/changeset/base/294647

Log:
  Use different ports in the TCP/UDP testcases with the first set and
  the second set (increment the original ports by 10)
  
  This avoids issues where the first listening socket might not be torn
  down by the time it makes it to the second set of testcases.
  
  The sockets should likely only be setup once, but this keeps in the
  spirit of the original testcases, so this will be easier to backport
  to ^/stable/9
  
  MFC after: 1 week
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/tools/regression/sockets/zerosend/zerosend.c
Directory Properties:
  head/   (props changed)

Modified: head/tools/regression/sockets/zerosend/zerosend.c
==============================================================================
--- head/tools/regression/sockets/zerosend/zerosend.c	Sat Jan 23 22:49:13 2016	(r294646)
+++ head/tools/regression/sockets/zerosend/zerosend.c	Sat Jan 23 22:51:22 2016	(r294647)
@@ -74,7 +74,7 @@ try_0write(const char *test, int fd)
 }
 
 static void
-setup_udp(const char *test, int *fdp)
+setup_udp(const char *test, int *fdp, int port1, int port2)
 {
 	struct sockaddr_in sin;
 	int sock1, sock2;
@@ -84,14 +84,14 @@ setup_udp(const char *test, int *fdp)
 	sin.sin_family = AF_INET;
 	sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
 
-	sin.sin_port = htons(PORT1);
+	sin.sin_port = htons(port1);
 	sock1 = socket(PF_INET, SOCK_DGRAM, 0);
 	if (sock1 < 0)
 		err(1, "%s: setup_udp: socket", test);
 	if (bind(sock1, (struct sockaddr *)&sin, sizeof(sin)) < 0)
 		err(1, "%s: setup_udp: bind(%s, %d)", test,
 		    inet_ntoa(sin.sin_addr), PORT1);
-	sin.sin_port = htons(PORT2);
+	sin.sin_port = htons(port2);
 	if (connect(sock1, (struct sockaddr *)&sin, sizeof(sin)) < 0)
 		err(1, "%s: setup_udp: connect(%s, %d)", test,
 		    inet_ntoa(sin.sin_addr), PORT2);
@@ -102,7 +102,7 @@ setup_udp(const char *test, int *fdp)
 	if (bind(sock2, (struct sockaddr *)&sin, sizeof(sin)) < 0)
 		err(1, "%s: setup_udp: bind(%s, %d)", test,
 		    inet_ntoa(sin.sin_addr), PORT2);
-	sin.sin_port = htons(PORT1);
+	sin.sin_port = htons(port1);
 	if (connect(sock2, (struct sockaddr *)&sin, sizeof(sin)) < 0)
 		err(1, "%s: setup_udp: connect(%s, %d)", test,
 		    inet_ntoa(sin.sin_addr), PORT1);
@@ -112,7 +112,7 @@ setup_udp(const char *test, int *fdp)
 }
 
 static void
-setup_tcp(const char *test, int *fdp)
+setup_tcp(const char *test, int *fdp, int port)
 {
 	fd_set writefds, exceptfds;
 	struct sockaddr_in sin;
@@ -127,7 +127,7 @@ setup_tcp(const char *test, int *fdp)
 	/*
 	 * First set up the listen socket.
 	 */
-	sin.sin_port = htons(PORT1);
+	sin.sin_port = htons(port);
 	sock1 = socket(PF_INET, SOCK_STREAM, 0);
 	if (sock1 < 0)
 		err(1, "%s: setup_tcp: socket", test);
@@ -246,19 +246,19 @@ main(void)
 {
 	int fd[2];
 
-	setup_udp("udp_0send", fd);
+	setup_udp("udp_0send", fd, PORT1, PORT2);
 	try_0send("udp_0send", fd[0]);
 	close_both(fd);
 
-	setup_udp("udp_0write", fd);
+	setup_udp("udp_0write", fd, PORT1 + 10, PORT2 + 10);
 	try_0write("udp_0write", fd[0]);
 	close_both(fd);
 
-	setup_tcp("tcp_0send", fd);
+	setup_tcp("tcp_0send", fd, PORT1);
 	try_0send("tcp_0send", fd[0]);
 	close_both(fd);
 
-	setup_tcp("tcp_0write", fd);
+	setup_tcp("tcp_0write", fd, PORT1 + 10);
 	try_0write("tcp_0write", fd[0]);
 	close_both(fd);
 


More information about the svn-src-all mailing list