diff options
author | Ludovic Courtès <ludo@gnu.org> | 2008-03-13 14:03:58 +0000 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2008-03-13 14:03:58 +0000 |
commit | eedcb08a2530145c87a86154e16a5a834d3aef37 (patch) | |
tree | 75bd11f8ce81ef33a38b215f3604ed1830441125 | |
parent | 62c5382b886f6a0e58fdff707fbf84eeef4bf166 (diff) | |
download | guile-eedcb08a2530145c87a86154e16a5a834d3aef37.tar.gz |
Honor $TMPDIR in the test suite.
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | test-suite/ChangeLog | 11 | ||||
-rw-r--r-- | test-suite/standalone/Makefile.am | 13 | ||||
-rw-r--r-- | test-suite/standalone/test-unwind.c | 41 | ||||
-rw-r--r-- | test-suite/tests/socket.test | 19 |
5 files changed, 74 insertions, 11 deletions
@@ -59,6 +59,7 @@ lead to a stack overflow. ** Fixed build issue with DEC/Compaq/HP's compiler ** Fixed `scm_from_complex_double' build issue on FreeBSD ** Fixed `alloca' build issue on FreeBSD 6 +** Make sure all tests honor `$TMPDIR' * Changes to the distribution diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index b2ebfe248..f662e12d2 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,14 @@ +2008-03-13 Ludovic Courtès <ludo@gnu.org> + + * standalone/Makefile.am (test_cflags): Add `-I' flags for + Gnulib, so that <alloca.h> can be found. + (snarfcppopts): Likewise. + + * tests/socket.test (temp-file-path): New. Replace calls to + `tmpnam' with calls to `temp-file-path', so that `$TMPDIR' is + honored. + * standalone/test-unwind.c (check_ports): Honor `$TMPDIR'. + 2008-03-12 Ludovic Courtès <ludo@gnu.org> * tests/srfi-37.test (short options without arguments): New diff --git a/test-suite/standalone/Makefile.am b/test-suite/standalone/Makefile.am index 4f1725f30..bafe0c711 100644 --- a/test-suite/standalone/Makefile.am +++ b/test-suite/standalone/Makefile.am @@ -29,15 +29,18 @@ BUILT_SOURCES = TESTS_ENVIRONMENT = "${top_builddir}/pre-inst-guile-env" -test_cflags = \ - -I$(top_srcdir)/test-suite/standalone \ - -I$(top_srcdir) \ +test_cflags = \ + -I$(top_srcdir)/test-suite/standalone \ + -I$(top_srcdir) \ + -I$(top_srcdir)/lib -I$(top_builddir)/lib \ $(EXTRA_DEFS) $(GUILE_CFLAGS) AM_LDFLAGS = $(GUILE_CFLAGS) -snarfcppopts = \ - $(DEFS) $(DEFAULT_INCLUDES) $(CPPFLAGS) $(CFLAGS) -I$(top_srcdir) +snarfcppopts = \ + $(DEFS) $(DEFAULT_INCLUDES) $(CPPFLAGS) $(CFLAGS) -I$(top_srcdir) \ + -I$(top_srcdir)/lib -I$(top_builddir)/lib + SUFFIXES = .x .c.x: ${top_builddir}/libguile/guile-snarf -o $@ $< $(snarfcppopts) diff --git a/test-suite/standalone/test-unwind.c b/test-suite/standalone/test-unwind.c index e2971beeb..472887abe 100644 --- a/test-suite/standalone/test-unwind.c +++ b/test-suite/standalone/test-unwind.c @@ -1,8 +1,36 @@ +/* Copyright (C) 2004, 2005, 2008 Free Software Foundation, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#if HAVE_CONFIG_H +# include <config.h> +#endif + +#include <alloca.h> + #include <libguile.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h> +#ifdef HAVE_STRING_H +# include <string.h> +#endif + + void set_flag (void *data); void func1 (void); void func2 (void); @@ -170,7 +198,17 @@ delete_file (void *data) void check_ports () { - char filename[] = "/tmp/check-ports.XXXXXX"; +#define FILENAME_TEMPLATE "/check-ports.XXXXXX" + char *filename; + const char *tmpdir = getenv ("TMPDIR"); + + if (tmpdir == NULL) + tmpdir = "/tmp"; + + filename = (char *) alloca (strlen (tmpdir) + + sizeof (FILENAME_TEMPLATE) + 1); + strcpy (filename, tmpdir); + strcat (filename, FILENAME_TEMPLATE); if (mktemp (filename) == NULL) exit (1); @@ -205,6 +243,7 @@ check_ports () } } scm_dynwind_end (); +#undef FILENAME_TEMPLATE } void diff --git a/test-suite/tests/socket.test b/test-suite/tests/socket.test index f5fc2be89..4bfc41557 100644 --- a/test-suite/tests/socket.test +++ b/test-suite/tests/socket.test @@ -1,6 +1,6 @@ ;;;; socket.test --- test socket functions -*- scheme -*- ;;;; -;;;; Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +;;;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -174,6 +174,15 @@ ;;; AF_UNIX sockets and `make-socket-address' ;;; +(define (temp-file-path) + ;; Return a temporary file path that honors `$TMPDIR', which `tmpnam' + ;; doesn't do. + (let ((dir (or (getenv "TMPDIR") "/tmp"))) + (string-append dir "/guile-test-socket-" + (number->string (current-time)) "-" + (number->string (random 100000))))) + + (if (defined? 'AF_UNIX) (with-test-prefix "AF_UNIX/SOCK_DGRAM" @@ -181,7 +190,7 @@ (let ((server-socket (socket AF_UNIX SOCK_DGRAM 0)) (server-bound? #f) - (path (tmpnam))) + (path (temp-file-path))) (pass-if "bind" (catch 'system-error @@ -196,7 +205,7 @@ (pass-if "bind/sockaddr" (let* ((sock (socket AF_UNIX SOCK_STREAM 0)) - (path (tmpnam)) + (path (temp-file-path)) (sockaddr (make-socket-address AF_UNIX path))) (catch 'system-error (lambda () @@ -233,7 +242,7 @@ (server-bound? #f) (server-listening? #f) (server-pid #f) - (path (tmpnam))) + (path (temp-file-path))) (pass-if "bind" (catch 'system-error @@ -248,7 +257,7 @@ (pass-if "bind/sockaddr" (let* ((sock (socket AF_UNIX SOCK_STREAM 0)) - (path (tmpnam)) + (path (temp-file-path)) (sockaddr (make-socket-address AF_UNIX path))) (catch 'system-error (lambda () |