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