On Mon, Apr 07, 2025 at 09:42:47AM +0200, Thomas Weißschuh wrote:
UAPI selftests may expect a "normal" userspace environment. For example the normal kernel API pseudo-filesystems should be mounted. This could be done from kernel code but it is non-idiomatic.
Add a preinit userspace executable which performs these setup steps before running the final test executable. This preinit executable is only ever run from the kernel. Give it access to autoconf.h and kconfig.h to adapt itself to the tested kernel.
Signed-off-by: Thomas Weißschuh thomas.weissschuh@linutronix.de
lib/kunit/Makefile | 9 ++++++- lib/kunit/uapi-preinit.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/kunit/uapi.c | 11 ++++++-- 3 files changed, 82 insertions(+), 3 deletions(-)
diff --git a/lib/kunit/Makefile b/lib/kunit/Makefile index 1b6be12676f89cafa34f0093d8136b36f4cf5532..0e9a26d90bf4d5128e270ecaa8f3465f28da0fa2 100644 --- a/lib/kunit/Makefile +++ b/lib/kunit/Makefile @@ -12,7 +12,14 @@ kunit-objs += test.o \ device.o \ platform.o -kunit-$(CONFIG_KUNIT_UAPI) += uapi.o +userprogs += uapi-preinit
as for kunit-example-uapi, please add a 'clean-files' definition:
clean-files += uapi-preinit