guix-commits
[Top][All Lists]
Advanced

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

[shepherd] 03/10: tests: Update for new 'register-services' interface.


From: Ludovic Courtès
Subject: [shepherd] 03/10: tests: Update for new 'register-services' interface.
Date: Thu, 27 Apr 2023 10:16:35 -0400 (EDT)

civodul pushed a commit to branch master
in repository shepherd.

commit 9526abcdfff05268e3e353aec56747735c1eda45
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Thu Apr 27 10:39:34 2023 +0200

    tests: Update for new 'register-services' interface.
    
    * tests/basic.sh, tests/close-on-exec.sh,
    tests/eval-load.sh, tests/file-creation-mask.sh,
    tests/forking-service.sh, tests/inetd.sh,
    tests/logging.sh, tests/one-shot.sh,
    tests/pid-file.sh, tests/replacement.sh,
    tests/respawn-throttling.sh, tests/respawn.sh,
    tests/restart.sh, tests/services/monitoring.sh,
    tests/services/repl.sh, tests/signals.sh,
    tests/starting-status.sh, tests/startup-failure.sh,
    tests/status-sexp.sh, tests/stopping-status.sh,
    tests/system-star.sh, tests/systemd.sh,
    tests/transient.sh: Pass 'register-services' a list.
---
 tests/basic.sh               | 70 +++++++++++++++++++--------------------
 tests/close-on-exec.sh       | 56 +++++++++++++++----------------
 tests/eval-load.sh           | 16 ++++-----
 tests/file-creation-mask.sh  | 18 +++++-----
 tests/forking-service.sh     | 57 ++++++++++++++++----------------
 tests/inetd.sh               | 79 ++++++++++++++++++++++----------------------
 tests/logging.sh             | 32 +++++++++---------
 tests/one-shot.sh            | 78 +++++++++++++++++++++----------------------
 tests/pid-file.sh            | 67 +++++++++++++++++++------------------
 tests/replacement.sh         | 36 ++++++++++----------
 tests/respawn-throttling.sh  | 12 +++----
 tests/respawn.sh             | 37 +++++++++++----------
 tests/restart.sh             | 30 ++++++++---------
 tests/services/monitoring.sh |  2 +-
 tests/services/repl.sh       |  4 +--
 tests/signals.sh             | 18 +++++-----
 tests/starting-status.sh     | 24 +++++++-------
 tests/startup-failure.sh     | 10 +++---
 tests/status-sexp.sh         | 26 +++++++--------
 tests/stopping-status.sh     | 28 ++++++++--------
 tests/system-star.sh         | 54 +++++++++++++++---------------
 tests/systemd.sh             | 20 +++++------
 tests/transient.sh           | 18 +++++-----
 23 files changed, 398 insertions(+), 394 deletions(-)

diff --git a/tests/basic.sh b/tests/basic.sh
index 04f37c4..ce8aa57 100644
--- a/tests/basic.sh
+++ b/tests/basic.sh
@@ -37,41 +37,41 @@ trap "cat $log || true; rm -f $socket $conf $stamp $log;
 cat > "$conf"<<EOF
 (use-modules (srfi srfi-26))
 (register-services
- (service
-   '(test)
-   #:start (lambda _
-             (call-with-output-file "$stamp"
-               (cut display "foo" <>))
-             #t)
-   #:stop  (lambda _
-             (delete-file "$stamp"))
-   #:respawn? #f)
- (service
-   '(test-2)
-   #:requirement '(test)
-   #:start (lambda _
-             (call-with-output-file "$stamp-2"
-               (cut display "bar" <>))
-             #t)
-   #:stop  (lambda _
-             (delete-file "$stamp-2"))
-   #:actions (actions (hi "Say hi."
-                          (lambda _
-                            (display "start\n\nend\n")
-                            #t))
-                      (fail "Fail." (const #f)))
-   #:respawn? #f)
- (service
-   '(spawn-with-system)
-   #:start (make-system-constructor "echo starting from $PWD")
-   #:stop (make-system-destructor "echo stopping from $PWD"))
- (service
-   '(broken)
-   #:requirement '()
-   #:start (lambda _
-             (mkdir "/this/throws/a/system/error"))
-   #:stop  (const #f)
-   #:respawn? #f))
+ (list (service
+        '(test)
+        #:start (lambda _
+                  (call-with-output-file "$stamp"
+                    (cut display "foo" <>))
+                  #t)
+        #:stop  (lambda _
+                  (delete-file "$stamp"))
+        #:respawn? #f)
+       (service
+        '(test-2)
+        #:requirement '(test)
+        #:start (lambda _
+                  (call-with-output-file "$stamp-2"
+                    (cut display "bar" <>))
+                  #t)
+        #:stop  (lambda _
+                  (delete-file "$stamp-2"))
+        #:actions (actions (hi "Say hi."
+                               (lambda _
+                                 (display "start\n\nend\n")
+                                 #t))
+                           (fail "Fail." (const #f)))
+        #:respawn? #f)
+       (service
+        '(spawn-with-system)
+        #:start (make-system-constructor "echo starting from $PWD")
+        #:stop (make-system-destructor "echo stopping from $PWD"))
+       (service
+        '(broken)
+        #:requirement '()
+        #:start (lambda _
+                  (mkdir "/this/throws/a/system/error"))
+        #:stop  (const #f)
+        #:respawn? #f)))
 EOF
 
 rm -f "$pid"
diff --git a/tests/close-on-exec.sh b/tests/close-on-exec.sh
index 62e82fa..6c625db 100644
--- a/tests/close-on-exec.sh
+++ b/tests/close-on-exec.sh
@@ -1,5 +1,5 @@
 # GNU Shepherd --- Ensure file descriptors are not leaked to children.
-# Copyright © 2022 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2022, 2023 Ludovic Courtès <ludo@gnu.org>
 #
 # This file is part of the GNU Shepherd.
 #
@@ -82,33 +82,33 @@ EOF
 
 cat > "$conf" <<EOF
 (register-services
- (service
-   '(system-ctor)
-   #:start (make-system-constructor "$exe")
-   #:stop  (const #f)
-   #:one-shot? #t)
- (service
-   '(forkexec-ctor)
-   #:start (make-forkexec-constructor '("$(type -P sleep)" "100"))
-   #:stop (make-kill-destructor))
- (service
-   '(inetd-ctor)
-   #:start (make-inetd-constructor '("$exe")
-                                   (list
-                                    (endpoint (make-socket-address
-                                               AF_INET
-                                               INADDR_LOOPBACK
-                                               5555))))
-   #:stop  (make-inetd-destructor))
- (service
-   '(systemd-ctor)
-   #:start (make-systemd-constructor '("$exe")
-                                    (list
-                                     (endpoint (make-socket-address
-                                                AF_INET
-                                                INADDR_LOOPBACK
-                                                5556))))
-   #:stop  (make-systemd-destructor)))
+ (list (service
+        '(system-ctor)
+        #:start (make-system-constructor "$exe")
+        #:stop  (const #f)
+        #:one-shot? #t)
+       (service
+        '(forkexec-ctor)
+        #:start (make-forkexec-constructor '("$(type -P sleep)" "100"))
+        #:stop (make-kill-destructor))
+       (service
+        '(inetd-ctor)
+        #:start (make-inetd-constructor '("$exe")
+                                        (list
+                                         (endpoint (make-socket-address
+                                                    AF_INET
+                                                    INADDR_LOOPBACK
+                                                    5555))))
+        #:stop  (make-inetd-destructor))
+       (service
+        '(systemd-ctor)
+        #:start (make-systemd-constructor '("$exe")
+                                          (list
+                                           (endpoint (make-socket-address
+                                                      AF_INET
+                                                      INADDR_LOOPBACK
+                                                      5556))))
+        #:stop  (make-systemd-destructor))))
 EOF
 
 rm -f "$pid" "$fd_count"
diff --git a/tests/eval-load.sh b/tests/eval-load.sh
index a367e0b..0ac78bf 100755
--- a/tests/eval-load.sh
+++ b/tests/eval-load.sh
@@ -31,14 +31,14 @@ trap "rm -f $socket $conf $log;
 
 cat > "$conf" <<EOF
 (register-services
- (service
-   '(a)
-   #:start (const #t)
-   #:respawn? #f)
- (service
-   '(b)
-   #:start (const #t)
-   #:respawn? #f))
+ (list (service
+        '(a)
+        #:start (const #t)
+        #:respawn? #f)
+       (service
+        '(b)
+        #:start (const #t)
+        #:respawn? #f)))
 EOF
 
 rm -f "$pid" "$socket"
diff --git a/tests/file-creation-mask.sh b/tests/file-creation-mask.sh
index 372e9fc..85fa310 100644
--- a/tests/file-creation-mask.sh
+++ b/tests/file-creation-mask.sh
@@ -48,15 +48,15 @@ cat > "$conf"<<EOF
   '("$SHELL" "-c" "touch $PWD/$service_new_file; echo foo"))
 
 (register-services
- (service
-   '(test)
-   #:start (make-forkexec-constructor %command
-                                      #:log-file "$PWD/$service_log"
-                                      ;; Set the umask such that file
-                                      ;; permissions are #o600.
-                                      #:file-creation-mask #o177)
-   #:stop (make-kill-destructor)
-   #:respawn? #f))
+ (list (service
+        '(test)
+        #:start (make-forkexec-constructor %command
+                                           #:log-file "$PWD/$service_log"
+                                           ;; Set the umask such that file
+                                           ;; permissions are #o600.
+                                           #:file-creation-mask #o177)
+        #:stop (make-kill-destructor)
+        #:respawn? #f)))
 EOF
 
 rm -f "$pid"
diff --git a/tests/forking-service.sh b/tests/forking-service.sh
index 77dbdd6..1bf4c3c 100644
--- a/tests/forking-service.sh
+++ b/tests/forking-service.sh
@@ -1,5 +1,5 @@
 # GNU Shepherd --- Test detecting a forked process' termination
-# Copyright © 2016, 2020, 2022 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2016, 2020, 2022, 2023 Ludovic Courtès <ludo@gnu.org>
 # Copyright © 2018 Carlo Zancanaro <carlo@zancanaro.id.au>
 #
 # This file is part of the GNU Shepherd.
@@ -53,48 +53,49 @@ cat > "$conf"<<EOF
   '("$SHELL" "-c" "ulimit -n >$PWD/$service_nofiles; sleep 600 & echo \$! > 
$PWD/$service_pid"))
 
 (register-services
- (service
-   ;; A service that forks into a different process.
-   '(test)
-   #:start (make-forkexec-constructor %command
-                                      #:pid-file "$PWD/$service_pid"
-                                      #:resource-limits '((nofile 1567 1567)))
-   #:stop  (make-kill-destructor)
-   #:respawn? #f))
+ (list (service
+        ;; A service that forks into a different process.
+        '(test)
+        #:start (make-forkexec-constructor
+                   %command
+                   #:pid-file "$PWD/$service_pid"
+                   #:resource-limits '((nofile 1567 1567)))
+        #:stop  (make-kill-destructor)
+        #:respawn? #f)))
 
 (define %command2
   '("$SHELL" "-c" "echo started >> $PWD/$service2_started; sleep 600 & echo 
\$! > $PWD/$service2_pid"))
 
 (register-services
- (service
-   ;; A service that forks into a different process.
-   '(test2)
-   #:start (make-forkexec-constructor %command2
-                                      #:pid-file "$PWD/$service2_pid")
-   #:stop  (make-kill-destructor)
-   #:respawn? #t))
+ (list (service
+        ;; A service that forks into a different process.
+        '(test2)
+        #:start (make-forkexec-constructor %command2
+                                           #:pid-file "$PWD/$service2_pid")
+        #:stop  (make-kill-destructor)
+        #:respawn? #t)))
 
 (define %command3
   '("$SHELL" "-c" "sleep 600"))
 
 (register-services
- (service
-   ;; A service that forks into a different process.
-   '(test3)
-   #:start (make-forkexec-constructor %command3)
-   #:stop  (make-kill-destructor)
-   #:respawn? #t))
+ (list (service
+        ;; A service that forks into a different process.
+        '(test3)
+        #:start (make-forkexec-constructor %command3)
+        #:stop  (make-kill-destructor)
+        #:respawn? #t)))
 
 (define %command4
   '("$SHELL" "-c" "trap 'echo ignoring SIGTERM' SIGTERM; while true ; do : ; 
done"))
 
 (register-services
- (service
-   ;; A service that ignores SIGTERM.
-   '(test4)
-   #:requirement '(test3)
-   #:start (make-forkexec-constructor %command4)
-   #:stop  (make-kill-destructor SIGTERM #:grace-period 3)))
+ (list (service
+        ;; A service that ignores SIGTERM.
+        '(test4)
+        #:requirement '(test3)
+        #:start (make-forkexec-constructor %command4)
+        #:stop  (make-kill-destructor SIGTERM #:grace-period 3))))
 EOF
 cat $conf
 
diff --git a/tests/inetd.sh b/tests/inetd.sh
index a1b463f..df2e6f1 100644
--- a/tests/inetd.sh
+++ b/tests/inetd.sh
@@ -39,45 +39,46 @@ cat > "$conf" <<EOF
   '("$SHELL" "-c" "echo hello; read line; echo \$line; echo done"))
 
 (register-services
- (service
-   '(test-inetd)
-   #:start (make-inetd-constructor %command
-                                   (list
-                                    (endpoint (make-socket-address
-                                               AF_INET
-                                               INADDR_LOOPBACK
-                                               $PORT))))
-   #:stop  (make-inetd-destructor))
- (service
-   '(test-inetd6)
-   #:start (make-inetd-constructor %command
-                                   (list
-                                    (endpoint (make-socket-address
-                                               AF_INET
-                                               INADDR_LOOPBACK
-                                               $PORT))
-                                    (endpoint (make-socket-address
-                                               AF_INET6
-                                               IN6ADDR_LOOPBACK
-                                               $PORT))))
-   #:stop  (make-inetd-destructor))
- (service
-   '(test-inetd-v6-only)
-   #:start (make-inetd-constructor %command
-                                   (list
-                                    (endpoint (make-socket-address
-                                               AF_INET6
-                                               IN6ADDR_LOOPBACK
-                                               $PORT))))
-   #:stop  (make-inetd-destructor))
- (service
-   '(test-inetd-unix)
-   #:start (make-inetd-constructor %command
-                                   (list
-                                    (endpoint (make-socket-address
-                                               AF_UNIX "$service_socket")))
-                                   #:max-connections 5)
-   #:stop  (make-inetd-destructor)))
+ (list
+  (service
+    '(test-inetd)
+    #:start (make-inetd-constructor %command
+                                   (list
+                                    (endpoint (make-socket-address
+                                               AF_INET
+                                               INADDR_LOOPBACK
+                                               $PORT))))
+    #:stop  (make-inetd-destructor))
+  (service
+    '(test-inetd6)
+    #:start (make-inetd-constructor %command
+                                   (list
+                                    (endpoint (make-socket-address
+                                               AF_INET
+                                               INADDR_LOOPBACK
+                                               $PORT))
+                                    (endpoint (make-socket-address
+                                               AF_INET6
+                                               IN6ADDR_LOOPBACK
+                                               $PORT))))
+    #:stop  (make-inetd-destructor))
+  (service
+    '(test-inetd-v6-only)
+    #:start (make-inetd-constructor %command
+                                   (list
+                                    (endpoint (make-socket-address
+                                               AF_INET6
+                                               IN6ADDR_LOOPBACK
+                                               $PORT))))
+    #:stop  (make-inetd-destructor))
+  (service
+    '(test-inetd-unix)
+    #:start (make-inetd-constructor %command
+                                   (list
+                                    (endpoint (make-socket-address
+                                               AF_UNIX "$service_socket")))
+                                   #:max-connections 5)
+    #:stop  (make-inetd-destructor))))
 
 (start-service (lookup-service 'test-inetd))
 EOF
diff --git a/tests/logging.sh b/tests/logging.sh
index 7f5a156..95384d5 100644
--- a/tests/logging.sh
+++ b/tests/logging.sh
@@ -48,22 +48,22 @@ cat > "$conf"<<EOF
   '("$SHELL" "$service_script"))
 
 (register-services
- (service
-   ;; Service with built-in logging.
-   '(test-builtin-logging)
-   #:start (make-forkexec-constructor %command
-                                      #:pid-file "$PWD/$service_pid")
-   #:stop  (make-kill-destructor)
-   #:respawn? #f)
-
- (service
-   ;; Service with built-in logging.
-   '(test-file-logging)
-   #:start (make-forkexec-constructor %command
-                                      #:log-file "$PWD/$service_log"
-                                      #:pid-file "$PWD/$service_pid")
-   #:stop  (make-kill-destructor)
-   #:respawn? #f))
+ (list (service
+        ;; Service with built-in logging.
+        '(test-builtin-logging)
+        #:start (make-forkexec-constructor %command
+                                           #:pid-file "$PWD/$service_pid")
+        #:stop  (make-kill-destructor)
+        #:respawn? #f)
+
+       (service
+        ;; Service with built-in logging.
+        '(test-file-logging)
+        #:start (make-forkexec-constructor %command
+                                           #:log-file "$PWD/$service_log"
+                                           #:pid-file "$PWD/$service_pid")
+        #:stop  (make-kill-destructor)
+        #:respawn? #f)))
 
 ;; Start it upfront to make sure the logging fiber works.
 (start-service (lookup-service 'test-file-logging))
diff --git a/tests/one-shot.sh b/tests/one-shot.sh
index 5b742c4..647b1a3 100644
--- a/tests/one-shot.sh
+++ b/tests/one-shot.sh
@@ -34,45 +34,45 @@ trap "cat $log || true; rm -f $socket $conf $stamp $log;
 cat > "$conf"<<EOF
 (use-modules (srfi srfi-26))
 (register-services
- (service
-   '(always-fail)
-   #:start (const #f)
-   #:one-shot? #t)
- (service
-   '(test)
-   #:start (lambda _
-             (call-with-output-file "$stamp"
-               (cut display "foo" <>))
-             #t)
-   #:one-shot? #t)
- (service
-   '(test-2)
-   #:requirement '(test)
-   #:start (lambda _
-             (call-with-output-file "$stamp-2"
-               (cut display "bar" <>))
-             #t)
-   #:stop  (lambda _
-             (delete-file "$stamp-2")
-             #f))
-
- ;; Several services depending on the same one-shot service.
- (service
-   '(one-shotty)
-   #:start (const #t)
-   #:one-shot? #t)
- (service
-   '(a)
-   #:requirement '(one-shotty)
-   #:start (const #t))
- (service
-   '(b)
-   #:requirement '(a one-shotty)
-   #:start (const #t))
- (service
-   '(c)
-   #:requirement '(a b one-shotty)
-   #:start (const #t)))
+ (list (service
+        '(always-fail)
+        #:start (const #f)
+        #:one-shot? #t)
+       (service
+        '(test)
+        #:start (lambda _
+                  (call-with-output-file "$stamp"
+                    (cut display "foo" <>))
+                  #t)
+        #:one-shot? #t)
+       (service
+        '(test-2)
+        #:requirement '(test)
+        #:start (lambda _
+                  (call-with-output-file "$stamp-2"
+                    (cut display "bar" <>))
+                  #t)
+        #:stop  (lambda _
+                  (delete-file "$stamp-2")
+                  #f))
+
+       ;; Several services depending on the same one-shot service.
+       (service
+        '(one-shotty)
+        #:start (const #t)
+        #:one-shot? #t)
+       (service
+        '(a)
+        #:requirement '(one-shotty)
+        #:start (const #t))
+       (service
+        '(b)
+        #:requirement '(a one-shotty)
+        #:start (const #t))
+       (service
+        '(c)
+        #:requirement '(a b one-shotty)
+        #:start (const #t))))
 
 (start-in-the-background '(a b c))
 EOF
diff --git a/tests/pid-file.sh b/tests/pid-file.sh
index 661ff97..b2d5bec 100644
--- a/tests/pid-file.sh
+++ b/tests/pid-file.sh
@@ -59,39 +59,40 @@ cat > "$conf"<<EOF
                         (sleep 100))))))
 
 (register-services
- (service
-   ;; A service that never produces its PID file, yet leaves a process
-   ;; behind it.
-   '(test)
-   #:start (make-forkexec-constructor %command
-                                      #:pid-file "/does-not-exist"
-
-                                      ;; Low-end ARMv7 machines are
-                                      ;; slow enough that creating
-                                      ;; $service_pid could take
-                                      ;; up to 4 seconds or so.
-                                      #:pid-file-timeout 6)
-   #:stop  (make-kill-destructor)
-   #:respawn? #f)
-
- (service
-   ;; Same one, but actually produces the PID file.
-   '(test-works)
-   #:start (make-forkexec-constructor %daemon-command-successful
-                                      #:pid-file "$PWD/$service_pid"
-                                      #:pid-file-timeout 6)
-   #:stop  (make-kill-destructor)
-   #:respawn? #f)
-
- (service
-   ;; This one "daemonizes", fails to create a PID file, but leaves
-   ;; a child process behind it.
-   '(test-daemonizes)
-   #:start (make-forkexec-constructor %daemon-command
-                                      #:pid-file "/does-not-exist"
-                                      #:pid-file-timeout 6)
-   #:stop  (make-kill-destructor)
-   #:respawn? #f))
+ (list
+  (service
+    ;; A service that never produces its PID file, yet leaves a process
+    ;; behind it.
+    '(test)
+    #:start (make-forkexec-constructor %command
+                                      #:pid-file "/does-not-exist"
+
+                                      ;; Low-end ARMv7 machines are
+                                      ;; slow enough that creating
+                                      ;; $service_pid could take
+                                      ;; up to 4 seconds or so.
+                                      #:pid-file-timeout 6)
+    #:stop  (make-kill-destructor)
+    #:respawn? #f)
+
+  (service
+    ;; Same one, but actually produces the PID file.
+    '(test-works)
+    #:start (make-forkexec-constructor %daemon-command-successful
+                                      #:pid-file "$PWD/$service_pid"
+                                      #:pid-file-timeout 6)
+    #:stop  (make-kill-destructor)
+    #:respawn? #f)
+
+  (service
+    ;; This one "daemonizes", fails to create a PID file, but leaves
+    ;; a child process behind it.
+    '(test-daemonizes)
+    #:start (make-forkexec-constructor %daemon-command
+                                      #:pid-file "/does-not-exist"
+                                      #:pid-file-timeout 6)
+    #:stop  (make-kill-destructor)
+    #:respawn? #f)))
 
 ;; Start it upfront.  This ensures the whole machinery works even
 ;; when called in a non-suspendable context (continuation barrier).
diff --git a/tests/replacement.sh b/tests/replacement.sh
index 21e3bc1..c4796e3 100644
--- a/tests/replacement.sh
+++ b/tests/replacement.sh
@@ -35,15 +35,15 @@ trap "rm -f $socket $conf $rconf $stamp $log;
 cat > "$conf"<<EOF
 (use-modules (srfi srfi-26))
 (register-services
- (service
-   '(test)
-   #:start (const #t)
-   #:actions (actions
-              (say-hello (lambda _
-                          (call-with-output-file "$stamp"
-                           (lambda (port)
-                            (display "Hello" port))))))
-   #:respawn? #f))
+ (list (service
+        '(test)
+        #:start (const #t)
+        #:actions (actions
+                   (say-hello (lambda _
+                               (call-with-output-file "$stamp"
+                                (lambda (port)
+                                 (display "Hello" port))))))
+        #:respawn? #f)))
 EOF
 
 rm -f "$pid" "$stamp" "$socket"
@@ -60,15 +60,15 @@ fi
 
 cat > "$rconf"<<EOF
 (register-services
- (service
-   '(test)
-   #:start (const #t)
-   #:actions (actions
-              (say-goodbye (lambda _
-                             (call-with-output-file "$stamp"
-                              (lambda (port)
-                                (display "Goodbye" port))))))
-   #:respawn? #f))
+ (list (service
+        '(test)
+        #:start (const #t)
+        #:actions (actions
+                   (say-goodbye (lambda _
+                                  (call-with-output-file "$stamp"
+                                   (lambda (port)
+                                     (display "Goodbye" port))))))
+        #:respawn? #f)))
 EOF
 
 $herd load root "$rconf"
diff --git a/tests/respawn-throttling.sh b/tests/respawn-throttling.sh
index c65762e..2cd169b 100644
--- a/tests/respawn-throttling.sh
+++ b/tests/respawn-throttling.sh
@@ -1,5 +1,5 @@
 # GNU Shepherd --- Test respawn throttling.
-# Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2016, 2023 Ludovic Courtès <ludo@gnu.org>
 #
 # This file is part of the GNU Shepherd.
 #
@@ -32,11 +32,11 @@ trap "cat $log || true ;
 
 cat > "$conf"<<EOF
 (register-services
- (service
-   '(keeps-respawning)
-   #:start (make-forkexec-constructor '("false"))
-   #:stop  (make-kill-destructor)
-   #:respawn? #t))
+ (list (service
+        '(keeps-respawning)
+        #:start (make-forkexec-constructor '("false"))
+        #:stop  (make-kill-destructor)
+        #:respawn? #t)))
 EOF
 
 rm -f "$pid"
diff --git a/tests/respawn.sh b/tests/respawn.sh
index b408977..28790a8 100644
--- a/tests/respawn.sh
+++ b/tests/respawn.sh
@@ -63,24 +63,25 @@ function assert_killed_service_is_respawned
 
 cat > "$conf"<<EOF
 (register-services
- (service
-   '(test1)
-   #:start (make-forkexec-constructor
-           '("$SHELL" "-c"
-             "echo \$\$ > $PWD/$service1_pid ; while true ; do sleep 1 ; 
done"))
-   #:stop  (make-kill-destructor)
-   #:respawn? #t)
- (service
-   '(test2)
-   #:start (make-forkexec-constructor
-            ;; The 'sleep' below is just to make it more likely
-            ;; that synchronization issues in handling #:pid-file
-            ;; would be caught.
-           '("$SHELL" "-c"
-             "sleep 0.7 ; echo \$\$ > $PWD/$service2_pid ; while true ; do 
sleep 1 ; done")
-            #:pid-file "$PWD/$service2_pid")
-   #:stop  (make-kill-destructor)
-   #:respawn? #t))
+ (list
+  (service
+    '(test1)
+    #:start (make-forkexec-constructor
+            '("$SHELL" "-c"
+              "echo \$\$ > $PWD/$service1_pid ; while true ; do sleep 1 ; 
done"))
+    #:stop  (make-kill-destructor)
+    #:respawn? #t)
+  (service
+    '(test2)
+    #:start (make-forkexec-constructor
+            ;; The 'sleep' below is just to make it more likely
+            ;; that synchronization issues in handling #:pid-file
+            ;; would be caught.
+            '("$SHELL" "-c"
+              "sleep 0.7 ; echo \$\$ > $PWD/$service2_pid ; while true ; do 
sleep 1 ; done")
+            #:pid-file "$PWD/$service2_pid")
+    #:stop  (make-kill-destructor)
+    #:respawn? #t)))
 (start-service (lookup-service 'test1))
 EOF
 
diff --git a/tests/restart.sh b/tests/restart.sh
index 836e43e..f2efaf4 100644
--- a/tests/restart.sh
+++ b/tests/restart.sh
@@ -1,5 +1,5 @@
 # GNU Shepherd --- Test restarting services.
-# Copyright © 2013, 2014, 2016 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2013, 2014, 2016, 2023 Ludovic Courtès <ludo@gnu.org>
 # Copyright © 2018 Carlo Zancanaro <carlo@zancanaro.id.au>
 #
 # This file is part of the GNU Shepherd.
@@ -33,20 +33,20 @@ trap "cat $log || true ;
 
 cat > "$conf"<<EOF
 (register-services
- (service
-   '(test1)
-   #:start (const #t)
-   #:stop  (const #t))
- (service
-   '(test2)
-   #:requirement '(test1)
-   #:start (const #t)
-   #:stop  (const #t))
- (service
-   '(test3)
-   #:requirement '(test2)
-   #:start (const #t)
-   #:stop  (const #t)))
+ (list (service
+        '(test1)
+        #:start (const #t)
+        #:stop  (const #t))
+       (service
+        '(test2)
+        #:requirement '(test1)
+        #:start (const #t)
+        #:stop  (const #t))
+       (service
+        '(test3)
+        #:requirement '(test2)
+        #:start (const #t)
+        #:stop  (const #t))))
 EOF
 
 rm -f "$pid"
diff --git a/tests/services/monitoring.sh b/tests/services/monitoring.sh
index 30c8c9d..80e1f47 100644
--- a/tests/services/monitoring.sh
+++ b/tests/services/monitoring.sh
@@ -33,7 +33,7 @@ trap "cat $log || true;
 cat > "$conf" <<EOF
 (use-modules (shepherd service monitoring))
 
-(register-services (monitoring-service))
+(register-services (list (monitoring-service)))
 EOF
 
 rm -f "$pid" "$log"
diff --git a/tests/services/repl.sh b/tests/services/repl.sh
index 09e25d1..8409c4e 100644
--- a/tests/services/repl.sh
+++ b/tests/services/repl.sh
@@ -34,7 +34,7 @@ trap "cat $log || true;
 cat > "$conf" <<EOF
 (use-modules (shepherd service repl))
 
-(register-services (repl-service "$repl_socket"))
+(register-services (list (repl-service "$repl_socket")))
 EOF
 
 rm -f "$pid" "$log" "$repl_socket"
@@ -101,7 +101,7 @@ guile -c '
    (object->string
     (quote (begin
              (use-modules (shepherd service) (shepherd service monitoring))
-             (register-services (monitoring-service #:period 2))
+             (register-services (list (monitoring-service #:period 2)))
              (start (quote monitoring)))))
    sock)
   (display ",q\n" sock)
diff --git a/tests/signals.sh b/tests/signals.sh
index 03907dc..02c2503 100644
--- a/tests/signals.sh
+++ b/tests/signals.sh
@@ -34,15 +34,15 @@ trap "rm -f $socket $conf $stamp $log;
 cat > "$conf"<<EOF
 (use-modules (srfi srfi-26))
 (register-services
- (service
-   '(test)
-   #:start (const #t)
-   #:stop  (lambda _
-             (call-with-output-file "$stamp"
-               (lambda (port)
-                 (display "stopped" port))))
-   #:respawn? #f))
- (start-service (lookup-service 'test))
+ (list (service
+        '(test)
+        #:start (const #t)
+        #:stop  (lambda _
+                  (call-with-output-file "$stamp"
+                    (lambda (port)
+                      (display "stopped" port))))
+        #:respawn? #f)))
+(start-service (lookup-service 'test))
 EOF
 
 for signal in INT TERM HUP; do
diff --git a/tests/starting-status.sh b/tests/starting-status.sh
index db7870b..e90aed6 100644
--- a/tests/starting-status.sh
+++ b/tests/starting-status.sh
@@ -34,18 +34,18 @@ trap "cat $log || true; rm -f $socket $conf $stamp $log;
 
 cat > "$conf" <<EOF
 (register-services
- (service
-   '(test)
-   #:start (lambda _
-             (let loop ((n 30))
-               (if (or (file-exists? "$stamp") (zero? n))
-                   (> n 0)
-                   (begin
-                     ((@ (fibers) sleep) 1)
-                     (loop (- n 1))))))
-   #:stop  (lambda _
-             (delete-file "$stamp"))
-   #:respawn? #f))
+ (list (service
+        '(test)
+        #:start (lambda _
+                  (let loop ((n 30))
+                    (if (or (file-exists? "$stamp") (zero? n))
+                        (> n 0)
+                        (begin
+                          ((@ (fibers) sleep) 1)
+                          (loop (- n 1))))))
+        #:stop  (lambda _
+                  (delete-file "$stamp"))
+        #:respawn? #f)))
 EOF
 
 rm -f "$pid" "$stamp"
diff --git a/tests/startup-failure.sh b/tests/startup-failure.sh
index a00be20..2c8d11a 100644
--- a/tests/startup-failure.sh
+++ b/tests/startup-failure.sh
@@ -32,11 +32,11 @@ trap "rm -f $socket $conf $log $stamp;
 
 cat > "$conf" <<EOF
 (register-services
- (service
-   '(may-fail)
-   #:start (lambda _
-             (file-exists? "$PWD/$stamp"))
-   #:respawn? #f))
+ (list (service
+        '(may-fail)
+        #:start (lambda _
+                  (file-exists? "$PWD/$stamp"))
+        #:respawn? #f)))
 EOF
 
 rm -f "$pid" "$stamp" "$socket"
diff --git a/tests/status-sexp.sh b/tests/status-sexp.sh
index ab7ac94..b7a16c2 100644
--- a/tests/status-sexp.sh
+++ b/tests/status-sexp.sh
@@ -31,19 +31,19 @@ trap "rm -f $socket $conf $stamp $log;
 
 cat > "$conf"<<EOF
 (register-services
- (service
-   '(foo)
-   #:start (const 'abc)
-   #:stop  (const #f)
-   #:documentation "Foo!"
-   #:respawn? #t)
- (service
-   '(bar)
-   #:requirement '(foo)
-   #:start (const 'up-and-running)
-   #:stop  (const #f)
-   #:documentation "Bar!"
-   #:respawn? #f))
+ (list (service
+        '(foo)
+        #:start (const 'abc)
+        #:stop  (const #f)
+        #:documentation "Foo!"
+        #:respawn? #t)
+       (service
+        '(bar)
+        #:requirement '(foo)
+        #:start (const 'up-and-running)
+        #:stop  (const #f)
+        #:documentation "Bar!"
+        #:respawn? #f)))
 
 (start-service (lookup-service 'foo))
 EOF
diff --git a/tests/stopping-status.sh b/tests/stopping-status.sh
index db248c2..1834a96 100644
--- a/tests/stopping-status.sh
+++ b/tests/stopping-status.sh
@@ -34,20 +34,20 @@ trap "cat $log || true; rm -f $socket $conf $stamp $log;
 
 cat > "$conf" <<EOF
 (register-services
- (service
-   '(test)
-   #:start (const #t)
-   #:stop  (lambda _
-             (let loop ((n 30))
-               (if (or (file-exists? "$stamp") (zero? n))
-                   (begin
-                     (delete-file "$stamp")
-                     (zero? n))   ;failure if N is zero
-                   (begin
-                     ((@ (fibers) sleep) 1)
-                     (loop (- n 1))))))
-
-   #:respawn? #f))
+ (list (service
+        '(test)
+        #:start (const #t)
+        #:stop  (lambda _
+                  (let loop ((n 30))
+                    (if (or (file-exists? "$stamp") (zero? n))
+                        (begin
+                          (delete-file "$stamp")
+                          (zero? n))   ;failure if N is zero
+                        (begin
+                          ((@ (fibers) sleep) 1)
+                          (loop (- n 1))))))
+
+        #:respawn? #f)))
 EOF
 
 rm -f "$pid" "$stamp"
diff --git a/tests/system-star.sh b/tests/system-star.sh
index 122aa30..b3cb933 100755
--- a/tests/system-star.sh
+++ b/tests/system-star.sh
@@ -34,33 +34,33 @@ script="while [ ! -f $PWD/$stamp ] ; do sleep 0.1 ; done ; 
exit \$(cat $PWD/$sta
 
 cat > "$conf" <<EOF
 (register-services
- (service
-   '(test)
-   #:start (lambda _
-             (list 'exit-code
-                   (status:exit-val
-                    (system* "$SHELL" "-c" "$script"))))
-   #:stop  (lambda _
-             (system* "$SHELL" "-c" "echo STOPPING")
-             (delete-file "$stamp"))
-   #:respawn? #f)
- (service
-   '(test-command-not-found)
-   #:start (lambda _
-             (zero? (system* "this command does not exist")))
-   #:stop  (const #f)
-   #:respawn? #f)
- (service
-   '(test-with-respawn)
-   #:start (make-forkexec-constructor
-             (list "$SHELL" "-cex"
-                   "[ ! -f $PWD/$stamp ] ; touch $PWD/$stamp ; sleep 60"))
-   #:stop  (lambda (pid)
-             (and (zero? (system* "$(type -P kill)" (number->string pid)))
-                  (begin
-                    (delete-file "$stamp")
-                    #f)))
-   #:respawn? #t))
+ (list (service
+        '(test)
+        #:start (lambda _
+                  (list 'exit-code
+                        (status:exit-val
+                         (system* "$SHELL" "-c" "$script"))))
+        #:stop  (lambda _
+                  (system* "$SHELL" "-c" "echo STOPPING")
+                  (delete-file "$stamp"))
+        #:respawn? #f)
+       (service
+        '(test-command-not-found)
+        #:start (lambda _
+                  (zero? (system* "this command does not exist")))
+        #:stop  (const #f)
+        #:respawn? #f)
+       (service
+        '(test-with-respawn)
+        #:start (make-forkexec-constructor
+                  (list "$SHELL" "-cex"
+                        "[ ! -f $PWD/$stamp ] ; touch $PWD/$stamp ; sleep 60"))
+        #:stop  (lambda (pid)
+                  (and (zero? (system* "$(type -P kill)" (number->string pid)))
+                       (begin
+                         (delete-file "$stamp")
+                         #f)))
+        #:respawn? #t)))
 EOF
 
 rm -f "$pid"
diff --git a/tests/systemd.sh b/tests/systemd.sh
index c485aef..4346252 100644
--- a/tests/systemd.sh
+++ b/tests/systemd.sh
@@ -59,16 +59,16 @@ cat > "$conf" <<EOF
   (list (endpoint (make-socket-address AF_UNIX "$service_socket"))))
 
 (register-services
- (service
-   '(test-systemd-unix)
-   #:start (make-systemd-constructor %command %endpoints)
-   #:stop  (make-systemd-destructor)
-   #:respawn? #t)
- (service
-   '(test-systemd-unix-eager)
-   #:start (make-systemd-constructor %command %endpoints
-                                     #:lazy-start? #f)
-   #:stop  (make-systemd-destructor)))
+ (list (service
+        '(test-systemd-unix)
+        #:start (make-systemd-constructor %command %endpoints)
+        #:stop  (make-systemd-destructor)
+        #:respawn? #t)
+       (service
+        '(test-systemd-unix-eager)
+        #:start (make-systemd-constructor %command %endpoints
+                                          #:lazy-start? #f)
+        #:stop  (make-systemd-destructor))))
 EOF
 
 rm -f "$pid"
diff --git a/tests/transient.sh b/tests/transient.sh
index ae48fb2..50434c9 100644
--- a/tests/transient.sh
+++ b/tests/transient.sh
@@ -1,5 +1,5 @@
 # GNU Shepherd --- Test transient services.
-# Copyright © 2022 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2022, 2023 Ludovic Courtès <ludo@gnu.org>
 #
 # This file is part of the GNU Shepherd.
 #
@@ -31,14 +31,14 @@ trap "cat $log || true; rm -f $socket $conf $log;
 
 cat > "$conf"<<EOF
 (register-services
- (service
-   '(transient-test1)
-   #:start (make-forkexec-constructor '("sleep" "600"))
-   #:transient? #t)
- (service
-   '(transient-test2)
-   #:start (make-forkexec-constructor '("sleep" "600"))
-   #:transient? #t))
+ (list (service
+        '(transient-test1)
+        #:start (make-forkexec-constructor '("sleep" "600"))
+        #:transient? #t)
+       (service
+        '(transient-test2)
+        #:start (make-forkexec-constructor '("sleep" "600"))
+        #:transient? #t)))
 EOF
 
 rm -f "$pid"



reply via email to

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