Skip to contentSkip to conversation

selftests: ALSA: Skip timer tests when device is unavailable

PATCH Applied Alireza Feyzabadi Farahani 3 participants 3 messages Sep 27 – Sep 28

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 selftests: ALSA: Skip timer tests when device is unavailable

When CONFIG_SND is disabled, opening /dev/snd/timer fails and the userspace timer tests report failures even though the test environment does not support ALSA timers.

Skip the affected tests when opening the timer device fails because the device is unavailable. Continue to report unexpected open failures as test failures.

---
Changes in v2:
- Limit the change to the timer tests, leaving the PCM and mixer tests unchanged, as suggested by Mark Brown.

 tools/testing/selftests/alsa/utimer-test.c | 6 ++++++
 1 file changed, 6 insertions(+)
tools/testing/selftests/alsa/utimer-test.c +6 -0
index 1a9ff010c..07aeaa777 100644
@@ -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);
Signature · 1 line
2.34.1
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Alireza Feyzabadi Farahani

When CONFIG_SND is disabled, opening /dev/snd/timer fails and the userspace timer tests report failures even though the test environment does not support ALSA timers.

Skip the affected tests when opening the timer device fails because the device is unavailable. Continue to report unexpected open failures as test failures.

Applied
#2 lore raw
In reply to Alireza Feyzabadi Farahani
Quoted 11 lines · Alireza Feyzabadi Farahani

When CONFIG_SND is disabled, opening /dev/snd/timer fails and the userspace timer tests report failures even though the test environment does not support ALSA timers.

Skip the affected tests when opening the timer device fails because the device is unavailable. Continue to report unexpected open failures as test failures.

Applied to for-next branch. Thanks.

Takashi