From patchwork Fri Apr 10 18:55:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 38801 Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) by sourceware.org (Postfix) with ESMTPS id 92B7C385B835 for ; Fri, 10 Apr 2020 19:03:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 92B7C385B835 IronPort-SDR: YEbrO1jUESzb4cOH6oocbYqmxD248ZRrax1x5FQRKXzW1q1RBVirL8F1aXaCrsiX2MgZ5enF04 BFBGviPF3MRQ+WH74KKbTIkGMwj00wCj4ux4kPMbD7LEpxJzVjALVMn47ms9WVRFYj7w1B99/T L9A5cVm3UxDYHrj0B3zgp8ztotZzmZuGcschjlLhN8VliuKca8n0ytiaMSCr1fijQMVtP3KnbT TJYollv7PqzHsy3/ejepz2qCvuA6rjcGXYu9MdQB0DKN4189G7MSMvV3md9bl+WugcxVVd2n9a jHI= X-IronPort-AV: E=Sophos;i="5.72,367,1580745600"; d="scan'208";a="243684709" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 Apr 2020 03:03:04 +0800 IronPort-SDR: 980ELc4rNOVHeWVVFcqVA5qGe6iiljiuZqUKt0H89oSEvb+dD1RrMKXaFotowMyumTIl/UdaHa E7RD3ng+AmDqtlMpNQaJu7QnMhGA9SPj7gl600xzZbEHeCpIcfil/1MPkSacqSkEZtIgLvndq4 iuZCv35SjiRE/UiFkM31cV0UTVfVPTj8siTHf9Rjp5tYixFaW3JUazQ1bkYdund47L6VX5SkI8 Goa5HsnlHxl4rwOlmKz6T2+is8s9KVH1i5c7A2+NeC46qzE6EJn6MiAoJb2SEyS569x7NxtqkQ 8s212otV/IYtkKaaKf1mFwHW Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2020 11:54:14 -0700 IronPort-SDR: u82CvEMvYvvhYvzAKBjUt/T4oL7cxIpu7Ns9zrUi2CM968i5cESPRgDjAyZl7q8tyFNYAOfvP5 zclg4gDsH9+cd22AdfVj9EYlvs6pL2UEXsdvlYoH5g5zPUfzsnYY5Q5Tzzpikho8R5Jj2j/pJY RQTl+/fQc9Nni1o61+MBoYelT0GlvYt0eK20UBiesNKExTNiAnpLZ/0kTGxxvPI6Ea2ciny9mw wmfW0Tob1R7hGBXGsMswXsBaAdZRFU5EO1GC/BB0v9WP8jKnNJ+ew83/ElTDa+sumIG36CnRwp xnY= WDCIronportException: Internal Received: from phd004806.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.55.150]) by uls-op-cesaip01.wdc.com with ESMTP; 10 Apr 2020 12:03:04 -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: Fri, 10 Apr 2020 11:55:12 -0700 Message-Id: <20200410185513.1284043-2-alistair.francis@wdc.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200410185513.1284043-1-alistair.francis@wdc.com> References: <20200410185513.1284043-1-alistair.francis@wdc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-24.5 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: Fri, 10 Apr 2020 19:03:09 -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