Netdev Archive on lore.kernel.org
 help / color / Atom feed
From: David Ahern <dsahern@kernel.org>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, schoen@loyalty.org,
	David Ahern <dsahern@gmail.com>
Subject: [PATCH net-next v4 06/13] selftests: Use separate stdout and stderr buffers in nettest
Date: Wed, 13 Jan 2021 20:09:42 -0700
Message-ID: <20210114030949.54425-7-dsahern@kernel.org> (raw)
In-Reply-To: <20210114030949.54425-1-dsahern@kernel.org>

From: David Ahern <dsahern@gmail.com>

When a single instance of nettest is doing both client and
server modes, stdout and stderr messages can get interlaced
and become unreadable. Allocate a new set of buffers for the
child process handling server mode.

Signed-off-by: David Ahern <dsahern@gmail.com>
---
 tools/testing/selftests/net/nettest.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/nettest.c b/tools/testing/selftests/net/nettest.c
index 685cbe8933de..aba3615ce977 100644
--- a/tools/testing/selftests/net/nettest.c
+++ b/tools/testing/selftests/net/nettest.c
@@ -1707,9 +1707,28 @@ static char *random_msg(int len)
 
 static int ipc_child(int fd, struct sock_args *args)
 {
+	char *outbuf, *errbuf;
+	int rc = 1;
+
+	outbuf = malloc(4096);
+	errbuf = malloc(4096);
+	if (!outbuf || !errbuf) {
+		fprintf(stderr, "server: Failed to allocate buffers for stdout and stderr\n");
+		goto out;
+	}
+
+	setbuffer(stdout, outbuf, 4096);
+	setbuffer(stderr, errbuf, 4096);
+
 	server_mode = 1; /* to tell log_msg in case we are in both_mode */
 
-	return do_server(args, fd);
+	rc = do_server(args, fd);
+
+out:
+	free(outbuf);
+	free(errbuf);
+
+	return rc;
 }
 
 static int ipc_parent(int cpid, int fd, struct sock_args *args)
-- 
2.24.3 (Apple Git-128)


  parent reply index

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-14  3:09 [PATCH net-next v4 00/13] selftests: Updates to allow single instance of nettest for client and server David Ahern
2021-01-14  3:09 ` [PATCH net-next v4 01/13] selftests: Move device validation in nettest David Ahern
2021-01-14  3:09 ` [PATCH net-next v4 02/13] selftests: Move convert_addr up " David Ahern
2021-01-14  3:09 ` [PATCH net-next v4 03/13] selftests: Move address validation " David Ahern
2021-01-14  3:09 ` [PATCH net-next v4 04/13] selftests: Add options to set network namespace to nettest David Ahern
2021-01-14  3:09 ` [PATCH net-next v4 05/13] selftests: Add support to nettest to run both client and server David Ahern
2021-01-14  3:09 ` David Ahern [this message]
2021-01-14  3:09 ` [PATCH net-next v4 07/13] selftests: Add missing newline in nettest error messages David Ahern
2021-01-14  3:09 ` [PATCH net-next v4 08/13] selftests: Make address validation apply only to client mode David Ahern
2021-01-14  3:09 ` [PATCH net-next v4 09/13] selftests: Consistently specify address for MD5 protection David Ahern
2021-01-14  3:09 ` [PATCH net-next v4 10/13] selftests: Add new option for client-side passwords David Ahern
2021-01-14  3:09 ` [PATCH net-next v4 11/13] selftests: Add separate options for server device bindings David Ahern
2021-01-14  3:09 ` [PATCH net-next v4 12/13] selftests: Remove exraneous newline in nettest David Ahern
2021-01-14  3:09 ` [PATCH net-next v4 13/13] selftests: Add separate option to nettest for address binding David Ahern
2021-01-15  0:30 ` [PATCH net-next v4 00/13] selftests: Updates to allow single instance of nettest for client and server patchwork-bot+netdevbpf

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=20210114030949.54425-7-dsahern@kernel.org \
    --to=dsahern@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=schoen@loyalty.org \
    /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

Netdev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netdev/0 netdev/git/0.git
	git clone --mirror https://lore.kernel.org/netdev/1 netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ https://lore.kernel.org/netdev \
		netdev@vger.kernel.org
	public-inbox-index netdev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netdev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git