summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2021-01-14 06:09:42 +0300
committerJakub Kicinski <kuba@kernel.org>2021-01-15 03:26:48 +0300
commitf222c37cf75a8a626a0ca9435378e9f87b0239f1 (patch)
tree987a8020d23cbd74b9cd07e538d72696af4af19e /tools
parent6469403c97b486285365c590a8f9eaad9c72f5c5 (diff)
downloadlinux-f222c37cf75a8a626a0ca9435378e9f87b0239f1.tar.xz
selftests: Use separate stdout and stderr buffers in nettest
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> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/net/nettest.c21
1 files changed, 20 insertions, 1 deletions
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)