Add module build support for KUnit IIO tests
Subsystems (2)
cover Add module build support for KUnit IIO tests
KUnit tests can be built as modules allowing to execute them at runtime by simply loading the modules.
Module build support is added with the following steps:
- add MODULE_* in the KUnit test drivers,
- export namespace symbols from the iio-rescale, and
- drop Kconfig built-in only constraints,
Along with the module build changes, this series also addresses minor touch ups such as:
- rename IIO_TEST_FORMAT Kconfig to match naming conventions,
- use tabs to indent the IIO_FORMAT_KUNIT_TEST Kconfig,
- drop ARCH=um mention from the IIO_RESCALE_KUNIT_TEST Kconfig help section,
- add IIO_FORMAT_KUNIT_TEST Kconfig help section,
- update dependency on KUNIT_ALL_TESTS to match the documentation.
All these are done in commit 05/05. I could rework the commit, but given that these changes are pretty minor, it seemed okay to do it all at once.
Cheers,
Liam
Liam Beguin (5):
iio: test: rescale: add MODULE_* information
iio: test: format: add MODULE_* information
iio: test: format: follow CONFIG_ naming convention
iio: afe: rescale: export symbols used during testing
iio: test: rework Kconfig to support modules
drivers/iio/afe/iio-rescale.c | 2 ++ drivers/iio/test/Kconfig | 26 ++++++++++++++++++-------- drivers/iio/test/Makefile | 2 +- drivers/iio/test/iio-test-format.c | 4 ++++ drivers/iio/test/iio-test-rescale.c | 5 +++++ 5 files changed, 30 insertions(+), 9 deletions(-)
base-commit: b1c428b6c3684ee8ddf4137d68b3e8d51d2a700f
Signature · 1 line
2.35.1.4.g5d01301f2b86
PATCH 1/5 iio: test: rescale: add MODULE_* information
In preparation for module support, add missing MODULE_* information.
--- drivers/iio/test/iio-test-rescale.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/iio/test/iio-test-rescale.c +4 -0
@@ -708,3 +708,7 @@ static struct kunit_suite iio_rescale_test_suite = { .test_cases = iio_rescale_test_cases, };kunit_test_suite (iio_rescale_test_suite); + +MODULE_AUTHOR ("Liam Beguin <[email protected]>" ); +MODULE_DESCRIPTION ("Test IIO rescale conversion functions" ); +MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.35.1.4.g5d01301f2b86
PATCH 2/5 iio: test: format: add MODULE_* information
In reply to Liam BeguinIn preparation for module support, add missing MODULE_* information.
--- drivers/iio/test/iio-test-format.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/iio/test/iio-test-format.c +4 -0
@@ -265,3 +265,7 @@ static struct kunit_suite iio_format_test_suite = { .test_cases = iio_format_test_cases, };kunit_test_suite (iio_format_test_suite); + +MODULE_AUTHOR ("Lars-Peter Clausen <[email protected]>" ); +MODULE_DESCRIPTION ("Test IIO formatting functions" ); +MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.35.1.4.g5d01301f2b86
PATCH 3/5 iio: test: format: follow CONFIG_ naming convention
In reply to Liam BeguinThe KUnit documentation indicates that all KUnit Kconfig entries must match CONFIG_<name>_KUNIT_TEST: where <name> is the name of the test suite. Rename the IIO_TEST_FORMAT configuration accordingly.
--- drivers/iio/test/Kconfig | 2 +- drivers/iio/test/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/iio/test/Kconfig +1 -1
@@ -14,6 +14,6 @@ config IIO_RESCALE_KUNIT_TEST This takes advantage of ARCH=um to run tests and should be used by developers to tests their changes to the rescaling logic. -config IIO_TEST_FORMAT +config IIO_FORMAT_KUNIT_TEST bool "Test IIO formatting functions" depends on KUNIT=y
drivers/iio/test/Makefile +1 -1
@@ -5,5 +5,5 @@ # Keep in alphabetical order obj-$(CONFIG_IIO_RESCALE_KUNIT_TEST) += iio-test-rescale.o -obj-$(CONFIG_IIO_TEST_FORMAT) += iio-test-format.o +obj-$(CONFIG_IIO_FORMAT_KUNIT_TEST) += iio-test-format.o CFLAGS_iio-test-format.o += $(DISABLE_STRUCTLEAK_PLUGIN)
Signature · 1 line
2.35.1.4.g5d01301f2b86
PATCH 4/5 iio: afe: rescale: export symbols used during testing
In reply to Liam BeguinIn preparation for module support, export symbols use during testing.
--- drivers/iio/afe/iio-rescale.c | 2 ++ drivers/iio/test/iio-test-rescale.c | 1 + 2 files changed, 3 insertions(+)
drivers/iio/afe/iio-rescale.c +2 -0
@@ -107,6 +107,7 @@ int rescale_process_scale(struct rescale *rescale, int scale_type,return -EOPNOTSUPP ; } } +EXPORT_SYMBOL_NS_GPL (rescale_process_scale,IIO_RESCALE ); int rescale_process_offset(struct rescale *rescale, int scale_type, int scale, int scale2, int schan_off,
@@ -140,6 +141,7 @@ int rescale_process_offset(struct rescale *rescale, int scale_type,return -EOPNOTSUPP ; } } +EXPORT_SYMBOL_NS_GPL (rescale_process_offset,IIO_RESCALE ); static int rescale_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan,
drivers/iio/test/iio-test-rescale.c +1 -0
@@ -712,3 +712,4 @@ kunit_test_suite(iio_rescale_test_suite);MODULE_AUTHOR ("Liam Beguin <[email protected]>" );MODULE_DESCRIPTION ("Test IIO rescale conversion functions" );MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (IIO_RESCALE );
Signature · 1 line
2.35.1.4.g5d01301f2b86
PATCH 5/5 iio: test: rework Kconfig to support modules
In reply to Liam BeguinRework the IIO test Kconfig to support building KUnit tests as modules. This lets users execute tests at runtime in addition to the usual tools/testing/kunit/kunit.py script.
--- drivers/iio/test/Kconfig | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
drivers/iio/test/Kconfig +17 -7
@@ -5,15 +5,25 @@ # Keep in alphabetical order config IIO_RESCALE_KUNIT_TEST - bool "Test IIO rescale conversion functions" - depends on KUNIT=y && IIO_RESCALE=y + tristate "Test IIO rescale conversion functions" if !KUNIT_ALL_TESTS + depends on KUNIT && IIO_RESCALE default KUNIT_ALL_TESTS help - If you want to run tests on the iio-rescale code say Y here. + build unit tests for the iio-rescale code. - This takes advantage of ARCH=um to run tests and should be used by - developers to tests their changes to the rescaling logic. + For more information on KUnit and unit tests in general, please refer + to the KUnit documentation in Documentation/dev-tools/kunit/. + + If unsure, say N. config IIO_FORMAT_KUNIT_TEST - bool "Test IIO formatting functions" - depends on KUNIT=y + tristate "Test IIO formatting functions" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + build unit tests for the IIO formatting functions. + + For more information on KUnit and unit tests in general, please refer + to the KUnit documentation in Documentation/dev-tools/kunit/. + + If unsure, say N.
Signature · 1 line
2.35.1.4.g5d01301f2b86
Jonathan Cameron
maintainerRe: [PATCH v1 5/5] iio: test: rework Kconfig to support modules
Quoted 5 lines · On Sat, 9 Jul 2022 21:31:09 -0400 Liam Beguin <[email protected]> wrote:
Rework the IIO test
Kconfigto support building KUnit tests as modules. This lets users execute tests at runtime in addition to the usualtools/testing/kunit/kunit.pyscript.Signed-off-by Liam Beguin <[email protected]>
One trivial comment inline. Fixed that up and applied to the togreg branch of iio.git. Not I'll only push out as testing for now as will be rebasing the tree after rc1.
Jonathan
Quoted 10 lines
--- drivers/iio/test/Kconfig | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)drivers/iio/test/Kconfig +0
-0@@ -5,15 +5,25 @@
drivers/iio/test/Kconfig line 12
Quoted 10 lines
drivers/iio/test/Kconfig +3
-3# Keep in alphabetical order config IIO_RESCALE_KUNIT_TEST - bool "Test IIO rescale conversion functions" - depends on KUNIT=y && IIO_RESCALE=y + tristate "Test IIO rescale conversion functions" if !KUNIT_ALL_TESTS + depends on KUNIT && IIO_RESCALE default KUNIT_ALL_TESTS help - If you want to run tests on the iio-rescale code say Y here. + build unit tests for the iio-rescale code.
Build
Quoted 21 lines
drivers/iio/test/Kconfig +14
-4- This takes advantage of ARCH=um to run tests and should be used by - developers to tests their changes to the rescaling logic. + For more information on KUnit and unit tests in general, please refer + to the KUnit documentation in Documentation/dev-tools/kunit/. + + If unsure, say N. config IIO_FORMAT_KUNIT_TEST - bool "Test IIO formatting functions" - depends on KUNIT=y + tristate "Test IIO formatting functions" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + build unit tests for the IIO formatting functions. + + For more information on KUnit and unit tests in general, please refer + to the KUnit documentation in Documentation/dev-tools/kunit/. + + If unsure, say N.