guix-commits
[Top][All Lists]
Advanced

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

[shepherd] 01/03: tests: Ensure log file is closed when service is stopp


From: Ludovic Courtès
Subject: [shepherd] 01/03: tests: Ensure log file is closed when service is stopped.
Date: Sun, 28 Aug 2022 11:33:57 -0400 (EDT)

civodul pushed a commit to branch master
in repository shepherd.

commit 9ac885273911c7a500e165adaf29c3c9d125d975
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Wed Jun 29 18:21:51 2022 +0200

    tests: Ensure log file is closed when service is stopped.
    
    * tests/logging.sh (find_file_descriptor): New function.
    Use it to check whether "$service_log" is closed after "herd stop
    test-file-logging".
---
 tests/logging.sh | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tests/logging.sh b/tests/logging.sh
index 6f96b3e..4d7a652 100644
--- a/tests/logging.sh
+++ b/tests/logging.sh
@@ -84,6 +84,26 @@ do
     grep -E '^2[0-9]{3}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} 
'"$message" "$service_log"
 done
 
+# Return the file descriptor corresponding to the given file.
+find_file_descriptor ()
+{
+    for fd in "/proc/$shepherd_pid/fd"/*
+    do
+       if [ "$(readlink $fd)" = "$1" ]
+       then
+           echo "$fd"
+           break
+       fi
+    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")"
+
 rm -f "$service_pid"
 $herd start test-builtin-logging
 for message in "STARTING" "STARTED" "café" "latin1 garbage: .* alors"



reply via email to

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