From 001e71b13375a27d22eae580c74961594d609468 Mon Sep 17 00:00:00 2001 From: tfheen Date: Mon, 18 Aug 2008 08:00:21 +0000 Subject: [PATCH] When an -expect fails in varnishtest, loop for up to a second since stats sometimes takes a little while to update git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3097 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishtest/vtc_varnish.c | 41 ++++++++++++--------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/varnish-cache/bin/varnishtest/vtc_varnish.c b/varnish-cache/bin/varnishtest/vtc_varnish.c index f6fcfcff..5dd253b3 100644 --- a/varnish-cache/bin/varnishtest/vtc_varnish.c +++ b/varnish-cache/bin/varnishtest/vtc_varnish.c @@ -416,29 +416,36 @@ varnish_expect(struct varnish *v, char * const *av) { uint64_t val, ref; int good; char *p; + int i; + + good = 0; + + for (i = 0; i < 10; i++, usleep(100000)) { #define MAC_STAT(n, t, f, d) \ - if (!strcmp(av[0], #n)) { \ - val = v->stats->n; \ - } else + if (!strcmp(av[0], #n)) { \ + val = v->stats->n; \ + } else #include "stat_field.h" #undef MAC_STAT { - vtc_log(v->vl, 0, "stats field %s unknown", av[0]); - } + vtc_log(v->vl, 0, "stats field %s unknown", av[0]); + } - ref = strtoumax(av[2], &p, 0); - if (ref == UINTMAX_MAX || *p) - vtc_log(v->vl, 0, "Syntax error in number (%s)", av[2]); - good = 0; - if (!strcmp(av[1], "==")) { if (val == ref) good = 1; } - else if (!strcmp(av[1], "!=")) { if (val != ref) good = 1; } - else if (!strcmp(av[1], ">")) { if (val > ref) good = 1; } - else if (!strcmp(av[1], "<")) { if (val < ref) good = 1; } - else if (!strcmp(av[1], ">=")) { if (val >= ref) good = 1; } - else if (!strcmp(av[1], "<=")) { if (val <= ref) good = 1; } - else { - vtc_log(v->vl, 0, "comparison %s unknown", av[1]); + ref = strtoumax(av[2], &p, 0); + if (ref == UINTMAX_MAX || *p) + vtc_log(v->vl, 0, "Syntax error in number (%s)", av[2]); + if (!strcmp(av[1], "==")) { if (val == ref) good = 1; } + else if (!strcmp(av[1], "!=")) { if (val != ref) good = 1; } + else if (!strcmp(av[1], ">")) { if (val > ref) good = 1; } + else if (!strcmp(av[1], "<")) { if (val < ref) good = 1; } + else if (!strcmp(av[1], ">=")) { if (val >= ref) good = 1; } + else if (!strcmp(av[1], "<=")) { if (val <= ref) good = 1; } + else { + vtc_log(v->vl, 0, "comparison %s unknown", av[1]); + } + if (good) + break; } if (good) vtc_log(v->vl, 2, "as expected: %s (%ju) %s %s", -- 2.39.5