summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2009-11-18 15:28:56 +0100
committerLudovic Courtès <ludo@gnu.org>2009-11-26 10:17:05 +0100
commit5411e043d0dd258a3724c8c5e3351944b91c543b (patch)
tree1e77f9e171c526c78aade5318f22a03a301344bd
parenta0f8a73f283ca8e5532090a137c95546836ddd4d (diff)
downloadguile-5411e043d0dd258a3724c8c5e3351944b91c543b.tar.gz
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.
-rw-r--r--test-suite/tests/socket.test34
1 files 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))