[master] e675d1c6b Make the duplicate filter colverage test explicit

Nils Goroll nils.goroll at uplex.de
Mon Sep 19 13:44:06 UTC 2022


commit e675d1c6b3e73713d5e2c1f6062805bc092bb4c0
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Tue Sep 13 19:08:41 2022 +0200

    Make the duplicate filter colverage test explicit
    
    Implicitly testing from all loads of vmod_debug caused confusing
    error messages and prevented explicitly testing for the error message.

diff --git a/bin/varnishtest/tests/m00000.vtc b/bin/varnishtest/tests/m00000.vtc
index dc674c3ae..73cda64f1 100644
--- a/bin/varnishtest/tests/m00000.vtc
+++ b/bin/varnishtest/tests/m00000.vtc
@@ -140,6 +140,14 @@ varnish v1 -errvcl {Symbol not found: 'obj'} {
 	}
 }
 
+varnish v1 -errvcl {rot13: VFP already registered (per-vcl)} {
+	import debug;
+	backend none none;
+	sub vcl_init {
+		debug.rot104();
+	}
+}
+
 varnish v1 -errvcl {Failed initialization} {
 	import debug;
 	import directors;
@@ -281,7 +289,7 @@ varnish v1 -cliok "vcl.list"
 
 varnish v1 -expect vmods == 3
 
-varnish v1 -cliok "vcl.discard vcl[1-8]"
+varnish v1 -cliok "vcl.discard vcl[1-9]"
 varnish v1 -cliok "vcl.list"
 varnish v1 -cliok "debug.vmod"
 
diff --git a/vmod/vmod_debug.c b/vmod/vmod_debug.c
index f8c603204..50a2b8eeb 100644
--- a/vmod/vmod_debug.c
+++ b/vmod/vmod_debug.c
@@ -334,6 +334,15 @@ xyzzy_test_priv_vcl(VRT_CTX, struct vmod_priv *priv)
 	assert(!strcmp(priv_vcl->foo, "FOO"));
 }
 
+VCL_VOID v_matchproto_(td_debug_rot104)
+xyzzy_rot104(VRT_CTX)
+{
+
+	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+	// This should fail
+	AN(VRT_AddFilter(ctx, &xyzzy_vfp_rot13, &xyzzy_vdp_rot13));
+}
+
 VCL_VOID v_matchproto_(td_debug_rot52)
 xyzzy_rot52(VRT_CTX, VCL_HTTP hp)
 {
@@ -456,15 +465,6 @@ event_load(VRT_CTX, struct vmod_priv *priv)
 	priv->methods = priv_vcl_methods;
 
 	AZ(VRT_AddFilter(ctx, &xyzzy_vfp_rot13, &xyzzy_vdp_rot13));
-
-	// This should fail
-	AN(VRT_AddFilter(ctx, &xyzzy_vfp_rot13, &xyzzy_vdp_rot13));
-	// Reset the error, we know what we're doing.
-	ctx->vpi->handling = 0;
-
-	VRT_RemoveFilter(ctx, &xyzzy_vfp_rot13, &xyzzy_vdp_rot13);
-	AZ(VRT_AddFilter(ctx, &xyzzy_vfp_rot13, &xyzzy_vdp_rot13));
-
 	AZ(VRT_AddFilter(ctx, NULL, &xyzzy_vdp_pedantic));
 	return (0);
 }
diff --git a/vmod/vmod_debug.vcc b/vmod/vmod_debug.vcc
index df8ba6247..6f9d8d71d 100644
--- a/vmod/vmod_debug.vcc
+++ b/vmod/vmod_debug.vcc
@@ -121,6 +121,11 @@ $Method STRING .test_priv_top(STRING s="")
 
 Test per-object priv_top via VRT_priv_top()
 
+$Function VOID rot104()
+
+Try to register the rot52 filter again. This should always fail
+the vcl.
+
 $Function VOID rot52(HTTP hdr)
 
 Encrypt the HTTP header with quad-ROT13 encryption,


More information about the varnish-commit mailing list