Message ID | 20240130162813.20278-1-mdoucha@suse.cz |
---|---|
State | Accepted |
Headers | show |
Series | waitpid01: Test all standard deadly signals | expand |
Hi Martin, nice work. Reviewed-by: Petr Vorel <pvorel@suse.cz> ... > +++ b/testcases/kernel/syscalls/waitpid/waitpid01.c > @@ -5,25 +5,57 @@ > * Copyright (c) 2018 Cyril Hrubis <chrubis@suse.cz> Very nice cleanup, you deserve copyright, right? * Copyright (C) 2024 SUSE LLC <mdoucha@suse.cz> > */ > Extend waitpid01 to test all standard signals that kill the target > process unless caught. Also remove waitpid02 since testing SIGFPE > in waitpid01 makes it redundant. > +static int testcase_list[] = { > + SIGABRT, > + SIGALRM, > + SIGBUS, > + SIGFPE, > + SIGHUP, > + SIGILL, > + SIGINT, > + SIGKILL, > + SIGPIPE, > + SIGPOLL, > + SIGPROF, > + SIGQUIT, > + SIGSEGV, > + SIGSYS, > + SIGTERM, > + SIGTRAP, > + SIGVTALRM, > + SIGXCPU, > + SIGXFSZ > +}; I suppose you ignored from the list of signals in man signal(7) these with action "Core" "Term" unless without standard ("-"), right? So user defined signals (SIGUSR1, SIGUSR2) does not make sense to test? Kind regards, Petr
On 30. 01. 24 18:22, Petr Vorel wrote: > Hi Martin, > > nice work. > > Reviewed-by: Petr Vorel <pvorel@suse.cz> > > ... >> +++ b/testcases/kernel/syscalls/waitpid/waitpid01.c >> @@ -5,25 +5,57 @@ >> * Copyright (c) 2018 Cyril Hrubis <chrubis@suse.cz> > > Very nice cleanup, you deserve copyright, right? > * Copyright (C) 2024 SUSE LLC <mdoucha@suse.cz> >> */ It's not that big of a change. > >> Extend waitpid01 to test all standard signals that kill the target >> process unless caught. Also remove waitpid02 since testing SIGFPE >> in waitpid01 makes it redundant. >> +static int testcase_list[] = { >> + SIGABRT, >> + SIGALRM, >> + SIGBUS, >> + SIGFPE, >> + SIGHUP, >> + SIGILL, >> + SIGINT, >> + SIGKILL, >> + SIGPIPE, >> + SIGPOLL, >> + SIGPROF, >> + SIGQUIT, >> + SIGSEGV, >> + SIGSYS, >> + SIGTERM, >> + SIGTRAP, >> + SIGVTALRM, >> + SIGXCPU, >> + SIGXFSZ >> +}; > > I suppose you ignored from the list of signals in man signal(7) these with > action "Core" "Term" unless without standard ("-"), right? > So user defined signals (SIGUSR1, SIGUSR2) does not make sense to test? I've skipped all non-standard signals (some of which are just aliases for standard ones) and I think it's better to avoid SIGUSR* since we use them internally. But we could also add signal(sig, SIG_DFL); before raise() and add SIGUSR* to the list. > Kind regards, > Petr
> On 30. 01. 24 18:22, Petr Vorel wrote: > > Hi Martin, > > nice work. > > Reviewed-by: Petr Vorel <pvorel@suse.cz> > > ... > > > +++ b/testcases/kernel/syscalls/waitpid/waitpid01.c > > > @@ -5,25 +5,57 @@ > > > * Copyright (c) 2018 Cyril Hrubis <chrubis@suse.cz> > > Very nice cleanup, you deserve copyright, right? > > * Copyright (C) 2024 SUSE LLC <mdoucha@suse.cz> > > > */ > It's not that big of a change. ack. > > > Extend waitpid01 to test all standard signals that kill the target > > > process unless caught. Also remove waitpid02 since testing SIGFPE > > > in waitpid01 makes it redundant. > > > +static int testcase_list[] = { > > > + SIGABRT, > > > + SIGALRM, > > > + SIGBUS, > > > + SIGFPE, > > > + SIGHUP, > > > + SIGILL, > > > + SIGINT, > > > + SIGKILL, > > > + SIGPIPE, > > > + SIGPOLL, > > > + SIGPROF, > > > + SIGQUIT, > > > + SIGSEGV, > > > + SIGSYS, > > > + SIGTERM, > > > + SIGTRAP, > > > + SIGVTALRM, > > > + SIGXCPU, > > > + SIGXFSZ > > > +}; > > I suppose you ignored from the list of signals in man signal(7) these with > > action "Core" "Term" unless without standard ("-"), right? > > So user defined signals (SIGUSR1, SIGUSR2) does not make sense to test? > I've skipped all non-standard signals (some of which are just aliases for > standard ones) and I think it's better to avoid SIGUSR* since we use them > internally. But we could also add signal(sig, SIG_DFL); before raise() and > add SIGUSR* to the list. Thanks for info. Feel free to send v2 (or let me know to wait). Otherwise I'll merge it in the evening or tomorrow. Kind regards, Petr > > Kind regards, > > Petr
On 31. 01. 24 11:14, Petr Vorel wrote: >> I've skipped all non-standard signals (some of which are just aliases for >> standard ones) and I think it's better to avoid SIGUSR* since we use them >> internally. But we could also add signal(sig, SIG_DFL); before raise() and >> add SIGUSR* to the list. > > Thanks for info. Feel free to send v2 (or let me know to wait). Otherwise I'll > merge it in the evening or tomorrow. Actually, let's just add SIGUSR1 and SIGUSR2 to the testcase list and merge. The LTP library signal handlers are reset to SIG_DFL in fork_testrun() so no special handling in the test is needed.
Hi Martin, > On 31. 01. 24 11:14, Petr Vorel wrote: > > > I've skipped all non-standard signals (some of which are just aliases for > > > standard ones) and I think it's better to avoid SIGUSR* since we use them > > > internally. But we could also add signal(sig, SIG_DFL); before raise() and > > > add SIGUSR* to the list. > > Thanks for info. Feel free to send v2 (or let me know to wait). Otherwise I'll > > merge it in the evening or tomorrow. > Actually, let's just add SIGUSR1 and SIGUSR2 to the testcase list and merge. > The LTP library signal handlers are reset to SIG_DFL in fork_testrun() so no > special handling in the test is needed. Good, merged. Thank you! Kind regards, Petr
Hi Martin, first this change (merged as ed5ccf6c1 ("waitpid01: Test all standard deadly signals") is failing on 6.6 on Debian: ed5ccf6c1 ("waitpid01: Test all standard deadly signals") waitpid01.c:88: TINFO: Testing child: raise(sig) waitpid01.c:109: TPASS: waitpid() returned correct pid 236064 waitpid01.c:118: TPASS: WIFSIGNALED() set in status waitpid01.c:126: TPASS: WTERMSIG() == SIGIOT/SIGABRT waitpid01.c:143: TPASS: Child dumped core as expected waitpid01.c:109: TPASS: waitpid() returned correct pid 236071 waitpid01.c:118: TPASS: WIFSIGNALED() set in status waitpid01.c:126: TPASS: WTERMSIG() == SIGALRM waitpid01.c:109: TPASS: waitpid() returned correct pid 236072 waitpid01.c:118: TPASS: WIFSIGNALED() set in status waitpid01.c:126: TPASS: WTERMSIG() == SIGBUS waitpid01.c:143: TPASS: Child dumped core as expected waitpid01.c:109: TPASS: waitpid() returned correct pid 236082 waitpid01.c:113: TFAIL: WIFSIGNALED() not set in status (exited with 0) ... waitpid01.c:88: TINFO: Testing child: kill(getpid(), sig) waitpid01.c:109: TPASS: waitpid() returned correct pid 236165 waitpid01.c:118: TPASS: WIFSIGNALED() set in status waitpid01.c:126: TPASS: WTERMSIG() == SIGIOT/SIGABRT waitpid01.c:143: TPASS: Child dumped core as expected waitpid01.c:109: TPASS: waitpid() returned correct pid 236176 waitpid01.c:118: TPASS: WIFSIGNALED() set in status waitpid01.c:126: TPASS: WTERMSIG() == SIGALRM waitpid01.c:109: TPASS: waitpid() returned correct pid 236177 waitpid01.c:118: TPASS: WIFSIGNALED() set in status waitpid01.c:126: TPASS: WTERMSIG() == SIGBUS waitpid01.c:143: TPASS: Child dumped core as expected waitpid01.c:109: TPASS: waitpid() returned correct pid 236187 waitpid01.c:113: TFAIL: WIFSIGNALED() not set in status (exited with 0) ... But it works on 6.8.0-rc1-2.gf4ba5db-default Tumbleweed, which I tested it before. Also patch does not apply. I had to patch waitpid01 myself, hopefully I did that correctly [1]. Kind regards, Petr [1] https://github.com/pevik/ltp/blob/mdoucha/waitpid05/testcases/kernel/syscalls/waitpid/waitpid01.c
> Hi Martin, > first this change (merged as ed5ccf6c1 ("waitpid01: Test all standard deadly > signals") is failing on 6.6 on Debian: > ed5ccf6c1 ("waitpid01: Test all standard deadly signals") > waitpid01.c:88: TINFO: Testing child: raise(sig) > waitpid01.c:109: TPASS: waitpid() returned correct pid 236064 > waitpid01.c:118: TPASS: WIFSIGNALED() set in status > waitpid01.c:126: TPASS: WTERMSIG() == SIGIOT/SIGABRT > waitpid01.c:143: TPASS: Child dumped core as expected > waitpid01.c:109: TPASS: waitpid() returned correct pid 236071 > waitpid01.c:118: TPASS: WIFSIGNALED() set in status > waitpid01.c:126: TPASS: WTERMSIG() == SIGALRM > waitpid01.c:109: TPASS: waitpid() returned correct pid 236072 > waitpid01.c:118: TPASS: WIFSIGNALED() set in status > waitpid01.c:126: TPASS: WTERMSIG() == SIGBUS > waitpid01.c:143: TPASS: Child dumped core as expected > waitpid01.c:109: TPASS: waitpid() returned correct pid 236082 > waitpid01.c:113: TFAIL: WIFSIGNALED() not set in status (exited with 0) => FYI it's SIGFPE (it would help readability to either print tst_strsig(sig) for each failure or as TINFO before testing). I tested other Debian (5.10 and 6.1) and they work, I wonder what is the problem. Kind regards, Petr > ... > waitpid01.c:88: TINFO: Testing child: kill(getpid(), sig) > waitpid01.c:109: TPASS: waitpid() returned correct pid 236165 > waitpid01.c:118: TPASS: WIFSIGNALED() set in status > waitpid01.c:126: TPASS: WTERMSIG() == SIGIOT/SIGABRT > waitpid01.c:143: TPASS: Child dumped core as expected > waitpid01.c:109: TPASS: waitpid() returned correct pid 236176 > waitpid01.c:118: TPASS: WIFSIGNALED() set in status > waitpid01.c:126: TPASS: WTERMSIG() == SIGALRM > waitpid01.c:109: TPASS: waitpid() returned correct pid 236177 > waitpid01.c:118: TPASS: WIFSIGNALED() set in status > waitpid01.c:126: TPASS: WTERMSIG() == SIGBUS > waitpid01.c:143: TPASS: Child dumped core as expected > waitpid01.c:109: TPASS: waitpid() returned correct pid 236187 > waitpid01.c:113: TFAIL: WIFSIGNALED() not set in status (exited with 0) > ... > But it works on 6.8.0-rc1-2.gf4ba5db-default Tumbleweed, which I tested it > before. > Also patch does not apply. I had to patch waitpid01 myself, hopefully I did that > correctly [1]. > Kind regards, > Petr > [1] https://github.com/pevik/ltp/blob/mdoucha/waitpid05/testcases/kernel/syscalls/waitpid/waitpid01.c
On 05. 02. 24 18:34, Petr Vorel wrote: > Hi Martin, > > first this change (merged as ed5ccf6c1 ("waitpid01: Test all standard deadly > signals") is failing on 6.6 on Debian: > > ed5ccf6c1 ("waitpid01: Test all standard deadly signals") > > waitpid01.c:88: TINFO: Testing child: raise(sig) > waitpid01.c:109: TPASS: waitpid() returned correct pid 236064 > waitpid01.c:118: TPASS: WIFSIGNALED() set in status > waitpid01.c:126: TPASS: WTERMSIG() == SIGIOT/SIGABRT > waitpid01.c:143: TPASS: Child dumped core as expected > waitpid01.c:109: TPASS: waitpid() returned correct pid 236071 > waitpid01.c:118: TPASS: WIFSIGNALED() set in status > waitpid01.c:126: TPASS: WTERMSIG() == SIGALRM > waitpid01.c:109: TPASS: waitpid() returned correct pid 236072 > waitpid01.c:118: TPASS: WIFSIGNALED() set in status > waitpid01.c:126: TPASS: WTERMSIG() == SIGBUS > waitpid01.c:143: TPASS: Child dumped core as expected > waitpid01.c:109: TPASS: waitpid() returned correct pid 236082 > waitpid01.c:113: TFAIL: WIFSIGNALED() not set in status (exited with 0) > ... > waitpid01.c:88: TINFO: Testing child: kill(getpid(), sig) > waitpid01.c:109: TPASS: waitpid() returned correct pid 236165 > waitpid01.c:118: TPASS: WIFSIGNALED() set in status > waitpid01.c:126: TPASS: WTERMSIG() == SIGIOT/SIGABRT > waitpid01.c:143: TPASS: Child dumped core as expected > waitpid01.c:109: TPASS: waitpid() returned correct pid 236176 > waitpid01.c:118: TPASS: WIFSIGNALED() set in status > waitpid01.c:126: TPASS: WTERMSIG() == SIGALRM > waitpid01.c:109: TPASS: waitpid() returned correct pid 236177 > waitpid01.c:118: TPASS: WIFSIGNALED() set in status > waitpid01.c:126: TPASS: WTERMSIG() == SIGBUS > waitpid01.c:143: TPASS: Child dumped core as expected > waitpid01.c:109: TPASS: waitpid() returned correct pid 236187 > waitpid01.c:113: TFAIL: WIFSIGNALED() not set in status (exited with 0) > ... > > But it works on 6.8.0-rc1-2.gf4ba5db-default Tumbleweed, which I tested it > before. I've tested the patch on kernel v6.6.1 on Tumbleweed and all testcases pass. The failure shows that SIGFPE doesn't trigger coredump for some reason, that's either a system bug or some parent process left over a SIGFPE handler. Could you try the Debian test again with this patch? diff --git a/testcases/kernel/syscalls/waitpid/waitpid01.c b/testcases/kernel/syscalls/waitpid/waitpid01.c index 367f7875c..a42b7e8ac 100644 --- a/testcases/kernel/syscalls/waitpid/waitpid01.c +++ b/testcases/kernel/syscalls/waitpid/waitpid01.c @@ -94,6 +94,9 @@ static void run(unsigned int n) int status; const struct testcase *tc = testcase_list + n; + if (tc->sig != SIGKILL) + SAFE_SIGNAL(tc->sig, SIG_DFL); + pid = SAFE_FORK(); if (!pid) variant_list[tst_variant].func(tc->sig);
Hi Martin, > On 05. 02. 24 18:34, Petr Vorel wrote: > > Hi Martin, > > first this change (merged as ed5ccf6c1 ("waitpid01: Test all standard deadly > > signals") is failing on 6.6 on Debian: > > ed5ccf6c1 ("waitpid01: Test all standard deadly signals") > > waitpid01.c:88: TINFO: Testing child: raise(sig) > > waitpid01.c:109: TPASS: waitpid() returned correct pid 236064 > > waitpid01.c:118: TPASS: WIFSIGNALED() set in status > > waitpid01.c:126: TPASS: WTERMSIG() == SIGIOT/SIGABRT > > waitpid01.c:143: TPASS: Child dumped core as expected > > waitpid01.c:109: TPASS: waitpid() returned correct pid 236071 > > waitpid01.c:118: TPASS: WIFSIGNALED() set in status > > waitpid01.c:126: TPASS: WTERMSIG() == SIGALRM > > waitpid01.c:109: TPASS: waitpid() returned correct pid 236072 > > waitpid01.c:118: TPASS: WIFSIGNALED() set in status > > waitpid01.c:126: TPASS: WTERMSIG() == SIGBUS > > waitpid01.c:143: TPASS: Child dumped core as expected > > waitpid01.c:109: TPASS: waitpid() returned correct pid 236082 > > waitpid01.c:113: TFAIL: WIFSIGNALED() not set in status (exited with 0) > > ... > > waitpid01.c:88: TINFO: Testing child: kill(getpid(), sig) > > waitpid01.c:109: TPASS: waitpid() returned correct pid 236165 > > waitpid01.c:118: TPASS: WIFSIGNALED() set in status > > waitpid01.c:126: TPASS: WTERMSIG() == SIGIOT/SIGABRT > > waitpid01.c:143: TPASS: Child dumped core as expected > > waitpid01.c:109: TPASS: waitpid() returned correct pid 236176 > > waitpid01.c:118: TPASS: WIFSIGNALED() set in status > > waitpid01.c:126: TPASS: WTERMSIG() == SIGALRM > > waitpid01.c:109: TPASS: waitpid() returned correct pid 236177 > > waitpid01.c:118: TPASS: WIFSIGNALED() set in status > > waitpid01.c:126: TPASS: WTERMSIG() == SIGBUS > > waitpid01.c:143: TPASS: Child dumped core as expected > > waitpid01.c:109: TPASS: waitpid() returned correct pid 236187 > > waitpid01.c:113: TFAIL: WIFSIGNALED() not set in status (exited with 0) > > ... > > But it works on 6.8.0-rc1-2.gf4ba5db-default Tumbleweed, which I tested it > > before. > I've tested the patch on kernel v6.6.1 on Tumbleweed and all testcases pass. > The failure shows that SIGFPE doesn't trigger coredump for some reason, > that's either a system bug or some parent process left over a SIGFPE > handler. Could you try the Debian test again with this patch? > diff --git a/testcases/kernel/syscalls/waitpid/waitpid01.c > b/testcases/kernel/syscalls/waitpid/waitpid01.c > index 367f7875c..a42b7e8ac 100644 > --- a/testcases/kernel/syscalls/waitpid/waitpid01.c > +++ b/testcases/kernel/syscalls/waitpid/waitpid01.c > @@ -94,6 +94,9 @@ static void run(unsigned int n) > int status; > const struct testcase *tc = testcase_list + n; > + if (tc->sig != SIGKILL) > + SAFE_SIGNAL(tc->sig, SIG_DFL); > + Ah, reset the signal, thanks! It works on the current master, but because different patch would broke your waiting waitpid01 patch, so that I'll review and merge it first. Will you send this as a patch or should I merge this as your Suggested-by: ? Kind regards, Petr > pid = SAFE_FORK(); > if (!pid) > variant_list[tst_variant].func(tc->sig);
On 06. 02. 24 11:44, Petr Vorel wrote: > Hi Martin, > >> On 05. 02. 24 18:34, Petr Vorel wrote: >> diff --git a/testcases/kernel/syscalls/waitpid/waitpid01.c >> b/testcases/kernel/syscalls/waitpid/waitpid01.c >> index 367f7875c..a42b7e8ac 100644 >> --- a/testcases/kernel/syscalls/waitpid/waitpid01.c >> +++ b/testcases/kernel/syscalls/waitpid/waitpid01.c >> @@ -94,6 +94,9 @@ static void run(unsigned int n) >> int status; >> const struct testcase *tc = testcase_list + n; > >> + if (tc->sig != SIGKILL) >> + SAFE_SIGNAL(tc->sig, SIG_DFL); >> + > > Ah, reset the signal, thanks! > > It works on the current master, but because different patch would broke your > waiting waitpid01 patch, so that I'll review and merge it first. > > Will you send this as a patch or should I merge this as your Suggested-by: ? You can add it to the waiting waitpid01 patch and push it together as a single commit.
> On 06. 02. 24 11:44, Petr Vorel wrote: > > Hi Martin, > > > On 05. 02. 24 18:34, Petr Vorel wrote: > > > diff --git a/testcases/kernel/syscalls/waitpid/waitpid01.c > > > b/testcases/kernel/syscalls/waitpid/waitpid01.c > > > index 367f7875c..a42b7e8ac 100644 > > > --- a/testcases/kernel/syscalls/waitpid/waitpid01.c > > > +++ b/testcases/kernel/syscalls/waitpid/waitpid01.c > > > @@ -94,6 +94,9 @@ static void run(unsigned int n) > > > int status; > > > const struct testcase *tc = testcase_list + n; > > > + if (tc->sig != SIGKILL) > > > + SAFE_SIGNAL(tc->sig, SIG_DFL); > > > + > > Ah, reset the signal, thanks! > > It works on the current master, but because different patch would broke your > > waiting waitpid01 patch, so that I'll review and merge it first. > > Will you send this as a patch or should I merge this as your Suggested-by: ? > You can add it to the waiting waitpid01 patch and push it together as a > single commit. Ideally this would be a separate fix in case of revert, but yeah, I'll add it to your next patch. Thanks! Kind regards, Petr
diff --git a/runtest/syscalls b/runtest/syscalls index 6e2407879..98f31c1ee 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1708,7 +1708,6 @@ wait402 wait402 wait403 wait403 waitpid01 waitpid01 -waitpid02 waitpid02 waitpid03 waitpid03 waitpid04 waitpid04 waitpid05 waitpid05 diff --git a/testcases/kernel/syscalls/waitpid/.gitignore b/testcases/kernel/syscalls/waitpid/.gitignore index cf9ddf6fa..2fac142c7 100644 --- a/testcases/kernel/syscalls/waitpid/.gitignore +++ b/testcases/kernel/syscalls/waitpid/.gitignore @@ -1,5 +1,4 @@ /waitpid01 -/waitpid02 /waitpid03 /waitpid04 /waitpid05 diff --git a/testcases/kernel/syscalls/waitpid/waitpid01.c b/testcases/kernel/syscalls/waitpid/waitpid01.c index 5a39a1107..b6d8f6078 100644 --- a/testcases/kernel/syscalls/waitpid/waitpid01.c +++ b/testcases/kernel/syscalls/waitpid/waitpid01.c @@ -5,25 +5,57 @@ * Copyright (c) 2018 Cyril Hrubis <chrubis@suse.cz> */ -/* - * Check that when a child kills itself by SIGALRM the waiting parent is - * correctly notified. +/*\ + * [Description] + * + * Check that when a child kills itself with one of the standard signals, + * the waiting parent is correctly notified. * - * Fork a child that raises(SIGALRM), the parent checks that SIGALRM was - * returned. + * Fork a child that raise()s given signal, the parent checks that the signal + * was returned. */ #include <stdlib.h> #include <sys/wait.h> #include "tst_test.h" -static void run(void) +static int testcase_list[] = { + SIGABRT, + SIGALRM, + SIGBUS, + SIGFPE, + SIGHUP, + SIGILL, + SIGINT, + SIGKILL, + SIGPIPE, + SIGPOLL, + SIGPROF, + SIGQUIT, + SIGSEGV, + SIGSYS, + SIGTERM, + SIGTRAP, + SIGVTALRM, + SIGXCPU, + SIGXFSZ +}; + +static void setup(void) +{ + struct rlimit lim = { 0 }; + + /* Disable core dumps */ + SAFE_SETRLIMIT(RLIMIT_CORE, &lim); +} + +static void run(unsigned int n) { pid_t pid; - int status; + int status, sig = testcase_list[n]; pid = SAFE_FORK(); if (!pid) { - raise(SIGALRM); + raise(sig); exit(0); } @@ -46,16 +78,18 @@ static void run(void) tst_res(TPASS, "WIFSIGNALED() set in status"); - if (WTERMSIG(status) != SIGALRM) { - tst_res(TFAIL, "WTERMSIG() != SIGALRM but %s", - tst_strsig(WTERMSIG(status))); + if (WTERMSIG(status) != sig) { + tst_res(TFAIL, "WTERMSIG() != %s but %s", tst_strsig(sig), + tst_strsig(WTERMSIG(status))); return; } - tst_res(TPASS, "WTERMSIG() == SIGALRM"); + tst_res(TPASS, "WTERMSIG() == %s", tst_strsig(sig)); } static struct tst_test test = { .forks_child = 1, - .test_all = run, + .setup = setup, + .test = run, + .tcnt = ARRAY_SIZE(testcase_list) }; diff --git a/testcases/kernel/syscalls/waitpid/waitpid02.c b/testcases/kernel/syscalls/waitpid/waitpid02.c deleted file mode 100644 index 1164a7834..000000000 --- a/testcases/kernel/syscalls/waitpid/waitpid02.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* - * NAME - * waitpid02.c - * - * DESCRIPTION - * Check that when a child gets killed by an integer zero - * divide exception, the waiting parent is correctly notified. - * - * ALGORITHM - * Fork a child and send a SIGFPE to it. The parent waits for the - * death of the child and checks that SIGFPE was returned. - * - * USAGE: <for command-line> - * waitpid02 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * 10/2002 Paul Larson - * Div by zero doesn't cause SIGFPE on some archs, fixed - * to send the signal with kill - * - * Restrictions - * None - */ - -#include <sys/file.h> -#include <sys/resource.h> -#include <sys/signal.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <errno.h> -#include "test.h" - -static void do_child(void); -static void setup(void); - -char *TCID = "waitpid02"; -int TST_TOTAL = 1; - -int main(int argc, char **argv) -{ - int lc; - - int pid, npid, sig, nsig; - int nexno, status; - - tst_parse_opts(argc, argv, NULL, NULL); -#ifdef UCLINUX - maybe_run_child(&do_child, ""); -#endif - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - tst_count = 0; - - sig = SIGFPE; - - pid = FORK_OR_VFORK(); - - if (pid < 0) - tst_brkm(TBROK|TERRNO, NULL, "fork failed"); - - if (pid == 0) { -#ifdef UCLINUX - self_exec(argv[0], ""); - /* No fork() error check is done so don't check here */ -#else - do_child(); -#endif - } else { - kill(pid, sig); - errno = 0; - while (((npid = waitpid(pid, &status, 0)) != -1) || - (errno == EINTR)) { - if (errno == EINTR) - continue; - - if (npid != pid) { - tst_resm(TFAIL, "waitpid error: " - "unexpected pid returned"); - } else { - tst_resm(TPASS, - "received expected pid"); - } - - nsig = WTERMSIG(status); - - /* - * nsig is the signal number returned by - * waitpid - */ - if (nsig != sig) { - tst_resm(TFAIL, "waitpid error: " - "unexpected signal returned"); - } else { - tst_resm(TPASS, "received expected " - "signal"); - } - - /* - * nexno is the exit number returned by - * waitpid - */ - nexno = WEXITSTATUS(status); - if (nexno != 0) { - tst_resm(TFAIL, "signal error: " - "unexpected exit number " - "returned"); - } else { - tst_resm(TPASS, "received expected " - "exit value"); - } - } - } - } - - tst_exit(); -} - -static void do_child(void) -{ - int exno = 1; - - while (1) - usleep(10); - - exit(exno); -} - -static void setup(void) -{ - /* SIGFPE is expected signal, so avoid creating any corefile. - * '1' is a special value, that will also avoid dumping via pipe. */ - struct rlimit r; - r.rlim_cur = 1; - r.rlim_max = 1; - setrlimit(RLIMIT_CORE, &r); - - TEST_PAUSE; -}
Extend waitpid01 to test all standard signals that kill the target process unless caught. Also remove waitpid02 since testing SIGFPE in waitpid01 makes it redundant. Signed-off-by: Martin Doucha <mdoucha@suse.cz> --- runtest/syscalls | 1 - testcases/kernel/syscalls/waitpid/.gitignore | 1 - testcases/kernel/syscalls/waitpid/waitpid01.c | 60 +++++-- testcases/kernel/syscalls/waitpid/waitpid02.c | 167 ------------------ 4 files changed, 47 insertions(+), 182 deletions(-) delete mode 100644 testcases/kernel/syscalls/waitpid/waitpid02.c