From: Hannes Reinecke <hare@xxxxxxx> To check that the test system has a specific systemctl unit, introduce the new helper function _have_systemctl_unit. Signed-off-by: Hannes Reinecke <hare@xxxxxxx> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@xxxxxxx> --- common/rc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/rc b/common/rc index bc6c2e4..ce7f975 100644 --- a/common/rc +++ b/common/rc @@ -500,6 +500,17 @@ _have_writeable_kmsg() { return 0 } +_have_systemctl_unit() { + local unit="$1" + + _have_program systemctl || return 1 + if ! grep -qe "$unit" < <(systemctl list-unit-files); then + SKIP_REASONS+=("systemctl unit '${unit}' is missing") + return 1 + fi + return 0 +} + # Run the given command as NORMAL_USER _run_user() { su "$NORMAL_USER" -c "$1" -- 2.49.0