From: Cyril Hrubis <chrubis@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] Split waitid01.c test into multiple tests
Date: Wed, 23 Feb 2022 11:46:10 +0100 [thread overview]
Message-ID: <YhYQcqq2tKd2Xf81@yuki> (raw)
In-Reply-To: <20220223091349.30833-1-andrea.cervesato@suse.de>
Hi!
Pushed with a few changes, thanks.
Apart from formatting changes there were two functional changes I did.
- with P_ALL the the id parameter is ignored so I've changed it to 0
- the CLD_DUMPED case is a bit more complicated, since have to make sure
that core dumps are enabled, so I did add a setup fucntion that
attempts to raise rlimit(RLIMIT_CORE) and if that fails we expect
CLD_KILLED instead of CLD_DUMPED
Full diff:
diff --git a/testcases/kernel/syscalls/waitid/waitid01.c b/testcases/kernel/syscalls/waitid/waitid01.c
index 60ecf9022..136eec8a6 100644
--- a/testcases/kernel/syscalls/waitid/waitid01.c
+++ b/testcases/kernel/syscalls/waitid/waitid01.c
@@ -25,7 +25,7 @@ static void run(void)
if (!pidchild)
exit(123);
- TST_EXP_PASS(waitid(P_ALL, getpid(), infop, WEXITED));
+ TST_EXP_PASS(waitid(P_ALL, 0, infop, WEXITED));
TST_EXP_EQ_LI(infop->si_pid, pidchild);
TST_EXP_EQ_LI(infop->si_status, 123);
TST_EXP_EQ_LI(infop->si_signo, SIGCHLD);
@@ -35,9 +35,8 @@ static void run(void)
static struct tst_test test = {
.test_all = run,
.forks_child = 1,
- .bufs =
- (struct tst_buffers[]){
- { &infop, .size = sizeof(*infop) },
- {},
- },
+ .bufs = (struct tst_buffers[]) {
+ {&infop, .size = sizeof(*infop)},
+ {},
+ },
};
diff --git a/testcases/kernel/syscalls/waitid/waitid10.c b/testcases/kernel/syscalls/waitid/waitid10.c
index 3b2b0fae9..869ef18bd 100644
--- a/testcases/kernel/syscalls/waitid/waitid10.c
+++ b/testcases/kernel/syscalls/waitid/waitid10.c
@@ -13,9 +13,11 @@
#include <stdlib.h>
#include <sys/wait.h>
+#include <sys/prctl.h>
#include "tst_test.h"
static siginfo_t *infop;
+static int core_dumps = 1;
static void run(void)
{
@@ -26,22 +28,47 @@ static void run(void)
volatile int a, zero = 0;
a = 1 / zero;
- exit(0);
+ exit(a);
}
- TST_EXP_PASS(waitid(P_ALL, pidchild, infop, WEXITED));
+ TST_EXP_PASS(waitid(P_ALL, 0, infop, WEXITED));
TST_EXP_EQ_LI(infop->si_pid, pidchild);
TST_EXP_EQ_LI(infop->si_status, SIGFPE);
TST_EXP_EQ_LI(infop->si_signo, SIGCHLD);
- TST_EXP_EQ_LI(infop->si_code, CLD_DUMPED);
+
+ if (core_dumps)
+ TST_EXP_EQ_LI(infop->si_code, CLD_DUMPED);
+ else
+ TST_EXP_EQ_LI(infop->si_code, CLD_KILLED);
+}
+
+static void setup(void)
+{
+ struct rlimit rlim;
+
+ SAFE_GETRLIMIT(RLIMIT_CORE, &rlim);
+
+ if (rlim.rlim_cur)
+ return;
+
+ if (!rlim.rlim_max) {
+ core_dumps = 0;
+ return;
+ }
+
+ tst_res(TINFO, "Raising RLIMIT_CORE rlim_cur=%li -> %li",
+ rlim.rlim_cur, rlim.rlim_max);
+
+ rlim.rlim_cur = rlim.rlim_max;
+ SAFE_SETRLIMIT(RLIMIT_CORE, &rlim);
}
static struct tst_test test = {
.test_all = run,
.forks_child = 1,
- .bufs =
- (struct tst_buffers[]){
- { &infop, .size = sizeof(*infop) },
- {},
- },
+ .setup = setup,
+ .bufs = (struct tst_buffers[]) {
+ {&infop, .size = sizeof(*infop)},
+ {},
+ },
};
diff --git a/testcases/kernel/syscalls/waitid/waitid11.c b/testcases/kernel/syscalls/waitid/waitid11.c
index 8f2b847ea..e3754bb1d 100644
--- a/testcases/kernel/syscalls/waitid/waitid11.c
+++ b/testcases/kernel/syscalls/waitid/waitid11.c
@@ -24,7 +24,7 @@ static void run(void)
pidchild = SAFE_FORK();
if (!pidchild) {
- sleep(10);
+ pause();
return;
}
@@ -40,9 +40,8 @@ static void run(void)
static struct tst_test test = {
.test_all = run,
.forks_child = 1,
- .bufs =
- (struct tst_buffers[]){
- { &infop, .size = sizeof(*infop) },
- {},
- },
+ .bufs = (struct tst_buffers[]) {
+ {&infop, .size = sizeof(*infop)},
+ {},
+ },
};
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
prev parent reply other threads:[~2022-02-23 10:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-23 9:13 [LTP] [PATCH v2] Split waitid01.c test into multiple tests Andrea Cervesato
2022-02-23 10:46 ` Cyril Hrubis [this message]
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=YhYQcqq2tKd2Xf81@yuki \
--to=chrubis@suse.cz \
--cc=andrea.cervesato@suse.de \
--cc=ltp@lists.linux.it \
/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