guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[shepherd] 01/06: tests: Check whether /proc/*/fd exists before relying


From: Ludovic Courtès
Subject: [shepherd] 01/06: tests: Check whether /proc/*/fd exists before relying on it.
Date: Mon, 1 Jan 2024 17:38:52 -0500 (EST)

civodul pushed a commit to branch main
in repository shepherd.

commit 39cef207068b67ad1d47717391929e4c8812dd39
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sun Dec 31 20:46:31 2023 +0100

    tests: Check whether /proc/*/fd exists before relying on it.
    
    /proc is optional on GNU/Hurd and does not expose as much as its Linux
    counterpart.
    
    * tests/inetd.sh, tests/logging.sh: Adjust accordingly.
---
 tests/inetd.sh   |  9 ++++++---
 tests/logging.sh | 19 +++++++++++++------
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/tests/inetd.sh b/tests/inetd.sh
index 2affb71..5f89742 100644
--- a/tests/inetd.sh
+++ b/tests/inetd.sh
@@ -228,6 +228,9 @@ $herd stop test-inetd-unix
 grep "is in use" "$log"
 $herd status
 
-# At this point, shepherd should have INITIAL_FD_COUNT - 1 file descriptors
-# opened.
-test $(file_descriptor_count) -lt $initial_fd_count
+if test -d "/proc/$$/fd"       # GNU/Hurd lacks /proc/*/fd.
+then
+    # At this point, shepherd should have INITIAL_FD_COUNT - 1 file
+    # descriptors opened.
+    test $(file_descriptor_count) -lt $initial_fd_count
+fi
diff --git a/tests/logging.sh b/tests/logging.sh
index 961e5b5..fcbfe71 100644
--- a/tests/logging.sh
+++ b/tests/logging.sh
@@ -99,12 +99,19 @@ find_file_descriptor ()
     done
 }
 
-# At this point, the log file is open.
-test -n "$(find_file_descriptor "$PWD/$service_log")"
-
-# Stop the service and ensure the log file has been closed.
-$herd stop test-file-logging
-test -z "$(find_file_descriptor "$PWD/$service_log")"
+if test -d "/proc/$$/fd"
+then
+    # At this point, the log file is open.
+    test -n "$(find_file_descriptor "$PWD/$service_log")"
+
+    # Stop the service and ensure the log file has been closed.
+    $herd stop test-file-logging
+    test -z "$(find_file_descriptor "$PWD/$service_log")"
+else
+    # On GNU/Hurd, /proc, when mounted, does not expose as much information as
+    # that of Linux; it lacks the 'fd' sub-directory.
+    echo "cannot inspect open file descriptors; skipping" >&2
+fi
 
 rm -f "$service_pid"
 $herd start test-builtin-logging



reply via email to

[Prev in Thread] Current Thread [Next in Thread]