On 02. 02. 22 15:10, Mark Brown wrote:
Add some coverage of event generation to mixer-test. Rather than doing a separate set of writes designed to trigger events we add a step to the existing write_and_verify() which checks to see if the value we read back from non-volatile controls matches the value before writing and that an event is or isn't generated as appropriate. The "tests" for events then simply check that no spurious or missing events were detected. This avoids needing further logic to generate appropriate values for each control type and maximises coverage.
When checking for events we use a timeout of 0. This relies on the kernel generating any event prior to returning to userspace when setting a control. That is currently the case and it is difficult to see it changing, if it does the test will need to be updated. Using a delay of 0 means that we don't slow things down unduly when checking for no event or when events fail to be generated.
We don't check behaviour for volatile controls since we can't tell what the behaviour is supposed to be for any given control.
Signed-off-by: Mark Brown broonie@kernel.org Reviewed-by: Shuah Khan skhan@linuxfoundation.org
...
/* The ID returned from the event is 1 less than numid */
mask = snd_ctl_event_elem_get_mask(event);
ev_id = snd_ctl_event_elem_get_numid(event);
if (ev_id != snd_ctl_elem_info_get_numid(ctl->info)) {
ksft_print_msg("Event for unexpected ctl %s\n",
snd_ctl_event_elem_get_name(event));
continue;
}
- } while ((mask & SND_CTL_EVENT_MASK_VALUE) != SND_CTL_EVENT_MASK_VALUE);
A special check for SND_CTL_EVENT_MASK_REMOVE (~0U) is missing here.
For the rest:
Reviewed-by: Jaroslav Kysela perex@perex.cz
Thanks, Jaroslav
-- Jaroslav Kysela perex@perex.cz Linux Sound Maintainer; ALSA Project; Red Hat, Inc.