r2673 - trunk/varnish-cache/bin/varnishtest

phk at projects.linpro.no phk at projects.linpro.no
Sun Jun 15 13:30:13 CEST 2008


Author: phk
Date: 2008-06-15 13:30:13 +0200 (Sun, 15 Jun 2008)
New Revision: 2673

Modified:
   trunk/varnish-cache/bin/varnishtest/t000.vtc
   trunk/varnish-cache/bin/varnishtest/vtc_server.c
Log:
Default server to repeat=1.

Accept connections, and close them right away.



Modified: trunk/varnish-cache/bin/varnishtest/t000.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/t000.vtc	2008-06-15 11:22:55 UTC (rev 2672)
+++ trunk/varnish-cache/bin/varnishtest/t000.vtc	2008-06-15 11:30:13 UTC (rev 2673)
@@ -1,7 +1,7 @@
 # Quis custodiet ipsos custodes?
 #
 
-server s1 -listen :9080 {
+server s1 -listen :9080 -repeat 2 {
 	rxreq
 	expect url == "/"
 	txresponse -body "0123456789"
@@ -18,4 +18,6 @@
 
 client c1 -run
 
+client c1 -run
+
 server s1 -wait

Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_server.c	2008-06-15 11:22:55 UTC (rev 2672)
+++ trunk/varnish-cache/bin/varnishtest/vtc_server.c	2008-06-15 11:30:13 UTC (rev 2673)
@@ -31,6 +31,9 @@
 #include <string.h>
 #include <pthread.h>
 
+#include <sys/types.h>
+#include <sys/socket.h>
+
 #include "vtc.h"
 
 #include "vqueue.h"
@@ -68,11 +71,25 @@
 server_thread(void *priv)
 {
 	struct server *s;
+	int i, fd;
+	struct sockaddr_storage addr_s;
+	struct sockaddr *addr;
+	socklen_t l;
 
+
 	CAST_OBJ_NOTNULL(s, priv, SERVER_MAGIC);
+	assert(s->sock >= 0);
 
 	printf("### Server %s started\n", s->name);
-	sleep(3);
+	for (i = 0; i < s->repeat; i++) {
+		if (s->repeat > 1)
+			printf("#### Server %s iteration %d\n", s->name, i);
+		addr = (void*)&addr_s;
+		l = sizeof addr_s;
+		fd = accept(s->sock, addr, &l);
+		printf("#### Accepted socket %d\n", fd);
+		close(fd);
+	}
 	printf("### Server %s ending\n", s->name);
 
 	return (NULL);
@@ -90,6 +107,7 @@
 	ALLOC_OBJ(s, SERVER_MAGIC);
 	s->name = name;
 	s->listen = ":9080";
+	s->repeat = 1;
 	s->depth = 1;
 	s->sock = -1;
 	VTAILQ_INSERT_TAIL(&servers, s, list);




More information about the varnish-commit mailing list