r2912 - trunk/varnish-cache/bin/varnishtest
phk at projects.linpro.no
phk at projects.linpro.no
Thu Jul 10 10:00:33 CEST 2008
Author: phk
Date: 2008-07-10 10:00:33 +0200 (Thu, 10 Jul 2008)
New Revision: 2912
Modified:
trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
Log:
Make it possible to check stats counter values for a varnish instance
Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-07-10 07:32:07 UTC (rev 2911)
+++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-07-10 08:00:33 UTC (rev 2912)
@@ -35,6 +35,7 @@
#include <string.h>
#include <signal.h>
#include <pthread.h>
+#include <inttypes.h>
#include <sys/types.h>
#include <sys/wait.h>
@@ -393,6 +394,47 @@
}
/**********************************************************************
+ * Check statistics
+ */
+
+static void
+varnish_expect(struct varnish *v, char * const *av) {
+ uint64_t val, ref;
+ int good;
+ char *p;
+
+#define MAC_STAT(n, t, f, d) \
+ 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]);
+ }
+
+ 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]);
+ }
+ if (good)
+ vtc_log(v->vl, 2, "as expected: %s (%ju) %s %s",
+ av[0], val, av[1], av[2]);
+ else
+ vtc_log(v->vl, 0, "Not true: %s (%ju) %s %s (%ju)",
+ av[0], val, av[1], av[2], ref);
+}
+
+/**********************************************************************
* Varnish server cmd dispatch
*/
@@ -478,6 +520,12 @@
varnish_wait(v);
continue;
}
+ if (!strcmp(*av, "-expect")) {
+ av++;
+ varnish_expect(v, av);
+ av += 2;
+ continue;
+ }
vtc_log(v->vl, 0, "Unknown varnish argument: %s", *av);
exit (1);
}
More information about the varnish-commit
mailing list