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

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: cs-amp-lib: Add KUnit test case for empty calibration entries

Add a test case for commit bb4485562f59 ("ASoC: cs-amp-lib: Ignore
empty UEFI calibration entries").

Any entries in the calibration blob that have calTime==0 are empty
entries. So they must not be returned by a lookup.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20240830144819.118362-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Richard Fitzgerald and committed by
Mark Brown
99c9767c 03515f9f

+44
+44
sound/soc/codecs/cs-amp-lib-test.c
··· 515 515 kunit_deactivate_static_stub(test, cs_amp_test_hooks->get_efi_variable); 516 516 } 517 517 518 + /* 519 + * If an entry has a timestamp of 0 it should be ignored even if it has 520 + * a matching target UID. 521 + */ 522 + static void cs_amp_lib_test_get_efi_cal_empty_entry_test(struct kunit *test) 523 + { 524 + struct cs_amp_lib_test_priv *priv = test->priv; 525 + struct cirrus_amp_cal_data result_data; 526 + u64 uid; 527 + 528 + cs_amp_lib_test_init_dummy_cal_blob(test, 8); 529 + 530 + /* Mark the 3rd entry invalid by zeroing calTime */ 531 + priv->cal_blob->data[2].calTime[0] = 0; 532 + priv->cal_blob->data[2].calTime[1] = 0; 533 + 534 + /* Get the UID value of the 3rd entry */ 535 + uid = priv->cal_blob->data[2].calTarget[1]; 536 + uid <<= 32; 537 + uid |= priv->cal_blob->data[2].calTarget[0]; 538 + 539 + /* Redirect calls to get EFI data */ 540 + kunit_activate_static_stub(test, 541 + cs_amp_test_hooks->get_efi_variable, 542 + cs_amp_lib_test_get_efi_variable); 543 + 544 + /* Lookup by UID should not find it */ 545 + KUNIT_EXPECT_EQ(test, 546 + cs_amp_get_efi_calibration_data(&priv->amp_pdev.dev, 547 + uid, -1, 548 + &result_data), 549 + -ENOENT); 550 + 551 + /* Get by index should ignore it */ 552 + KUNIT_EXPECT_EQ(test, 553 + cs_amp_get_efi_calibration_data(&priv->amp_pdev.dev, 554 + 0, 2, 555 + &result_data), 556 + -ENOENT); 557 + 558 + kunit_deactivate_static_stub(test, cs_amp_test_hooks->get_efi_variable); 559 + } 560 + 518 561 static const struct cirrus_amp_cal_controls cs_amp_lib_test_calibration_controls = { 519 562 .alg_id = 0x9f210, 520 563 .mem_region = WMFW_ADSP2_YM, ··· 739 696 cs_amp_lib_test_get_cal_gen_params), 740 697 KUNIT_CASE_PARAM(cs_amp_lib_test_get_efi_cal_by_index_fallback_test, 741 698 cs_amp_lib_test_get_cal_gen_params), 699 + KUNIT_CASE(cs_amp_lib_test_get_efi_cal_empty_entry_test), 742 700 743 701 /* Tests for writing calibration data */ 744 702 KUNIT_CASE(cs_amp_lib_test_write_cal_data_test),