All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] Add KUNIT tests for ASoC topology
@ 2021-01-20 15:28 Amadeusz Sławiński
  2021-01-20 15:28 ` [PATCH 1/5] ASoC: topology: Properly unregister DAI on removal Amadeusz Sławiński
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Amadeusz Sławiński @ 2021-01-20 15:28 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Takashi Iwai
  Cc: Cezary Rojewski, Amadeusz Sławiński,
	Pierre-Louis Bossart, alsa-devel

This series adds unit tests for ASoC topology.

First fix problems found when developing and running test cases and
then add tests implementation.

Tests themselves are quite simple and just call
snd_soc_tplg_component_load() with various parameters and check the
result. Tests themselves are described in more detail in commits
adding them.

Goal is to expand the amount of test cases in following patches.

Prerequisity for this patchset are 2 patches which have already been
sent:
https://lore.kernel.org/alsa-devel/20210114163602.911205-1-amadeuszx.slawinski@linux.intel.com/T/#t

Description on how typical test case itself works:

In order to load topology we need to have 3 things:
card, codec component & platform component.

In typical test case we register card and platform component and bind
to dummy codec. There are of course execeptions, when we want to
test behaviour of topology API when component or card is missing.
Note that this is bit different from typical scenario (in SOF and skylake
drivers) where card is registered by machine driver and component by
platform driver, as we register both when setting up test.

If you check the test case most of them have similar architecture of:
1.
	/* run test */
	ret = snd_soc_register_card(&kunit_comp->card);
	if (ret != 0 && ret != -EPROBE_DEFER)
		KUNIT_FAIL(test, "Failed to register card");

2.
	ret = snd_soc_component_initialize(&kunit_comp->comp, &test_component, test_dev);
	KUNIT_EXPECT_EQ(test, 0, ret);

3.
	ret = snd_soc_add_component(&kunit_comp->comp, NULL, 0);
	KUNIT_EXPECT_EQ(test, 0, ret);

Ad. 1.
First we register card, which in most tests returns -EPROBE_DEFER
(from snd_soc_bind_card()), as platform component is not yet created.
I test for both 0 and -EPROBE_DEFER, as it makes it easier to reshuffle
this code around if needed and there is one test case which does it in
different order.

Ad. 2.
Then we initialize platform component with structure pointing at proper
probe function, which calls snd_soc_tplg_component_load() with test
parameters and checks expected result.

Ad. 3.
And then in follow up we call snd_soc_add_component() which creates
platform component for us and calls snd_soc_try_rebind_card() which
if everything is bound properly calls previously set probe function.

Amadeusz Sławiński (5):
  ASoC: topology: Properly unregister DAI on removal
  Revert "ASoC: soc-devres: add devm_snd_soc_register_dai()"
  ASoC: topology: KUnit: Add KUnit tests passing various arguments to
    snd_soc_tplg_component_load
  ASoC: topology: KUnit: Add KUnit tests passing empty topology with
    variants to snd_soc_tplg_component_load
  ASoC: topology: KUnit: Add KUnit tests passing topology with PCM to
    snd_soc_tplg_component_load

 include/sound/soc.h           |   4 -
 sound/soc/Kconfig             |  17 +
 sound/soc/Makefile            |   5 +
 sound/soc/soc-devres.c        |  37 --
 sound/soc/soc-topology-test.c | 843 ++++++++++++++++++++++++++++++++++
 sound/soc/soc-topology.c      |   9 +-
 6 files changed, 870 insertions(+), 45 deletions(-)
 create mode 100644 sound/soc/soc-topology-test.c

-- 
2.25.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-01-21 19:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20 15:28 [PATCH 0/5] Add KUNIT tests for ASoC topology Amadeusz Sławiński
2021-01-20 15:28 ` [PATCH 1/5] ASoC: topology: Properly unregister DAI on removal Amadeusz Sławiński
2021-01-20 15:28 ` [PATCH 2/5] Revert "ASoC: soc-devres: add devm_snd_soc_register_dai()" Amadeusz Sławiński
2021-01-20 17:29   ` Mark Brown
2021-01-21 15:08     ` Amadeusz Sławiński
2021-01-20 15:28 ` [PATCH 3/5] ASoC: topology: KUnit: Add KUnit tests passing various arguments to snd_soc_tplg_component_load Amadeusz Sławiński
2021-01-20 15:28 ` [PATCH 4/5] ASoC: topology: KUnit: Add KUnit tests passing empty topology with variants " Amadeusz Sławiński
2021-01-20 15:28 ` [PATCH 5/5] ASoC: topology: KUnit: Add KUnit tests passing topology with PCM " Amadeusz Sławiński
2021-01-21  0:05 ` (subset) [PATCH 0/5] Add KUNIT tests for ASoC topology Mark Brown
2021-01-21 19:39 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.