Commit 4bb98fa1 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Put storage file in ${tmpdir}



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5527 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent dcb63d42
......@@ -7,7 +7,7 @@ server s1 {
txresp -hdr "Connection: close" -body "012345\n"
} -start
varnish v1 -arg "-s file,varnishtest_backing,10M" -vcl+backend {} -start
varnish v1 -arg "-s file,${tmpdir}/varnishtest_backing,10M" -vcl+backend {} -start
client c1 {
txreq -url "/"
......@@ -18,4 +18,4 @@ client c1 {
server s1 -wait
varnish v1 -stop
shell "rm ../varnishd/varnishtest_backing"
shell "rm ${tmpdir}/varnishtest_backing"
......@@ -62,7 +62,6 @@ static char *vtc_desc;
volatile sig_atomic_t vtc_error; /* Error encountered */
int vtc_stop; /* Stops current test without error */
pthread_t vtc_thread;
char vtc_tmpdir[PATH_MAX];
static struct vtclog *vltop;
/**********************************************************************
......@@ -473,7 +472,8 @@ static const struct cmds cmds[] = {
};
int
exec_file(const char *fn, const char *script, char *logbuf, unsigned loglen)
exec_file(const char *fn, const char *script, const char *tmpdir,
char *logbuf, unsigned loglen)
{
unsigned old_err;
char *cwd, *p;
......@@ -492,10 +492,8 @@ exec_file(const char *fn, const char *script, char *logbuf, unsigned loglen)
macro_def(vltop, NULL, "bad_ip", "10.255.255.255");
srandomdev();
bprintf(vtc_tmpdir, "/tmp/vtc.%d.%08x", getpid(), (unsigned)random());
AZ(mkdir(vtc_tmpdir, 0700));
macro_def(vltop, NULL, "tmpdir", vtc_tmpdir);
AZ(chdir(tmpdir));
macro_def(vltop, NULL, "tmpdir", tmpdir);
vtc_stop = 0;
vtc_desc = NULL;
......
......@@ -61,7 +61,6 @@ cmd_f cmd_sema;
extern volatile sig_atomic_t vtc_error; /* Error, bail out */
extern int vtc_stop; /* Abandon current test, no error */
extern pthread_t vtc_thread;
extern char vtc_tmpdir[PATH_MAX];
void init_sema(void);
......@@ -76,7 +75,8 @@ void vtc_log(struct vtclog *vl, unsigned lvl, const char *fmt, ...);
void vtc_dump(struct vtclog *vl, unsigned lvl, const char *pfx,
const char *str);
int exec_file(const char *fn, const char *script, char *logbuf, unsigned loglen);
int exec_file(const char *fn, const char *script, const char *tmpdir,
char *logbuf, unsigned loglen);
void macro_def(struct vtclog *vl, const char *instance, const char *name,
const char *fmt, ...);
......
......@@ -71,6 +71,7 @@ struct vtc_job {
struct vev *ev;
struct vev *evt;
char *buf;
char *tmpdir;
unsigned bufsiz;
double t0;
};
......@@ -186,6 +187,10 @@ tst_cb(const struct vev *ve, int what)
AZ(munmap(jp->buf, jp->bufsiz));
if (jp->evt != NULL)
vev_del(vb, jp->evt);
bprintf(buf, "rm -rf %s", jp->tmpdir);
AZ(system(buf));
free(jp->tmpdir);
FREE_OBJ(jp);
return (1);
}
......@@ -202,6 +207,8 @@ start_test(void)
struct vtc_tst *tp;
int p[2], sfd, retval;
struct vtc_job *jp;
char tmpdir[PATH_MAX];
ALLOC_OBJ(jp, JOB_MAGIC);
AN(jp);
......@@ -213,6 +220,10 @@ start_test(void)
assert(jp->buf != MAP_FAILED);
memset(jp->buf, 0, jp->bufsiz);
srandomdev();
bprintf(tmpdir, "/tmp/vtc.%d.%08x", getpid(), (unsigned)random());
AZ(mkdir(tmpdir, 0700));
tp = VTAILQ_FIRST(&tst_head);
CHECK_OBJ_NOTNULL(tp, TST_MAGIC);
AN(tp->ntodo);
......@@ -222,6 +233,8 @@ start_test(void)
VTAILQ_INSERT_TAIL(&tst_head, tp, list);
jp->tst = tp;
jp->tmpdir = strdup(tmpdir);
AN(jp->tmpdir);
AZ(pipe(p));
assert(p[0] > STDERR_FILENO);
......@@ -236,7 +249,8 @@ start_test(void)
assert(dup2(p[1], STDERR_FILENO) == STDERR_FILENO);
for (sfd = STDERR_FILENO + 1; sfd < 100; sfd++)
(void)close(sfd);
retval = exec_file(jp->tst->filename, jp->tst->script, jp->buf, jp->bufsiz);
retval = exec_file(jp->tst->filename, jp->tst->script,
jp->tmpdir, jp->buf, jp->bufsiz);
_exit(retval);
}
AZ(close(p[1]));
......
......@@ -147,6 +147,7 @@ static struct varnish *
varnish_new(const char *name)
{
struct varnish *v;
struct vsb *vsb;
char buf[1024];
AN(name);
......@@ -154,17 +155,20 @@ varnish_new(const char *name)
AN(v);
REPLACE(v->name, name);
bprintf(buf, "%s/%s", vtc_tmpdir, name);
v->workdir = strdup(buf);
v->vl = vtc_logopen(name);
AN(v->vl);
bprintf(buf, "${tmpdir}/%s", name);
vsb = macro_expand(v->vl, buf);
AN(vsb);
v->workdir = strdup(vsb_data(vsb));
AN(v->workdir);
vsb_delete(vsb);
bprintf(buf, "rm -rf %s ; mkdir -p %s ; echo ' %ld' > %s/_S",
v->workdir, v->workdir, random(), v->workdir);
AZ(system(buf));
v->vl = vtc_logopen(name);
AN(v->vl);
v->vl1 = vtc_logopen(name);
AN(v->vl1);
......@@ -250,7 +254,7 @@ varnish_thread(void *priv)
static void
varnish_launch(struct varnish *v)
{
struct vsb *vsb;
struct vsb *vsb, *vsb1;
int i, nfd, nap;
struct vss_addr **ap;
char abuf[128], pbuf[128];
......@@ -272,7 +276,7 @@ varnish_launch(struct varnish *v)
vtc_log(v->vl, 2, "Launch");
vsb = vsb_newauto();
AN(vsb);
vsb_printf(vsb, "cd ../varnishd &&");
vsb_printf(vsb, "cd ${topbuild}/bin/varnishd &&");
vsb_printf(vsb, " ./varnishd -d -d -n %s", v->workdir);
vsb_printf(vsb, " -l 10m,1m,-");
vsb_printf(vsb, " -p auto_restart=off");
......@@ -286,6 +290,11 @@ varnish_launch(struct varnish *v)
vsb_finish(vsb);
AZ(vsb_overflowed(vsb));
vtc_log(v->vl, 3, "CMD: %s", vsb_data(vsb));
vsb1 = macro_expand(v->vl, vsb_data(vsb));
AN(vsb1);
vsb_delete(vsb);
vsb = vsb1;
vtc_log(v->vl, 3, "CMD: %s", vsb_data(vsb));
AZ(pipe(&v->fds[0]));
AZ(pipe(&v->fds[2]));
v->pid = fork();
......
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