Hello all,

The attached patch adds an option '-m tmpdir' to varnishtest, which sets
the directory within which the vtc.* temp directories are created for
each test, previously hard-wired to /tmp (-t was already taken).

This became necessary for me because Varnish was being built on a build
server for which /tmp was mounted with the noexec option. That caused
'make check' to fail, because some of the tests save shared objects into
a temp directory and then attempt to load them.

The Makefile for varnishtest is patched so that if you have TMPDIR
defined in the environment before 'make check' is called, then
varnishtest uses that, otherwise it uses /tmp.


Best,
Geoff
-- 
** * * UPLEX - Nils Goroll Systemoptimierung

Scheffelstraße 32
22301 Hamburg

Tel +49 40 2880 5731
Mob +49 176 636 90917
Fax +49 40 42949753

http://uplex.de
From f2818e50bd36663d62d9fb70db7f32bb951fe2a9 Mon Sep 17 00:00:00 2001
From: Geoff Simmons <[email protected]>
Date: Mon, 30 Sep 2013 20:53:52 +0200
Subject: [PATCH] Option to choose another root tmp-directory in varnishtest & make check

---
 bin/varnishtest/Makefile.am |    3 ++-
 bin/varnishtest/vtc_main.c  |   11 +++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/bin/varnishtest/Makefile.am b/bin/varnishtest/Makefile.am
index 2ea62f5..228d356 100644
--- a/bin/varnishtest/Makefile.am
+++ b/bin/varnishtest/Makefile.am
@@ -1,6 +1,7 @@
 #
 
-VTC_LOG_COMPILER = ./varnishtest -v -i
+TMPDIR ?= /tmp
+VTC_LOG_COMPILER = ./varnishtest -v -i -m $(TMPDIR)
 TEST_EXTENSIONS = .vtc
 TESTS = @VTC_TESTS@
 
diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c
index 04aba0d..6cbbcba 100644
--- a/bin/varnishtest/vtc_main.c
+++ b/bin/varnishtest/vtc_main.c
@@ -85,6 +85,7 @@ static int vtc_verbosity = 1;		/* Verbosity Level */
 static int vtc_good;
 static int vtc_fail;
 static int leave_temp;
+static char *tmp;
 
 /**********************************************************************
  * Parse a -D option argument into a name/val pair, and insert
@@ -151,6 +152,7 @@ usage(void)
 	fprintf(stderr, FMT, "-k", "Continue on test failure");
 	fprintf(stderr, FMT, "-l", "Leave /tmp/vtc.* if test fails");
 	fprintf(stderr, FMT, "-L", "Always leave /tmp/vtc.*");
+	fprintf(stderr, FMT, "-m tmpdir", "Create tmp dirs in this directory");
 	fprintf(stderr, FMT, "-n iterations", "Run tests this many times");
 	fprintf(stderr, FMT, "-q", "Quiet mode: report only failures");
 	fprintf(stderr, FMT, "-t duration", "Time tests out after this long");
@@ -268,7 +270,8 @@ start_test(void)
 	memset(jp->buf, 0, jp->bufsiz);
 
 	srandomdev();
-	bprintf(tmpdir, "/tmp/vtc.%d.%08x", (int)getpid(), (unsigned)random());
+	bprintf(tmpdir, "%s/vtc.%d.%08x", tmp, (int)getpid(),
+		(unsigned)random());
 	AZ(mkdir(tmpdir, 0711));
 
 	tp = VTAILQ_FIRST(&tst_head);
@@ -332,10 +335,11 @@ main(int argc, char * const *argv)
 	char *p;
 
 	extmacro_def("varnishd", "varnishd"); /* Default to path lookup */
+	tmp = strdup("/tmp");
 
 	setbuf(stdout, NULL);
 	setbuf(stderr, NULL);
-	while ((ch = getopt(argc, argv, "D:ij:klLn:qt:v")) != -1) {
+	while ((ch = getopt(argc, argv, "D:ij:klLm:n:qt:v")) != -1) {
 		switch (ch) {
 		case 'D':
 			if (!parse_D_opt(optarg)) {
@@ -360,6 +364,9 @@ main(int argc, char * const *argv)
 		case 'k':
 			vtc_continue = !vtc_continue;
 			break;
+		case 'm':
+			tmp = strdup(optarg);
+			break;
 		case 'n':
 			ntest = strtoul(optarg, NULL, 0);
 			break;
-- 
1.7.2.5

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to