Skip to content

Commit

Permalink
ALSA: hda: cirrus_scodec: Add KUnit test
Browse files Browse the repository at this point in the history
Add a KUnit test for cirrus_scodec_get_speaker_id(). It is impractical
to have enough hardware with every possible permutation of speaker id.
So use a test harness to test all theoretically supported options.

The test harness consists of:
- a mock GPIO controller.
- a mock struct device to represent the scodec driver
- software nodes to provide the fwnode info that would normally come
  from ACPI.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230918095129.440-3-rf@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Richard Fitzgerald authored and Takashi Iwai committed Sep 18, 2023
1 parent 6f03b44 commit 2144833
Show file tree
Hide file tree
Showing 4 changed files with 394 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sound/pci/hda/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ config SND_HDA_PATCH_LOADER
config SND_HDA_CIRRUS_SCODEC
tristate

config SND_HDA_CIRRUS_SCODEC_KUNIT_TEST
tristate "KUnit test for Cirrus side-codec library" if !KUNIT_ALL_TESTS
select SND_HDA_CIRRUS_SCODEC
depends on KUNIT
default KUNIT_ALL_TESTS
help
This builds KUnit tests for the cirrus side-codec library.
For more information on KUnit and unit tests in general,
please refer to the KUnit documentation in
Documentation/dev-tools/kunit/.
If in doubt, say "N".

config SND_HDA_SCODEC_CS35L41
tristate
select SND_HDA_GENERIC
Expand Down
2 changes: 2 additions & 0 deletions sound/pci/hda/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ snd-hda-codec-hdmi-objs := patch_hdmi.o hda_eld.o

# side codecs
snd-hda-cirrus-scodec-objs := cirrus_scodec.o
snd-hda-cirrus-scodec-test-objs := cirrus_scodec_test.o
snd-hda-scodec-cs35l41-objs := cs35l41_hda.o cs35l41_hda_property.o
snd-hda-scodec-cs35l41-i2c-objs := cs35l41_hda_i2c.o
snd-hda-scodec-cs35l41-spi-objs := cs35l41_hda_spi.o
Expand Down Expand Up @@ -58,6 +59,7 @@ obj-$(CONFIG_SND_HDA_CODEC_HDMI) += snd-hda-codec-hdmi.o

# side codecs
obj-$(CONFIG_SND_HDA_CIRRUS_SCODEC) += snd-hda-cirrus-scodec.o
obj-$(CONFIG_SND_HDA_CIRRUS_SCODEC_KUNIT_TEST) += snd-hda-cirrus-scodec-test.o
obj-$(CONFIG_SND_HDA_SCODEC_CS35L41) += snd-hda-scodec-cs35l41.o
obj-$(CONFIG_SND_HDA_SCODEC_CS35L41_I2C) += snd-hda-scodec-cs35l41-i2c.o
obj-$(CONFIG_SND_HDA_SCODEC_CS35L41_SPI) += snd-hda-scodec-cs35l41-spi.o
Expand Down
Loading

0 comments on commit 2144833

Please sign in to comment.