Commit 0032bfe5 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a Reset pass after each testfile



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2698 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 2552d36f
...@@ -217,6 +217,18 @@ parse_string(char *buf, const struct cmds *cmd, void *priv) ...@@ -217,6 +217,18 @@ parse_string(char *buf, const struct cmds *cmd, void *priv)
} }
} }
/**********************************************************************
* Reset commands (between tests)
*/
static void
reset_cmds(const struct cmds *cmd)
{
for (; cmd->name != NULL; cmd++)
cmd->cmd(NULL, NULL);
}
/********************************************************************** /**********************************************************************
* Output test description * Output test description
*/ */
...@@ -224,7 +236,11 @@ parse_string(char *buf, const struct cmds *cmd, void *priv) ...@@ -224,7 +236,11 @@ parse_string(char *buf, const struct cmds *cmd, void *priv)
static void static void
cmd_test(char **av, void *priv) cmd_test(char **av, void *priv)
{ {
(void)priv; (void)priv;
if (av == NULL)
return;
assert(!strcmp(av[0], "test")); assert(!strcmp(av[0], "test"));
printf("# TEST %s\n", av[1]); printf("# TEST %s\n", av[1]);
...@@ -240,6 +256,8 @@ void ...@@ -240,6 +256,8 @@ void
cmd_dump(char **av, void *priv) cmd_dump(char **av, void *priv)
{ {
if (av == NULL)
return;
printf("cmd_dump(%p)\n", priv); printf("cmd_dump(%p)\n", priv);
while (*av) while (*av)
printf("\t<%s>\n", *av++); printf("\t<%s>\n", *av++);
...@@ -264,6 +282,7 @@ exec_file(const char *fn) ...@@ -264,6 +282,7 @@ exec_file(const char *fn)
buf = read_file(fn); buf = read_file(fn);
parse_string(buf, cmds, NULL); parse_string(buf, cmds, NULL);
printf("# TEST %s completed\n", fn); printf("# TEST %s completed\n", fn);
reset_cmds(cmds);
} }
/********************************************************************** /**********************************************************************
......
...@@ -163,9 +163,20 @@ client_run(struct client *c) ...@@ -163,9 +163,20 @@ client_run(struct client *c)
void void
cmd_client(char **av, void *priv) cmd_client(char **av, void *priv)
{ {
struct client *c; struct client *c, *c2;
(void)priv; (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")); assert(!strcmp(av[0], "client"));
av++; av++;
......
...@@ -165,6 +165,8 @@ server_wait(struct server *s) ...@@ -165,6 +165,8 @@ server_wait(struct server *s)
exit (1); exit (1);
} }
s->tp = NULL; s->tp = NULL;
AZ(close(s->sock));
s->sock = -1;
} }
/********************************************************************** /**********************************************************************
...@@ -174,9 +176,20 @@ server_wait(struct server *s) ...@@ -174,9 +176,20 @@ server_wait(struct server *s)
void void
cmd_server(char **av, void *priv) cmd_server(char **av, void *priv)
{ {
struct server *s; struct server *s, *s2;
(void)priv; (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")); assert(!strcmp(av[0], "server"));
av++; av++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment