Skip to content

Commit

Permalink
iio: test: add basic tests for the iio-rescale driver
Browse files Browse the repository at this point in the history
The iio-rescale driver supports various combinations of scale types and
offsets. These can often result in large integer multiplications. Make
sure these calculations are done right by adding a set of kunit test
cases that build on top of iio-test-format.

To run these tests, add the following to .kunitconfig
	$ cat .kunitconfig
	CONFIG_IIO=y
	CONFIG_IIO_RESCALE_KUNIT_TEST=y
	CONFIG_KUNIT=y

Then run:
	$ ./tools/testing/kunit/kunit.py run --kunitconfig .kunitconfig

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
Reviewed-by: Peter Rosin <peda@axentia.se>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220213025739.2561834-7-liambeguin@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
  • Loading branch information
Liam Beguin authored and Jonathan Cameron committed Feb 28, 2022
1 parent 2eb3057 commit 8e74a48
Show file tree
Hide file tree
Showing 3 changed files with 721 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/iio/test/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
#

# Keep in alphabetical order
config IIO_RESCALE_KUNIT_TEST
bool "Test IIO rescale conversion functions"
depends on KUNIT=y && !IIO_RESCALE
default KUNIT_ALL_TESTS
help
If you want to run tests on the iio-rescale code say Y here.

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
bool "Test IIO formatting functions"
depends on KUNIT=y
1 change: 1 addition & 0 deletions drivers/iio/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
#

# Keep in alphabetical order
obj-$(CONFIG_IIO_RESCALE_KUNIT_TEST) += iio-test-rescale.o ../afe/iio-rescale.o
obj-$(CONFIG_IIO_TEST_FORMAT) += iio-test-format.o
CFLAGS_iio-test-format.o += $(DISABLE_STRUCTLEAK_PLUGIN)
Loading

0 comments on commit 8e74a48

Please sign in to comment.