From: Mark Brown <broonie@kernel.org>
To: Takashi Iwai <tiwai@suse.de>, Jaroslav Kysela <perex@perex.cz>,
Shuah Khan <shuah@kernel.org>
Cc: alsa-devel@alsa-project.org, linux-kselftest@vger.kernel.org,
Mark Brown <broonie@kernel.org>
Subject: [PATCH v3 3/7] kselftest/alsa: pcm - Always run the default set of tests
Date: Fri, 2 Dec 2022 00:17:45 +0000 [thread overview]
Message-ID: <20221202001749.3321187-4-broonie@kernel.org> (raw)
In-Reply-To: <20221202001749.3321187-1-broonie@kernel.org>
Rather than allowing the system specific tests to replace the default set
of tests instead run them in addition to the standard set of tests. In
order to avoid name collisions in the reported tests we add an additional
test class element to the reported tests. Doing this means we always get a
consistent baseline of coverage no matter what card we run on but retain
the ability to specify specific coverage for a given system.
Signed-off-by: Mark Brown <broonie@kernel.org>
---
tools/testing/selftests/alsa/pcm-test.c | 83 +++++++++++++++++--------
1 file changed, 58 insertions(+), 25 deletions(-)
diff --git a/tools/testing/selftests/alsa/pcm-test.c b/tools/testing/selftests/alsa/pcm-test.c
index e973b03ae1fd..afc616ddc820 100644
--- a/tools/testing/selftests/alsa/pcm-test.c
+++ b/tools/testing/selftests/alsa/pcm-test.c
@@ -36,6 +36,11 @@ struct pcm_data *pcm_list = NULL;
int num_missing = 0;
struct pcm_data *pcm_missing = NULL;
+enum test_class {
+ TEST_CLASS_DEFAULT,
+ TEST_CLASS_SYSTEM,
+};
+
void timestamp_now(timestamp_t *tstamp)
{
if (clock_gettime(CLOCK_MONOTONIC_RAW, tstamp))
@@ -217,7 +222,8 @@ static void find_pcms(void)
snd_config_delete(config);
}
-static void test_pcm_time(struct pcm_data *data, const char *test_name, snd_config_t *pcm_cfg)
+static void test_pcm_time(struct pcm_data *data, enum test_class class,
+ const char *test_name, snd_config_t *pcm_cfg)
{
char name[64], key[128], msg[256];
const char *cs;
@@ -236,6 +242,19 @@ static void test_pcm_time(struct pcm_data *data, const char *test_name, snd_conf
bool pass = false;
snd_pcm_hw_params_t *hw_params;
snd_pcm_sw_params_t *sw_params;
+ const char *test_class_name;
+
+ switch (class) {
+ case TEST_CLASS_DEFAULT:
+ test_class_name = "default";
+ break;
+ case TEST_CLASS_SYSTEM:
+ test_class_name = "system";
+ break;
+ default:
+ ksft_exit_fail_msg("Unknown test class %d\n", class);
+ break;
+ }
snd_pcm_hw_params_alloca(&hw_params);
snd_pcm_sw_params_alloca(&sw_params);
@@ -366,8 +385,8 @@ static void test_pcm_time(struct pcm_data *data, const char *test_name, snd_conf
goto __close;
}
- ksft_print_msg("%s.%d.%d.%d.%s hw_params.%s.%s.%ld.%ld.%ld.%ld sw_params.%ld\n",
- test_name,
+ ksft_print_msg("%s.%s.%d.%d.%d.%s hw_params.%s.%s.%ld.%ld.%ld.%ld sw_params.%ld\n",
+ test_class_name, test_name,
data->card, data->device, data->subdevice,
snd_pcm_stream_name(data->stream),
snd_pcm_access_name(access),
@@ -415,8 +434,9 @@ static void test_pcm_time(struct pcm_data *data, const char *test_name, snd_conf
msg[0] = '\0';
pass = true;
__close:
- ksft_test_result(pass, "%s.%d.%d.%d.%s%s%s\n",
- test_name,
+
+ ksft_test_result(pass, "%s.%s.%d.%d.%d.%s%s%s\n",
+ test_class_name, test_name,
data->card, data->device, data->subdevice,
snd_pcm_stream_name(data->stream),
msg[0] ? " " : "", msg);
@@ -425,13 +445,37 @@ static void test_pcm_time(struct pcm_data *data, const char *test_name, snd_conf
snd_pcm_close(handle);
}
+void run_time_tests(struct pcm_data *pcm, enum test_class class,
+ snd_config_t *cfg)
+{
+ const char *test_name, *test_type;
+ snd_config_t *pcm_cfg;
+ snd_config_iterator_t i, next;
+
+ if (!cfg)
+ return;
+
+ cfg = conf_get_subtree(cfg, "test", NULL);
+ if (cfg == NULL)
+ return;
+
+ snd_config_for_each(i, next, cfg) {
+ pcm_cfg = snd_config_iterator_entry(i);
+ if (snd_config_get_id(pcm_cfg, &test_name) < 0)
+ ksft_exit_fail_msg("snd_config_get_id\n");
+ test_type = conf_get_string(pcm_cfg, "type", NULL, "time");
+ if (strcmp(test_type, "time") == 0)
+ test_pcm_time(pcm, class, test_name, pcm_cfg);
+ else
+ ksft_exit_fail_msg("unknown test type '%s'\n", test_type);
+ }
+}
+
int main(void)
{
struct pcm_data *pcm;
snd_config_t *global_config, *default_pcm_config, *cfg, *pcm_cfg;
- snd_config_iterator_t i, next;
- int num_pcm_tests = 0, num_tests;
- const char *test_name, *test_type;
+ int num_pcm_tests = 0, num_tests, num_std_pcm_tests;
ksft_print_header();
@@ -444,10 +488,13 @@ int main(void)
find_pcms();
+ num_std_pcm_tests = conf_get_count(default_pcm_config, "test", NULL);
+
for (pcm = pcm_list; pcm != NULL; pcm = pcm->next) {
+ num_pcm_tests += num_std_pcm_tests;
cfg = pcm->pcm_config;
if (cfg == NULL)
- cfg = default_pcm_config;
+ continue;
num_tests = conf_get_count(cfg, "test", NULL);
if (num_tests > 0)
num_pcm_tests += num_tests;
@@ -462,22 +509,8 @@ int main(void)
}
for (pcm = pcm_list; pcm != NULL; pcm = pcm->next) {
- cfg = pcm->pcm_config;
- if (cfg == NULL)
- cfg = default_pcm_config;
- cfg = conf_get_subtree(cfg, "test", NULL);
- if (cfg == NULL)
- continue;
- snd_config_for_each(i, next, cfg) {
- pcm_cfg = snd_config_iterator_entry(i);
- if (snd_config_get_id(pcm_cfg, &test_name) < 0)
- ksft_exit_fail_msg("snd_config_get_id\n");
- test_type = conf_get_string(pcm_cfg, "type", NULL, "time");
- if (strcmp(test_type, "time") == 0)
- test_pcm_time(pcm, test_name, pcm_cfg);
- else
- ksft_exit_fail_msg("unknown test type '%s'\n", test_type);
- }
+ run_time_tests(pcm, TEST_CLASS_DEFAULT, default_pcm_config);
+ run_time_tests(pcm, TEST_CLASS_SYSTEM, pcm->pcm_config);
}
snd_config_delete(global_config);
--
2.30.2
next prev parent reply other threads:[~2022-12-02 0:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-02 0:17 [PATCH v3 0/7] kselftest/alsa: pcm-test improvements Mark Brown
2022-12-02 0:17 ` [PATCH v3 1/7] kselftest/alsa: pcm - Drop recent coverage improvement changes Mark Brown
2022-12-02 0:17 ` [PATCH v3 2/7] kselftest/alsa: pcm - move more configuration to configuration files Mark Brown
2022-12-02 0:17 ` Mark Brown [this message]
2022-12-02 0:17 ` [PATCH v3 4/7] kselftest/alsa: pcm - skip tests when we fail to set params Mark Brown
2022-12-02 0:17 ` [PATCH v3 5/7] kselftest/alsa: pcm - Support optional description for tests Mark Brown
2022-12-02 0:17 ` [PATCH v3 6/7] kselftest/alsa: pcm - Provide descriptions for the default tests Mark Brown
2022-12-02 0:17 ` [PATCH v3 7/7] kselftest/alsa: pcm - Add more coverage by default Mark Brown
2022-12-02 8:58 ` [PATCH v3 0/7] kselftest/alsa: pcm-test improvements Jaroslav Kysela
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221202001749.3321187-4-broonie@kernel.org \
--to=broonie@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=perex@perex.cz \
--cc=shuah@kernel.org \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox