[master] 6515f17 Add an optional argument to the debug.argtest function
Poul-Henning Kamp
phk at FreeBSD.org
Fri Mar 2 14:16:08 UTC 2018
commit 6515f17ed61ee979a170612a3467d87fedd757b1
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Fri Mar 2 14:14:47 2018 +0000
Add an optional argument to the debug.argtest function
diff --git a/bin/varnishtest/tests/m00019.vtc b/bin/varnishtest/tests/m00019.vtc
index c8251c9..b2c9d66 100644
--- a/bin/varnishtest/tests/m00019.vtc
+++ b/bin/varnishtest/tests/m00019.vtc
@@ -24,6 +24,7 @@ varnish v1 -vcl+backend {
set resp.http.foo4 = debug.argtest("1", 2.4, three="3d", four=-1);
set resp.http.foo5 = debug.argtest("1", 2.5);
set resp.http.foo6 = debug.argtest("1", four=6);
+ set resp.http.foo7 = debug.argtest("1", opt="7");
set resp.http.obj0 = obj0.string() + ", " + obj0.number();
set resp.http.obj1 = obj1.string() + ", " + obj1.number();
@@ -38,12 +39,13 @@ client c1 {
txreq
rxresp
expect resp.bodylen == "6"
- expect resp.http.foo1 == "1 2.1 3a , 4"
- expect resp.http.foo2 == "1 -2.2 3b , 4"
- expect resp.http.foo3 == "1 2.3 3c , 4"
- expect resp.http.foo4 == "1 2.4 3d , -1"
- expect resp.http.foo5 == "1 2.5 3 , 4"
- expect resp.http.foo6 == "1 2 3 , 6"
+ expect resp.http.foo1 == "1 2.1 3a , 4 0 <undef>"
+ expect resp.http.foo2 == "1 -2.2 3b , 4 0 <undef>"
+ expect resp.http.foo3 == "1 2.3 3c , 4 0 <undef>"
+ expect resp.http.foo4 == "1 2.4 3d , -1 0 <undef>"
+ expect resp.http.foo5 == "1 2.5 3 , 4 0 <undef>"
+ expect resp.http.foo6 == "1 2 3 , 6 0 <undef>"
+ expect resp.http.foo7 == "1 2 3 , 4 1 7"
expect resp.http.obj0 == "default, one"
expect resp.http.obj1 == "only_argument, one"
diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc
index ba5fa94..c27e866 100644
--- a/lib/libvmod_debug/vmod.vcc
+++ b/lib/libvmod_debug/vmod.vcc
@@ -117,7 +117,9 @@ Encrypt the HTTP header with quad-ROT13 encryption,
$Function STRING argtest(
STRING one, REAL two =2, STRING three= "3",
- STRING comma="," , INT four = 4 )
+ STRING comma=",", INT four = 4,
+ [ STRING opt]
+)
$Function INT vre_limit()
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index 579d384..d833fb2 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -151,12 +151,14 @@ xyzzy_rot52(VRT_CTX, VCL_HTTP hp)
}
VCL_STRING v_matchproto_(td_debug_argtest)
-xyzzy_argtest(VRT_CTX, VCL_STRING one, VCL_REAL two, VCL_STRING three,
- VCL_STRING comma, VCL_INT four)
+xyzzy_argtest(VRT_CTX, struct xyzzy_argtest_arg *arg)
{
char buf[100];
- bprintf(buf, "%s %g %s %s %ld", one, two, three, comma, four);
+ AN(arg);
+ bprintf(buf, "%s %g %s %s %ld %d %s",
+ arg->one, arg->two, arg->three, arg->comma, arg->four,
+ arg->valid_opt, arg->valid_opt ? arg->opt : "<undef>");
return (WS_Copy(ctx->ws, buf, -1));
}
More information about the varnish-commit
mailing list