[4.1] 1e09758 Add the vtc feature ignore_unknown_macro.
PÃ¥l Hermunn Johansen
hermunn at varnish-software.com
Tue Aug 8 11:36:06 CEST 2017
commit 1e09758e0d5e5a27b3a6643f450554f558f5031d
Author: Geoff Simmons <geoff at uplex.de>
Date: Wed Jul 5 07:26:31 2017 +0200
Add the vtc feature ignore_unknown_macro.
Closes: #2357
diff --git a/bin/varnishtest/tests/a00018.vtc b/bin/varnishtest/tests/a00018.vtc
new file mode 100644
index 0000000..036aa45
--- /dev/null
+++ b/bin/varnishtest/tests/a00018.vtc
@@ -0,0 +1,35 @@
+varnishtest "feature ignore_unknown_macro"
+
+feature ignore_unknown_macro
+
+server s1 {
+ rxreq
+ expect req.http.Foo == "${foo}"
+ txresp -hdr "Bar: ${bar}"
+} -start
+
+varnish v1 -vcl {
+ backend default {
+ .host = "${s1_addr}";
+ .port = "${s1_port}";
+ }
+
+ sub vcl_deliver {
+ if (resp.http.Bar == "${bar}") {
+ set resp.http.Baz = "${baz}";
+ }
+ }
+} -start
+
+client c1 {
+ txreq -hdr "Foo: ${foo}"
+ rxresp
+ expect resp.status == 200
+ expect resp.http.Bar == "${bar}"
+ expect resp.http.Baz == "${baz}"
+} -run
+
+shell {
+ touch ${tmpdir}/tst
+ rm ${tmpdir}/tst
+}
diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c
index ba9a18a..0405e19 100644
--- a/bin/varnishtest/vtc.c
+++ b/bin/varnishtest/vtc.c
@@ -56,6 +56,7 @@ volatile sig_atomic_t vtc_error; /* Error encountered */
int vtc_stop; /* Stops current test without error */
pthread_t vtc_thread;
static struct vtclog *vltop;
+static int ign_unknown_macro = 0;
/**********************************************************************
* Macro facility
@@ -197,13 +198,18 @@ macro_expand(struct vtclog *vl, const char *text)
p += 2;
m = macro_get(p, q);
if (m == NULL) {
- VSB_delete(vsb);
- vtc_log(vl, 0, "Macro ${%.*s} not found", (int)(q - p),
- p);
- return (NULL);
+ if (!ign_unknown_macro) {
+ VSB_delete(vsb);
+ vtc_log(vl, 0, "Macro ${%.*s} not found",
+ (int)(q - p), p);
+ return (NULL);
+ }
+ VSB_printf(vsb, "${%.*s}", (int)(q - p), p);
+ }
+ else {
+ VSB_printf(vsb, "%s", m);
+ free(m);
}
- VSB_printf(vsb, "%s", m);
- free(m);
text = q + 1;
}
AZ(VSB_finish(vsb));
@@ -744,6 +750,9 @@ cmd_feature(CMD_ARGS)
good = 1;
else
vtc_stop = 1;
+ } else if (!strcmp(*av, "ignore_unknown_macro")) {
+ ign_unknown_macro = 1;
+ good = 1;
}
if (good)
continue;
More information about the varnish-commit
mailing list