[master] dd5aa53 Pass varnishd parameters through varnishtest
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Mon Feb 22 16:26:52 CET 2016
commit dd5aa5322d1a3b4934672d562084cbad2cd8bce9
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Sun Feb 21 21:22:53 2016 +0100
Pass varnishd parameters through varnishtest
Parameters are not checked and passed as is to varnishd command lines.
The parameters are prepended at the beginning of the command line to
preserve parameters needed by varnishtest or used in test cases.
diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c
index 0f00a80..cd3fb1d 100644
--- a/bin/varnishtest/vtc_main.c
+++ b/bin/varnishtest/vtc_main.c
@@ -95,6 +95,7 @@ static int vtc_fail;
static char *tmppath;
static char *cwd = NULL;
char *vmod_path = NULL;
+struct vsb *params_vsb = NULL;
int leave_temp;
int vtc_witness = 0;
int feature_dns;
@@ -137,6 +138,7 @@ usage(void)
fprintf(stderr, FMT, "-L", "Always leave temporary vtc.*");
fprintf(stderr, FMT, "-l", "Leave temporary vtc.* if test fails");
fprintf(stderr, FMT, "-n iterations", "Run tests this many times");
+ fprintf(stderr, FMT, "-p name=val", "Pass a varnishd parameter");
fprintf(stderr, FMT, "-q", "Quiet mode: report only failures");
fprintf(stderr, FMT, "-t duration", "Time tests out after this long");
fprintf(stderr, FMT, "-v", "Verbose mode: always report test log");
@@ -487,9 +489,12 @@ main(int argc, char * const *argv)
vmod_path = NULL;
+ params_vsb = VSB_new_auto();
+ AN(params_vsb);
+
setbuf(stdout, NULL);
setbuf(stderr, NULL);
- while ((ch = getopt(argc, argv, "b:D:hij:kLln:qt:vW")) != -1) {
+ while ((ch = getopt(argc, argv, "b:D:hij:kLln:p:qt:vW")) != -1) {
switch (ch) {
case 'b':
if (VNUM_2bytes(optarg, &bufsiz, 0)) {
@@ -529,6 +534,10 @@ main(int argc, char * const *argv)
case 'n':
ntest = strtoul(optarg, NULL, 0);
break;
+ case 'p':
+ VSB_printf(params_vsb, " -p ");
+ VSB_quote(params_vsb, optarg, -1, VSB_QUOTE_NONL);
+ break;
case 'q':
if (vtc_verbosity > 0)
vtc_verbosity--;
@@ -567,6 +576,8 @@ main(int argc, char * const *argv)
VTAILQ_INSERT_TAIL(&tst_head, tp, list);
}
+ VSB_finish(params_vsb);
+
feature_dns = dns_works();
ip_magic();
diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index 1757722..8df63ea 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -55,6 +55,7 @@
extern int leave_temp;
extern char *vmod_path;
+extern struct vsb *params_vsb;
struct varnish {
unsigned magic;
@@ -405,6 +406,7 @@ varnish_launch(struct varnish *v)
VSB_printf(vsb, "cd ${pwd} &&");
VSB_printf(vsb, " exec varnishd %s -d -n %s",
v->jail, v->workdir);
+ VSB_printf(vsb, VSB_data(params_vsb));
if (vtc_witness)
VSB_cat(vsb, " -p debug=+witness");
if (leave_temp)
diff --git a/doc/sphinx/reference/varnishtest.rst b/doc/sphinx/reference/varnishtest.rst
index d689929..ba8708d 100644
--- a/doc/sphinx/reference/varnishtest.rst
+++ b/doc/sphinx/reference/varnishtest.rst
@@ -48,6 +48,8 @@ The following options are available:
-n iterations Run tests this many times
+-p name=val Pass parameters to all varnishd command lines
+
-q Quiet mode: report only failures
-t duration Time tests out after this long
More information about the varnish-commit
mailing list