summaryrefslogtreecommitdiffstats
path: root/lib/libarchive
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2008-12-08 17:22:44 +0000
committerkientzle <kientzle@FreeBSD.org>2008-12-08 17:22:44 +0000
commit8900544198d4a9310769464163dc2ef60f13a7a5 (patch)
tree1c120678585252c88f1de692d7a2798bcdf9cc73 /lib/libarchive
parentd251d3cda9c7c4cf676cd9269afc99ae7f51fbb7 (diff)
downloadFreeBSD-src-8900544198d4a9310769464163dc2ef60f13a7a5.zip
FreeBSD-src-8900544198d4a9310769464163dc2ef60f13a7a5.tar.gz
Obey the TMPDIR, TMP, TEMP, or TEMPDIR environment variables
when choosing a scratch directory for the tests. Fallback to "/tmp", of course.
Diffstat (limited to 'lib/libarchive')
-rw-r--r--lib/libarchive/test/main.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/libarchive/test/main.c b/lib/libarchive/test/main.c
index de48c88..1de2532 100644
--- a/lib/libarchive/test/main.c
+++ b/lib/libarchive/test/main.c
@@ -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)
OpenPOWER on IntegriCloud