Skip to content

[PW_SID:970692] kunit: Introduce UAPI testing framework#511

Closed
linux-riscv-bot wants to merge 16 commits into
workflow__riscv__fixesfrom
pw970692
Closed

[PW_SID:970692] kunit: Introduce UAPI testing framework#511
linux-riscv-bot wants to merge 16 commits into
workflow__riscv__fixesfrom
pw970692

Conversation

@linux-riscv-bot
Copy link
Copy Markdown

PR for series 970692 applied to workflow__riscv__fixes

Name: kunit: Introduce UAPI testing framework
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=970692
Version: 3

t-8ch added 16 commits June 11, 2025 09:20
The duplication makes maintenance harder. Changes need to be done in two
places and the lines will grow overly long.

Use an intermediary variable instead.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Make sure the byte order and ABI of the userprogs matches the one of the
kernel, similar to how the bit size is handled.
Otherwise the userprogs may not be executable.
This happens for example on powerpc little endian, or riscv32.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
For the kunit UAPI functionality this feature is needed.

This reverts commit d1b99cd ("init: remove unused CONFIG_CC_CAN_LINK_STATIC")

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Userprogs are built with the regular kernel compiler $CC.
A kernel compiler does not necessarily contain a libc which is required
for a normal userspace application.
However the kernel tree does contain a minimal libc implementation
"nolibc" which can be used to build userspace applications.

Introduce support to build userprogs against nolibc instead of the
default libc of the compiler, which may not exist.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Nolibc does not support all architectures.
Add a kconfig option, so users can know where it is available.

The new option is maintained inside tools/include/nolibc/ as only that
directory is responsible for nolibc's availability.

Reviewed-by: Nicolas Schier <n.schier@avm.de>
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Some upcoming new documentation should link directly to the userprogs section.

Add a label to the section so it can be referenced.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Various subsystems embed non-code build artifacts into the kernel,
for example the initramfs, /proc/config.gz, vDSO image, etc.
Currently each user has their own implementation for that.

Add a common "blob" framework to provide this functionality.
It provides standard kbuild and C APIs to embed and later access non-code
build artifacts into the kernel image or modules.

Reviewed-by: Nicolas Schier <n.schier@avm.de>
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Currently there is no test validating the result reporting from nested
tests. Add one, it will also be used to validate upcoming changes to the
nested test parsing.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
If a subtest itself reports success, but the outer testcase fails,
the whole testcase should be reported as a failure.
However the status is recalculated based on the test counts,
overwriting the outer test result.
Synthesize a failed test in this case to make sure the failure is not
swallowed.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Skipped tests reported by kselftest.h use a different format than KTAP,
there is no explicit test name. Normally the test name is part of the
free-form string after the SKIP keyword:

	ok 3 # SKIP test: some reason

Extend the parser to handle those correctly. Use the free-form string as
test name instead.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
An upcoming change will add 'userprogs' to the kunit subdirectory.
For kbuild to properly clean up these build artifacts the subdirectory
needs to be always processed.

Pushing the special logic for hook.o into the kunit Makefile also makes the
logic easier to understand.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The upcoming kunit UAPI framework will run userspace executables as part of
kunit. These may use the LSX or LASX instructions.

Make sure the kunit kernel can handle these instructions.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Enable running UAPI tests as part of kunit.
The selftests are embedded into the kernel image and their output is
forwarded to kunit for unified reporting.

The implementation reuses parts of usermode drivers and usermode
helpers. However these frameworks are not used directly as they make it
impossible to retrieve a thread's exit code.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Extend the example to show how to run a userspace executable.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Show that the selftests are executed from a fairly "normal"
userspace context.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v3,01/16] kbuild: userprogs: avoid duplicating of flags inherited from kernel"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 103.83 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v3,01/16] kbuild: userprogs: avoid duplicating of flags inherited from kernel"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 937.44 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v3,01/16] kbuild: userprogs: avoid duplicating of flags inherited from kernel"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1260.70 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v3,01/16] kbuild: userprogs: avoid duplicating of flags inherited from kernel"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 21.20 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v3,01/16] kbuild: userprogs: avoid duplicating of flags inherited from kernel"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 22.00 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v3,01/16] kbuild: userprogs: avoid duplicating of flags inherited from kernel"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.67 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v3,01/16] kbuild: userprogs: avoid duplicating of flags inherited from kernel"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 71.94 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v3,01/16] kbuild: userprogs: avoid duplicating of flags inherited from kernel"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v3,01/16] kbuild: userprogs: avoid duplicating of flags inherited from kernel"
kdoc
Desc: Detects for kdoc errors
Duration: 0.91 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v3,01/16] kbuild: userprogs: avoid duplicating of flags inherited from kernel"
module-param
Desc: Detect module_param changes
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v3,01/16] kbuild: userprogs: avoid duplicating of flags inherited from kernel"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v3,01/16] kbuild: userprogs: avoid duplicating of flags inherited from kernel"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.30 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v3,02/16] kbuild: userprogs: also inherit byte order and ABI from kernel"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 104.42 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v3,02/16] kbuild: userprogs: also inherit byte order and ABI from kernel"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 938.04 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 14: "[v3,14/16] kunit: uapi: Add example for UAPI tests"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 74.15 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 14: "[v3,14/16] kunit: uapi: Add example for UAPI tests"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 14: "[v3,14/16] kunit: uapi: Add example for UAPI tests"
kdoc
Desc: Detects for kdoc errors
Duration: 0.90 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 14: "[v3,14/16] kunit: uapi: Add example for UAPI tests"
module-param
Desc: Detect module_param changes
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 14: "[v3,14/16] kunit: uapi: Add example for UAPI tests"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 14: "[v3,14/16] kunit: uapi: Add example for UAPI tests"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.31 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 15: "[v3,15/16] kunit: uapi: Introduce preinit executable"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 104.73 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 15: "[v3,15/16] kunit: uapi: Introduce preinit executable"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 936.72 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 15: "[v3,15/16] kunit: uapi: Introduce preinit executable"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1256.62 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 15: "[v3,15/16] kunit: uapi: Introduce preinit executable"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 20.77 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 15: "[v3,15/16] kunit: uapi: Introduce preinit executable"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 22.40 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 15: "[v3,15/16] kunit: uapi: Introduce preinit executable"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 2.12 seconds
Result: WARNING
Output:

WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#49: 
new file mode 100644

total: 0 errors, 1 warnings, 0 checks, 107 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit 67923e982a27 ("kunit: uapi: Introduce preinit executable") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 1 warnings, 0 checks, 107 lines checked
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?


@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 15: "[v3,15/16] kunit: uapi: Introduce preinit executable"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 72.08 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 15: "[v3,15/16] kunit: uapi: Introduce preinit executable"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 15: "[v3,15/16] kunit: uapi: Introduce preinit executable"
kdoc
Desc: Detects for kdoc errors
Duration: 0.90 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 15: "[v3,15/16] kunit: uapi: Introduce preinit executable"
module-param
Desc: Detect module_param changes
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 15: "[v3,15/16] kunit: uapi: Introduce preinit executable"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 15: "[v3,15/16] kunit: uapi: Introduce preinit executable"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.32 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 16: "[v3,16/16] kunit: uapi: Validate usability of /proc"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 105.53 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 16: "[v3,16/16] kunit: uapi: Validate usability of /proc"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 941.19 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 16: "[v3,16/16] kunit: uapi: Validate usability of /proc"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1260.62 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 16: "[v3,16/16] kunit: uapi: Validate usability of /proc"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 21.49 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 16: "[v3,16/16] kunit: uapi: Validate usability of /proc"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 22.38 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 16: "[v3,16/16] kunit: uapi: Validate usability of /proc"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.73 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 16: "[v3,16/16] kunit: uapi: Validate usability of /proc"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 74.08 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 16: "[v3,16/16] kunit: uapi: Validate usability of /proc"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.76 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 16: "[v3,16/16] kunit: uapi: Validate usability of /proc"
kdoc
Desc: Detects for kdoc errors
Duration: 0.89 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 16: "[v3,16/16] kunit: uapi: Validate usability of /proc"
module-param
Desc: Detect module_param changes
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 16: "[v3,16/16] kunit: uapi: Validate usability of /proc"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 16: "[v3,16/16] kunit: uapi: Validate usability of /proc"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.31 seconds
Result: PASS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants