is-active return code isn't the correct way to verify a service is
fully stopped; instead use show --property=ActiveState to verify it
is 'inactive'
This also could use the text output of is-active, but (per manpage)
the show command is "intended to be used whenever computer-parsable
output is required."
systemctl is-active returns non-zero even while the service is
'deactivating', but not actually stopped, which allows the testcase
to fail intermittently on slow machines, if the service hasn't
actually stopped before reaching the check to verify the service
stopped.
For example:
$ systemctl is-active systemd-timesyncd
active
$ timedatectl set-ntp false ; systemctl is-active systemd-timesyncd ; echo $?
deactivating
3
So the test code which does:
$ while systemctl is-active --quiet systemd-timesyncd; do sleep 1; done
will never actually perform that sleep.
echo 'disable NTP'
timedatectl set-ntp false
-while systemctl is-active --quiet systemd-timesyncd; do sleep 1; done
+while [ "$(systemctl --no-pager show systemd-timesyncd --property ActiveState)" != "ActiveState=inactive" ]; do sleep 1; done
assert_ntp false
assert_rc 3 systemctl is-active --quiet systemd-timesyncd
timedatectl set-ntp true
wait_mon "NTP" "boolean true"
assert_ntp true
-while [ "$(systemctl is-active systemd-timesyncd)" = "activating" ]; do sleep 1; done
+while [ "$(systemctl --no-pager show systemd-timesyncd --property ActiveState)" != "ActiveState=active" ]; do sleep 1; done
assert_rc 0 systemctl is-active --quiet systemd-timesyncd
echo 're-disable NTP'