Re: [PATCH 0/3] bitmap: Convert test_bitmap to kunit test

From: Shuah Khan
Date: Wed Jul 31 2024 - 12:26:25 EST


On 7/30/24 21:06, David Gow wrote:
On Tue, 30 Jul 2024 at 23:49, Shuah Khan <skhan@xxxxxxxxxxxxxxxxxxx> wrote:

On 7/29/24 02:29, Muhammad Usama Anjum wrote:
On 7/27/24 12:26 AM, Shuah Khan wrote:
On 7/26/24 05:06, Muhammad Usama Anjum wrote:
In this series, test_bitmap is being converted to kunit test. Multiple
patches will make the review process smooth.

- Patch-1: Convert the tests in lib/test_bitmap.c to kunit
- Patch-2: Rename the lib/test_bitmap.c to lib/bitmap_kunit.c and other
configuration options
- Patch-3: Remove the bitmap.sh selftest

Muhammad Usama Anjum (3):
bitmap: convert test_bitmap to KUnit test
bitmap: Rename module
selftests: lib: remove test_bitmap

MAINTAINERS | 2 +-
lib/Kconfig.debug | 15 +-
lib/Makefile | 2 +-
lib/{test_bitmap.c => bitmap_kunit.c} | 624 ++++++++++++--------------
tools/testing/selftests/lib/Makefile | 2 +-
tools/testing/selftests/lib/bitmap.sh | 3 -
tools/testing/selftests/lib/config | 1 -
7 files changed, 295 insertions(+), 354 deletions(-)
rename lib/{test_bitmap.c => bitmap_kunit.c} (70%)
delete mode 100755 tools/testing/selftests/lib/bitmap.sh


Can you tell me how this conversion helps?

It is removing the ability to run bitmap tests during boot.
It doesn't make sense to blindly convert all test under lib
to kunit - Nack on this change or any change that takes away
the ability to run tests and makes them dependent on kunit.
Let's discuss this on discussion thread [1].

So - it doesn't mean that it is a done deal. Each patch will be
reviewed on individual basis. This test in particular clearly its
use-case right in the config which was deleted without understanding
it.

-config TEST_BITMAP
- tristate "Test bitmap_*() family of functions at runtime"
- help
- Enable this option to test the bitmap functions at boot.


This line above is the important piece of information which tells
you how the test is intended to be used.

1. You can enable this option and boot the kernel to check for regressions.

Converting the test to KUnit _does not break this_. You can still
enable this option and boot the kernel to test for regressions if it's
a KUnit test.

2. You can load the module on a running kernel to check for health.

This is where the disagreement lies in my mind. While you can do this
with KUnit, the kernel does have to have been built with CONFIG_KUNIT
enabled (either built-in or as a module).

Right. It appears the confusion is coming in because "What's the problem
enabling CONFIG_KUNIT". The question is would you recommend enabling
CONFIG_KUNIT in distribution kernels - there is a confusion that
unit testing can be enabled in all environments.

The answer is no. Running tests should not require should not require
CONFIG_KUNIT - I would call this not disagreement, but not understanding
the role of unit (open box) vs closed box testing.

We want to users to be able to run as many tests possible without
needing to enable KUnit or other config options to verify kernels
they build. KUnit is a tool for kernel developers to verify - it
is a unit testing framework that is where it brings value.

It isn't a replacement for selftests and other tests. I am not happy
to seer tests that are supported as kselftests be changed to now
require KUNIT to be enabled.

thanks,
-- Shuah