A kernel built without CONFIG_SND exposes no ALSA devices. In that environment, the mixer and PCM tests currently report success with a zero-test plan, while the userspace timer tests fail when opening /dev/snd/timer. Neither result accurately describes an unsupported test environment.
Report KSFT_SKIP when no sound cards are detected and when the timer device is unavailable. Keep the PCM missing-card failures when a matching hardware configuration says that a card should exist, and continue to fail timer opens for unexpected errors. Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218479 Signed-off-by: Alireza Feyzabadi Farahani <[email protected]> --- tools/testing/selftests/alsa/mixer-test.c | 2 ++ tools/testing/selftests/alsa/pcm-test.c | 2 ++ tools/testing/selftests/alsa/utimer-test.c | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/tools/testing/selftests/alsa/mixer-test.c b/tools/testing/selftests/alsa/mixer-test.c index 6edffcd6f..ab70645d5 100644 --- a/tools/testing/selftests/alsa/mixer-test.c +++ b/tools/testing/selftests/alsa/mixer-test.c @@ -1378,6 +1378,8 @@ int main(void) ksft_print_header(); find_controls(); + if (!card_list) + ksft_exit_skip("No sound cards detected\n"); ksft_set_plan(num_controls * TESTS_PER_CONTROL); diff --git a/tools/testing/selftests/alsa/pcm-test.c b/tools/testing/selftests/alsa/pcm-test.c index ee04ccef7..de07de650 100644 --- a/tools/testing/selftests/alsa/pcm-test.c +++ b/tools/testing/selftests/alsa/pcm-test.c @@ -613,6 +613,8 @@ int main(void) conf_load(); find_pcms(); + if (!card_list && !conf_cards) + ksft_exit_skip("No sound cards detected\n"); for (conf = conf_cards; conf; conf = conf->next) if (conf->card < 0) diff --git a/tools/testing/selftests/alsa/utimer-test.c b/tools/testing/selftests/alsa/utimer-test.c index 1a9ff010c..07aeaa777 100644 --- a/tools/testing/selftests/alsa/utimer-test.c +++ b/tools/testing/selftests/alsa/utimer-test.c @@ -51,6 +51,9 @@ FIXTURE_SETUP(timer_f) { self->utimer_info->resolution = (NANO / FRAME_RATE * PERIOD_SIZE); timer_dev_fd = open("/dev/snd/timer", O_RDONLY); + if (timer_dev_fd < 0 && + (errno == ENOENT || errno == ENODEV || errno == ENXIO)) + SKIP(return, "ALSA timer device unavailable"); ASSERT_GE(timer_dev_fd, 0); if (ioctl(timer_dev_fd, SNDRV_TIMER_IOCTL_CREATE, self->utimer_info) < 0) { @@ -156,6 +159,9 @@ TEST(wrong_timers_test) { }; timer_dev_fd = open("/dev/snd/timer", O_RDONLY); + if (timer_dev_fd < 0 && + (errno == ENOENT || errno == ENODEV || errno == ENXIO)) + SKIP(return, "ALSA timer device unavailable"); ASSERT_GE(timer_dev_fd, 0); utimer_fd = ioctl(timer_dev_fd, SNDRV_TIMER_IOCTL_CREATE, &wrong_timer); -- 2.34.1

