summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/alsa
diff options
context:
space:
mode:
authorNĂ­colas F. R. A. Prado <nfraprado@collabora.com>2023-06-21 01:08:25 +0300
committerTakashi Iwai <tiwai@suse.de>2023-07-10 09:58:00 +0300
commit0825d54a3081151201bbfe05f4d408613ef3ef1e (patch)
treebb65290095640ab8b8a5ec39ab9d881aae20a98c /tools/testing/selftests/alsa
parent35bc3efb3157cc5a9c3b5853591c4dcef40f6029 (diff)
downloadlinux-0825d54a3081151201bbfe05f4d408613ef3ef1e.tar.xz
kselftest/alsa: pcm-test: Move stream duration and margin to variables
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> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230620220839.2215057-2-nfraprado@collabora.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'tools/testing/selftests/alsa')
-rw-r--r--tools/testing/selftests/alsa/pcm-test.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/testing/selftests/alsa/pcm-test.c b/tools/testing/selftests/alsa/pcm-test.c
index b7eef32addb4..9384aebae99b 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 @@ __format:
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 @@ __format:
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;
}