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 sample rate as skips

If constraint selection gives us a sample rate other than the one that we
asked for that isn't a failure, that is the device implementing sample
rate 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-3-broonie@kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Mark Brown and committed by
Takashi Iwai
f944f8b5 22eeb8f5

+17 -6
+17 -6
tools/testing/selftests/alsa/pcm-test.c
··· 247 247 bool pass = false, automatic = true; 248 248 snd_pcm_hw_params_t *hw_params; 249 249 snd_pcm_sw_params_t *sw_params; 250 + bool skip = false; 250 251 251 252 snd_pcm_hw_params_alloca(&hw_params); 252 253 snd_pcm_sw_params_alloca(&sw_params); ··· 322 321 goto __close; 323 322 } 324 323 if (rrate != rate) { 325 - snprintf(msg, sizeof(msg), "rate mismatch %ld != %ld", rate, rrate); 324 + snprintf(msg, sizeof(msg), "rate unsupported %ld != %ld", rate, rrate); 325 + skip = true; 326 326 goto __close; 327 327 } 328 328 rperiod_size = period_size; ··· 419 417 msg[0] = '\0'; 420 418 pass = true; 421 419 __close: 422 - ksft_test_result(pass, "%s.%d.%d.%d.%s%s%s\n", 423 - test->cfg_prefix, 424 - data->card, data->device, data->subdevice, 425 - snd_pcm_stream_name(data->stream), 426 - msg[0] ? " " : "", msg); 420 + if (!skip) { 421 + ksft_test_result(pass, "%s.%d.%d.%d.%s%s%s\n", 422 + test->cfg_prefix, 423 + data->card, data->device, data->subdevice, 424 + snd_pcm_stream_name(data->stream), 425 + msg[0] ? " " : "", msg); 426 + } else { 427 + ksft_test_result_skip("%s.%d.%d.%d.%s%s%s\n", 428 + test->cfg_prefix, 429 + data->card, data->device, 430 + data->subdevice, 431 + snd_pcm_stream_name(data->stream), 432 + msg[0] ? " " : "", msg); 433 + } 427 434 free(samples); 428 435 if (handle) 429 436 snd_pcm_close(handle);