svn commit: r185771 - head/lib/libarchive/test
Tim Kientzle
kientzle at FreeBSD.org
Mon Dec 8 09:22:45 PST 2008
Author: kientzle
Date: Mon Dec 8 17:22:44 2008
New Revision: 185771
URL: http://svn.freebsd.org/changeset/base/185771
Log:
Obey the TMPDIR, TMP, TEMP, or TEMPDIR environment variables
when choosing a scratch directory for the tests. Fallback
to "/tmp", of course.
Modified:
head/lib/libarchive/test/main.c
Modified: head/lib/libarchive/test/main.c
==============================================================================
--- head/lib/libarchive/test/main.c Mon Dec 8 17:18:37 2008 (r185770)
+++ head/lib/libarchive/test/main.c Mon Dec 8 17:22:44 2008 (r185771)
@@ -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)
More information about the svn-src-head
mailing list