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)
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to