check for dmapi module before running dmapi tests
[xfstests-dev.git] / common.dmapi
index df15da166cc96e2c06ac2c7f8338c0ce19f649e2..10409c30531c8647b54c9d2d3de32e2af9e473bf 100644 (file)
@@ -13,11 +13,15 @@ DMAPI_QASUITE2_DIR=$here/dmapi/src/suite2/
 DMAPI_LS_TO_COPY_PATH=$DMAPI_QASUITE2_DIR/bindir/ls_to_copy
 
 _dmapi_scratch_mount () {
-    if [ `echo "$MOUNT_OPTIONS" | grep -c dmapi` -gt 0 -o \
-         `echo "$MOUNT_OPTIONS" | grep -c dmi` -gt 0 ] ; then
-        #already got dmapi options set
-        _scratch_mount
+    if [ `lsmod | grep -c dmapi` -gt 0 ] ; then
+        if [ `echo "$MOUNT_OPTIONS" | grep -c dmapi` -gt 0 -o \
+            `echo "$MOUNT_OPTIONS" | grep -c dmi` -gt 0 ] ; then
+            #already got dmapi options set
+            _scratch_mount
+        else
+            _scratch_mount "-o dmapi,mtpt=$SCRATCH_MNT"
+        fi
     else
-        _scratch_mount "-o dmapi,mtpt=$SCRATCH_MNT"
+        _notrun "DMAPI modules not loaded"
     fi
 }