[master] 10b7f26 Add "-errvcl $expect_error $vcl" facility, which is better than badvcl in that you can make sure it fails for the right reason.
Poul-Henning Kamp
phk at varnish-cache.org
Wed Oct 24 23:13:34 CEST 2012
commit 10b7f26c8d874778379f798e0622c70f932c5148
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Oct 24 21:12:31 2012 +0000
Add "-errvcl $expect_error $vcl" facility, which is better than
badvcl in that you can make sure it fails for the right reason.
All -badvcl's should be converted to -errvcl without undue delay.
diff --git a/bin/varnishtest/tests/m00001.vtc b/bin/varnishtest/tests/m00001.vtc
index 47c5ba6..5d07b97 100644
--- a/bin/varnishtest/tests/m00001.vtc
+++ b/bin/varnishtest/tests/m00001.vtc
@@ -47,12 +47,12 @@ varnish v1 -cliok "vcl.discard vcl1"
varnish v1 -cliok "vcl.list"
varnish v1 -cliok "debug.vmod"
-varnish v1 -badvcl {
+varnish v1 -errvcl {Module std already imported.} {
import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ;
import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ;
}
-varnish v1 -badvcl {
+varnish v1 -errvcl {Symbol not found: 'std' (expected type BOOL):} {
import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ;
sub vcl_recv {
diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index 10c1d31..b38a289 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -594,7 +594,7 @@ varnish_cli(struct varnish *v, const char *cli, unsigned exp)
*/
static void
-varnish_vcl(struct varnish *v, const char *vcl, enum VCLI_status_e expect)
+varnish_vcl(struct varnish *v, const char *vcl, enum VCLI_status_e expect, char **resp)
{
struct vsb *vsb;
enum VCLI_status_e u;
@@ -610,7 +610,7 @@ varnish_vcl(struct varnish *v, const char *vcl, enum VCLI_status_e expect)
++v->vcl_nbr, NONSENSE, vcl, NONSENSE);
AZ(VSB_finish(vsb));
- u = varnish_ask_cli(v, VSB_data(vsb), NULL);
+ u = varnish_ask_cli(v, VSB_data(vsb), resp);
if (u != expect) {
VSB_delete(vsb);
vtc_log(v->vl, 0,
@@ -857,13 +857,30 @@ cmd_varnish(CMD_ARGS)
}
if (!strcmp(*av, "-badvcl")) {
AN(av[1]);
- varnish_vcl(v, av[1], CLIS_PARAM);
+ varnish_vcl(v, av[1], CLIS_PARAM, NULL);
av++;
continue;
}
+ if (!strcmp(*av, "-errvcl")) {
+ char *r = NULL;
+ AN(av[1]);
+ AN(av[2]);
+ varnish_vcl(v, av[2], CLIS_PARAM, &r);
+ if (strstr(r, av[1]) == NULL)
+ vtc_log(v->vl, 0,
+ "Did not find expected string: (\"%s\")",
+ av[1]);
+ else
+ vtc_log(v->vl, 3,
+ "Found expected string: (\"%s\")",
+ av[1]);
+ free(r);
+ av += 2;
+ continue;
+ }
if (!strcmp(*av, "-vcl")) {
AN(av[1]);
- varnish_vcl(v, av[1], CLIS_OK);
+ varnish_vcl(v, av[1], CLIS_OK, NULL);
av++;
continue;
}
More information about the varnish-commit
mailing list