selftests/alsa: Let the pcmtest test run on kselftest kernels
Subsystems (4)
cover selftests/alsa: Let the pcmtest test run on kselftest kernels
On the kernels that CI labs such as KernelCI build for kselftest, every test-pcmtest-driver case skips. The KernelCI arm64 kselftest kernel has CONFIG_SND_PCMTEST, CONFIG_SND_SEQ_UMP and CONFIG_SND_UTIMER off, and nothing would load the pcmtest module even if it were built.
Patch 1 adds a config file for make kselftest-merge with only the options the tests themselves need. When Ben sent a config file in March [1], Mark pointed out that mixer-test and pcm-test check whatever drivers a system has, while test-pcmtest-driver does need a config option for its module. So no drivers are listed here. Patch 2 lets test-pcmtest-driver load the module itself.
Tested in QEMU (x86_64) on sound/for-next 0dfd513a1557, with a kernel from defconfig and make kselftest-merge and no sound modules loaded at boot. All four options are on with patch 1 and off without it. On the kernel with patch 1, test-pcmtest-driver goes from 10 skipped to 10 passed with patch 2, and seq-ump-test, which skips without CONFIG_SND_SEQ_UMP, passes.
[1] https://lore.kernel.org/all/[email protected]/
Prepared with Claude Code (Claude Opus 5.5).
HyeongJun An (2):
selftests/alsa: Add a config file for the test-only options
selftests: ALSA: pcmtest: Load the module when it is missing
tools/testing/selftests/alsa/config | 6 ++++++ tools/testing/selftests/alsa/test-pcmtest-driver.c | 4 ++++ 2 files changed, 10 insertions(+) create mode 100644 tools/testing/selftests/alsa/config
Signature · 1 line
2.43.0
PATCH 1/2 selftests/alsa: Add a config file for the test-only options
Some of the ALSA selftests need kernel options that a normal config does not enable. test-pcmtest-driver needs the pcmtest driver, seq-ump-test needs CONFIG_SND_SEQ_UMP, utimer-test needs CONFIG_SND_UTIMER, and aloop-test needs snd-aloop. Without them these tests skip.
CI systems build their kselftest kernels with make kselftest-merge, which merges the config file of each selftest directory, and alsa has none. On the KernelCI arm64 kselftest kernel all four options are off, and every test-pcmtest-driver case skips.
Add a config file with only these options. mixer-test and pcm-test check whatever sound drivers a system has, so no drivers are listed.
--- tools/testing/selftests/alsa/config | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tools/testing/selftests/alsa/config
tools/testing/selftests/alsa/config new file +6 -0
@@ -0,0 +1,6 @@ +CONFIG_DEBUG_FS=y +CONFIG_SND_ALOOP=m +CONFIG_SND_PCMTEST=m +CONFIG_SND_SEQUENCER=m +CONFIG_SND_SEQ_UMP=y +CONFIG_SND_UTIMER=y
Signature · 1 line
2.43.0
Mark Brown
maintainerRe: [PATCH 1/2] selftests/alsa: Add a config file for the test-only options
Quoted 6 lines · HyeongJun An
Some of the ALSA selftests need kernel options that a normal config does not enable. test-pcmtest-driver needs the pcmtest driver, seq-ump-test needs
CONFIG_SND_SEQ_UMP, utimer-test needsCONFIG_SND_UTIMER, and aloop-test needs snd-aloop. Without them these tests skip.+CONFIG_SND_PCMTEST=m
This is inside CONFIG_SND_DRIVERS, you need to select that in case the underlying config has disabled it.
PATCH 2/2 selftests: ALSA: pcmtest: Load the module when it is missing
In reply to HyeongJun Antest-pcmtest-driver skips when the pcmtest debugfs files are missing. The driver has no device to bind to, so nothing loads the module, and the test skips even on a kernel that builds it.
Run modprobe once before skipping, as the net pktgen test does. The module stays loaded. In the default order the test runs after mixer-test and pcm-test, so the extra card does not change what they check.
--- tools/testing/selftests/alsa/test-pcmtest-driver.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/alsa/test-pcmtest-driver.c +4 -0
@@ -6,6 +6,7 @@* Copyright 2023 Ivan Orlov <[email protected]> */ #include <errno.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> #include <alsa/asoundlib.h>
@@ -171,6 +172,9 @@ FIXTURE_SETUP(pcmtest) {SKIP (return,"This test needs root to run!" ); err =read_patterns (); +/* nothing loads the module on its own, so ask for it */ +if (err && !system ("modprobe -q snd-pcmtest" )) + err =read_patterns ();if (err)SKIP (return,"Can't read patterns. Probably, module isn't loaded" );
Signature · 1 line
2.43.0
Mark Brown
maintainerRe: [PATCH 2/2] selftests: ALSA: pcmtest: Load the module when it is missing
Quoted 9 lines · HyeongJun An
test-pcmtest-driver skips when the pcmtest debugfs files are missing. The driver has no device to bind to, so nothing loads the module, and the test skips even on a kernel that builds it.
Run modprobe once before skipping, as the net pktgen test does. The module stays loaded. In the default order the test runs after mixer-test and pcm-test, so the extra card does not change what they check.
tools/testing/selftests/alsa/test-pcmtest-driver.c FIXTURE_SETUP(pcmtest) { · line 177
Quoted 6 lines
tools/testing/selftests/alsa/test-pcmtest-driver.c +3
-0@@ -171,6 +172,9 @@ FIXTURE_SETUP(pcmtest) {SKIP (return,"This test needs root to run!" ); err =read_patterns (); +/* nothing loads the module on its own, so ask for it */ +if (err && !system ("modprobe -q snd-pcmtest" )) + err =read_patterns ();
It'd be polite to unload the module if we caused it to be loaded, though potentially more trouble than it's worth. I'm also not sure if this does the right thing if someone decided to build the driver in (to make it easier to deploy onto a test system for example).