Commit 023e9d1b authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Go further with the uniquely named tmpdir thing and put the varnishd

workdir below there as well.

Do not remove the tmpdir if we have verbosity and failure, otherwise do.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4487 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent d5098466
......@@ -42,7 +42,6 @@ SVNID("$Id$")
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "compat/asprintf.h"
#include "libvarnish.h"
#include "vsb.h"
......@@ -59,6 +58,7 @@ char *vtc_desc;
int vtc_error; /* Error encountered */
int vtc_stop; /* Stops current test without error */
pthread_t vtc_thread;
char *vtc_tmpdir;
/**********************************************************************
* Macro facility
......@@ -140,7 +140,7 @@ macro_get(const char *name)
}
struct vsb *
macro_expand(char *name)
macro_expand(const char *name)
{
struct vsb *vsb;
char *p, *q;
......@@ -525,7 +525,7 @@ main(int argc, char * const *argv)
static struct vtclog *vl;
double tmax, t0, t00;
const char *nmax;
char *tmpdir, *cmd;
char cmd[BUFSIZ];
setbuf(stdout, NULL);
setbuf(stderr, NULL);
......@@ -556,10 +556,10 @@ main(int argc, char * const *argv)
init_macro();
init_sema();
tmpdir = tempnam(NULL, "vtc");
AN(tmpdir);
mkdir(tmpdir, 0700);
macro_def(vl, NULL, "tmpdir", tmpdir);
vtc_tmpdir = tempnam(NULL, "vtc");
AN(vtc_tmpdir);
AZ(mkdir(vtc_tmpdir, 0700));
macro_def(vl, NULL, "tmpdir", vtc_tmpdir);
vtc_thread = pthread_self();
tmax = 0;
nmax = NULL;
......@@ -579,12 +579,12 @@ main(int argc, char * const *argv)
break;
}
/* XXX this will always remove the tmpdir even on failures.
* Maybe we should keep it in that case? */
assert(asprintf(&cmd, "rm -rf %s", tmpdir) > 0);
AZ(system(cmd));
free(tmpdir);
free(cmd);
/* Remove tmpdir on success or non-verbosity */
if (vtc_error == 0 || vtc_verbosity == 0) {
bprintf(cmd, "rm -rf %s", vtc_tmpdir);
AZ(system(cmd));
free(vtc_tmpdir);
}
if (vtc_error)
return (2);
......
......@@ -60,6 +60,7 @@ extern int vtc_verbosity;
extern int vtc_error; /* Error, bail out */
extern int vtc_stop; /* Abandon current test, no error */
extern pthread_t vtc_thread;
extern char *vtc_tmpdir;
void init_sema(void);
......@@ -78,4 +79,4 @@ void vtc_dump(struct vtclog *vl, unsigned lvl, const char *pfx,
void macro_def(struct vtclog *vl, const char *instance, const char *name,
const char *fmt, ...);
struct vsb *macro_expand(char *name);
struct vsb *macro_expand(const char *name);
......@@ -46,7 +46,6 @@ SVNID("$Id$")
#include <sys/wait.h>
#include <sys/socket.h>
#include "compat/asprintf.h"
#include "vqueue.h"
#include "miniobj.h"
#include "libvarnish.h"
......@@ -144,22 +143,19 @@ static struct varnish *
varnish_new(const char *name)
{
struct varnish *v;
char *c;
char buf[1024];
AN(name);
ALLOC_OBJ(v, VARNISH_MAGIC);
AN(v);
REPLACE(v->name, name);
if (getuid() == 0)
assert(asprintf(&v->workdir, "/tmp/__%s", name) >= 0);
else
assert(asprintf(&v->workdir, "/tmp/__%s.%d", name, getuid()) >= 0);
bprintf(buf, "%s/%s", vtc_tmpdir, name);
v->workdir = strdup(buf);
AN(v->workdir);
assert(asprintf(&c, "rm -rf %s ; mkdir -p %s", v->workdir, v->workdir) >= 0);
AN(c);
AZ(system(c));
bprintf(buf, "rm -rf %s ; mkdir -p %s", v->workdir, v->workdir);
AZ(system(buf));
v->vl = vtc_logopen(name);
AN(v->vl);
......
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