Skip to content

Commit bf2d44d

Browse files
rfvirgilbroonie
authored andcommitted
ASoC: wm_adsp: Add kunit test for firmware file search
Add KUnit testing of the wm_adsp code that searches for firmware files. Also make the SND_SOC_WM_ADSP Kconfig symbol visible if KUNIT is enabled so that wm_adsp can be manually included for KUnit testing. The firmware filename is composed of several fields, some of which are optional, and there is a search algorithm to fallback from specific to generic versions of firmware for a device. This KUnit test verifies that wm_adsp is searching for the correct sequence of filenames. The are two ways of testing this, and both are used in this KUnit test. 1. Trap the calls to firmware_request_nowarn() and test that the sequence of filenames request is correct. This is the most thorough test because it proves that exactly the expected filenames are requested, in the correct order. But it doesn't fully cover regression testing. If a change to the search algorithm changes the expected sequence of requested files, the test must also be changed to expect that new sequence. If the expectation is wrong, the tests can pass (because the search order is as expected) while picking a different file in some cases from what it did before the change. 2. Test which file is picked from a simulated directory of files. This is better for regression testing because it is independent of the search algorithm. It does not need to change if the search algorithm changes. It is not testing exactly which files the algorithm searches for, only which file it eventually picks from a given set of available files. In other words, the regression test is: does it still pick the same file from the same directory of files? But it is impractical for thorough testing. It doesn't prove that exactly the correct files were searched for, unless it was to test with every possible combination of file names and directory content that could ever exist. Clearly this is impossible to implement, since the number of combations of possible valid filenames in a directory and number of files in a directory is astronomically large. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20260310141817.1871794-5-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent b4e6b01 commit bf2d44d

3 files changed

Lines changed: 1238 additions & 1 deletion

File tree

sound/soc/codecs/Kconfig

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ config SND_SOC_WM_HUBS
398398
default m if SND_SOC_WM8993=m || SND_SOC_WM8994=m
399399

400400
config SND_SOC_WM_ADSP
401-
tristate
401+
tristate "Cirrus Logic wm_adsp driver" if KUNIT
402402
select FW_CS_DSP
403403
select SND_SOC_COMPRESS
404404
default y if SND_SOC_MADERA=y
@@ -424,6 +424,18 @@ config SND_SOC_WM_ADSP
424424
default m if SND_SOC_CS35L56=m
425425
default m if SND_SOC_CS48L32=m
426426

427+
config SND_SOC_WM_ADSP_TEST
428+
tristate "KUnit tests for Cirrus Logic wm_adsp" if !KUNIT_ALL_TESTS
429+
depends on KUNIT
430+
depends on SND_SOC_WM_ADSP
431+
default KUNIT_ALL_TESTS
432+
help
433+
This builds KUnit tests for the Cirrus Logic wm_adsp library.
434+
For more information on KUnit and unit tests in general,
435+
please refer to the KUnit documentation in
436+
Documentation/dev-tools/kunit/.
437+
If in doubt, say "N".
438+
427439
config SND_SOC_AB8500_CODEC
428440
tristate
429441
depends on ABX500_CORE

sound/soc/codecs/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ snd-soc-wcd938x-sdw-y := wcd938x-sdw.o
361361
snd-soc-wcd939x-y := wcd939x.o
362362
snd-soc-wcd939x-sdw-y := wcd939x-sdw.o
363363
snd-soc-wm-adsp-y := wm_adsp.o
364+
snd-soc-wm-adsp-test-y := wm_adsp_fw_find_test.o
364365
snd-soc-wm0010-y := wm0010.o
365366
snd-soc-wm1250-ev1-y := wm1250-ev1.o
366367
snd-soc-wm2000-y := wm2000.o
@@ -862,6 +863,7 @@ obj-$(CONFIG_SND_SOC_WM9705) += snd-soc-wm9705.o
862863
obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o
863864
obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o
864865
obj-$(CONFIG_SND_SOC_WM_ADSP) += snd-soc-wm-adsp.o
866+
obj-$(CONFIG_SND_SOC_WM_ADSP_TEST) += snd-soc-wm-adsp-test.o
865867
obj-$(CONFIG_SND_SOC_WM_HUBS) += snd-soc-wm-hubs.o
866868
obj-$(CONFIG_SND_SOC_WSA881X) += snd-soc-wsa881x.o
867869
obj-$(CONFIG_SND_SOC_WSA883X) += snd-soc-wsa883x.o

0 commit comments

Comments
 (0)