From patchwork Thu Apr 9 20:11:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 38799 Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by sourceware.org (Postfix) with ESMTPS id 8B5F4385B835 for ; Thu, 9 Apr 2020 20:21:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8B5F4385B835 IronPort-SDR: zeXnB0cFV2l5noeOpTc7ntYLdzyhWf2GcdKh3aUoc/wxclEjvtCIy2REPEf4qk8AHKOluRzRCe C8aybmdJ6tFwhR7CYpZMYfP/pmSpv0yGkjCM8OudWm4FCtXTZrZbqdQl2ruHFJZztashFUHa56 dXB41cacV/Q5+pANM5AlXJERMvX6DzbXEGeREr9ZlGgfDEp5dx8tcU2p9QZLsP4HsNV7XMHWPf Sl2tmQbpqp49RQChlzemppg3j8CXpWS9yCrPvlFsmdQBFJvfVIcx3CPLBjEyZRj26YhwHzKRFb 0fs= X-IronPort-AV: E=Sophos;i="5.72,363,1580745600"; d="scan'208";a="139316634" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 10 Apr 2020 04:21:10 +0800 IronPort-SDR: 9Smyp0CN5uHx4AvhsKRUROj4QOilLYY1vYMsSKHKekUgOhSqPjR+DR1bq7ULgok+ApNo0sZ+U0 GtDvDcswWDWdZRk7p/kdY+8kcoYuJ93q1s8gLNVU5Nq950wraIqqSABweZlUNEf+D7BruRhoy2 RSEs/DRW6iUGqUhqftaLaAvWLjKRA/EpWNgXTcCAWOE7ocWIZU/reG1zaBJYWuDkbAQ0i1qLyv R8CV6XtkksBB8Cso90TV1tGY3zxNUi4vO7C0S1Xf84XRX/oTD7raaXgaNLwal57tWhLiv934h8 hjQldEMK//Q7TcUpwIQNq1dM Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2020 13:11:49 -0700 IronPort-SDR: rzkaUNEEbIodycwZj4G5B2S/FHplL1ym+UM2TrgKCuVERDxD0rfzGt1emvdZUWZHaonNAJdb3I PJ8SJoia9jHJ2EJZ/zqjZVoj21l1QBJ68d6Lb81rFsRP17ghu0f4ATHW2XFD3jxMo3TNGqQSQ6 NX73BqcDINVPdfyjZjPpQ8HANBENuqzbo4VupLNgq5/aizhaOm8BR5xvgqgmgjJQKDe4pxQ4XU Oanqw8Ml1ARxsFiXwIlL2am6mgHSj0KouN3fuFR4z2gjzoLWlAt3w5+tzTfwwkVfaLemdHjcrQ +iY= WDCIronportException: Internal Received: from 5zs6pc2.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.55.151]) by uls-op-cesaip02.wdc.com with ESMTP; 09 Apr 2020 13:21:09 -0700 From: Alistair Francis To: libc-alpha@sourceware.org Cc: alistair23@gmail.com, Alistair Francis Subject: [PATCH v3 2/2] linux: Add wait4 test case Date: Thu, 9 Apr 2020 13:11:54 -0700 Message-Id: <20200409201154.3365671-2-alistair.francis@wdc.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200409201154.3365671-1-alistair.francis@wdc.com> References: <20200409201154.3365671-1-alistair.francis@wdc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-25.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Apr 2020 20:21:13 -0000 Add a simple test that checks if the wait4 syscall works without an rusage argument. This test would have caught the bugs introduced in commit 600f00b "linux: Use long time_t for wait4/getrusage". --- sysdeps/unix/sysv/linux/Makefile | 2 +- sysdeps/unix/sysv/linux/tst-wait4.c | 51 +++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 sysdeps/unix/sysv/linux/tst-wait4.c diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 60dc5cf9e5..d5fdb4369a 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -98,7 +98,7 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \ tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \ test-errno-linux tst-memfd_create tst-mlock2 tst-pkey \ tst-rlimit-infinity tst-ofdlocks tst-gettid tst-gettid-kill \ - tst-tgkill + tst-tgkill tst-wait4 tests-internal += tst-ofdlocks-compat tst-sigcontext-get_pc CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables diff --git a/sysdeps/unix/sysv/linux/tst-wait4.c b/sysdeps/unix/sysv/linux/tst-wait4.c new file mode 100644 index 0000000000..44287797a7 --- /dev/null +++ b/sysdeps/unix/sysv/linux/tst-wait4.c @@ -0,0 +1,51 @@ +/* Smoke test for the wait4 system call. + Copyright (C) 2019-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include +#include +#include + +/* Check that wait4 works with no rusage arg. */ +static void +test_wait4_no_usage (void) +{ + pid_t child = fork (); + + if (child == 0) + { + pause (); + exit (0); + } + + wait4 (child, &(int){0}, WNOHANG, NULL); + kill (child, SIGKILL); +} + +static int +do_test (void) +{ + test_wait4_no_usage(); + + return 0; +} + +#include