[master] b532d13 Exercise the VSC's created from VMODs

Poul-Henning Kamp phk at FreeBSD.org
Tue Mar 13 08:58:08 UTC 2018


commit b532d1340ed8745b183e2aff2fa9cfa94b02bd2c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Mar 13 08:56:39 2018 +0000

    Exercise the VSC's created from VMODs

diff --git a/bin/varnishtest/tests/m00000.vtc b/bin/varnishtest/tests/m00000.vtc
index fc0ecf1..7bdaa02 100644
--- a/bin/varnishtest/tests/m00000.vtc
+++ b/bin/varnishtest/tests/m00000.vtc
@@ -13,10 +13,12 @@ varnish v1 -vcl+backend {
 
 	sub vcl_init {
 		new objx = debug.obj();
+		debug.vsc_new();
 	}
 
 	sub vcl_recv {
 		debug.rot52(req);
+		debug.vsc_count();
 	}
 
 	sub vcl_deliver {
@@ -36,6 +38,8 @@ varnish v1 -vcl+backend {
 	}
 } -start
 
+varnish v1 -expect DEBUG.count == 0
+
 client c1 {
 	txreq -url "/bar"
 	rxresp
@@ -50,6 +54,8 @@ client c1 {
 	expect resp.http.not == -1
 } -run
 
+varnish v1 -expect DEBUG.count == 1
+
 logexpect l1 -v v1 -g raw -d 1 {
 	expect * 1001 VCL_call		{^DELIVER}
 	expect 0 =    RespUnset	{^foo: bAr}
diff --git a/lib/libvmod_debug/VSC_debug.vsc b/lib/libvmod_debug/VSC_debug.vsc
index aac6410..d6902ff 100644
--- a/lib/libvmod_debug/VSC_debug.vsc
+++ b/lib/libvmod_debug/VSC_debug.vsc
@@ -5,7 +5,7 @@
 
 	Test counters from vmod_debug
 
-.. varnish_vsc:: foo
+.. varnish_vsc:: count
 	:type:		counter
 	:level:		debug
 	:oneliner:	arbitrary counter
diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc
index 20f75ec..d6094bc 100644
--- a/lib/libvmod_debug/vmod.vcc
+++ b/lib/libvmod_debug/vmod.vcc
@@ -170,6 +170,10 @@ $Function VOID vsc_new()
 
 Add a vsc
 
+$Function VOID vsc_count(INT val = 1)
+
+Update counter
+
 $Function VOID vsc_destroy()
 
 Remove a vsc
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index 4de4947..0da45d8 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -371,6 +371,14 @@ xyzzy_vsc_new(VRT_CTX)
 }
 
 VCL_VOID
+xyzzy_vsc_count(VRT_CTX, VCL_INT cnt)
+{
+	(void)ctx;
+	AN(vsc);
+	vsc->count += cnt;
+}
+
+VCL_VOID
 xyzzy_vsc_destroy(VRT_CTX)
 {
 	(void)ctx;


More information about the varnish-commit mailing list