r4455 - in trunk/varnish-cache/bin/varnishtest: . tests
tfheen at projects.linpro.no
tfheen at projects.linpro.no
Wed Jan 13 15:55:46 CET 2010
Author: tfheen
Date: 2010-01-13 15:55:46 +0100 (Wed, 13 Jan 2010)
New Revision: 4455
Modified:
trunk/varnish-cache/bin/varnishtest/tests/a00009.vtc
trunk/varnish-cache/bin/varnishtest/tests/b00014.vtc
trunk/varnish-cache/bin/varnishtest/tests/p00000.vtc
trunk/varnish-cache/bin/varnishtest/tests/p00001.vtc
trunk/varnish-cache/bin/varnishtest/tests/p00002.vtc
trunk/varnish-cache/bin/varnishtest/tests/p00003.vtc
trunk/varnish-cache/bin/varnishtest/tests/p00004.vtc
trunk/varnish-cache/bin/varnishtest/tests/p00005.vtc
trunk/varnish-cache/bin/varnishtest/tests/p00006.vtc
trunk/varnish-cache/bin/varnishtest/tests/v00016.vtc
trunk/varnish-cache/bin/varnishtest/vtc.c
Log:
Add tmpdir macro to varnishtest
Make a tmpdir macro available that points at a temporary directory
which will be cleaned up after the test has run. Adjust test cases to
use this rather than hard-coding paths in /tmp.
Modified: trunk/varnish-cache/bin/varnishtest/tests/a00009.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/a00009.vtc 2010-01-13 13:52:24 UTC (rev 4454)
+++ trunk/varnish-cache/bin/varnishtest/tests/a00009.vtc 2010-01-13 14:55:46 UTC (rev 4455)
@@ -2,4 +2,4 @@
test "See that the VCL compiler works"
-shell "cd ../varnishd && ./varnishd -b 127.0.0.1:80 -C -n /tmp/__v1"
+shell "cd ../varnishd && ./varnishd -b 127.0.0.1:80 -C -n ${tmpdir}"
Modified: trunk/varnish-cache/bin/varnishtest/tests/b00014.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/b00014.vtc 2010-01-13 13:52:24 UTC (rev 4454)
+++ trunk/varnish-cache/bin/varnishtest/tests/b00014.vtc 2010-01-13 14:55:46 UTC (rev 4455)
@@ -12,19 +12,17 @@
txresp -body "bar"
} -start
-shell "echo 'backend foo { .host = \"${s1_addr}\"; .port = \"${s1_port}\"; }' > /tmp/_b00014.vcl"
-varnish v1 -arg "-f /tmp/_b00014.vcl" -start
+shell "echo 'backend foo { .host = \"${s1_addr}\"; .port = \"${s1_port}\"; }' > ${tmpdir}/_b00014.vcl"
+varnish v1 -arg "-f ${tmpdir}/_b00014.vcl" -start
client c1 {
txreq -url /foo
rxresp
} -run
-varnish v1 -cliok "vcl.load foo /tmp/_b00014.vcl" -cliok "vcl.use foo"
+varnish v1 -cliok "vcl.load foo ${tmpdir}/_b00014.vcl" -cliok "vcl.use foo"
client c1 {
txreq -url /bar
rxresp
} -run
-
-shell "rm -f /tmp/_b00014.vcl"
Modified: trunk/varnish-cache/bin/varnishtest/tests/p00000.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/p00000.vtc 2010-01-13 13:52:24 UTC (rev 4454)
+++ trunk/varnish-cache/bin/varnishtest/tests/p00000.vtc 2010-01-13 14:55:46 UTC (rev 4455)
@@ -7,11 +7,11 @@
txresp
} -start
-shell "rm -f /tmp/__v1/_.per"
+shell "rm -f ${tmpdir}/_.per"
varnish v1 \
-arg "-pdiag_bitmap=0x20000" \
- -arg "-spersistent,/tmp/__v1/_.per,10m" -vcl+backend { } -start
+ -arg "-spersistent,${tmpdir}/_.per,10m" -vcl+backend { } -start
varnish v1 -stop
Modified: trunk/varnish-cache/bin/varnishtest/tests/p00001.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/p00001.vtc 2010-01-13 13:52:24 UTC (rev 4454)
+++ trunk/varnish-cache/bin/varnishtest/tests/p00001.vtc 2010-01-13 14:55:46 UTC (rev 4455)
@@ -2,7 +2,7 @@
test "Change TTL on persistent object"
-shell "rm -f /tmp/__v1/_.per"
+shell "rm -f ${tmpdir}/_.per"
server s1 {
rxreq
@@ -11,7 +11,7 @@
varnish v1 \
-arg "-pdiag_bitmap=0x20000" \
- -arg "-spersistent,/tmp/__v1/_.per,10m" -vcl+backend { } -start
+ -arg "-spersistent,${tmpdir}/_.per,10m" -vcl+backend { } -start
client c1 {
txreq -url "/"
Modified: trunk/varnish-cache/bin/varnishtest/tests/p00002.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/p00002.vtc 2010-01-13 13:52:24 UTC (rev 4454)
+++ trunk/varnish-cache/bin/varnishtest/tests/p00002.vtc 2010-01-13 14:55:46 UTC (rev 4455)
@@ -2,7 +2,7 @@
test "Ban a persistent object"
-shell "rm -f /tmp/__v1/_.per[12]"
+shell "rm -f ${tmpdir}/_.per[12]"
server s1 {
rxreq
@@ -11,8 +11,8 @@
varnish v1 \
-arg "-pdiag_bitmap=0x20000" \
- -arg "-spersistent,/tmp/__v1/_.per1,10m" \
- -arg "-spersistent,/tmp/__v1/_.per2,10m" \
+ -arg "-spersistent,${tmpdir}/_.per1,10m" \
+ -arg "-spersistent,${tmpdir}/_.per2,10m" \
-vcl+backend { } -start
client c1 {
Modified: trunk/varnish-cache/bin/varnishtest/tests/p00003.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/p00003.vtc 2010-01-13 13:52:24 UTC (rev 4454)
+++ trunk/varnish-cache/bin/varnishtest/tests/p00003.vtc 2010-01-13 14:55:46 UTC (rev 4455)
@@ -2,7 +2,7 @@
test "Ban a persistent object"
-shell "rm -f /tmp/__v1/_.per"
+shell "rm -f ${tmpdir}/_.per"
server s1 {
rxreq
@@ -11,7 +11,7 @@
varnish v1 \
-arg "-pdiag_bitmap=0x20000" \
- -arg "-spersistent,/tmp/__v1/_.per,10m" \
+ -arg "-spersistent,${tmpdir}/_.per,10m" \
-vcl+backend { } -start
varnish v1 -cliok purge.list
Modified: trunk/varnish-cache/bin/varnishtest/tests/p00004.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/p00004.vtc 2010-01-13 13:52:24 UTC (rev 4454)
+++ trunk/varnish-cache/bin/varnishtest/tests/p00004.vtc 2010-01-13 14:55:46 UTC (rev 4455)
@@ -2,7 +2,7 @@
test "Check object references"
-shell "rm -f /tmp/__v1/_.per"
+shell "rm -f ${tmpdir}/_.per"
server s1 {
rxreq
@@ -13,7 +13,7 @@
varnish v1 \
-arg "-pdiag_bitmap=0x20000" \
- -arg "-spersistent,/tmp/__v1/_.per,10m" \
+ -arg "-spersistent,${tmpdir}/_.per,10m" \
-vcl+backend { } -start
client c1 {
Modified: trunk/varnish-cache/bin/varnishtest/tests/p00005.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/p00005.vtc 2010-01-13 13:52:24 UTC (rev 4454)
+++ trunk/varnish-cache/bin/varnishtest/tests/p00005.vtc 2010-01-13 14:55:46 UTC (rev 4455)
@@ -2,7 +2,7 @@
test "Check expiry of non-instantiated object"
-shell "rm -f /tmp/__v1/_.per"
+shell "rm -f ${tmpdir}/_.per"
server s1 {
rxreq
@@ -11,7 +11,7 @@
varnish v1 \
-arg "-pdiag_bitmap=0x30000" \
- -arg "-spersistent,/tmp/__v1/_.per,10m" \
+ -arg "-spersistent,${tmpdir}/_.per,10m" \
-vcl+backend {
sub vcl_fetch {
set beresp.ttl = 3s;
Modified: trunk/varnish-cache/bin/varnishtest/tests/p00006.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/p00006.vtc 2010-01-13 13:52:24 UTC (rev 4454)
+++ trunk/varnish-cache/bin/varnishtest/tests/p00006.vtc 2010-01-13 14:55:46 UTC (rev 4455)
@@ -2,7 +2,7 @@
test "Check that Vary headers are stored"
-shell "rm -f /tmp/__v1/_.per"
+shell "rm -f ${tmpdir}/_.per"
server s1 {
rxreq
@@ -13,7 +13,7 @@
varnish v1 \
- -arg "-spersistent,/tmp/__v1/_.per,10m" \
+ -arg "-spersistent,${tmpdir}/_.per,10m" \
-vcl+backend { } -start
client c1 {
Modified: trunk/varnish-cache/bin/varnishtest/tests/v00016.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/v00016.vtc 2010-01-13 13:52:24 UTC (rev 4454)
+++ trunk/varnish-cache/bin/varnishtest/tests/v00016.vtc 2010-01-13 14:55:46 UTC (rev 4455)
@@ -2,19 +2,19 @@
test "Various VCL compiler coverage tests"
-shell "true > /tmp/_varnishtest_empty_file"
+shell "true > ${tmpdir}/_varnishtest_empty_file"
varnish v1 -vcl {
backend b { .host = "127.0.0.1"; }
- include "/tmp/_varnishtest_empty_file" ;
+ include "${tmpdir}/_varnishtest_empty_file" ;
}
varnish v1 -badvcl {
backend b { .host = "127.0.0.1"; }
- include "/tmp/_varnishtest_empty_file" |
+ include "${tmpdir}/_varnishtest_empty_file" |
}
-shell "rm -f /tmp/_varnishtest_empty_file"
+shell "rm -f ${tmpdir}/_varnishtest_empty_file"
varnish v1 -badvcl {
backend b { .host = "127.0.0.1"; }
Modified: trunk/varnish-cache/bin/varnishtest/vtc.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.c 2010-01-13 13:52:24 UTC (rev 4454)
+++ trunk/varnish-cache/bin/varnishtest/vtc.c 2010-01-13 14:55:46 UTC (rev 4455)
@@ -40,6 +40,8 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include "compat/asprintf.h"
#include "libvarnish.h"
@@ -509,6 +511,7 @@
static struct vtclog *vl;
double tmax, t0, t00;
const char *nmax;
+ char *tmpdir, *cmd;
setbuf(stdout, NULL);
setbuf(stderr, NULL);
@@ -538,6 +541,10 @@
init_macro();
init_sema();
+ tmpdir = tempnam(NULL, "vtc");
+ AN(tmpdir);
+ mkdir(tmpdir, 0700);
+ macro_def(vl, NULL, "tmpdir", tmpdir);
vtc_thread = pthread_self();
tmax = 0;
nmax = NULL;
@@ -558,6 +565,13 @@
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);
+
if (vtc_error)
return (2);
More information about the varnish-commit
mailing list