From 5411e043d0dd258a3724c8c5e3351944b91c543b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 18 Nov 2009 15:28:56 +0100 Subject: [PATCH] Work around path name length limitations in `socket.test'. * test-suite/tests/socket.test (%tmpdir, %curdir): New variables. Chdir to %TMPDIR. Switch back to %CURDIR at the end. (temp-file-path): Return a base file name, not an absolute path. --- test-suite/tests/socket.test | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/test-suite/tests/socket.test b/test-suite/tests/socket.test index 5b738fdc9..e73f58510 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, 2008 Free Software Foundation, Inc. +;;;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 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,13 +174,28 @@ ;;; AF_UNIX sockets and `make-socket-address' ;;; +(define %tmpdir + ;; Honor `$TMPDIR', which tmpnam(3) doesn't do. + (or (getenv "TMPDIR") "/tmp")) + +(define %curdir + ;; Remember the current working directory. + (getcwd)) + +;; Temporarily cd to %TMPDIR. The goal is to work around path name +;; limitations, which can lead to exceptions like: +;; +;; (misc-error "scm_to_sockaddr" +;; "unix address path too long: ~A" +;; ("/tmp/nix-build-fb7bph4ifh0vr3ihigm702dzffdnapfj-guile-coverage-1.9.5.drv-0/guile-test-socket-1258553296-77619") +;; #f) +(chdir %tmpdir) + (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))))) + ;; Return a temporary file name, assuming the current directory is %TMPDIR. + (string-append "guile-test-socket-" + (number->string (current-time)) "-" + (number->string (random 100000)))) (if (defined? 'AF_UNIX) @@ -404,4 +419,7 @@ (let ((status (cdr (waitpid server-pid)))) (eq? 0 (status:exit-val status))))) - #t))) \ No newline at end of file + #t))) + +;; Switch back to the previous directory. +(false-if-exception (chdir %curdir))