The wait_for_event() skips an event for a different control with a
continue inside its do-while loop. But continue goes straight to the
loop condition, and that tests the mask of the event just skipped. So
a value event for another control ends the wait as if it were ours.

A driver that notifies a second control from its put() queues that
event first. The core only sends ours once put() returns. So the wait
returns early and leaves ours in the queue. The next test then
reports it as spurious. And event_missing passes for a control whose
put() said nothing changed, as long as it notified a neighbour.

To fix this, clear the mask before skipping the event.

Fixes: b1446bda5645 ("kselftest: alsa: Check for event generation when we write 
to controls")
Signed-off-by: HyeongJun An <[email protected]>
Assisted-by: Claude:claude-opus-5-5
---
 tools/testing/selftests/alsa/mixer-test.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/alsa/mixer-test.c 
b/tools/testing/selftests/alsa/mixer-test.c
index 53a72753bb08..02136c436e16 100644
--- a/tools/testing/selftests/alsa/mixer-test.c
+++ b/tools/testing/selftests/alsa/mixer-test.c
@@ -267,6 +267,8 @@ static int wait_for_event(struct ctl_data *ctl, int timeout)
                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));
+                       /* The loop condition must not see the other control's 
mask */
+                       mask = 0;
                        continue;
                }
 
-- 
2.43.0


Reply via email to