From patchwork Thu Jan 14 03:09:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 363424 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B362C433E0 for ; Thu, 14 Jan 2021 03:11:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38E3B2368A for ; Thu, 14 Jan 2021 03:11:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727589AbhANDLT (ORCPT ); Wed, 13 Jan 2021 22:11:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:53062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727521AbhANDLS (ORCPT ); Wed, 13 Jan 2021 22:11:18 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C285B23787; Thu, 14 Jan 2021 03:09:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610593800; bh=vUaYP8Hi9hjLrmV7JP5BErEhnxwbLhof13DtOQujLX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VSqoe1f6mt60GjMW05GF7wG26L8f+2wI0BPV2YBlhtKUhK0QLcsCn7xQRgWmpT5i/ pPDyHZoek3nsg7L1j9VvBNzGDnaMrzJhBh2UHPrGfAlDy0PoXFv2Tqnn3DG4qb3jIa t2NFDilXRV4Yt3v+57TWp4FwSmiUvpOZr4kw5GbOAlzJXekFNPP2PIgexPobDHXi5T NX18nYjYS6IkFayqtI6zA6y8evVlLsjKOhDQPVEJmCvrQWn80yEHQqZlvWb3+Koh2b G+KOp2yCRwusiCvyPtYK83dUufM/PFa82HB7GQSo4GAchFgUzwREL2/9oHdJIQV9dT Cjo7RTQscQTIQ== From: David Ahern To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, schoen@loyalty.org, David Ahern 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> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210114030949.54425-1-dsahern@kernel.org> References: <20210114030949.54425-1-dsahern@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: David Ahern 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 --- 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)