All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: tiwai@suse.de, perex@perex.cz
Cc: alsa-devel@alsa-project.org
Subject: [alsa-utils][PATCH 11/14] axfer: test: use memfd_create() for mapper-test
Date: Thu, 11 Mar 2021 14:21:42 +0900	[thread overview]
Message-ID: <20210311052146.404003-12-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <20210311052146.404003-1-o-takashi@sakamocchi.jp>

The mapper test program writes audio data frame to files, and read
them from the files, then validate them. For the operations, usage of
any in-memory file is good to shorten time of overall operations.

This commit uses shm by memfd_create().

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 axfer/test/mapper-test.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/axfer/test/mapper-test.c b/axfer/test/mapper-test.c
index 0bed4bb..477871d 100644
--- a/axfer/test/mapper-test.c
+++ b/axfer/test/mapper-test.c
@@ -6,11 +6,20 @@
 //
 // Licensed under the terms of the GNU General Public License, version 2.
 
+#include <aconfig.h>
+#ifdef HAVE_MEMFD_CREATE
+#define _GNU_SOURCE
+#endif
+
 #include "../mapper.h"
 #include "../misc.h"
 
 #include "generator.h"
 
+#ifdef HAVE_MEMFD_CREATE
+#include <sys/mman.h>
+#endif
+
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdbool.h>
@@ -230,7 +239,11 @@ static int test_mapper(struct mapper_trial *trial, snd_pcm_access_t access,
 	for (i = 0; i < cntr_count; ++i) {
 		const char *path = trial->paths[i];
 
+#ifdef HAVE_MEMFD_CREATE
+		cntr_fds[i] = memfd_create(path, 0);
+#else
 		cntr_fds[i] = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644);
+#endif
 		if (cntr_fds[i] < 0) {
 			err = -errno;
 			goto end;
@@ -255,10 +268,8 @@ static int test_mapper(struct mapper_trial *trial, snd_pcm_access_t access,
 		       frames_per_second, frames_per_buffer, check_buffer,
 		       frame_count, cntr_fds, cntr_count);
 end:
-	for (i = 0; i < cntr_count; ++i) {
-		unlink(trial->paths[i]);
+	for (i = 0; i < cntr_count; ++i)
 		close(cntr_fds[i]);
-	}
 
 	free(cntr_fds);
 
-- 
2.27.0


  parent reply	other threads:[~2021-03-11  5:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11  5:21 [alsa-utils][PATCH 00/14] axfer: reduce test time Takashi Sakamoto
2021-03-11  5:21 ` [alsa-utils][PATCH 01/14] axfer: minor code arrangement for container module in a point of nonblocking flag Takashi Sakamoto
2021-03-11  5:21 ` [alsa-utils][PATCH 02/14] axfer: minor code arrangement in a point of stdio detection Takashi Sakamoto
2021-03-11  5:21 ` [alsa-utils][PATCH 03/14] axfer: minor code arrangement in a point of opened file descriptor Takashi Sakamoto
2021-03-11  5:21 ` [alsa-utils][PATCH 04/14] axfer: minor code arrangement to allocate containers Takashi Sakamoto
2021-03-11  5:21 ` [alsa-utils][PATCH 05/14] axfer: open file descriptor outside of container module Takashi Sakamoto
2021-03-11  5:21 ` [alsa-utils][PATCH 06/14] axfer: maintain lifetime of " Takashi Sakamoto
2021-03-11  5:21 ` [alsa-utils][PATCH 07/14] autotools: preparation to use memfd_create(2) Takashi Sakamoto
2021-03-11  5:21 ` [alsa-utils][PATCH 08/14] axfer: test: minor code arrangement to use the same file descriptor for container-test Takashi Sakamoto
2021-03-11  5:21 ` [alsa-utils][PATCH 09/14] axfer: test: use memfd_create() " Takashi Sakamoto
2021-03-11  5:21 ` [alsa-utils][PATCH 10/14] axfer: test: minor code arrangement to use the same file descriptor for mappter-test Takashi Sakamoto
2021-03-11  5:21 ` Takashi Sakamoto [this message]
2021-03-11  5:21 ` [alsa-utils][PATCH 12/14] axfer: test: reduce test case for maximum number of frame count Takashi Sakamoto
2021-03-11  5:21 ` [alsa-utils][PATCH 13/13] Revert "axfer: test - add run-test-in-tmpdir.sh script" Takashi Sakamoto
2021-03-11  5:32   ` Takashi Sakamoto
2021-03-11  5:21 ` [alsa-utils][PATCH 13/14] axfer: test: reduce test case for maximum number of samples per frame Takashi Sakamoto
2021-03-11  5:21 ` [alsa-utils][PATCH 14/14] Revert "axfer: test - add run-test-in-tmpdir.sh script" Takashi Sakamoto
2021-03-11  8:32 ` [alsa-utils][PATCH 00/14] axfer: reduce test time 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=20210311052146.404003-12-o-takashi@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=perex@perex.cz \
    --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 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.