]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
common: add a helper if a driver is available
authorChristoph Hellwig <hch@lst.de>
Wed, 1 Jun 2022 06:48:32 +0000 (08:48 +0200)
committerShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Thu, 2 Jun 2022 04:24:13 +0000 (13:24 +0900)
Unlike _have_modules this allows allows for a built-in driver.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
common/rc

index 53ce3c3f420c4770a3bebaa09646f52eb6139e61..1a69728ac29cb90d11449c788fe1aa86250d341e 100644 (file)
--- 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