From: Frantisek Sumsal Date: Tue, 22 Jun 2021 10:12:34 +0000 (+0200) Subject: test: ignore the "freezing" & "thawing" intermediate states X-Git-Tag: v249-rc2~27^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=907300c3c3db0940964dd511f9744529226a69a2;p=thirdparty%2Fsystemd.git 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 ``` --- diff --git a/test/units/testsuite-38.sh b/test/units/testsuite-38.sh index 818f69bc635..e58bae81fec 100755 --- a/test/units/testsuite-38.sh +++ b/test/units/testsuite-38.sh @@ -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