r5528 - trunk/varnish-cache/bin/varnishtest
phk at varnish-cache.org
phk at varnish-cache.org
Tue Nov 9 11:16:39 CET 2010
Author: phk
Date: 2010-11-09 11:16:38 +0100 (Tue, 09 Nov 2010)
New Revision: 5528
Modified:
trunk/varnish-cache/bin/varnishtest/vtc.c
trunk/varnish-cache/bin/varnishtest/vtc_main.c
Log:
Implement -l and -L to control leaving behind the /tmp/vtc.* directories
(on error and unconditionally).
Drop the LOG into the /tmp/vtc.* directory if we leave it behind.
Sync usage() to reality.
Modified: trunk/varnish-cache/bin/varnishtest/vtc.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.c 2010-11-09 09:23:47 UTC (rev 5527)
+++ trunk/varnish-cache/bin/varnishtest/vtc.c 2010-11-09 10:16:38 UTC (rev 5528)
@@ -478,6 +478,7 @@
unsigned old_err;
char *cwd, *p;
char topbuild[BUFSIZ];
+ FILE *f;
vtc_loginit(logbuf, loglen);
vltop = vtc_logopen("top");
@@ -486,15 +487,23 @@
init_macro();
init_sema();
+ /* We are still in bin/varnishtest at this point */
cwd = getcwd(NULL, PATH_MAX);
bprintf(topbuild, "%s/%s", cwd, TOP_BUILDDIR);
macro_def(vltop, NULL, "topbuild", topbuild);
macro_def(vltop, NULL, "bad_ip", "10.255.255.255");
+ /* Move into our tmpdir */
AZ(chdir(tmpdir));
macro_def(vltop, NULL, "tmpdir", tmpdir);
+ /* Drop file to tell what was going on here */
+ f = fopen("INFO", "w");
+ AN(f);
+ fprintf(f, "Test case: %s\n", fn);
+ AZ(fclose(f));
+
vtc_stop = 0;
vtc_desc = NULL;
vtc_log(vltop, 1, "TEST %s starting", fn);
Modified: trunk/varnish-cache/bin/varnishtest/vtc_main.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_main.c 2010-11-09 09:23:47 UTC (rev 5527)
+++ trunk/varnish-cache/bin/varnishtest/vtc_main.c 2010-11-09 10:16:38 UTC (rev 5528)
@@ -85,6 +85,7 @@
static int vtc_verbosity = 1; /* Verbosity Level */
static int vtc_good;
static int vtc_fail;
+static int leave_temp;
/**********************************************************************
* Read a file into memory
@@ -123,7 +124,16 @@
static void
usage(void)
{
- fprintf(stderr, "usage: varnishtest [-n iter] [-qv] file ...\n");
+ fprintf(stderr, "usage: varnishtest [options] file ...\n");
+#define FMT " %-28s # %s\n"
+ fprintf(stderr, FMT, "-j jobs", "Run this many tests in parallel");
+ 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, "-n iterations", "Run tests this many times");
+ fprintf(stderr, FMT, "-q", "Quiet mode: report only failues");
+ fprintf(stderr, FMT, "-t duration", "Time tests out after this long");
+ fprintf(stderr, FMT, "-v", "Verbose mode: always report test log");
exit(1);
}
@@ -139,6 +149,7 @@
int i, stx;
pid_t px;
double t;
+ FILE *f;
CAST_OBJ_NOTNULL(jp, ve->priv, JOB_MAGIC);
@@ -160,6 +171,7 @@
if (i == 0) {
njob--;
px = wait4(jp->child, &stx, 0, NULL);
+ assert(px == jp->child);
t = TIM_mono() - jp->t0;
AZ(close(ve->fd));
@@ -173,6 +185,18 @@
else
vtc_good++;
+ if (leave_temp == 0 || (leave_temp == 1 && !stx)) {
+ bprintf(buf, "rm -rf %s", jp->tmpdir);
+ AZ(system(buf));
+ } else {
+ bprintf(buf, "%s/LOG", jp->tmpdir);
+ f = fopen(buf, "w");
+ AN(f);
+ (void)fprintf(f, "%s\n", jp->buf);
+ AZ(fclose(f));
+ }
+ free(jp->tmpdir);
+
if (stx) {
printf("# top TEST %s FAILED (%.3f)\n",
jp->tst->filename, t);
@@ -188,9 +212,6 @@
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);
}
@@ -209,7 +230,6 @@
struct vtc_job *jp;
char tmpdir[PATH_MAX];
-
ALLOC_OBJ(jp, JOB_MAGIC);
AN(jp);
@@ -286,11 +306,17 @@
setbuf(stdout, NULL);
setbuf(stderr, NULL);
- while ((ch = getopt(argc, argv, "j:kL:n:qt:v")) != -1) {
+ while ((ch = getopt(argc, argv, "j:klLn:qt:v")) != -1) {
switch (ch) {
case 'j':
npar = strtoul(optarg, NULL, 0);
break;
+ case 'l':
+ leave_temp = 1;
+ break;
+ case 'L':
+ leave_temp = 2;
+ break;
case 'k':
vtc_continue = !vtc_continue;
break;
More information about the varnish-commit
mailing list