Skip to content

Linux kselftests

Nikita Sobolev edited this page Jul 6, 2020 · 11 revisions

Kernel config

Firstly make sure, that you have these patches:

https://lkml.org/lkml/2020/5/21/538

https://www.spinics.net/lists/stable/msg352902.html

Enable these options in a kernel config:

CONFIG_UTS_NS=y
CONFIG_USER_NS=y
CONFIG_PID_NS=y
CONFIG_TEST_STATIC_KEYS=m
CONFIG_TEST_USER_COPY=m
CONFIG_JUMP_LABEL=y
CONFIG_MODULE_UNLOAD=y

Buildroot config

Enable these options in buildroot config:

BR2_PACKAGE_PYTHON=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
BR2_PACKAGE_LINUX_TOOLS_SELFTESTS=y

Files you need to have in your image

Copy linux/tools/testing/selftests/kselftest_module.sh into a directory with selftests in your image.

Run tests on the target

cd /usr/lib/kselftests/
./run_kselftest.sh

See example with results.

Known issues

Firmware test problem. To make firmware test work we need to have some options to be activated in kernel config:

CONFIG_TEST_FIRMWARE=y
CONFIG_FW_LOADER=y
CONFIG_FW_LOADER_USER_HELPER=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y

Firmware test can execute with errors because of diff util limitations in busybox. The script uses -Z option, that is not supported in diff from busybox. But -Z can be changed to -b option. Then test runs as it should. Nevertheless, it will fail on one of tests (test_request_firmware_nowait_custom_nofile ). This test makes the system wait forever (checked on nsim and HSDK). If this test is excluded, other tests can run successfully:
diff fw_filesystem.sh:

- for i in $(seq 1 5); do
- test_request_firmware_nowait_custom_nofile $i
- done

This part of the code should be deleted.

Clone this wiki locally