mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
test: add basic test for timer serialization
Set an OnCalendar= timer before the downgrade, then test for its validity after the downgrade and the upgrade.
This commit is contained in:
committed by
Luca Boccassi
parent
ad6e02e7b4
commit
9b31b3d5ee
@@ -28,7 +28,7 @@ if [[ $($unitscmd --output json | jq length) -gt 0 ]]; then
|
||||
fi
|
||||
|
||||
check_sd() {
|
||||
local unit fail=0
|
||||
local unit fail=0 timer1_new timer2_new
|
||||
for unit in $($unitscmd --output json | jq -r '.[].unit'); do
|
||||
if ! grep -sxqF "$unit" /tmp/failed-units; then
|
||||
fail=1
|
||||
@@ -52,12 +52,33 @@ check_sd() {
|
||||
fail=1
|
||||
fi
|
||||
|
||||
# ignore the systemctl status error code until we sort out
|
||||
# https://github.com/systemd/systemd/issues/38214
|
||||
systemctl status upgrade_timer_test.{service,timer} || true
|
||||
timer1_new=$(systemctl show -P TimersCalendar upgrade_timer_test.timer)
|
||||
timer2_new=$(systemctl show -P NextElapseUSecRealtime upgrade_timer_test.timer)
|
||||
|
||||
if [[ "$timer1" != "$timer1_new" ]]; then
|
||||
echo "Timer changed unexpectedly: '$timer1' != '$timer1_new'"
|
||||
fail=1
|
||||
fi
|
||||
if [[ "$timer2" != "$timer2_new" ]]; then
|
||||
echo "Timer changed unexpectedly: '$timer2' != '$timer2_new'"
|
||||
fail=1
|
||||
fi
|
||||
|
||||
[[ $fail -eq 0 ]]
|
||||
}
|
||||
|
||||
# Copy the unit in /run so systemd finds it after the downgrade
|
||||
cp /usr/lib/systemd/tests/testdata/units/TEST-88-UPGRADE.service /run/systemd/system
|
||||
|
||||
now=$(date +%s)
|
||||
after_2h=$((now + 3600 * 2))
|
||||
systemd-run --on-calendar="@$after_2h" -u upgrade_timer_test date
|
||||
timer1=$(systemctl show -P TimersCalendar upgrade_timer_test.timer)
|
||||
timer2=$(systemctl show -P NextElapseUSecRealtime upgrade_timer_test.timer)
|
||||
|
||||
dnf downgrade -y --allowerasing --disablerepo '*' "$pkgdir"/distro/*.rpm
|
||||
|
||||
# Some distros don't ship networkd, so the test will always fail
|
||||
|
||||
Reference in New Issue
Block a user