I've written the attached patch becuase I thought I needed something like
expect resp.http.foo is set
or
expect resp.http.bar is unset
in vtc.
It turned out that I don't need it, but maybe others will find this useful.
Nils
Index: varnish-cache/bin/varnishtest/vtc_http.c
===================================================================
--- varnish-cache/bin/varnishtest/vtc_http.c (revision 5518)
+++ varnish-cache/bin/varnishtest/vtc_http.c (working copy)
@@ -193,11 +193,11 @@
hh = hp->resp;
hdr = spec + 10;
} else
- return (spec);
+ return (NULL);
hdr = http_find_header(hh, hdr);
if (hdr != NULL)
return (hdr);
- return (spec);
+ return (NULL);
}
static void
@@ -221,6 +221,37 @@
lhs = cmd_var_resolve(hp, av[0]);
cmp = av[1];
rhs = cmd_var_resolve(hp, av[2]);
+ if (!rhs)
+ rhs = av[2];
+
+ if (!strcmp(cmp, "is")) {
+ if (!strcmp(rhs, "set")) {
+ if (lhs == NULL)
+ vtc_log(hp->vl, 0, "EXPECT %s (%s) %s %s (%s)
failed",
+ av[0], "<unset>", av[1], av[2], rhs);
+ else
+ vtc_log(hp->vl, 4, "EXPECT %s (%s) %s %s (%s)
match",
+ av[0], lhs, av[1], av[2], rhs);
+ } else if (!strcmp(rhs, "unset")) {
+ if (lhs != NULL)
+ vtc_log(hp->vl, 0, "EXPECT %s (%s) %s %s (%s)
failed",
+ av[0], lhs, av[1], av[2], rhs);
+ else
+ vtc_log(hp->vl, 4, "EXPECT %s (%s) %s %s (%s)
match",
+ av[0], "<unset>", av[1], av[2], rhs);
+ } else {
+ if (!lhs)
+ lhs = av[0];
+
+ vtc_log(hp->vl, 0, "EXPECT %s (%s) %s %s (%s) right
operator to \"is\" not implemented",
+ av[0], lhs, av[1], av[2], rhs);
+ }
+ return;
+ }
+
+ if (!lhs)
+ lhs = av[0];
+
if (!strcmp(cmp, "==")) {
if (strcmp(lhs, rhs))
vtc_log(hp->vl, 0, "EXPECT %s (%s) %s %s (%s) failed",
@@ -236,7 +267,7 @@
vtc_log(hp->vl, 4, "EXPECT %s (%s) %s %s (%s) match",
av[0], lhs, av[1], av[2], rhs);
} else {
- vtc_log(hp->vl, 0, "EXPECT %s (%s) %s %s (%s) not implemented",
+ vtc_log(hp->vl, 0, "EXPECT %s (%s) %s %s (%s) comparator not
implemented",
av[0], lhs, av[1], av[2], rhs);
}
}
_______________________________________________
varnish-dev mailing list
[email protected]
http://lists.varnish-cache.org/mailman/listinfo/varnish-dev