From: Christoph Hellwig Date: Wed, 1 Jun 2022 06:48:32 +0000 (+0200) Subject: common: add a helper if a driver is available X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=e9645877fbf0;p=users%2Fsagi%2Fblktests.git common: add a helper if a driver is available Unlike _have_modules this allows allows for a built-in driver. Signed-off-by: Christoph Hellwig Reviewed-by: Shin'ichiro Kawasaki Signed-off-by: Shin'ichiro Kawasaki --- diff --git a/common/rc b/common/rc index 53ce3c3..1a69728 100644 --- a/common/rc +++ b/common/rc @@ -28,6 +28,18 @@ _have_root() { return 0 } +_have_driver() +{ + local modname="${1/-/_}" + + if [ ! -d "/sys/module/${modname}" ] && ! modprobe -q "${modname}"; then + SKIP_REASON="driver ${modname} is not available" + return 1 + fi + + return 0 +} + _have_modules() { local missing=() local module