lib: Convert test_user_copy to KUnit test
Subsystems (2)
PATCH v2 1/1 lib: Convert test_user_copy to KUnit test
This adds the conversion of the runtime tests of test_user_copy fuctions, from lib/test_user_copy.c to KUnit tests.
---
v2:
* splitted patch in 3:
- Allows to install and load modules in root filesystem;
- Provides an userspace memory context when tests are compiled as module;
- Convert test_user_copy to KUnit test;
* removed entry for CONFIG_TEST_USER_COPY;
* replaced pr_warn to KUNIT_EXPECT_FALSE_MSG in test macro to decrease the diff;
---
lib/Kconfig.debug | 28 ++++++++------
lib/Makefile | 2 +-
lib/{test_user_copy.c => user_copy_kunit.c} | 42 +++++++++------------
3 files changed, 35 insertions(+), 37 deletions(-)
rename lib/{test_user_copy.c => user_copy_kunit.c} (91%)lib/Kconfig.debug +16 -12
@@ -2078,18 +2078,6 @@ config TEST_VMALLOC If unsure, say N. -config TEST_USER_COPY - tristate "Test user/kernel boundary protections" - depends on m - help - This builds the "test_user_copy" module that runs sanity checks - on the copy_to/from_user infrastructure, making sure basic - user/kernel boundary testing is working. If it fails to load, - a regression has been detected in the user/kernel memory boundary - protections. - - If unsure, say N. - config TEST_BPF tristate "Test BPF filter functionality" depends on m && NET
@@ -2154,6 +2142,22 @@ config SYSCTL_KUNIT_TEST If unsure, say N. +config USER_COPY_KUNIT + tristate "KUnit Test for user/kernel boundary protections" + depends on KUNIT + depends on m + help + This builds the "user_copy_kunit" module that runs sanity checks + on the copy_to/from_user infrastructure, making sure basic + user/kernel boundary testing is working. If it fails to load, + a regression has been detected in the user/kernel memory boundary + protections. + + 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 LIST_KUNIT_TEST tristate "KUnit Test for Kernel Linked-list structures" if !KUNIT_ALL_TESTS depends on KUNIT
lib/Makefile +1 -1
@@ -78,7 +78,6 @@ obj-$(CONFIG_TEST_VMALLOC) += test_vmalloc.o obj-$(CONFIG_TEST_OVERFLOW) += test_overflow.o obj-$(CONFIG_TEST_RHASHTABLE) += test_rhashtable.o obj-$(CONFIG_TEST_SORT) += test_sort.o -obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o obj-$(CONFIG_TEST_PRINTF) += test_printf.o
@@ -318,3 +317,4 @@ obj-$(CONFIG_OBJAGG) += objagg.o # KUnit tests obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o +obj-$(CONFIG_USER_COPY_KUNIT) += user_copy_kunit.o
lib/user_copy_kunit.c renamed from lib/test_user_copy.c +18 -24
100 lines not on this page · raw message
base-commit: 725aca9585956676687c4cb803e88f770b0df2b2
prerequisite-patch-id: 5e5f9a8a05c5680fda1b04c9ab1b95ce91dc88b2
prerequisite-patch-id: 4d997940f4a9f303424af9bac412de1af861f9d9
prerequisite-patch-id: 582b6d9d28ce4b71628890ec832df6522ca68de0
prerequisite-patch-id: 5cd745ed9bbb0b36010c5de8adc19bfa86ad8be0
prerequisite-patch-id: 42f17b389ec15baf50dd1c43f6e30b8d2dff7964
Signature · 1 line
2.26.2
Quoted 5 lines · Vitor Massaru Iha
This adds the conversion of the runtime tests of
test_user_copyfuctions, fromlib/test_user_copy.cto KUnit tests.Signed-off-by Vitor Massaru Iha <[email protected]>
Thanks!