]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: reduce number of 'systemctl daemon-reload' a bit
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 1 Jun 2024 13:25:06 +0000 (22:25 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 1 Jun 2024 13:28:32 +0000 (22:28 +0900)
test/units/TEST-04-JOURNAL.LogFilterPatterns.sh

index 04062bd76f729cd4ba7c57ce7d732b9c2d0319cd..37fdd5f82bdccb5995f47ae89907f747b4b8bf27 100755 (executable)
@@ -4,7 +4,9 @@ set -eux
 set -o pipefail
 
 # shellcheck source=test/units/util.sh
- . "$(dirname "$0")"/util.sh
+. "$(dirname "$0")"/util.sh
+
+NEEDS_RELOAD=
 
 add_logs_filtering_override() {
     local unit="${1:?}"
@@ -13,13 +15,18 @@ add_logs_filtering_override() {
 
     mkdir -p "/run/systemd/system/$unit.d/"
     echo -ne "[Service]\nLogFilterPatterns=$log_filter" >"/run/systemd/system/$unit.d/$override_name.conf"
-    systemctl daemon-reload
+    NEEDS_RELOAD=1
 }
 
 run_service_and_fetch_logs() {
     local unit="${1:?}"
     local start
 
+    if [[ -n "$NEEDS_RELOAD" ]]; then
+        systemctl daemon-reload
+        NEEDS_RELOAD=
+    fi
+
     journalctl --sync
     start="$(date '+%Y-%m-%d %T.%6N')"
     systemctl start "$unit"