From: "Nícolas F. R. A. Prado" <nfraprado@collabora.com>
To: Mark Brown <broonie@kernel.org>
Cc: kernel@collabora.com,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"Nícolas F. R. A. Prado" <nfraprado@collabora.com>,
"Jaroslav Kysela" <perex@perex.cz>,
"Shuah Khan" <shuah@kernel.org>, "Takashi Iwai" <tiwai@suse.com>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: [PATCH 1/2] kselftest/alsa: pcm-test: Move stream duration and margin to variables
Date: Tue, 20 Jun 2023 18:08:25 -0400 [thread overview]
Message-ID: <20230620220839.2215057-2-nfraprado@collabora.com> (raw)
In-Reply-To: <20230620220839.2215057-1-nfraprado@collabora.com>
The duration to stream for and time margin to consider the stream failed
are currently hardcoded values. Move them to variables so they can be
reused and more easily changed.
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
tools/testing/selftests/alsa/pcm-test.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/alsa/pcm-test.c b/tools/testing/selftests/alsa/pcm-test.c
index 3e390fe67eb9..a2b6db33b513 100644
--- a/tools/testing/selftests/alsa/pcm-test.c
+++ b/tools/testing/selftests/alsa/pcm-test.c
@@ -258,6 +258,8 @@ 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 int duration_s = 4, margin_ms = 100;
+ const int duration_ms = duration_s * 1000;
const char *cs;
int i, err;
snd_pcm_t *handle = NULL;
@@ -442,7 +444,7 @@ static void test_pcm_time(struct pcm_data *data, enum test_class class,
skip = false;
timestamp_now(&tstamp);
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < duration_s; i++) {
if (data->stream == SND_PCM_STREAM_PLAYBACK) {
frames = snd_pcm_writei(handle, samples, rate);
if (frames < 0) {
@@ -472,8 +474,8 @@ static void test_pcm_time(struct pcm_data *data, enum test_class class,
snd_pcm_drain(handle);
ms = timestamp_diff_ms(&tstamp);
- if (ms < 3900 || ms > 4100) {
- snprintf(msg, sizeof(msg), "time mismatch: expected 4000ms got %lld", ms);
+ if (ms < duration_ms - margin_ms || ms > duration_ms + margin_ms) {
+ snprintf(msg, sizeof(msg), "time mismatch: expected %dms got %lld", duration_ms, ms);
goto __close;
}
--
2.41.0
next prev parent reply other threads:[~2023-06-20 22:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-20 22:08 [PATCH 0/2] kselftest/alsa: Decrease pcm-test duration to avoid timeouts Nícolas F. R. A. Prado
2023-06-20 22:08 ` Nícolas F. R. A. Prado [this message]
2023-06-21 9:52 ` [PATCH 1/2] kselftest/alsa: pcm-test: Move stream duration and margin to variables AngeloGioacchino Del Regno
2023-06-20 22:08 ` [PATCH 2/2] kselftest/alsa: pcm-test: Decrease stream duration from 4 to 2 seconds Nícolas F. R. A. Prado
2023-06-21 13:08 ` Mark Brown
2023-06-21 14:08 ` Jaroslav Kysela
2023-06-21 14:39 ` Mark Brown
2023-06-21 16:03 ` Nícolas F. R. A. Prado
2023-06-21 16:34 ` Takashi Iwai
2023-06-21 17:08 ` Mark Brown
2023-06-21 18:13 ` Takashi Iwai
2023-06-21 18:19 ` Mark Brown
2023-07-10 7:00 ` Takashi Iwai
2023-07-12 22:03 ` Mark Brown
2023-07-13 8:47 ` Takashi Iwai
2023-07-13 20:39 ` Mark Brown
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=20230620220839.2215057-2-nfraprado@collabora.com \
--to=nfraprado@collabora.com \
--cc=alsa-devel@alsa-project.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=broonie@kernel.org \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=perex@perex.cz \
--cc=shuah@kernel.org \
--cc=tiwai@suse.com \
/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