summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2009-09-24 23:46:53 -0700
committerDan Nicholson <dbn.lists@gmail.com>2009-09-24 23:46:53 -0700
commit9b648a05fcf742908c7484eccefff4c382d7c38e (patch)
tree889703e27be9a9fe587e979e4736683b57cb7dda /src
parent057d0cb6c69531852d5482b8eec16956cdf4f4f9 (diff)
tet: Pass the results file name through the environment
Instead of having the test program calculate the the results file and potentially getting out of sync with tcc, grab the name of the file from the TET_RESFILE environment variable.
Diffstat (limited to 'src')
-rw-r--r--src/tet3/tcc/exec.c22
-rw-r--r--src/tet3/tcm/ictp.c65
2 files changed, 19 insertions, 68 deletions
diff --git a/src/tet3/tcc/exec.c b/src/tet3/tcc/exec.c
index 3389270e..e7b018ff 100644
--- a/src/tet3/tcc/exec.c
+++ b/src/tet3/tcc/exec.c
@@ -75,8 +75,7 @@ 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=")];
+ char resbuf[MAXPATH + sizeof("TET_RESFILE=")];
struct systab *sp;
long remid;
#ifdef TET_LITE /* -LITE-CUT-LINE- */
@@ -106,17 +105,14 @@ 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);
- }
+ /* put the results filename into the environment */
+ sprintf(resbuf, "TET_RESFILE=%.*s", MAXPATH, prp->pr_tetxres);
+ 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 */
diff --git a/src/tet3/tcm/ictp.c b/src/tet3/tcm/ictp.c
index 61df0130..2051e63b 100644
--- a/src/tet3/tcm/ictp.c
+++ b/src/tet3/tcm/ictp.c
@@ -161,7 +161,7 @@ static char srcFile[] = __FILE__; /* file name for error reporting */
#ifdef TET_LITE /* -LITE-CUT-LINE- */
char *tet_tmpresfile;
static char *tmpresenv;
- static char *resenv, *resfile;
+ static char *resfile;
#else /* -START-LITE-CUT- */
TET_IMPORT int tet_iclast = ~(~0 << S_ICBITS) - 2;
/* used in auto sync before cleanup */
@@ -799,65 +799,24 @@ static int ismaster()
TET_IMPORT void tet_openres(progname)
char *progname;
{
- char *resdir, *p;
- char buf[MAXPATH];
- static char resvar[] = "TET_RESFILE";
- char *resname;
static char tmpvar[] = "TET_TMPRESFILE";
- char *tmpname;
-
- /* set results filename from the program name */
- if (progname) {
- /* results file is prog.log */
- resname = malloc(strlen(tet_basename(progname)) + 5);
- if (!resname)
- fatal(errno, "can't allocate resname in tet_openres()",
- NULL);
- sprintf(resname, "%s.log", tet_basename(progname));
-
- /* temporary results file is prog.log.tmp */
- tmpname = malloc(strlen(resname) + 5);
- if (!tmpname)
- fatal(errno, "can't allocate tmpname in tet_openres()",
- NULL);
- sprintf(tmpname, "%s.tmp", resname);
- }
- else {
- resname = strdup("tet_xres");
- if (!resname)
- fatal(errno, "can't allocate resname in tet_openres()",
- NULL);
- tmpname = strdup("tet_res.tmp");
- if (!tmpname)
- fatal(errno, "can't allocate tmpname in tet_openres()",
- NULL);
- }
-
- /* 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;
- }
+ char buf[MAXPATH];
+ char *p;
- 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));
+ /* get results filename from the environment */
+ resfile = getenv("TET_RESFILE");
+ if (!resfile)
+ fatal(0, "TET_RESFILE not set in the environment", NULL);
- tmpresenv = malloc(strlen(resdir)+sizeof(tmpvar)+strlen(tmpname)+5);
+ tmpresenv = malloc(strlen(tmpvar) + strlen(resfile) +
+ strlen("=.tmp") + 1);
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, resdir, resname);
- resfile = resenv + sizeof(resvar);
-
- (void) sprintf(tmpresenv, "%s=%s/%s", tmpvar, resdir, tmpname);
+ sprintf(tmpresenv, "%s=%s.tmp", tmpvar, resfile);
tet_tmpresfile = tmpresenv + sizeof(tmpvar);
/* create the leading directories for the results file */
@@ -883,10 +842,6 @@ char *progname;
/* override umask (must be writable by set-uid children) */
(void) CHMOD(resfile, MODE666);
- /* put pathname in environment to be picked up in exec'ed programs */
- if (tet_putenv(resenv) != 0)
- tet_error(0, "tet_putenv() failed when setting TET_RESFILE");
-
tet_combined_ok = 1;
}