summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-06-01 15:25:06 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-06-01 15:28:32 +0200
commit5f03c19f7bf10d989274b6e3fec1ef088a9514cf (patch)
tree79ba5cc239fb02de0bfc59b6479582ed483cd773
parenttest: sync journal in short-living services (diff)
downloadsystemd-5f03c19f7bf10d989274b6e3fec1ef088a9514cf.tar.xz
systemd-5f03c19f7bf10d989274b6e3fec1ef088a9514cf.zip
test: reduce number of 'systemctl daemon-reload' a bit
-rwxr-xr-xtest/units/TEST-04-JOURNAL.LogFilterPatterns.sh11
1 files changed, 9 insertions, 2 deletions
diff --git a/test/units/TEST-04-JOURNAL.LogFilterPatterns.sh b/test/units/TEST-04-JOURNAL.LogFilterPatterns.sh
index 04062bd76f..37fdd5f82b 100755
--- a/test/units/TEST-04-JOURNAL.LogFilterPatterns.sh
+++ b/test/units/TEST-04-JOURNAL.LogFilterPatterns.sh
@@ -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"