Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2479484ybc; Sun, 17 Nov 2019 22:51:42 -0800 (PST) X-Google-Smtp-Source: APXvYqw5uobor7bG59BkrykjKxTgKkamDCRHqbyowHjD30DrJDORq2fNUqXbBrP9k5u/xPDSopNZ X-Received: by 2002:a17:906:cca:: with SMTP id l10mr24383739ejh.161.1574059902020; Sun, 17 Nov 2019 22:51:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574059902; cv=none; d=google.com; s=arc-20160816; b=bhnJ0iNzaGLW16uEIZgvJfNFZ+eF68ov++vO9LuBmW1Eg2AbudjHsSU3LkXhwxmFmP /k+sT27s+JHj8lzgzdXKYDU4ScMI11oN27wroFrweI9pvvxs7vN+rkg6hVJh0dNwTtwI hZC/omVqjoyKgaBu0emIyXnC0NfsvJxZzwvHb3bzsNO9UGoPIxuJDrtDE+I92+tSk0W7 aVwfa/lBzXP/na7nF8f7qSr1R/+iiX641anTAw2gJw2MYs6qxMTaI0MSEGp/PUOwEW5f o0qNUCY0cT1FQLQy+lHjdo64OkiQ8yE4bPQmVrboHUfRqMIAUaPK3eLSsSgC4yUgwf7t AzaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=2q1X71G2F9ogvEiNMzRBPTVvugNQ98J/RkFcfMnV5l8=; b=GLOovCQcFo1MFcsUPrq1x4AkhdnZdi2OtZnNI0sxeWySDDeOAip0lyaXO4HRJAjDkr dUtOzFSv4m/oWjx7nNf206SFdRbWijY4kmRlJSl0+njDfc/7Ppp/W7vR4iiK0SoLAZHm jgQgJq1CB0pa4r9LqbhK6/UIaPuYvSgfNlo8al64OONC20h+I8unciMacwQYdEOgpWSk 8XNiRuo/9U8/L4T2dasBCUVZ0L/aajjFgnrs0rpWrTEtRehcidDzg7p4xW9pHbWKwl3Q Jadn6RU3v4Q7USGHjnSSX6eE7s4yAzepaqSNRqUsapK/qHNxMr9S92S/0rVfqPazKcpN zlNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RwQG4Y4L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i18si2799471edt.319.2019.11.17.22.51.18; Sun, 17 Nov 2019 22:51:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RwQG4Y4L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726712AbfKRGr5 (ORCPT + 99 others); Mon, 18 Nov 2019 01:47:57 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42714 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726455AbfKRGr5 (ORCPT ); Mon, 18 Nov 2019 01:47:57 -0500 Received: by mail-pf1-f194.google.com with SMTP id s5so9881682pfh.9 for ; Sun, 17 Nov 2019 22:47:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=2q1X71G2F9ogvEiNMzRBPTVvugNQ98J/RkFcfMnV5l8=; b=RwQG4Y4LfJbbqnf+V2FUH58y984DNZKbHPGhNQWEhjLgfbxhDKG5/9smqzS/EYNKpn gmeMXYAtrkD1Lg6hzZjWQl2lx/nluvJLY4MDWJPaX4YUNNAdrPKYom/A3oN4WypZ5sRg sSgU/QT38wEQahGYgToWCWnLFUMIrW2vDL7jRSjO5r6RPQvAJV3wmkgVr6xR5PdcfLoY tubrh0341XmOHbMRzFp7FCDFge+9RXP/Wf2yLWLEm6j6Dhl4zC37N1FVYozC02LfFSjJ zSY4giNcaML1l/+hSdgId2tTh8ikbVIzGQv25PRhBvQ/9ioZpInYuh10aJgExezI2B7G j6Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2q1X71G2F9ogvEiNMzRBPTVvugNQ98J/RkFcfMnV5l8=; b=h/KZGKF2Gq/Ib5fQ4adttYrGj8yKVyD+QBvEWNXqJRbYzE1pFc9kRCBt3xRaUvZvEM rgEGiUA/LcwM/tFMrwwzr5mMUK0Vpt3O2flZ0cPlWMignBBju5aq7B5i572I9Ku9yYL6 wGdHklamnMYtQE7xeHcv4WeEyE25HPeCInWuPP67/9fVZogowuG71cu7t1fkh163dWNy 2s82+DYcAx0CTzBqlwvDkXjV9SsxG4dhVpzhTm1Fj6r/fX45iGS3ZWoxfHVs7VQmHzbF 7LW9QR3FvvwfNRs7kM6bmcSXMdFLCiLXeK7kvN1UX3yHFXr3DpoFOi6QJ4ih86AZAry4 y4cg== X-Gm-Message-State: APjAAAXm/1bnVXj42iZBHHNtNy1Y9WtckdQswxKBwmlTFeWyJBfRsPQE jOsENsGht2YeWwwquJBO7lCgjdGYTpA= X-Received: by 2002:a65:628f:: with SMTP id f15mr30205410pgv.91.1574059676543; Sun, 17 Nov 2019 22:47:56 -0800 (PST) Received: from laptop.hsd1.wa.comcast.net ([2601:600:817f:a132:df3e:521d:99d5:710d]) by smtp.gmail.com with ESMTPSA id v3sm21728403pfi.26.2019.11.17.22.47.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Nov 2019 22:47:56 -0800 (PST) From: Andrei Vagin To: Christian Brauner Cc: Adrian Reber , linux-kernel@vger.kernel.org, Andrei Vagin Subject: [PATCH 1/3] selftests/clone3: flush stdout and stderr before clone3() and _exit() Date: Sun, 17 Nov 2019 22:47:48 -0800 Message-Id: <20191118064750.408003-1-avagin@gmail.com> X-Mailer: git-send-email 2.17.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Buffers have to be flushed before clone3() to avoid double messages in the log. Signed-off-by: Andrei Vagin --- tools/testing/selftests/clone3/clone3_selftests.h | 2 ++ tools/testing/selftests/clone3/clone3_set_tid.c | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/clone3/clone3_selftests.h b/tools/testing/selftests/clone3/clone3_selftests.h index e5a62dfef67a..c8899e773c8e 100644 --- a/tools/testing/selftests/clone3/clone3_selftests.h +++ b/tools/testing/selftests/clone3/clone3_selftests.h @@ -29,6 +29,8 @@ struct clone_args { static pid_t sys_clone3(struct clone_args *args, size_t size) { + fflush(stdout); + fflush(stderr); return syscall(__NR_clone3, args, size); } diff --git a/tools/testing/selftests/clone3/clone3_set_tid.c b/tools/testing/selftests/clone3/clone3_set_tid.c index 3480e1c46983..e93369dcfe3b 100644 --- a/tools/testing/selftests/clone3/clone3_set_tid.c +++ b/tools/testing/selftests/clone3/clone3_set_tid.c @@ -30,6 +30,13 @@ static int pipe_1[2]; static int pipe_2[2]; +static void child_exit(int ret) +{ + fflush(stdout); + fflush(stderr); + _exit(ret); +} + static int call_clone3_set_tid(pid_t *set_tid, size_t set_tid_size, int flags, @@ -84,8 +91,8 @@ static int call_clone3_set_tid(pid_t *set_tid, } if (set_tid[0] != getpid()) - _exit(EXIT_FAILURE); - _exit(exit_code); + child_exit(EXIT_FAILURE); + child_exit(exit_code); } if (expected_pid == 0 || expected_pid == pid) { @@ -249,7 +256,7 @@ int main(int argc, char *argv[]) pid = fork(); if (pid == 0) { ksft_print_msg("Child has PID %d\n", getpid()); - _exit(EXIT_SUCCESS); + child_exit(EXIT_SUCCESS); } if (waitpid(pid, &status, 0) < 0) ksft_exit_fail_msg("Waiting for child %d failed", pid); @@ -309,7 +316,7 @@ int main(int argc, char *argv[]) */ test_clone3_set_tid(set_tid, 3, CLONE_NEWPID, 0, 42, true); - _exit(ksft_cnt.ksft_pass); + child_exit(ksft_cnt.ksft_pass); } close(pipe_1[1]); -- 2.23.0