blob: 07eed53b08ce7de2403725710954cae36528fa2a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# shellcheck shell=bash disable=SC2034 # sourced by run-maint-scenarios.sh
# Scenario: a failed unit's state is reset.
#
# A transient oneshot that exits 1 lands in systemctl --failed; the remedy
# resets it and the failed list returns to its pre-break size. The unit name
# rides the remedy's item argument, exercising the priv verb's unit-name
# validation. The base image carries its own failed unit (grub-btrfsd — no
# snapshot dirs in the VM), so the assert scopes to this scenario's unit and
# the count delta, never the absolute failed list.
SCENARIO_DESC="failed unit reset clears the failed list"
SCENARIO_GROUP="systemd"
SCENARIO_PROFILES="any"
scenario_break() {
PRE_FAILED_COUNT=$(mexec "systemctl --failed --no-legend | wc -l") \
&& mexec "systemd-run --unit=maint-scenario-fail --service-type=oneshot --no-block /bin/false; sleep 2; systemctl is-failed maint-scenario-fail.service"
}
scenario_fix() {
mfix unit_reset maint-scenario-fail.service
}
scenario_assert() {
local pre="$PRE_FAILED_COUNT"
unset PRE_FAILED_COUNT # don't leak scenario state past this scenario
mexec "! systemctl is-failed maint-scenario-fail.service >/dev/null 2>&1" \
&& [ "$(mexec "systemctl --failed --no-legend | wc -l")" = "$pre" ]
}
|