#!/usr/bin/env bash set -eux set -o pipefail fail () { systemd-analyze log-level info exit 1 } # Wait for a service to enter a state within a timeout period, if it doesn't # enter the desired state within the timeout period then this function will # exit the test case with a non zero exit code. wait_on_state_or_fail () { service=$1 expected_state=$2 timeout=$3 state=$(systemctl show "$service" --property=ActiveState --value) while [ "$state" != "$expected_state" ]; do if [ "$timeout" = "0" ]; then fail fi timeout=$((timeout - 1)) sleep 1 state=$(systemctl show "$service" --property=ActiveState --value) done } systemd-analyze log-level debug systemd-analyze log-target console cat >/run/systemd/system/testservice-fail-59.service </run/systemd/system/testservice-fail-restart-59.service </run/systemd/system/testservice-abort-restart-59.service </testok exit 0