[master] d2d9a68 Make it possible to expect that a VSC counter is not there by:

Poul-Henning Kamp phk at FreeBSD.org
Tue Mar 10 09:31:23 CET 2015


commit d2d9a685c593d682880389cf85db7526c809b540
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Mar 10 08:30:53 2015 +0000

    Make it possible to expect that a VSC counter is not there by:
    
    	varnish ${id} -expect !${vsc-identifier}

diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index da20964..0473002 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -762,18 +762,24 @@ static void
 varnish_expect(const struct varnish *v, char * const *av) {
 	uint64_t ref;
 	int good;
+	char *r;
 	char *p;
 	char *q;
-	int i;
+	int i, not = 0;
 	struct stat_priv sp;
 
-	p = strchr(av[0], '.');
+	r = av[0];
+	if (r[0] == '!') {
+		not = 1;
+		r++;
+	}
+	p = strchr(r, '.');
 	if (p == NULL) {
 		strcpy(sp.target_type, "MAIN");
 		sp.target_ident[0] = '\0';
-		bprintf(sp.target_name, "%s", av[0]);
+		bprintf(sp.target_name, "%s", r);
 	} else {
-		bprintf(sp.target_type, "%.*s", (int)(p - av[0]), av[0]);
+		bprintf(sp.target_type, "%.*s", (int)(p - r), r);
 		p++;
 		q = strrchr(p, '.');
 		bprintf(sp.target_name, "%s", q + 1);
@@ -801,6 +807,9 @@ varnish_expect(const struct varnish *v, char * const *av) {
 			continue;
 		}
 
+		if (not)
+			vtc_log(v->vl, 0, "Found (not expected): %s", av[0]+1);
+
 		good = 0;
 		ref = strtoumax(av[2], &p, 0);
 		if (ref == UINTMAX_MAX || *p)
@@ -819,10 +828,17 @@ varnish_expect(const struct varnish *v, char * const *av) {
 	}
 	if (good == -1) {
 		vtc_log(v->vl, 0, "VSM error: %s", VSM_Error(v->vd));
-		VSM_ResetError(v->vd);
-	} else if (good == -2) {
+	}
+	if (good == -2) {
+		if (not) {
+			vtc_log(v->vl, 2, "not found (as expected): %s",
+			    av[0] + 1);
+			return;
+		}
 		vtc_log(v->vl, 0, "stats field %s unknown", av[0]);
-	} else if (good) {
+	}
+
+	if (good == 1) {
 		vtc_log(v->vl, 2, "as expected: %s (%ju) %s %s",
 		    av[0], sp.val, av[1], av[2]);
 	} else {



More information about the varnish-commit mailing list