Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Dec 2008 17:22:44 +0000 (UTC)
From:      Tim Kientzle <kientzle@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r185771 - head/lib/libarchive/test
Message-ID:  <200812081722.mB8HMicp066187@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812081722.mB8HMicp066187>