Skip to contentSkip to conversation

selftests: ALSA: pcmtest: Compare all captured bytes in ni_capture

PATCH In review HyeongJun An 2 participants 2 messages Oct 21

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

PATCH 1/1 selftests: ALSA: pcmtest: Compare all captured bytes in ni_capture

The ni_capture test reads rate * time frames into each channel buffer and then compares rate * time bytes. A frame is sample_size bytes per channel, so with S16_LE only the first half of each channel is checked. If the second half is wrong the test still passes.

Compare rate * time * sample_size bytes per channel.

Fixes 10b98a4db11a ("selftests: ALSA: Add test for the 'pcmtest' driver")
Assisted-by Claude:claude-opus-5-5
---
 tools/testing/selftests/alsa/test-pcmtest-driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/alsa/test-pcmtest-driver.c +1 -1
index e025a7bac26b..18ee72d5d4c9 100644
@@ -265,7 +265,7 @@ TEST_F(pcmtest, ni_capture) {
 	snd_pcm_close(handle);
 
 	for (i = 0; i < CH_NUM; i++) {
-		for (j = 0; j < params.rate * params.time; j++)
+		for (j = 0; j < params.rate * params.time * params.sample_size; j++)
 			ASSERT_EQ(chan_samples[i][j], patterns[i].buf[j % patterns[i].len]);
 		free(chan_samples[i]);
 	}
Signature · 1 line
2.43.0
#1 lore raw
Quoted 11 lines · HyeongJun An

The ni_capture test reads rate * time frames into each channel buffer and then compares rate * time bytes. A frame is sample_size bytes per channel, so with S16_LE only the first half of each channel is checked. If the second half is wrong the test still passes.

Compare rate * time * sample_size bytes per channel.

Fixes 10b98a4db11a ("selftests: ALSA: Add test for the 'pcmtest' driver")
Assisted-by Claude:claude-opus-5-5

Applied now. Thanks.

Takashi