[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 04/04: tests: Test behavior when loading the config file thro
From: |
Ludovic Courtès |
Subject: |
[shepherd] 04/04: tests: Test behavior when loading the config file throws. |
Date: |
Thu, 23 May 2024 17:26:15 -0400 (EDT) |
civodul pushed a commit to branch devel
in repository shepherd.
commit 73662b700889defd963c9c3b38a96a06c37052e0
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Thu May 23 22:50:25 2024 +0200
tests: Test behavior when loading the config file throws.
* tests/config-failure.sh: Add test.
---
tests/config-failure.sh | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/tests/config-failure.sh b/tests/config-failure.sh
index 1cea2ad..7453447 100644
--- a/tests/config-failure.sh
+++ b/tests/config-failure.sh
@@ -1,5 +1,5 @@
# GNU Shepherd --- Test shepherd behavior when config file errors out.
-# Copyright © 2023 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2023-2024 Ludovic Courtès <ludo@gnu.org>
#
# This file is part of the GNU Shepherd.
#
@@ -75,3 +75,22 @@ $herd stop root
while kill -0 "$shepherd_pid" ; do sleep 0.3 ; done
if kill -0 "$(cat "$child_pid")"; then false; else true; fi
+
+# Bogus configuration that throws when it's loaded.
+cat > "$conf" <<EOF
+this-is-an-unbound-variable
+EOF
+
+rm -f "$pid" "$stamp" "$log"
+shepherd -I -s "$socket" -c "$conf" -l "$log" --pid="$pid" &
+
+until test -f "$pid"; do sleep 0.3; done
+shepherd_pid="$(cat $pid)"
+until grep "While loading configuration.* this-is-an-unbound-variable" "$log";
+do sleep 0.3; done
+
+# It should still be possible to communicate with shepherd.
+$herd status
+$herd stop root
+
+while kill -0 "$shepherd_pid" ; do sleep 0.3 ; done