Skip to contentSkip to conversation

selftests: ALSA: Skip utimer test when CONFIG_SND_UTIMER is not enabled

PATCH Applied Ben Copeland 3 participants 3 messages Mar 19 – Mar 27

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

PATCH 1/1 selftests: ALSA: Skip utimer test when CONFIG_SND_UTIMER is not enabled

The timer_f.utimer test hard-fails with ASSERT_EQ when SNDRV_TIMER_IOCTL_CREATE returns -1 on kernels without CONFIG_SND_UTIMER. This causes the entire alsa kselftest suite to report a failure rather than skipping the unsupported test.

When CONFIG_SND_UTIMER is not enabled, the ioctl is not recognised and the kernel returns -ENOTTY. If the timer device or subdevice does not exist, -ENXIO is returned. Skip the test in both cases, but still fail on any other unexpected error.

---
 tools/testing/selftests/alsa/utimer-test.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
tools/testing/selftests/alsa/utimer-test.c +9 -1
index d221972cd8fb..1a9ff010cb11 100644
@@ -15,6 +15,7 @@
 #include <stdlib.h>
 #include <pthread.h>
 #include <string.h>
+#include <errno.h>
 
 #define FRAME_RATE 8000
 #define PERIOD_SIZE 4410
@@ -52,7 +53,14 @@ FIXTURE_SETUP(timer_f) {
 	timer_dev_fd = open("/dev/snd/timer", O_RDONLY);
 	ASSERT_GE(timer_dev_fd, 0);
 
-	ASSERT_EQ(ioctl(timer_dev_fd, SNDRV_TIMER_IOCTL_CREATE, self->utimer_info), 0);
+	if (ioctl(timer_dev_fd, SNDRV_TIMER_IOCTL_CREATE, self->utimer_info) < 0) {
+		int err = errno;
+
+		close(timer_dev_fd);
+		if (err == ENOTTY || err == ENXIO)
+			SKIP(return, "CONFIG_SND_UTIMER not enabled");
+		ASSERT_EQ(err, 0);
+	}
 	ASSERT_GE(self->utimer_info->fd, 0);
 
 	close(timer_dev_fd);
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Ben Copeland

The timer_f.utimer test hard-fails with ASSERT_EQ when SNDRV_TIMER_IOCTL_CREATE returns -1 on kernels without CONFIG_SND_UTIMER. This causes the entire alsa kselftest suite to report a failure rather than skipping the unsupported test.

Applied
#2 lore raw
In reply to Ben Copeland
Quoted 6 lines · Ben Copeland

The timer_f.utimer test hard-fails with ASSERT_EQ when SNDRV_TIMER_IOCTL_CREATE returns -1 on kernels without CONFIG_SND_UTIMER. This causes the entire alsa kselftest suite to report a failure rather than skipping the unsupported test.

Quoted 8 lines

When CONFIG_SND_UTIMER is not enabled, the ioctl is not recognised and the kernel returns -ENOTTY. If the timer device or subdevice does not exist, -ENXIO is returned. Skip the test in both cases, but still fail on any other unexpected error.

Applied to for-next branch now. Thanks.

Takashi