From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Mark Brown <broonie@kernel.org>, Takashi Iwai <tiwai@suse.de>,
Shuah Khan <shuah@kernel.org>, Jaroslav Kysela <perex@perex.cz>
Cc: alsa-devel@alsa-project.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v2] kselftest: alsa: Add simplistic test for ALSA mixer controls kselftest
Date: Mon, 6 Dec 2021 10:31:17 -0600 [thread overview]
Message-ID: <d9a31741-6690-2d63-f86e-555e6afa83fc@linux.intel.com> (raw)
In-Reply-To: <33692870-fccc-6d63-2c95-056a21fff791@linux.intel.com>
>> +// This test will iterate over all cards detected in the system, exercising
>
> would it make sense to test only specific cards? People doing automated
> tests might have a USB device for capture of analog loopbacks, or
> injection of specific streams for capture, and usually care about
typo: Usually don't care about testing such devices.
'testing the tester' is a separate endeavor.
> testing such devices - which do need manual setups and wiring btw.
>
>> + switch (snd_ctl_elem_info_get_type(ctl->info)) {
>> + case SND_CTL_ELEM_TYPE_NONE:
>> + ksft_print_msg("%s Invalid control type NONE\n", ctl->name);
>> + err = -1;
>> + break;
>> +
>> + case SND_CTL_ELEM_TYPE_BOOLEAN:
>> + int_val = snd_ctl_elem_value_get_boolean(ctl->def_val, 0);
>> + switch (int_val) {
>> + case 0:
>> + case 1:
>> + break;
>> + default:
>> + ksft_print_msg("%s Invalid boolean value %ld\n",
>> + ctl->name, int_val);
>> + err = -1;
>> + break;
>> + }
>> + break;
>> +
>> + case SND_CTL_ELEM_TYPE_INTEGER:
>> + int_val = snd_ctl_elem_value_get_integer(ctl->def_val, 0);
>> +
>> + if (int_val < snd_ctl_elem_info_get_min(ctl->info)) {
>> + ksft_print_msg("%s value %ld less than minimum %ld\n",
>> + ctl->name, int_val,
>> + snd_ctl_elem_info_get_min(ctl->info));
>> + err = -1;
>> + }
>> +
>> + if (int_val > snd_ctl_elem_info_get_max(ctl->info)) {
>> + ksft_print_msg("%s value %ld more than maximum %ld\n",
>> + ctl->name, int_val,
>> + snd_ctl_elem_info_get_max(ctl->info));
>> + err = -1;
>> + }
>> +
>> + /* Only check step size if there is one and we're in bounds */
>> + if (err >= 0 && snd_ctl_elem_info_get_step(ctl->info) &&
>> + (int_val - snd_ctl_elem_info_get_min(ctl->info) %
>> + snd_ctl_elem_info_get_step(ctl->info))) {
>> + ksft_print_msg("%s value %ld invalid for step %ld minimum %ld\n",
>> + ctl->name, int_val,
>> + snd_ctl_elem_info_get_step(ctl->info),
>> + snd_ctl_elem_info_get_min(ctl->info));
>> + err = -1;
>> + }
>> + break;
>> +
>> + case SND_CTL_ELEM_TYPE_INTEGER64:
>> + int64_val = snd_ctl_elem_value_get_integer64(ctl->def_val, 0);
>> +
>> + if (int64_val < snd_ctl_elem_info_get_min64(ctl->info)) {
>> + ksft_print_msg("%s value %lld less than minimum %lld\n",
>> + ctl->name, int64_val,
>> + snd_ctl_elem_info_get_min64(ctl->info));
>> + err = -1;
>> + }
>> +
>> + if (int64_val > snd_ctl_elem_info_get_max64(ctl->info)) {
>> + ksft_print_msg("%s value %lld more than maximum %lld\n",
>> + ctl->name, int64_val,
>> + snd_ctl_elem_info_get_max(ctl->info));
>> + err = -1;
>> + }
>> +
>> + /* Only check step size if there is one and we're in bounds */
>> + if (err >= 0 && snd_ctl_elem_info_get_step64(ctl->info) &&
>> + (int64_val - snd_ctl_elem_info_get_min64(ctl->info)) %
>> + snd_ctl_elem_info_get_step64(ctl->info)) {
>> + ksft_print_msg("%s value %lld invalid for step %lld minimum %lld\n",
>> + ctl->name, int64_val,
>> + snd_ctl_elem_info_get_step64(ctl->info),
>> + snd_ctl_elem_info_get_min64(ctl->info));
>> + err = -1;
>> + }
>> + break;
>> +
>> + default:
>> + /* No tests for other types */
>
> these types include ENUMERATED, BYTES and IEC958, but see below for
> ENUMERATED...
>
>> + ksft_test_result_skip("get_value.%d.%d\n",
>> + ctl->card->card, ctl->elem);
>> + return;
>> + }
>> +
>> +out:
>> + ksft_test_result(err >= 0, "get_value.%d.%d\n",
>> + ctl->card->card, ctl->elem);
>> +}
>> +
>> +bool show_mismatch(struct ctl_data *ctl, int index,
>> + snd_ctl_elem_value_t *read_val,
>> + snd_ctl_elem_value_t *expected_val)
>> +{
>> + long long expected_int, read_int;
>> +
>> + /*
>> + * We factor out the code to compare values representable as
>> + * integers, ensure that check doesn't log otherwise.
>> + */
>> + expected_int = 0;
>> + read_int = 0;
>> +
>> + switch (snd_ctl_elem_info_get_type(ctl->info)) {
>> + case SND_CTL_ELEM_TYPE_BOOLEAN:
>> + expected_int = snd_ctl_elem_value_get_boolean(expected_val,
>> + index);
>> + read_int = snd_ctl_elem_value_get_boolean(read_val, index);
>> + break;
>> +
>> + case SND_CTL_ELEM_TYPE_INTEGER:
>> + expected_int = snd_ctl_elem_value_get_integer(expected_val,
>> + index);
>> + read_int = snd_ctl_elem_value_get_integer(read_val, index);
>> + break;
>> +
>> + case SND_CTL_ELEM_TYPE_INTEGER64:
>> + expected_int = snd_ctl_elem_value_get_integer64(expected_val,
>> + index);
>> + read_int = snd_ctl_elem_value_get_integer64(read_val,
>> + index);
>> + break;
>> +
>> + case SND_CTL_ELEM_TYPE_ENUMERATED:
>
> ... here you are handling ENUMERATED types?
>
>> + expected_int = snd_ctl_elem_value_get_enumerated(expected_val,
>> + index);
>> + read_int = snd_ctl_elem_value_get_enumerated(read_val,
>> + index);
>> + break;
>> +
>> + default:
>> + break;
>> + }
>> +
>> + if (expected_int != read_int) {
>> + ksft_print_msg("%s.%d expected %lld but read %lld\n",
>> + ctl->name, index, expected_int, read_int);
>> + return true;
>> + } else {
>> + return false;
>> + }
>> +}
>
next prev parent reply other threads:[~2021-12-06 16:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-06 16:03 [PATCH v2] kselftest: alsa: Add simplistic test for ALSA mixer controls kselftest Mark Brown
2021-12-06 16:27 ` Pierre-Louis Bossart
2021-12-06 16:31 ` Pierre-Louis Bossart [this message]
2021-12-06 16:39 ` Mark Brown
2021-12-06 17:01 ` Pierre-Louis Bossart
2021-12-06 18:17 ` Mark Brown
2021-12-07 3:20 ` Takashi Sakamoto
2021-12-07 8:05 ` Jaroslav Kysela
2021-12-07 14:25 ` Mark Brown
2021-12-07 14:36 ` Takashi Iwai
2021-12-07 14:49 ` Mark Brown
2021-12-08 14:26 ` Takashi Sakamoto
2021-12-08 14:31 ` Takashi Sakamoto
2021-12-08 16:07 ` Mark Brown
2021-12-08 17:42 ` Shuah Khan
2021-12-08 18:39 ` Mark Brown
2021-12-08 18:59 ` Shuah Khan
2021-12-08 20:12 ` Mark Brown
2021-12-08 21:14 ` Shuah Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d9a31741-6690-2d63-f86e-555e6afa83fc@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=perex@perex.cz \
--cc=shuah@kernel.org \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).