* [PATCH 1/2] selftests/alsa: Add a config file for the test-only options
2026-11-26 3:55 [PATCH 0/2] selftests/alsa: Let the pcmtest test run on kselftest kernels HyeongJun An
@ 2026-11-26 3:55 ` HyeongJun An
2026-11-26 16:08 ` Mark Brown
2026-11-26 3:55 ` [PATCH 2/2] selftests: ALSA: pcmtest: Load the module when it is missing HyeongJun An
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: HyeongJun An @ 2026-11-26 3:55 UTC (permalink / raw)
To: Mark Brown, Takashi Iwai
Cc: Jaroslav Kysela, Shuah Khan, Ivan Orlov, Ben Copeland,
linux-sound, linux-kselftest, linux-kernel, 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 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.
Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
---
tools/testing/selftests/alsa/config | 6 ++++++
1 file changed, 6 insertions(+)
create mode 100644 tools/testing/selftests/alsa/config
diff --git a/tools/testing/selftests/alsa/config b/tools/testing/selftests/alsa/config
new file mode 100644
index 000000000000..67fa26a87217
--- /dev/null
+++ b/tools/testing/selftests/alsa/config
@@ -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
--
2.43.0
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 1/2] selftests/alsa: Add a config file for the test-only options
2026-11-26 3:55 ` [PATCH 1/2] selftests/alsa: Add a config file for the test-only options HyeongJun An
@ 2026-11-26 16:08 ` Mark Brown
0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2026-11-26 16:08 UTC (permalink / raw)
To: HyeongJun An
Cc: Takashi Iwai, Jaroslav Kysela, Shuah Khan, Ivan Orlov,
Ben Copeland, linux-sound, linux-kselftest, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 472 bytes --]
On Thu, Nov 26, 2026 at 12:55:24PM +0900, HyeongJun An wrote:
> 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.
> +CONFIG_SND_PCMTEST=m
This is inside CONFIG_SND_DRIVERS, you need to select that in case the
underlying config has disabled it.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] selftests: ALSA: pcmtest: Load the module when it is missing
2026-11-26 3:55 [PATCH 0/2] selftests/alsa: Let the pcmtest test run on kselftest kernels HyeongJun An
2026-11-26 3:55 ` [PATCH 1/2] selftests/alsa: Add a config file for the test-only options HyeongJun An
@ 2026-11-26 3:55 ` HyeongJun An
2026-11-26 16:11 ` Mark Brown
2026-11-28 6:52 ` [PATCH v2 0/2] selftests/alsa: Let the pcmtest test run on kselftest kernels HyeongJun An
` (2 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: HyeongJun An @ 2026-11-26 3:55 UTC (permalink / raw)
To: Mark Brown, Takashi Iwai
Cc: Jaroslav Kysela, Shuah Khan, Ivan Orlov, Ben Copeland,
linux-sound, linux-kselftest, linux-kernel, 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.
Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
---
tools/testing/selftests/alsa/test-pcmtest-driver.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/testing/selftests/alsa/test-pcmtest-driver.c b/tools/testing/selftests/alsa/test-pcmtest-driver.c
index b796a5613c6f..ea6a9e0f7483 100644
--- a/tools/testing/selftests/alsa/test-pcmtest-driver.c
+++ b/tools/testing/selftests/alsa/test-pcmtest-driver.c
@@ -6,6 +6,7 @@
* Copyright 2023 Ivan Orlov <ivan.orlov0322@gmail.com>
*/
#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");
--
2.43.0
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 2/2] selftests: ALSA: pcmtest: Load the module when it is missing
2026-11-26 3:55 ` [PATCH 2/2] selftests: ALSA: pcmtest: Load the module when it is missing HyeongJun An
@ 2026-11-26 16:11 ` Mark Brown
0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2026-11-26 16:11 UTC (permalink / raw)
To: HyeongJun An
Cc: Takashi Iwai, Jaroslav Kysela, Shuah Khan, Ivan Orlov,
Ben Copeland, linux-sound, linux-kselftest, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1028 bytes --]
On Thu, Nov 26, 2026 at 12:55:25PM +0900, HyeongJun An wrote:
> 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.
> @@ -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).
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 0/2] selftests/alsa: Let the pcmtest test run on kselftest kernels
2026-11-26 3:55 [PATCH 0/2] selftests/alsa: Let the pcmtest test run on kselftest kernels HyeongJun An
2026-11-26 3:55 ` [PATCH 1/2] selftests/alsa: Add a config file for the test-only options HyeongJun An
2026-11-26 3:55 ` [PATCH 2/2] selftests: ALSA: pcmtest: Load the module when it is missing HyeongJun An
@ 2026-11-28 6:52 ` HyeongJun An
2026-11-28 6:52 ` [PATCH v2 1/2] selftests/alsa: Add a config file for the test-only options HyeongJun An
2026-11-28 6:52 ` [PATCH v2 2/2] selftests: ALSA: pcmtest: Load the module when it is missing HyeongJun An
4 siblings, 0 replies; 8+ messages in thread
From: HyeongJun An @ 2026-11-28 6:52 UTC (permalink / raw)
To: broonie, tiwai
Cc: perex, shuah, ivan.orlov0322, ben.copeland, linux-sound,
linux-kselftest, linux-kernel, HyeongJun An
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. Patch 2 lets test-pcmtest-driver load
the module itself and unload it again at exit.
Tested in QEMU on sound/for-next 486060b97284, on x86_64 from
x86_64_defconfig and on arm64 from defconfig, each followed by make
kselftest-merge. On both, test-pcmtest-driver passes all 10 cases. The
module is gone after the run when it was not loaded before, and stays
loaded when it was. With a base config that turns off CONFIG_SND_DRIVERS,
the v1 config file lost CONFIG_SND_PCMTEST and CONFIG_SND_ALOOP in the
merge, and this one keeps them.
Changes in v2:
- Patch 1: Enable CONFIG_SND_DRIVERS, which pcmtest and aloop are under
(Mark). Name the options that are off on KernelCI. snd-aloop is on
there, so v1 was wrong to say all four were off.
- Patch 2: Unload the module at exit if the test loaded it (Mark).
v1: https://lore.kernel.org/all/20261126035526.1779288-1-sammiee5311@gmail.com/
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 | 7 +++++++
.../selftests/alsa/test-pcmtest-driver.c | 20 +++++++++++++++++++
2 files changed, 27 insertions(+)
create mode 100644 tools/testing/selftests/alsa/config
--
2.43.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/2] selftests/alsa: Add a config file for the test-only options
2026-11-26 3:55 [PATCH 0/2] selftests/alsa: Let the pcmtest test run on kselftest kernels HyeongJun An
` (2 preceding siblings ...)
2026-11-28 6:52 ` [PATCH v2 0/2] selftests/alsa: Let the pcmtest test run on kselftest kernels HyeongJun An
@ 2026-11-28 6:52 ` HyeongJun An
2026-11-28 6:52 ` [PATCH v2 2/2] selftests: ALSA: pcmtest: Load the module when it is missing HyeongJun An
4 siblings, 0 replies; 8+ messages in thread
From: HyeongJun An @ 2026-11-28 6:52 UTC (permalink / raw)
To: broonie, tiwai
Cc: perex, shuah, ivan.orlov0322, ben.copeland, linux-sound,
linux-kselftest, linux-kernel, 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 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 CONFIG_SND_PCMTEST, CONFIG_SND_SEQ_UMP
and CONFIG_SND_UTIMER are off, and every test-pcmtest-driver case skips.
Add a config file with only these options. pcmtest and aloop are under
CONFIG_SND_DRIVERS, so enable that too in case the base config turns it
off. mixer-test and pcm-test check whatever sound drivers a system has,
so no drivers are listed.
Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
---
tools/testing/selftests/alsa/config | 7 +++++++
1 file changed, 7 insertions(+)
create mode 100644 tools/testing/selftests/alsa/config
diff --git a/tools/testing/selftests/alsa/config b/tools/testing/selftests/alsa/config
new file mode 100644
index 000000000000..23ea0ccfdfa6
--- /dev/null
+++ b/tools/testing/selftests/alsa/config
@@ -0,0 +1,7 @@
+CONFIG_DEBUG_FS=y
+CONFIG_SND_ALOOP=m
+CONFIG_SND_DRIVERS=y
+CONFIG_SND_PCMTEST=m
+CONFIG_SND_SEQUENCER=m
+CONFIG_SND_SEQ_UMP=y
+CONFIG_SND_UTIMER=y
--
2.43.0
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v2 2/2] selftests: ALSA: pcmtest: Load the module when it is missing
2026-11-26 3:55 [PATCH 0/2] selftests/alsa: Let the pcmtest test run on kselftest kernels HyeongJun An
` (3 preceding siblings ...)
2026-11-28 6:52 ` [PATCH v2 1/2] selftests/alsa: Add a config file for the test-only options HyeongJun An
@ 2026-11-28 6:52 ` HyeongJun An
4 siblings, 0 replies; 8+ messages in thread
From: HyeongJun An @ 2026-11-28 6:52 UTC (permalink / raw)
To: broonie, tiwai
Cc: perex, shuah, ivan.orlov0322, ben.copeland, linux-sound,
linux-kselftest, linux-kernel, 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. Each test
runs in a child process, so record whether the module was loaded before
the tests start, and unload it at exit if the tests loaded it.
Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
---
A built-in pcmtest creates its debugfs files at boot, so read_patterns()
succeeds and modprobe is not run. If debugfs is not mounted, modprobe of
a built-in module returns 0, the second read fails, and the test skips as
before.
.../selftests/alsa/test-pcmtest-driver.c | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/tools/testing/selftests/alsa/test-pcmtest-driver.c b/tools/testing/selftests/alsa/test-pcmtest-driver.c
index b796a5613c6f..3bd6f75ac6f6 100644
--- a/tools/testing/selftests/alsa/test-pcmtest-driver.c
+++ b/tools/testing/selftests/alsa/test-pcmtest-driver.c
@@ -6,6 +6,7 @@
* Copyright 2023 Ivan Orlov <ivan.orlov0322@gmail.com>
*/
#include <errno.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <alsa/asoundlib.h>
@@ -149,6 +150,22 @@ static int setup_handle(snd_pcm_t **handle, snd_pcm_sw_params_t *swparams,
return 0;
}
+static bool module_was_loaded;
+
+/* remember whether snd-pcmtest was loaded before the tests ran */
+static void __attribute__((constructor)) check_module(void)
+{
+ module_was_loaded = !access("/sys/module/snd_pcmtest", F_OK);
+}
+
+/* each test runs in a child, so unload in the parent once all are done */
+static void __attribute__((destructor)) unload_module(void)
+{
+ if (!module_was_loaded && !access("/sys/module/snd_pcmtest", F_OK) &&
+ system("modprobe -r -q snd-pcmtest"))
+ ksft_print_msg("Failed to unload snd-pcmtest\n");
+}
+
FIXTURE(pcmtest) {
int card;
snd_pcm_sw_params_t *swparams;
@@ -171,6 +188,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");
--
2.43.0
^ permalink raw reply [flat|nested] 8+ messages in thread