summaryrefslogtreecommitdiff
path: root/drivers/iio/test
AgeCommit message (Collapse)AuthorFilesLines
2022-08-16iio: test: Mark file local structure arrays static.Jonathan Cameron1-2/+2
Warning cleanup: drivers/iio/test/iio-test-rescale.c:32:30: warning: symbol 'scale_cases' was not declared. Should it be static? drivers/iio/test/iio-test-rescale.c:480:30: warning: symbol 'offset_cases' was not declared. Should it be static? Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Liam Beguin <liambeguin@gmail.com> Reviewed-by: Liam Beguin <liambeguin@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20220807145457.646062-2-jic23@kernel.org
2022-07-16iio: test: rework Kconfig to support modulesLiam Beguin1-7/+17
Rework 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. Signed-off-by: Liam Beguin <liambeguin@gmail.com> Link: https://lore.kernel.org/r/20220710013109.3349104-6-liambeguin@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-07-16iio: afe: rescale: export symbols used during testingLiam Beguin1-0/+1
In preparation for module support, export symbols use during testing. Signed-off-by: Liam Beguin <liambeguin@gmail.com> Link: https://lore.kernel.org/r/20220710013109.3349104-5-liambeguin@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-07-16iio: test: format: follow CONFIG_ naming conventionLiam Beguin2-2/+2
The 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. Signed-off-by: Liam Beguin <liambeguin@gmail.com> Link: https://lore.kernel.org/r/20220710013109.3349104-4-liambeguin@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-07-16iio: test: format: add MODULE_* informationLiam Beguin1-0/+4
In preparation for module support, add missing MODULE_* information. Signed-off-by: Liam Beguin <liambeguin@gmail.com> Link: https://lore.kernel.org/r/20220710013109.3349104-3-liambeguin@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-07-16iio: test: rescale: add MODULE_* informationLiam Beguin1-0/+4
In preparation for module support, add missing MODULE_* information. Signed-off-by: Liam Beguin <liambeguin@gmail.com> Link: https://lore.kernel.org/r/20220710013109.3349104-2-liambeguin@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-19iio: test: fix missing MODULE_LICENSE for IIO_RESCALE=mLiam Beguin2-2/+2
When IIO_RESCALE_KUNIT_TEST=y and IIO_RESCALE=m, drivers/iio/afe/iio-rescale.o is built twice causing the MODULE_LICENSE() to be lost, as shown by: ERROR: modpost: missing MODULE_LICENSE() in drivers/iio/afe/iio-rescale.o Rework the build configuration to have the dependency specified in the Kconfig. Reported-by: Randy Dunlap <rdunlap@infradead.org> Fixes: 8e74a48d17d5 ("iio: test: add basic tests for the iio-rescale driver") Signed-off-by: Liam Beguin <liambeguin@gmail.com> Acked-by: Randy Dunlap <rdunlap@infradead.org> Tested-by: Randy Dunlap <rdunlap@infradead.org> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org> Link: https://lore.kernel.org/r/20220601142138.3331278-1-liambeguin@gmail.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-02-28iio: test: add basic tests for the iio-rescale driverLiam Beguin3-0/+721
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>
2021-11-27iio: test: Add test for IIO_VAL_INT_64.Andriy Tryshnivskyy1-0/+54
Add test for newly introduced type IIO_VAL_INT_64. Signed-off-by: Andriy Tryshnivskyy <andriy.tryshnivskyy@opensynergy.com> Reported-by: kernel test robot <lkp@intel.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20211105100501.1904-3-andriy.tryshnivskyy@opensynergy.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-11-27iio: test: Add check against NULL for buffer in tests.Andriy Tryshnivskyy1-27/+42
Add KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf) for every test. Also use ARRAY_SIZE(values) where it is possible. Signed-off-by: Andriy Tryshnivskyy <andriy.tryshnivskyy@opensynergy.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20211105100501.1904-2-andriy.tryshnivskyy@opensynergy.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-07iio/test-format: build kunit tests without structleak pluginBrendan Higgins1-0/+1
The structleak plugin causes the stack frame size to grow immensely when used with KUnit: ../drivers/iio/test/iio-test-format.c: In function ‘iio_test_iio_format_value_fixedpoint’: ../drivers/iio/test/iio-test-format.c:98:1: warning: the frame size of 2336 bytes is larger than 2048 bytes [-Wframe-larger-than=] Turn it off in this file. Signed-off-by: Brendan Higgins <brendanhiggins@google.com> Suggested-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Kees Cook <keescook@chromium.org> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2021-06-24iio: Remove a cast in iio-test-format which is no longer requiredDavid Gow1-1/+1
KUnit's EXPECT macros no longer typecheck as stringently, so casting the result of strcmp() is now unnecessary. Signed-off-by: David Gow <davidgow@google.com> Reviewed-by: Brendan Higgins <brendanhiggins@google.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2021-03-11iio: Add basic unit test for iio_format_value()Lars-Peter Clausen3-0/+214
The IIO core provides a function to do formatting of fixedpoint numbers. In the past there have been some issues with the implementation of the function where for example negative numbers were not handled correctly. Introduce a basic unit test based on kunit that tests the function and ensures that the generated output matches the expected output. This gives us some confidence that future modifications to the function implementation will not break ABI compatibility. To run the unit tests follow the kunit documentation and add CONFIG_IIO=y CONFIG_IIO_TEST_FORMAT=y to the .kunitconfig and run > ./tools/testing/kunit/kunit.py run Configuring KUnit Kernel ... Building KUnit Kernel ... Starting KUnit Kernel ... ============================================================ ======== [PASSED] iio-format ======== [PASSED] iio_test_iio_format_value_integer [PASSED] iio_test_iio_format_value_fixedpoint [PASSED] iio_test_iio_format_value_fractional [PASSED] iio_test_iio_format_value_fractional_log2 [PASSED] iio_test_iio_format_value_multiple ============================================================ Testing complete. 21 tests run. 0 failed. 0 crashed. Elapsed time: 8.242s total, 0.001s configuring, 3.865s building, 0.000s running Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Link: https://lore.kernel.org/r/20201215191743.2725-3-lars@metafoo.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>