vtest: Allow to inject varnishd arguments via VTEST_VARNISHD_ADD_ARGS

This is useful to test extensions with otherwise unaltered varnish test cases,
for example:

VTEST_VARNISHD_ADD_ARGS='-E/tmp/lib/varnish/vmods/libvmod_slash.so -sfellow=fellow,${tmpdir}/fellow.stv,100MB,1MB,64KB -sTransient=fellow,${tmpdir}/transient.stv,100MB,1MB,64KB' ./varnishtest -i ...

These arguments are added and this injection method does not achieve
its goal in all cases (e.g. for the example it breaks when other
stevedore definitions conflict), but it still reduces the cases
requiring manual intervention substantially.
parent ed761641
......@@ -93,6 +93,8 @@ struct varnish {
#define NONSENSE "%XJEIFLH|)Xspa8P"
#define VARNISHD_ADD_ARGS_ENV_VAR "VTEST_VARNISHD_ADD_ARGS"
static VTAILQ_HEAD(, varnish) varnishes =
VTAILQ_HEAD_INITIALIZER(varnishes);
......@@ -389,7 +391,7 @@ varnish_launch(struct varnish *v)
char abuf[128], pbuf[128];
struct pollfd fd[3];
enum VCLI_status_e u;
const char *err;
const char *err, *env_args;
char *r = NULL;
/* Create listener socket */
......@@ -429,6 +431,9 @@ varnish_launch(struct varnish *v)
VSB_printf(vsb, " -P %s/varnishd.pid", v->workdir);
if (vmod_path != NULL)
VSB_printf(vsb, " -p vmod_path=%s", vmod_path);
env_args = getenv(VARNISHD_ADD_ARGS_ENV_VAR);
if (env_args)
VSB_printf(vsb, " %s", env_args);
VSB_printf(vsb, " %s", VSB_data(v->args));
AZ(VSB_finish(vsb));
vtc_log(v->vl, 3, "CMD: %s", VSB_data(vsb));
......@@ -1068,6 +1073,9 @@ vsl_catchup(struct varnish *v)
* \-arg STRING
* Pass an argument to varnishd, for example "-h simple_list".
*
* The environment variable VTEST_VARNISHD_ADD_ARGS can be used to
* inject additional arguments.
*
* \-vcl STRING
* Specify the VCL to load on this Varnish instance. You'll probably
* want to use multi-lines strings for this ({...}).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment