diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tet3/tcc/exec.c | 15 | ||||
-rw-r--r-- | src/tet3/tcm/ictp.c | 32 |
2 files changed, 39 insertions, 8 deletions
diff --git a/src/tet3/tcc/exec.c b/src/tet3/tcc/exec.c index 80cf630b..3389270e 100644 --- a/src/tet3/tcc/exec.c +++ b/src/tet3/tcc/exec.c @@ -75,6 +75,8 @@ char *path, **argv, *tcdir, *outfile; static #endif /* TET_LITE */ /* -LITE-CUT-LINE- */ char buf[sizeof fmt + LNUMSZ]; + char *resdir; + char resbuf[MAXPATH + sizeof("TET_RESDIR=")]; struct systab *sp; long remid; #ifdef TET_LITE /* -LITE-CUT-LINE- */ @@ -104,6 +106,19 @@ char *path, **argv, *tcdir, *outfile; sp->sy_activity = prp->pr_activity; } + /* put the results directory into the environment */ + resdir = resdirname(); + if (resdir) { + sprintf(resbuf, "TET_RESDIR=%s", resdir); + TRACE3(tet_Ttcc, 6, "putenv \"%s\" on system %s", + resbuf, tet_i2a(*prp->pr_sys)); + if (tcc_putenv(*prp->pr_sys, resbuf) < 0) { + prperror(prp, *prp->pr_sys, tet_tcerrno, + "tcc_putenv(TET_RESDIR) failed", NULL); + return(-1L); + } + } + /* change to the test case directory */ if (sychdir(sp, tcdir) < 0) { prperror(prp, *prp->pr_sys, errno ? errno : tet_tcerrno, diff --git a/src/tet3/tcm/ictp.c b/src/tet3/tcm/ictp.c index 7933f510..61df0130 100644 --- a/src/tet3/tcm/ictp.c +++ b/src/tet3/tcm/ictp.c @@ -799,7 +799,8 @@ static int ismaster() TET_IMPORT void tet_openres(progname) char *progname; { - char cwdbuf[MAXPATH]; + char *resdir, *p; + char buf[MAXPATH]; static char resvar[] = "TET_RESFILE"; char *resname; static char tmpvar[] = "TET_TMPRESFILE"; @@ -834,29 +835,44 @@ char *progname; /* set full path name of execution results file and temp results file, in a form convenient for placing in the environment */ + if (!(resdir = getenv("TET_RESDIR"))) { + if (GETCWD(buf, sizeof(buf)) == NULL) + fatal(errno, "getcwd() failed", NULL); + resdir = buf; + } - if (GETCWD(cwdbuf, (size_t)MAXPATH) == NULL) - fatal(errno, "getcwd() failed", (char *) 0); - - resenv = malloc(strlen(cwdbuf)+sizeof(resvar)+strlen(resname)+5); + resenv = malloc(strlen(resdir)+sizeof(resvar)+strlen(resname)+5); if (resenv == NULL) fatal(errno, "can't allocate resenv in tet_openres()", (char *) 0); TRACE2(tet_Tbuf, 6, "allocate resenv = %s", tet_i2x(resenv)); - tmpresenv = malloc(strlen(cwdbuf)+sizeof(tmpvar)+strlen(tmpname)+5); + tmpresenv = malloc(strlen(resdir)+sizeof(tmpvar)+strlen(tmpname)+5); if (tmpresenv == NULL) fatal(errno, "can't allocate tmpresenv in tet_openres()", (char *) 0); TRACE2(tet_Tbuf, 6, "allocate tmpresenv = %s", tet_i2x(tmpresenv)); - (void) sprintf(resenv, "%s=%s/%s", resvar, cwdbuf, resname); + (void) sprintf(resenv, "%s=%s/%s", resvar, resdir, resname); resfile = resenv + sizeof(resvar); - (void) sprintf(tmpresenv, "%s=%s/%s", tmpvar, cwdbuf, tmpname); + (void) sprintf(tmpresenv, "%s=%s/%s", tmpvar, resdir, tmpname); tet_tmpresfile = tmpresenv + sizeof(tmpvar); + /* create the leading directories for the results file */ + strncpy(buf, resfile, sizeof(buf) - 1); + for (p = buf + strlen(buf) - 1; p > buf; p--) + if (isdirsep(*p)) + break; + if (p > buf) { + *p = '\0'; + if (tet_mkalldirs(buf) != 0 && errno != EEXIST) + fatal(errno, + "cannot create results file directory:", + buf); + } + /* create the execution results file and open in append mode */ (void) remove(resfile); |