Skip to content

Commit

Permalink
common/null_blk: introduce _have_null_blk_feature
Browse files Browse the repository at this point in the history
Introduce a helper function _have_null_blk_feature which checks
/sys/kernel/config/features. It allows test cases to adapt to null_blk
feature support status.

Reviewed-by: Chaitanya Kulkarni <[email protected]>
Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
  • Loading branch information
kawasaki committed Jan 23, 2024
1 parent f7977df commit 4e10207
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions common/null_blk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ _have_null_blk() {
_have_driver null_blk
}

_have_null_blk_feature() {
# Ensure that null_blk driver is built-in or loaded
if ! [[ -d /sys/module/null_blk ]]; then
if ! modprobe -q null_blk; then
return 1
fi
if [[ ! "${MODULES_TO_UNLOAD[*]}" =~ null_blk ]]; then
MODULES_TO_UNLOAD+=(null_blk)
fi
fi

# Check that null_blk has the specified feature
grep -qe "$1" /sys/kernel/config/nullb/features
}

_remove_null_blk_devices() {
if [[ -d /sys/kernel/config/nullb ]]; then
find /sys/kernel/config/nullb -mindepth 1 -maxdepth 1 \
Expand Down

0 comments on commit 4e10207

Please sign in to comment.