1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-16 15:11:52 +00:00

Obey the TMPDIR, TMP, TEMP, or TEMPDIR environment variables

when choosing a scratch directory for the tests.  Fallback
to "/tmp", of course.
This commit is contained in:
Tim Kientzle 2008-12-08 17:22:44 +00:00
parent 71fbac11b0
commit 18f815b95c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=185771

View File

@ -897,6 +897,7 @@ int main(int argc, char **argv)
time_t now;
char *refdir_alloc = NULL;
char *progname, *p;
char *tmp;
char tmpdir[256];
char tmpdir_timestamp[256];
@ -916,6 +917,17 @@ int main(int argc, char **argv)
testprog = getenv(ENVBASE);
#endif
if (getenv("TMPDIR") != NULL)
tmp = getenv("TMPDIR");
else if (getenv("TMP") != NULL)
tmp = getenv("TMP");
else if (getenv("TEMP") != NULL)
tmp = getenv("TEMP");
else if (getenv("TEMPDIR") != NULL)
tmp = getenv("TEMPDIR");
else
tmp = "/tmp";
/* Allow -d to be controlled through the environment. */
if (getenv(ENVBASE "_DEBUG") != NULL)
dump_on_failure = 1;
@ -976,7 +988,8 @@ int main(int argc, char **argv)
strftime(tmpdir_timestamp, sizeof(tmpdir_timestamp),
"%Y-%m-%dT%H.%M.%S",
localtime(&now));
sprintf(tmpdir, "/tmp/%s.%s-%03d", progname, tmpdir_timestamp, i);
sprintf(tmpdir, "%s/%s.%s-%03d", tmp, progname,
tmpdir_timestamp, i);
if (mkdir(tmpdir,0755) == 0)
break;
if (errno == EEXIST)