Skip to content

Commit 7c26543

Browse files
hreineckekawasaki
authored andcommitted
common/rc: introduce _have_systemctl_unit()
To check that the test system has a specific systemctl unit, introduce the new helper function _have_systemctl_unit. Signed-off-by: Hannes Reinecke <[email protected]> Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
1 parent ec8f147 commit 7c26543

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

common/rc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,17 @@ _have_writeable_kmsg() {
500500
return 0
501501
}
502502

503+
_have_systemctl_unit() {
504+
local unit="$1"
505+
506+
_have_program systemctl || return 1
507+
if ! grep -qe "$unit" < <(systemctl list-unit-files); then
508+
SKIP_REASONS+=("systemctl unit '${unit}' is missing")
509+
return 1
510+
fi
511+
return 0
512+
}
513+
503514
# Run the given command as NORMAL_USER
504515
_run_user() {
505516
su "$NORMAL_USER" -c "$1"

0 commit comments

Comments
 (0)