[PATCH blktests 1/2] common/rc: add _have_kernel_options helper function
Shinichiro Kawasaki
shinichiro.kawasaki at wdc.com
Tue Nov 11 02:32:33 PST 2025
On Nov 08, 2025 / 02:00, Chaitanya Kulkarni wrote:
> Add a new helper function _have_kernel_options() that accepts multiple
> kernel config options as arguments. This allows tests to check for
> multiple kernel options in a single call, making the requires()
> function more concise.
>
> Example usage:
> requires() {
> _have_kernel_options IO_URING BLK_DEV_INTEGRITY
> }
>
> Instead of:
> requires() {
> _have_kernel_option IO_URING
> _have_kernel_option BLK_DEV_INTEGRITY
> }
>
> The function iterates through all provided options and returns failure
> if any option is not enabled, maintaining the same error reporting
> behavior as individual calls.
>
> Signed-off-by: Chaitanya Kulkarni <ckulkarnilinux at gmail.com>
> ---
> common/rc | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/common/rc b/common/rc
> index 86bb991..545da61 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -226,6 +226,12 @@ _have_kernel_option() {
> return 0
> }
>
> +_have_kernel_options() {
> + for opt in "$@"; do
Nit: spaces are used for indent.
> + _have_kernel_option "$opt" || return 1
This early return means that all of the options in $@ may not be checked. This
is not good. Let's say there are two kernel options disabled, FOO and BAR. With
this implmenetation, only FOO is reported by single blktests run.
"kernel option FOO has not been enabled"
The user will enable FOO, rebuild kernel, run blktests again and see this:
"kernel option BAR has not been enabled"
Now the user needs to rebuild the kernel again. This is troublesome.
I suggest to check all of the options in $@ and report all of disabled options,
like,
"kernel option FOO has not been enabled"
"kernel option BAR has not been enabled"
This will report more complete conditions to run test cases, and reduce the risk
that users lose their precious time. IOW, I suggest the implementation like:
_have_kenrel_options() {
local ret=0
for opt in "$@"; do
_have_kernel_option "$opt" || ret=1
done
return $ret
}
> + done
> +}
Other than the comments above, the two patches look good to me. If you are okay
with them, I can fold-in the suggested changes when I apply them (assuming
there is no other comment on the list). Please let me know your preference.
More information about the Linux-nvme
mailing list