Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <broonie@kernel.org>
Link: https://lore.kernel.org/r/20221201170745.1111236-4-broonie@kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Mark Brown and committed by
Takashi Iwai
8370d9b0 f944f8b5

+8 -1
+8 -1
tools/testing/selftests/alsa/pcm-test.c
··· 241 241 snd_pcm_sframes_t frames; 242 242 long long ms; 243 243 long rate, channels, period_size, buffer_size; 244 + unsigned int rchannels; 244 245 unsigned int rrate; 245 246 snd_pcm_uframes_t rperiod_size, rbuffer_size, start_threshold; 246 247 timestamp_t tstamp; ··· 311 310 snd_pcm_format_name(format), snd_strerror(err)); 312 311 goto __close; 313 312 } 314 - err = snd_pcm_hw_params_set_channels(handle, hw_params, channels); 313 + rchannels = channels; 314 + err = snd_pcm_hw_params_set_channels_near(handle, hw_params, &rchannels); 315 315 if (err < 0) { 316 316 snprintf(msg, sizeof(msg), "snd_pcm_hw_params_set_channels %ld: %s", channels, snd_strerror(err)); 317 + goto __close; 318 + } 319 + if (rchannels != channels) { 320 + snprintf(msg, sizeof(msg), "channels unsupported %ld != %ld", channels, rchannels); 321 + skip = true; 317 322 goto __close; 318 323 } 319 324 rrate = rate;