mirror of
https://github.com/systemd/systemd.git
synced 2024-11-27 12:13:33 +08:00
test: ignore the "freezing" & "thawing" intermediate states
When checking the unit state after `systemctl freeze|thaw` we can be "too fast" and get the intermediate state (freezing/thawing) which we're not interested in. Let's wait a bit and try to get the state again in such cases to avoid unnecessary flakiness. ``` [ 29.390203] testsuite-38.sh[218]: + state=thawing [ 29.390203] testsuite-38.sh[218]: + '[' thawing = running ']' [ 29.390203] testsuite-38.sh[218]: + echo 'error: unexpected freezer state, expected: running, actual: thawing' [ 29.390203] testsuite-38.sh[218]: error: unexpected freezer state, expected: running, actual: thawing [ 29.390203] testsuite-38.sh[218]: + exit 1 ```
This commit is contained in:
parent
b5ce2feebc
commit
907300c3c3
@ -82,11 +82,18 @@ check_freezer_state() {
|
||||
name="${1%.$suffix}"
|
||||
object_path="/org/freedesktop/systemd1/unit/${name//-/_2d}_2e${suffix}"
|
||||
|
||||
state=$(busctl get-property \
|
||||
org.freedesktop.systemd1 \
|
||||
"${object_path}" \
|
||||
org.freedesktop.systemd1.Unit \
|
||||
FreezerState | cut -d " " -f2 | tr -d '"')
|
||||
for _ in {0..10}; do
|
||||
state=$(busctl get-property \
|
||||
org.freedesktop.systemd1 \
|
||||
"${object_path}" \
|
||||
org.freedesktop.systemd1.Unit \
|
||||
FreezerState | cut -d " " -f2 | tr -d '"')
|
||||
|
||||
# Ignore the intermediate freezing & thawing states in case we check
|
||||
# the unit state too quickly
|
||||
[[ "$state" =~ ^(freezing|thawing)$ ]] || break
|
||||
sleep .5
|
||||
done
|
||||
|
||||
[ "$state" = "$2" ] || {
|
||||
echo "error: unexpected freezer state, expected: $2, actual: $state" >&2
|
||||
|
Loading…
Reference in New Issue
Block a user