From 6d1d6554e3fab91e17c965792435e68d1ed85262 Mon Sep 17 00:00:00 2001 From: phk Date: Sun, 15 Jun 2008 21:11:19 +0000 Subject: [PATCH] Add a Reset pass after each testfile git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2698 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishtest/vtc.c | 19 +++++++++++++++++++ varnish-cache/bin/varnishtest/vtc_client.c | 13 ++++++++++++- varnish-cache/bin/varnishtest/vtc_server.c | 15 ++++++++++++++- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/varnish-cache/bin/varnishtest/vtc.c b/varnish-cache/bin/varnishtest/vtc.c index aeb93234..aa96b610 100644 --- a/varnish-cache/bin/varnishtest/vtc.c +++ b/varnish-cache/bin/varnishtest/vtc.c @@ -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 */ @@ -224,7 +236,11 @@ parse_string(char *buf, const struct cmds *cmd, void *priv) 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 @@ void 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 @@ exec_file(const char *fn) buf = read_file(fn); parse_string(buf, cmds, NULL); printf("# TEST %s completed\n", fn); + reset_cmds(cmds); } /********************************************************************** diff --git a/varnish-cache/bin/varnishtest/vtc_client.c b/varnish-cache/bin/varnishtest/vtc_client.c index 783c2b63..efcaba8e 100644 --- a/varnish-cache/bin/varnishtest/vtc_client.c +++ b/varnish-cache/bin/varnishtest/vtc_client.c @@ -163,9 +163,20 @@ client_run(struct client *c) 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++; diff --git a/varnish-cache/bin/varnishtest/vtc_server.c b/varnish-cache/bin/varnishtest/vtc_server.c index 36eade98..dec6cab0 100644 --- a/varnish-cache/bin/varnishtest/vtc_server.c +++ b/varnish-cache/bin/varnishtest/vtc_server.c @@ -165,6 +165,8 @@ server_wait(struct server *s) exit (1); } s->tp = NULL; + AZ(close(s->sock)); + s->sock = -1; } /********************************************************************** @@ -174,9 +176,20 @@ server_wait(struct server *s) 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++; -- 2.39.5