Commit 1e09758e authored by Geoff Simmons's avatar Geoff Simmons Committed by Pål Hermunn Johansen

Add the vtc feature ignore_unknown_macro.

Closes: #2357
parent 07271b8f
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
}
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment