Commit 12664cd8 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Collect stdout/err from the test-running process in a VSB and emit

it at the end of the run where it is far more likely to be noticed.
parent b6f0915b
...@@ -77,6 +77,8 @@ struct vtc_job { ...@@ -77,6 +77,8 @@ struct vtc_job {
char *tmpdir; char *tmpdir;
unsigned bufsiz; unsigned bufsiz;
double t0; double t0;
struct vsb *diag;
int killed;
}; };
int iflg = 0; int iflg = 0;
...@@ -161,21 +163,23 @@ tst_cb(const struct vev *ve, int what) ...@@ -161,21 +163,23 @@ tst_cb(const struct vev *ve, int what)
pid_t px; pid_t px;
double t; double t;
FILE *f; FILE *f;
char *p;
struct vsb *v;
CAST_OBJ_NOTNULL(jp, ve->priv, JOB_MAGIC); CAST_OBJ_NOTNULL(jp, ve->priv, JOB_MAGIC);
// printf("CB %p %s %d\n", ve, jp->tst->filename, what); // printf("CB %p %s %d\n", ve, jp->tst->filename, what);
if (what == 0) if (what == 0) {
jp->killed = 1;
AZ(kill(jp->child, SIGKILL)); /* XXX: Timeout */ AZ(kill(jp->child, SIGKILL)); /* XXX: Timeout */
else } else {
assert(what & (EV_RD | EV_HUP)); assert(what & (EV_RD | EV_HUP));
}
*buf = '\0'; *buf = '\0';
i = read(ve->fd, buf, sizeof buf - 1); i = read(ve->fd, buf, sizeof buf);
if (i > 0) { if (i > 0)
buf[i] = '\0'; VSB_bcat(jp->diag, buf, i);
printf("######## %s ########\n%s", jp->tst->filename, buf);
}
if (i == 0) { if (i == 0) {
njob--; njob--;
px = wait4(jp->child, &stx, 0, NULL); px = wait4(jp->child, &stx, 0, NULL);
...@@ -187,10 +191,21 @@ tst_cb(const struct vev *ve, int what) ...@@ -187,10 +191,21 @@ tst_cb(const struct vev *ve, int what)
if (ecode == 0) if (ecode == 0)
ecode = WEXITSTATUS(stx); ecode = WEXITSTATUS(stx);
if (ecode > 1 && vtc_verbosity) AZ(VSB_finish(jp->diag));
printf("%s\n", jp->buf); v = VSB_new_auto();
else if (vtc_verbosity > 1) AN(v);
printf("%s\n", jp->buf); VSB_cat(v, jp->buf);
p = strchr(jp->buf, '\0');
if (p > jp->buf && p[-1] != '\n')
VSB_putc(v, '\n');
VSB_quote_pfx(v, "* diag 0.0 ",
VSB_data(jp->diag), -1, VSB_QUOTE_NONL);
AZ(VSB_finish(v));
VSB_destroy(&jp->diag);
AZ(munmap(jp->buf, jp->bufsiz));
if ((ecode > 1 && vtc_verbosity) || vtc_verbosity > 1)
printf("%s", VSB_data(v));
if (!ecode) if (!ecode)
vtc_good++; vtc_good++;
...@@ -206,13 +221,14 @@ tst_cb(const struct vev *ve, int what) ...@@ -206,13 +221,14 @@ tst_cb(const struct vev *ve, int what)
bprintf(buf, "%s/LOG", jp->tmpdir); bprintf(buf, "%s/LOG", jp->tmpdir);
f = fopen(buf, "w"); f = fopen(buf, "w");
AN(f); AN(f);
(void)fprintf(f, "%s\n", jp->buf); (void)fprintf(f, "%s\n", VSB_data(v));
AZ(fclose(f)); AZ(fclose(f));
} }
free(jp->tmpdir); free(jp->tmpdir);
VSB_destroy(&v);
if (ecode > 1) { if (ecode > 1) {
printf("# top TEST %s FAILED (%.3f)", printf("# top TEST %s FAILED (%.3f)",
jp->tst->filename, t); jp->tst->filename, t);
if (WIFSIGNALED(stx)) if (WIFSIGNALED(stx))
printf(" signal=%d\n", WTERMSIG(stx)); printf(" signal=%d\n", WTERMSIG(stx));
...@@ -223,11 +239,10 @@ tst_cb(const struct vev *ve, int what) ...@@ -223,11 +239,10 @@ tst_cb(const struct vev *ve, int what)
exit(2); exit(2);
} }
} else if (vtc_verbosity) { } else if (vtc_verbosity) {
printf("# top TEST %s %s (%.3f)\n", printf("# top TEST %s %s (%.3f)\n",
jp->tst->filename, jp->tst->filename,
ecode ? "skipped" : "passed", t); ecode ? "skipped" : "passed", t);
} }
AZ(munmap(jp->buf, jp->bufsiz));
if (jp->evt != NULL) if (jp->evt != NULL)
vev_del(vb, jp->evt); vev_del(vb, jp->evt);
...@@ -252,6 +267,9 @@ start_test(void) ...@@ -252,6 +267,9 @@ start_test(void)
ALLOC_OBJ(jp, JOB_MAGIC); ALLOC_OBJ(jp, JOB_MAGIC);
AN(jp); AN(jp);
jp->diag = VSB_new_auto();
AN(jp->diag);
jp->bufsiz = vtc_bufsiz; jp->bufsiz = vtc_bufsiz;
jp->buf = mmap(NULL, jp->bufsiz, PROT_READ|PROT_WRITE, jp->buf = mmap(NULL, jp->bufsiz, PROT_READ|PROT_WRITE,
......
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