Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kselftest/alsa - mixer-test: Log values associated with event issues

While it is common for driver bugs with events to apply to all events there
are some issues which only trigger for specific values. Understanding these
is easier if we know what we were trying to do when configuring the control
so add logging for the specific values involved in the spurious event.

Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230322-alsa-mixer-event-values-v1-1-78189fcf6655@kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Mark Brown and committed by
Takashi Iwai
05a2cdfe b1e675d1

+44
+44
tools/testing/selftests/alsa/mixer-test.c
··· 458 458 ctl->card->card, ctl->elem); 459 459 } 460 460 461 + static void show_values(struct ctl_data *ctl, snd_ctl_elem_value_t *orig_val, 462 + snd_ctl_elem_value_t *read_val) 463 + { 464 + long long orig_int, read_int; 465 + int i; 466 + 467 + for (i = 0; i < snd_ctl_elem_info_get_count(ctl->info); i++) { 468 + switch (snd_ctl_elem_info_get_type(ctl->info)) { 469 + case SND_CTL_ELEM_TYPE_BOOLEAN: 470 + orig_int = snd_ctl_elem_value_get_boolean(orig_val, i); 471 + read_int = snd_ctl_elem_value_get_boolean(read_val, i); 472 + break; 473 + 474 + case SND_CTL_ELEM_TYPE_INTEGER: 475 + orig_int = snd_ctl_elem_value_get_integer(orig_val, i); 476 + read_int = snd_ctl_elem_value_get_integer(read_val, i); 477 + break; 478 + 479 + case SND_CTL_ELEM_TYPE_INTEGER64: 480 + orig_int = snd_ctl_elem_value_get_integer64(orig_val, 481 + i); 482 + read_int = snd_ctl_elem_value_get_integer64(read_val, 483 + i); 484 + break; 485 + 486 + case SND_CTL_ELEM_TYPE_ENUMERATED: 487 + orig_int = snd_ctl_elem_value_get_enumerated(orig_val, 488 + i); 489 + read_int = snd_ctl_elem_value_get_enumerated(read_val, 490 + i); 491 + break; 492 + 493 + default: 494 + return; 495 + } 496 + 497 + ksft_print_msg("%s.%d orig %lld read %lld, is_volatile %d\n", 498 + ctl->name, i, orig_int, read_int, 499 + snd_ctl_elem_info_is_volatile(ctl->info)); 500 + } 501 + } 502 + 461 503 static bool show_mismatch(struct ctl_data *ctl, int index, 462 504 snd_ctl_elem_value_t *read_val, 463 505 snd_ctl_elem_value_t *expected_val) ··· 639 597 if (err < 1) { 640 598 ksft_print_msg("No event generated for %s\n", 641 599 ctl->name); 600 + show_values(ctl, initial_val, read_val); 642 601 ctl->event_missing++; 643 602 } 644 603 } else { 645 604 if (err != 0) { 646 605 ksft_print_msg("Spurious event generated for %s\n", 647 606 ctl->name); 607 + show_values(ctl, initial_val, read_val); 648 608 ctl->event_spurious++; 649 609 } 650 610 }