summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/alsa
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2022-12-01 20:07:42 +0300
committerTakashi Iwai <tiwai@suse.de>2022-12-01 22:02:12 +0300
commit8370d9b00c929398cc79572a9b584878024ceb59 (patch)
tree1eb122a60b655a3fa5d2939358b473ba5a756932 /tools/testing/selftests/alsa
parentf944f8b539ea76bd70348bfc35dfa0780e510c0f (diff)
downloadlinux-8370d9b00c929398cc79572a9b584878024ceb59.tar.xz
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>
Diffstat (limited to 'tools/testing/selftests/alsa')
-rw-r--r--tools/testing/selftests/alsa/pcm-test.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/testing/selftests/alsa/pcm-test.c b/tools/testing/selftests/alsa/pcm-test.c
index edb820fe2ee6..c701cf507a95 100644
--- a/tools/testing/selftests/alsa/pcm-test.c
+++ b/tools/testing/selftests/alsa/pcm-test.c
@@ -241,6 +241,7 @@ static void test_pcm_time1(struct pcm_data *data,
snd_pcm_sframes_t frames;
long long ms;
long rate, channels, period_size, buffer_size;
+ unsigned int rchannels;
unsigned int rrate;
snd_pcm_uframes_t rperiod_size, rbuffer_size, start_threshold;
timestamp_t tstamp;
@@ -310,11 +311,17 @@ __format:
snd_pcm_format_name(format), snd_strerror(err));
goto __close;
}
- err = snd_pcm_hw_params_set_channels(handle, hw_params, channels);
+ rchannels = channels;
+ err = snd_pcm_hw_params_set_channels_near(handle, hw_params, &rchannels);
if (err < 0) {
snprintf(msg, sizeof(msg), "snd_pcm_hw_params_set_channels %ld: %s", channels, snd_strerror(err));
goto __close;
}
+ if (rchannels != channels) {
+ snprintf(msg, sizeof(msg), "channels unsupported %ld != %ld", channels, rchannels);
+ skip = true;
+ goto __close;
+ }
rrate = rate;
err = snd_pcm_hw_params_set_rate_near(handle, hw_params, &rrate, 0);
if (err < 0) {