r2698 - trunk/varnish-cache/bin/varnishtest

phk at projects.linpro.no phk at projects.linpro.no
Sun Jun 15 23:11:19 CEST 2008


Author: phk
Date: 2008-06-15 23:11:19 +0200 (Sun, 15 Jun 2008)
New Revision: 2698

Modified:
   trunk/varnish-cache/bin/varnishtest/vtc.c
   trunk/varnish-cache/bin/varnishtest/vtc_client.c
   trunk/varnish-cache/bin/varnishtest/vtc_server.c
Log:
Add a Reset pass after each testfile



Modified: trunk/varnish-cache/bin/varnishtest/vtc.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.c	2008-06-15 20:57:30 UTC (rev 2697)
+++ trunk/varnish-cache/bin/varnishtest/vtc.c	2008-06-15 21:11:19 UTC (rev 2698)
@@ -218,13 +218,29 @@
 }
 
 /**********************************************************************
+ * Reset commands (between tests)
+ */
+
+static void
+reset_cmds(const struct cmds *cmd)
+{
+
+	for (; cmd->name != NULL; cmd++)
+		cmd->cmd(NULL, NULL);
+}
+
+/**********************************************************************
  * Output test description
  */
 
 static void
 cmd_test(char **av, void *priv)
 {
+
 	(void)priv;
+
+	if (av == NULL)
+		return;
 	assert(!strcmp(av[0], "test"));
 
 	printf("#    TEST %s\n", av[1]);
@@ -240,6 +256,8 @@
 cmd_dump(char **av, void *priv)
 {
 
+	if (av == NULL)
+		return;
 	printf("cmd_dump(%p)\n", priv);
 	while (*av)
 		printf("\t<%s>\n", *av++);
@@ -264,6 +282,7 @@
 	buf = read_file(fn);
 	parse_string(buf, cmds, NULL);
 	printf("#    TEST %s completed\n", fn);
+	reset_cmds(cmds);
 }
 
 /**********************************************************************

Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_client.c	2008-06-15 20:57:30 UTC (rev 2697)
+++ trunk/varnish-cache/bin/varnishtest/vtc_client.c	2008-06-15 21:11:19 UTC (rev 2698)
@@ -163,9 +163,20 @@
 void
 cmd_client(char **av, void *priv)
 {
-	struct client *c;
+	struct client *c, *c2;
 
 	(void)priv;
+
+	if (av == NULL) {
+		/* Reset and free */
+		VTAILQ_FOREACH_SAFE(c, &clients, list, c2) {
+			VTAILQ_REMOVE(&clients, c, list);
+			FREE_OBJ(c);
+			/* XXX: MEMLEAK */
+		}
+		return;
+	}
+
 	assert(!strcmp(av[0], "client"));
 	av++;
 

Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_server.c	2008-06-15 20:57:30 UTC (rev 2697)
+++ trunk/varnish-cache/bin/varnishtest/vtc_server.c	2008-06-15 21:11:19 UTC (rev 2698)
@@ -165,6 +165,8 @@
 		exit (1);
 	}
 	s->tp = NULL;
+	AZ(close(s->sock));
+	s->sock = -1;
 }
 
 /**********************************************************************
@@ -174,9 +176,20 @@
 void
 cmd_server(char **av, void *priv)
 {
-	struct server *s;
+	struct server *s, *s2;
 
 	(void)priv;
+
+	if (av == NULL) {
+		/* Reset and free */
+		VTAILQ_FOREACH_SAFE(s, &servers, list, s2) {
+			VTAILQ_REMOVE(&servers, s, list);
+			FREE_OBJ(s);
+			/* XXX: MEMLEAK */
+		}
+		return;
+	}
+
 	assert(!strcmp(av[0], "server"));
 	av++;
 




More information about the varnish-commit mailing list