From: Alistair Francis <alistair.francis@wdc.com>
To: libc-alpha@sourceware.org
Cc: alistair23@gmail.com, Alistair Francis <alistair.francis@wdc.com>
Subject: [PATCH v3 2/2] linux: Add wait4 test case
Date: Thu, 9 Apr 2020 13:11:54 -0700 [thread overview]
Message-ID: <20200409201154.3365671-2-alistair.francis@wdc.com> (raw)
In-Reply-To: <20200409201154.3365671-1-alistair.francis@wdc.com>
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
+ <https://www.gnu.org/licenses/>. */
+
+#include <support/check.h>
+#include <support/namespace.h>
+#include <sys/wait.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+/* 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 <support/test-driver.c>
--
2.26.0
next prev parent reply other threads:[~2020-04-09 20:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-09 20:11 [PATCH v3 1/2] linux: wait4: Fix incorrect return value comparison Alistair Francis
2020-04-09 20:11 ` Alistair Francis [this message]
2020-04-09 21:46 ` [PATCH v3 2/2] linux: Add wait4 test case Adhemerval Zanella
2020-04-09 20:52 ` [PATCH v3 1/2] linux: wait4: Fix incorrect return value comparison Adhemerval Zanella
2020-04-10 18:55 [PATCH v4 " Alistair Francis
2020-04-10 18:55 ` [PATCH v3 2/2] linux: Add wait4 test case Alistair Francis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200409201154.3365671-2-alistair.francis@wdc.com \
--to=alistair.francis@wdc.com \
--cc=alistair23@gmail.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).