Skip to content

Commit 8370d9b

Browse files
broonietiwai
authored andcommitted
kselftest/alsa: Report failures to set the requested channels as skips
If constraint selection gives us a number of channels other than the one that we asked for that isn't a failure, that is the device implementing constraints and advertising that it can't support whatever we asked for. Report such cases as a test skip rather than failure so we don't have false positives. Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent f944f8b commit 8370d9b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tools/testing/selftests/alsa/pcm-test.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ static void test_pcm_time1(struct pcm_data *data,
241241
snd_pcm_sframes_t frames;
242242
long long ms;
243243
long rate, channels, period_size, buffer_size;
244+
unsigned int rchannels;
244245
unsigned int rrate;
245246
snd_pcm_uframes_t rperiod_size, rbuffer_size, start_threshold;
246247
timestamp_t tstamp;
@@ -310,11 +311,17 @@ static void test_pcm_time1(struct pcm_data *data,
310311
snd_pcm_format_name(format), snd_strerror(err));
311312
goto __close;
312313
}
313-
err = snd_pcm_hw_params_set_channels(handle, hw_params, channels);
314+
rchannels = channels;
315+
err = snd_pcm_hw_params_set_channels_near(handle, hw_params, &rchannels);
314316
if (err < 0) {
315317
snprintf(msg, sizeof(msg), "snd_pcm_hw_params_set_channels %ld: %s", channels, snd_strerror(err));
316318
goto __close;
317319
}
320+
if (rchannels != channels) {
321+
snprintf(msg, sizeof(msg), "channels unsupported %ld != %ld", channels, rchannels);
322+
skip = true;
323+
goto __close;
324+
}
318325
rrate = rate;
319326
err = snd_pcm_hw_params_set_rate_near(handle, hw_params, &rrate, 0);
320327
if (err < 0) {

0 commit comments

Comments
 (0)