Hi,

Trying to make life easier for VMOD writers and users, a macro
expansion similar to ${date} for VMOD names. It should be simple
enough to hopefully be considered for the 4.1 series too.

Best,
Dridi
From 5b5bb9d1165f888ed6def438b070fc6e46da6310 Mon Sep 17 00:00:00 2001
From: Dridi Boukelmoune <dridi.boukelmo...@gmail.com>
Date: Wed, 17 Feb 2016 23:55:04 +0100
Subject: [PATCH] Automatically expand vmod_* macros in varnishtest

By default varnishtest will expand ${vmod_wossname} to wossname unless
it was already defined. It allows VMOD writers and users to reuse a
same test case against an installed VMOD or during a build, just like
`varnishtest -i` does for the std, directors and debug VMODs.
---
 bin/varnishtest/vtc.c      | 3 +++
 bin/varnishtest/vtc_main.c | 5 -----
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c
index 8890a62..cd6cee6 100644
--- a/bin/varnishtest/vtc.c
+++ b/bin/varnishtest/vtc.c
@@ -203,6 +203,9 @@ macro_get(const char *b, const char *e)
 	}
 	if (m != NULL)
 		retval = strdup(m->val);
+	else if (l > 5 && !memcmp(b, "vmod_", 5))
+		retval = strndup(b + 5, l - 5);
+
 	AZ(pthread_mutex_unlock(&macro_mtx));
 	return (retval);
 }
diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c
index 7272e22..5914bcb 100644
--- a/bin/varnishtest/vtc_main.c
+++ b/bin/varnishtest/vtc_main.c
@@ -479,11 +479,6 @@ main(int argc, char * const *argv)
 #include "programs.h"
 #undef VTC_PROG
 
-	/* Default import spec of vmods */
-#define VTC_VMOD(l)	extmacro_def("vmod_" #l, #l);
-#include "vmods.h"
-#undef VTC_VMOD
-
 	if (getenv("TMPDIR") != NULL)
 		tmppath = strdup(getenv("TMPDIR"));
 	else
-- 
2.5.0

_______________________________________________
varnish-dev mailing list
varnish-dev@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to