From owner-svn-src-head@FreeBSD.ORG Mon Dec 8 17:22:44 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B949A106578E; Mon, 8 Dec 2008 17:22:44 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A6CCF8FC1C; Mon, 8 Dec 2008 17:22:44 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mB8HMi0b066188; Mon, 8 Dec 2008 17:22:44 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mB8HMicp066187; Mon, 8 Dec 2008 17:22:44 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <200812081722.mB8HMicp066187@svn.freebsd.org> From: Tim Kientzle Date: Mon, 8 Dec 2008 17:22:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r185771 - head/lib/libarchive/test X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Dec 2008 17:22:45 -0000 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)