1
0
mirror of https://github.com/systemd/systemd synced 2025-11-21 17:54:46 +01:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Frantisek Sumsal
0cb252d50f test: store and compare just the property value
Follow-up for 5730a400fd5ee82566fe03eb832121a0d4bc26b6.
2025-09-29 23:01:24 +02:00
Yu Watanabe
2c883d7591 units: move FailureAction= to the correct section
FailureAction= in [Service] is still supported but deprecated.

Follow-up for e3d4148d50909119c4e9327e6ad96d3ca7f4661a.
2025-09-29 22:47:24 +02:00
2 changed files with 7 additions and 7 deletions

View File

@ -45,15 +45,15 @@ assert_eq "$(journalctl -q -p info --since="@$JOURNAL_TS" --unit="$UNIT_NAME" --
# Restarting the timer unit shouldn't trigger neither the timer nor the service, so these # Restarting the timer unit shouldn't trigger neither the timer nor the service, so these
# fields should remain constant through the following tests # fields should remain constant through the following tests
SERVICE_INV_ID="$(systemctl show --property=InvocationID "$UNIT_NAME.service")" SERVICE_INV_ID="$(systemctl show -P InvocationID "$UNIT_NAME.service")"
TIMER_LAST_TRIGGER="$(systemctl show --property=LastTriggerUSec "$UNIT_NAME.timer")" TIMER_LAST_TRIGGER="$(systemctl show -P LastTriggerUSec "$UNIT_NAME.timer")"
# Now restart the timer and check if the timer and the service weren't triggered again # Now restart the timer and check if the timer and the service weren't triggered again
systemctl restart "$UNIT_NAME.timer" systemctl restart "$UNIT_NAME.timer"
sleep 5 sleep 5
assert_eq "$(journalctl -q -p info --since="@$JOURNAL_TS" --unit="$UNIT_NAME" --grep="$TEST_MESSAGE" | wc -l)" "1" assert_eq "$(journalctl -q -p info --since="@$JOURNAL_TS" --unit="$UNIT_NAME" --grep="$TEST_MESSAGE" | wc -l)" "1"
assert_eq "$SERVICE_INV_ID" "$(systemctl show --property=InvocationID "$UNIT_NAME.service")" assert_eq "$SERVICE_INV_ID" "$(systemctl show -P InvocationID "$UNIT_NAME.service")"
assert_eq "$TIMER_LAST_TRIGGER" "$(systemctl show --property=LastTriggerUSec "$UNIT_NAME.timer")" assert_eq "$TIMER_LAST_TRIGGER" "$(systemctl show -P LastTriggerUSec "$UNIT_NAME.timer")"
# Set the timer into the past, restart it, and again check if it wasn't triggered # Set the timer into the past, restart it, and again check if it wasn't triggered
TIMER_TS="$(date --date="-1 day" "+%Y-%m-%d %H:%M:%S")" TIMER_TS="$(date --date="-1 day" "+%Y-%m-%d %H:%M:%S")"
@ -68,8 +68,8 @@ assert_in "OnCalendar=$TIMER_TS" "$(systemctl show -P TimersCalendar "$UNIT_NAME
systemctl restart "$UNIT_NAME.timer" systemctl restart "$UNIT_NAME.timer"
sleep 5 sleep 5
assert_eq "$(journalctl -q -p info --since="@$JOURNAL_TS" --unit="$UNIT_NAME" --grep="$TEST_MESSAGE" | wc -l)" "1" assert_eq "$(journalctl -q -p info --since="@$JOURNAL_TS" --unit="$UNIT_NAME" --grep="$TEST_MESSAGE" | wc -l)" "1"
assert_eq "$SERVICE_INV_ID" "$(systemctl show --property=InvocationID "$UNIT_NAME.service")" assert_eq "$SERVICE_INV_ID" "$(systemctl show -P InvocationID "$UNIT_NAME.service")"
assert_eq "$TIMER_LAST_TRIGGER" "$(systemctl show --property=LastTriggerUSec "$UNIT_NAME.timer")" assert_eq "$TIMER_LAST_TRIGGER" "$(systemctl show -P LastTriggerUSec "$UNIT_NAME.timer")"
# Cleanup # Cleanup
systemctl stop "$UNIT_NAME".{timer,service} systemctl stop "$UNIT_NAME".{timer,service}

View File

@ -18,9 +18,9 @@ AssertPathExists=/etc/initrd-release
DefaultDependencies=no DefaultDependencies=no
After=plymouth-start.service After=plymouth-start.service
Before=initrd-root-device.target systemd-hibernate-resume.service Before=initrd-root-device.target systemd-hibernate-resume.service
FailureAction=poweroff-force
[Service] [Service]
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
ExecStart={{LIBEXECDIR}}/systemd-battery-check ExecStart={{LIBEXECDIR}}/systemd-battery-check
FailureAction=poweroff-force