ASoC: cs-amp-lib: Add KUnit test for calibration helpers
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Mon, 4 Mar 2024 14:37:05 +0000 (14:37 +0000)
committerMark Brown <broonie@kernel.org>
Mon, 4 Mar 2024 20:27:35 +0000 (20:27 +0000)
commit177862317a98adde284233aee074fc6e6a51cf95
tree20e472c8ebfff2ea1d2600340391254f5dec992f
parent9e6f39535c794adea6ba802a52c722d193c28124
ASoC: cs-amp-lib: Add KUnit test for calibration helpers

Add a KUnit test for the cs-amp-lib library. This has test cases
for cs_amp_get_efi_calibration_data() and cs_amp_write_cal_coeffs().

A KUNIT_STATIC_STUB_REDIRECT() has been added to
cs_amp_get_efi_variable() and cs_amp_write_cal_coeff() so that the
KUnit test can redirect these to test harness functions.

Much of the testing involves invoking the same function with different
parameters, i.e. the number of amps and the amp index within the array.
This uses parameterization rather than looping. The idea is to avoid
looping over configurations within one test case as that has a higher
chance of having a bug that doesn't actually test all the expected cases.
Having the test run exactly one configuration, and then tear-down, is less
prone to accidentally skipped configurations.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://msgid.link/r/20240304143705.26362-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/cs-amp-lib.h
sound/soc/codecs/Kconfig
sound/soc/codecs/Makefile
sound/soc/codecs/cs-amp-lib-test.c [new file with mode: 0644]
sound/soc/codecs/cs-amp-lib.c