syscalls/kill01: Remove it
PATCH 1/4 syscalls/kill01: Remove it
kill11 has covered this test, so remove it.
--- runtest/syscalls | 1 - testcases/kernel/syscalls/kill/.gitignore | 1 - testcases/kernel/syscalls/kill/kill01.c | 161 ------------------------------ 3 files changed, 163 deletions(-) delete mode 100644 testcases/kernel/syscalls/kill/kill01.c
runtest/syscalls +0 -1
@@ -614,7 +614,6 @@ kcmp01 kcmp01 kcmp02 kcmp02 kcmp03 kcmp03 -kill01 kill01 kill02 kill02 kill03 kill03 kill04 kill04
testcases/kernel/syscalls/kill/.gitignore +0 -1
@@ -1,4 +1,3 @@ -/kill01 /kill02 /kill03 /kill04
testcases/kernel/syscalls/kill/kill01.c deleted +0 -161
161 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 2/4 syscalls/kill03, 04: Cleanup && Convert to new library
1) Remove uclinux code
2) Take use of safe macro
3) Merge kill04 into kill03
4) Add error test that pid is INT_MIN
--- runtest/syscalls | 1 - testcases/kernel/syscalls/kill/.gitignore | 1 - testcases/kernel/syscalls/kill/kill03.c | 203 +++++++++--------------------- testcases/kernel/syscalls/kill/kill04.c | 133 -------------------- 4 files changed, 59 insertions(+), 279 deletions(-) delete mode 100644 testcases/kernel/syscalls/kill/kill04.c
runtest/syscalls +0 -1
@@ -616,7 +616,6 @@ kcmp03 kcmp03 kill02 kill02 kill03 kill03 -kill04 kill04 kill05 kill05 kill06 kill06 kill07 kill07
testcases/kernel/syscalls/kill/.gitignore +0 -1
@@ -1,6 +1,5 @@ /kill02 /kill03 -/kill04 /kill05 /kill06 /kill07
testcases/kernel/syscalls/kill/kill03.c +59 -144
224 lines not on this page · raw message
testcases/kernel/syscalls/kill/kill04.c deleted +0 -133
133 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 2/4 syscalls/kill03, 04: Cleanup && Convert to new library
Feiyu Zhu <[email protected]> wrote:
...
testcases/kernel/syscalls/kill/kill03.c line 24
Quoted 11 lines
testcases/kernel/syscalls/kill/kill03.c +10
-0+#include <unistd.h> +#include "tst_test.h" + +static pid_t real_pid, fake_pid, int_min_pid; +static void cleanup (void ); + +static struct tcase { + int test_sig; + int exp_errno; + int child_flag;
The child_flag field is not necessary, we could prepare a real child in setup()
and reclaim it after testing via check the real_pid value, that will be more easily.
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200820/2115494a/attachment.htm>
PATCH 2/4 syscalls/kill03, 04: Cleanup && Convert to new library
Hi Li
Quoted 16 lines
Feiyu Zhu <[email protected] <mailto:[email protected]>> wrote:
... +#include <unistd.h> +#include "tst_test.h" + +static pid_t real_pid, fake_pid, int_min_pid; +static void cleanup(void); + +static struct tcase { +? ? ? ?int test_sig; +? ? ? ?int exp_errno; +? ? ? ?int child_flag;
Quoted 4 lines
The
child_flagfield is not necessary, we could prepare a real child insetup()
and?reclaim it after testing via check thereal_pidvalue, that will be more easily.
When I reviewed this patch in internal, I had the same idea. But when I try it and this case will hang because sub test will wait children finished by using tst_reap_childrens below:
lib/tst_test.c
static void run_tests(void)
{
...
for (i = 0; i < tst_test->tcnt; i++) {
saved_results = *results;
tst_test->test(i);
if (getpid() != main_pid) {
exit(0);
}
tst_reap_children();
if (results_equal(&saved_results, results))
tst_brk(TBROK, "Test %i haven't reported
results!", i);
}}
Also, we can use the current process id but it may has unexpected result when kill succeed. So fork a child to test maybe a better solution.
Quoted 6 lines
Signature · 3 lines
-- Regards, Li Wang
PATCH 2/4 syscalls/kill03, 04: Cleanup && Convert to new library
Quoted 48 lines · Yang Xu
Hi Li
Quoted 2 lines
Feiyu Zhu <[email protected] <mailto:[email protected]>>
Quoted 14 lines · wrote:
... +#include <unistd.h> +#include "tst_test.h" + +static pid_t real_pid, fake_pid, int_min_pid; +static void cleanup(void); + +static struct tcase { + int test_sig; + int exp_errno; + int child_flag;Quoted 4 lines
The
child_flagfield is not necessary, we could prepare a real child insetup()
and reclaim it after testing via check thereal_pidvalue, that will be more easily.When I reviewed this patch in internal, I had the same idea. But when I try it and this case will hang because sub test will wait children finished by using
tst_reap_childrensbelow:
lib/tst_test.c
static voidrun_tests(void){ ... for (i = 0; i < tst_test->tcnt; i++) { saved_results = *results; tst_test->test(i); if (getpid() != main_pid) { exit(0); } tst_reap_children(); if (results_equal(&saved_results, results)) tst_brk(TBROK, "Test %i haven't reported results!", i); }
Quoted 5 lines
}
Also, we can use the current process id but it may has unexpected result when kill succeed. So fork a child to test maybe a better solution.
Hmm, sorry for the uncleared description, actually I meant, to use real_pid instead of the tc->child_flag directly, then start to reclaim the child when thereal_pid test finishing.
Does this below diff work for you?
testcases/kernel/syscalls/kill/kill03.c +3 -10
@@ -21,24 +21,17 @@ static void cleanup(void);static struct tcase {int test_sig;int exp_errno; -int child_flag;pid_t *pid; } tcases[] = { - {2000 ,EINVAL ,1 , &real_pid}, - {SIGKILL ,ESRCH ,0 , &fake_pid}, - {SIGKILL ,ESRCH ,0 , &int_min_pid} + {2000 ,EINVAL , &real_pid}, + {SIGKILL ,ESRCH , &fake_pid}, + {SIGKILL ,ESRCH , &int_min_pid} };static void verify_kill (unsigned int n) {struct tcase *tc = &tcases[n]; -if (tc->child_flag) { - real_pid =SAFE_FORK (); -if (!real_pid) -pause (); - } -TEST (kill (*tc->pid, tc->test_sig));if (TST_RET !=-1 ) { tst_res(TFAIL, "kill should fail but not, return %ld",
TST_RET);
@@ -51,14 +44,19 @@ static void verify_kill(unsigned int n)
tst_res(TFAIL | TTERRNO, "kill expected %s but got",
tst_strerrno(tc->exp_errno));
- if (tc->child_flag) {
+ if (real_pid) {
cleanup();
real_pid = 0;
}+
}
static void setup(void)
{
+ real_pid = SAFE_FORK();
+ if (!real_pid)
+ pause();
+
fake_pid = tst_get_unused_pid();
int_min_pid = INT_MIN;}
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200821/9d88dd10/attachment-0001.htm>
PATCH 2/4 syscalls/kill03, 04: Cleanup && Convert to new library
Hi Li
Quoted 63 lines
On Fri, Aug 21, 2020 at 9:18 AM Yang Xu <[email protected] <mailto:[email protected]>> wrote:
Hi Li > > Feiyu Zhu <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>> wrote: > >? ? ?... >? ? ?+#include <unistd.h> >? ? ?+#include "tst_test.h" >? ? ?+ >? ? ?+static pid_t real_pid, fake_pid, int_min_pid; >? ? ?+static void cleanup(void); >? ? ?+ >? ? ?+static struct tcase { >? ? ?+? ? ? ?int test_sig; >? ? ?+? ? ? ?int exp_errno; >? ? ?+? ? ? ?int child_flag; > > > The child_flag field is not necessary, we could prepare a real child in > setup() > and?reclaim it after testing via check the real_pid value, that will be > more easily. When I reviewed this patch in internal, I had the same idea. But when I try it and this case will hang because sub test will wait children finished by using tst_reap_childrens below: lib/tst_test.c static void run_tests(void) { ? ? ? ? ... ? ? ? ? ?for (i = 0; i < tst_test->tcnt; i++) { ? ? ? ? ? ? ? ? ?saved_results = *results; ? ? ? ? ? ? ? ? ?tst_test->test(i); ? ? ? ? ? ? ? ? ?if (getpid() != main_pid) { ? ? ? ? ? ? ? ? ? ? ? ? ?exit(0); ? ? ? ? ? ? ? ? ?} ? ? ? ? ? ? ? ? ?tst_reap_children(); ? ? ? ? ? ? ? ? ?if (results_equal(&saved_results, results)) ? ? ? ? ? ? ? ? ? ? ? ? ?tst_brk(TBROK, "Test %i haven't reported results!", i); ? ? ? ? ?} } Also, we can use the current process id but it may has unexpected result when kill succeed. So fork a child to test maybe a better solution.
Quoted 6 lines
Hmm, sorry for the uncleared description, actually I meant, to use
real_pidinstead of the?tc->child_flag directly, then start to reclaim the child when thereal_pidtest finishing.Does this below diff work for you?
It looks well. But the real_pid only valid when the first sub test and the real pid is equals to 0 when using -i parameters because we have killed this children.
For pid = 0, it means then sig is sent to every process in the process group of the calling process. So it looks like we test different thing when using -i parameters. What do you think about this?
Quoted 56 lines
testcases/kernel/syscalls/kill/kill03.c +3
-10@@ -21,24 +21,17 @@ static void cleanup(void); ?static struct tcase { ? ? ? ? int test_sig; ? ? ? ? int exp_errno; - ? ? ? int child_flag; ? ? ? ? pid_t *pid; ?} tcases[] = { - ? ? ? {2000, EINVAL, 1, &real_pid}, - ? ? ? {SIGKILL, ESRCH, 0, &fake_pid}, - ? ? ? {SIGKILL, ESRCH, 0, &int_min_pid} + ? ? ? {2000, EINVAL, &real_pid}, + ? ? ? {SIGKILL, ESRCH, &fake_pid}, + ? ? ? {SIGKILL, ESRCH, &int_min_pid} ?}; ?static void verify_kill(unsigned int n) ?{ ? ? ? ? struct tcase *tc = &tcases[n]; - ? ? ? if (tc->child_flag) { - ? ? ? ? ? ? ? real_pid = SAFE_FORK(); - ? ? ? ? ? ? ? if (!real_pid) - ? ? ? ? ? ? ? ? ? ? ? pause(); - ? ? ? } - ? ? ? ? TEST(kill(*tc->pid, tc->test_sig)); ? ? ? ? if (TST_RET != -1) { ? ? ? ? ? ? ? ? tst_res(TFAIL, "kill should fail but not, return %ld",
TST_RET);testcases/kernel/syscalls/kill/kill03.c +6
-1@@ -51,14 +44,19 @@ static void verify_kill(unsigned int n) ? ? ? ? ? ? ? ? tst_res(TFAIL | TTERRNO, "kill expected %s but got", ? ? ? ? ? ? ? ? ? ? ? ? tst_strerrno(tc->exp_errno)); - ? ? ? if (tc->child_flag) { + ? ? ? if (real_pid) { ? ? ? ? ? ? ? ? cleanup(); ? ? ? ? ? ? ? ? real_pid = 0; ? ? ? ? } + ?} ?static void setup(void) ?{ + ? ? ? real_pid = SAFE_FORK(); + ? ? ? if (!real_pid) + ? ? ? ? ? ? ? pause(); + ? ? ? ? fake_pid = tst_get_unused_pid(); ? ? ? ? int_min_pid = INT_MIN; ?}Signature · 2 lines
Regards, Li Wang
PATCH 2/4 syscalls/kill03, 04: Cleanup && Convert to new library
Quoted 8 lines · Yang Xu
...
Quoted 6 lines
Also, we can use the current process id but it may has unexpected result
when kill succeed. So fork a child to test maybe a better solution.Hmm, sorry for the uncleared description, actually I meant, to use
real_pid
Quoted 9 lines
Quoted 5 lines
instead of the
tc->child_flagdirectly, then start to reclaim the child when thereal_pidtest finishing.Does this below diff work for you?
It looks well. But the
real_pidonly valid when the first sub test and the real pid is equals to 0 when using -i parameters because we have killed this children.
Yes, you're right.
How about moving up the real_pid creator to the main process? does it work for you?
static void verify_kill(unsigned int n)
{
if (!real_pid) {
real_pid = SAFE_FORK();
if (!real_pid)
pause();
}
TEST(kill(*tc->pid, tc->test_sig));
...
if (real_pid) {
cleanup();
real_pid = 0;
}}
Quoted 5 lines
For pid = 0, it means then sig is sent to every process in the process group of the calling process. So it looks like we test different thing when using -i parameters. What do you think about this?
I even think it is a good idea for code simplification:). In this case, the first
the subtest is just to verify invalid signal for kill(), it doesn't matter to go withkill(0, invalid_signal), that only tries to kill the current main process. isn't it?
If we go this way, not only the tc->child_flag is no needed, but also not necessary
to fork a new child to be killed.
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200821/57245fb5/attachment-0001.htm>
PATCH 2/4 syscalls/kill03, 04: Cleanup && Convert to new library
Hi Li
Quoted 40 lines
On Fri, Aug 21, 2020 at 10:22 AM Yang Xu <[email protected] <mailto:[email protected]>> wrote:
...
>? ? ?Also, we can use the current process id but it may has unexpected >? ? ?result
>? ? ?when kill succeed. So fork a child to test maybe a better
solution.
>
>
> Hmm, sorry for the uncleared description, actually I meant, to
usereal_pid
> instead of the?tc->child_flag directly, then start to reclaim the
child
> when the
>real_pidtest finishing.
>
> Does this below diff work for you?
It looks well. But thereal_pidonly valid when the first sub test and the real pid is equals to 0 when using -i parameters because we have killed this children.Yes, you're right.
How about moving up thereal_pidcreator to the main process? does it work for you?static void
verify_kill(unsigned int n)
{
? ? ? ? if (!real_pid) {
? ? ? ? ? ? ? ?real_pid=SAFE_FORK();
? ? ? ? ? ? ? ? if (!real_pid)
? ? ? ? ? ? ? ? ? ? ? ?pause();
? ? ? ? }? ? ? ?
TEST(kill(*tc->pid, tc->test_sig));
...
Quoted 7 lines
? ? ? ? if (
real_pid) {
? ? ? ? ? ? ? ?cleanup();
? ? ? ? ? ? ? ?real_pid= 0;
? ? ? ? }}
Yes, it looks ok,
Quoted 6 lines
For pid = 0, it means? then sig is sent to every process in the process group of the calling process.? So it looks like we test different thing when using -i parameters.? What do you think about this?
Quoted 6 lines
I even think it is a good idea for code simplification:). In this case, the first
the subtest is just to verify invalid signal forkill(), it doesn't matter to go withkill(0, invalid_signal), that only tries to kill the current main process. isn't it?
Yes. I think using current process id instead of 0 is more easier because the invalid signal can't kill process forever.
static void setup(void)
{
real_pid = getpid();
fake_pid = tst_get_unused_pid();
int_min_pid = INT_MIN;
}Quoted 8 lines
If we go this way, not only the?tc->child_flag is no needed, but also not necessary
to fork a new child to be killed.Signature · 2 lines
Regards, Li Wang
PATCH 2/4 syscalls/kill03, 04: Cleanup && Convert to new library
Quoted 8 lines · Yang Xu
...
Yes. I think using current process id instead of 0 is more easier because the invalid signal can't kill process forever.static void setup(void)
{ real_pid = getpid();
Agreed!
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200821/1cb95f23/attachment.htm>
PATCH 3/4 syscalls/kill05:Cleanup && Convert to new library
In reply to Feiyu Zhu1) Take use of some safe macros
--- testcases/kernel/syscalls/kill/Makefile | 4 +- testcases/kernel/syscalls/kill/kill05.c | 243 ++++++++------------------------ 2 files changed, 58 insertions(+), 189 deletions(-)
testcases/kernel/syscalls/kill/Makefile +2 -2
@@ -3,11 +3,11 @@ top_srcdir ?= ../../../.. -LTPLIBS = ltpipc +LTPLIBS = ltpipc ltpnewipc include $(top_srcdir)/include/mk/testcases.mk kill07: LTPLDLIBS = -lltpipc -kill05: LTPLDLIBS = -lltpipc +kill05: LTPLDLIBS = -lltpnewipc include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/kill/kill05.c +56 -187
286 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 3/4 syscalls/kill05:Cleanup && Convert to new library
Quoted 3 lines · Feiyu Zhu
...
* Looping with the -i option does not work correctly.
This line should be removed since it works well with -i.
Quoted 5 lines
+static void
wait_for_flag(int value){ while (1) { if (*flag == value)
Sleep 1sec is too long here, we can use usleep(100) for a replacement.
+static struct tst_test test = {
testcases/kernel/syscalls/kill/kill05.c void wait_for_flag(int value) · line 108
Quoted 5 lines
testcases/kernel/syscalls/kill/kill05.c +4
-0+ .setup = setup, + .cleanup = cleanup, + .test_all = verify_kill, + .needs_tmpdir = 1,
'.needs_tmdir' is redundant.
testcases/kernel/syscalls/kill/kill05.c void wait_for_flag(int value) · line 111
Quoted 4 lines
testcases/kernel/syscalls/kill/kill05.c +3
-0+ .needs_root = 1, + .forks_child = 1, +};
The remaining part looks good.
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200821/d8fb8c0e/attachment.htm>
PATCH 4/4 syscalls/kill06:Cleanup && Convert to new library
In reply to Feiyu Zhu1) Take use of some safe macros
--- testcases/kernel/syscalls/kill/kill06.c | 208 ++++++-------------------------- 1 file changed, 37 insertions(+), 171 deletions(-)
testcases/kernel/syscalls/kill/kill06.c +37 -171
@@ -1,187 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* +* Copyright (c) International Business Machines Corp., 2001 * -* 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 -* kill06.c -* -* DESCRIPTION -* Test case to check the basic functionality of kill() when killing an -* entire process group with a negative pid. -* -* ALGORITHM -* call setup -* loop if the -i option was given -* fork 5 children -* execute the kill system call -* check the return value -* if return value is -1 -* issue a FAIL message, break remaining tests and cleanup -* if we are doing functional testing -* if the processes were terminated with the expected signal. -* issue a PASS message -* otherwise -* issue a FAIL message -* call cleanup -* -* USAGE -* kill06 [-c n] [-f] [-i n] [-I x] [-P x] [-t] -* where, -c n : Run n copies concurrently. -* -f : Turn off functionality Testing. -* -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. +* Test case to check the basic functionality of kill() when killing an +* entire process group with a negative pid. * * HISTORY * 07/2001 Ported by Wayne Boyer -* -* RESTRICTIONS -* This test should be run as a non-root user. */ -#include "test.h" - +#include <sys/types.h> #include <signal.h> -#include <errno.h> #include <sys/wait.h> +#include <unistd.h> +#include <stdlib.h> +#include "tst_test.h" -void cleanup (void ); -void setup (void ); -void do_child (void ); - -char *TCID ="kill06" ; -int TST_TOTAL =1 ; - -#define TEST_SIG SIGKILL - -int main (int ac,char **av) +static void verify_kill (void ) { -int lc; -pid_t pid1, pid2; -int exno, status, nsig, i; - -tst_parse_opts (ac, av,NULL ,NULL ); -#ifdef UCLINUX -maybe_run_child (&do_child,"" ); -#endif - -setup ();/* global setup */ - -/* The following loop checks looping state if -i option given */ -for (lc =0 ;TEST_LOOPING (lc); lc++) { - -/* reset tst_count in case we are looping */ - tst_count =0 ; - status =1 ; - exno =1 ; - -/* Fork a process and set the process group so that */ -/* it is different from this one. Fork 5 more children. */ - - pid1 =FORK_OR_VFORK (); -if (pid1 <0 ) { -tst_brkm (TBROK , cleanup,"Fork of first child failed" ); - }else if (pid1 ==0 ) { -setpgrp (); -for (i =0 ; i <5 ; i++) { - pid2 =FORK_OR_VFORK (); -if (pid2 <0 ) { -tst_brkm (TBROK , cleanup,"Fork failed" ); - }else if (pid2 ==0 ) { -#ifdef UCLINUX -if (self_exec (av[0 ],"" ) <0 ) { -tst_brkm (TBROK , cleanup, -"self_exec of " -"child failed" ); - } -#else -do_child (); -#endif - } - } -/* Kill all processes in this process group */ -TEST (kill (-getpgrp (),TEST_SIG )); -sleep (300 ); - -tst_resm (TINFO ,"%d never received a" -" signal" ,getpid ()); -exit (exno); - }else { -waitpid (pid1, &status,0 ); -if (TEST_RETURN !=0 ) { -tst_brkm (TFAIL , cleanup,"%s failed - errno = " -"%d : %s" ,TCID ,TEST_ERRNO , -strerror (TEST_ERRNO )); - } +pid_t pid, child_pid[5 ]; +int nsig, i, status; + + pid =SAFE_FORK (); +if (pid ==0 ) { +setpgrp (); +for (i =0 ; i <5 ; i++) { + child_pid[i] =SAFE_FORK (); +if (!child_pid[i]) +pause (); } -/* -* Check to see if the process was terminated with the -* expected signal. -*/ - nsig =WTERMSIG (status); -if (!nsig) { -tst_resm (TFAIL ,"Did not receive any signal" ); - }else if (nsig ==TEST_SIG ) { -tst_resm (TPASS ,"received expected signal %d" , - nsig); - }else { -tst_resm (TFAIL , -"expected signal %d received %d" , -TEST_SIG , nsig); - } +TEST (kill (-getpgrp (),SIGKILL )); +if (TST_RET !=0 ) +tst_res (TFAIL |TTERRNO ,"kill failed" ); +tst_res (TINFO ,"%d never received a signal" ,getpid ()); +exit (0 ); } - -cleanup (); -tst_exit (); -} - -/* -* do_child() -*/ -void do_child (void ) -{ -int exno =1 ; - -sleep (299 ); - -tst_resm (TINFO ,"%d never received a" " signal" ,getpid ()); -exit (exno); -} - -/* -* setup() - performs all ONE TIME setup for this test -*/ -void setup (void ) -{ -/* Setup default signal handling */ -tst_sig (FORK ,DEF_HANDLER , cleanup); - -TEST_PAUSE ; + +SAFE_WAITPID (pid, &status,0 ); + nsig =WTERMSIG (status); +if (nsig !=SIGKILL ) { +tst_res (TFAIL ,"wait: unexpected signal %d returned, " +"expected SIGKILL(9)" , nsig); +return ; + } +tst_res (TPASS ,"receive expected signal SIGKILL(9)" ); } -/* -* cleanup() - performs all the ONE TIME cleanup for this test@completion -* or premature exit. -*/ -void cleanup (void ) -{ - -} +static struct tst_test test = { + .forks_child =1 , + .test_all = verify_kill, +};
Signature · 1 line
1.8.3.1
PATCH 4/4 syscalls/kill06:Cleanup && Convert to new library
Feiyu Zhu <[email protected]> wrote:
...
Quoted 2 lines
+
pid_tpid, child_pid[5];
I'd suggest dropping these two variables since it makes no sense to save the children PIDs in the following testing.
testcases/kernel/syscalls/kill/kill06.c line 28
Quoted 8 lines
testcases/kernel/syscalls/kill/kill06.c +7
-0+int nsig, i, status; + + pid =SAFE_FORK (); +if (pid ==0 ) { +setpgrp (); +for (i =0 ; i <5 ; i++) { + child_pid[i] =SAFE_FORK ();
if we drop the arrays, that loop would be like:
for (i = 0; i < 5; i++) {
if (!SAFE_FORK())
pause();
}Quoted 14 lines
testcases/kernel/syscalls/kill/kill06.c +2
-9+if (!child_pid[i]) +pause (); } -/* -* Check to see if the process was terminated with the -* expected signal. -*/ - nsig =WTERMSIG (status); -if (!nsig) { -tst_resm (TFAIL ,"Did not receive any signal" ); - }else if (nsig ==TEST_SIG ) { - tst_resm(TPASS, "received expected signal %d",
testcases/kernel/syscalls/kill/kill06.c line 36
Quoted 10 lines
testcases/kernel/syscalls/kill/kill06.c +4
-6- nsig); - }else { -tst_resm (TFAIL , -"expected signal %d received %d" , -TEST_SIG , nsig); - } +TEST (kill (-getpgrp (),SIGKILL )); +if (TST_RET !=0 ) +tst_res (TFAIL |TTERRNO ,"kill failed" ); +tst_res (TINFO ,"%d never received a signal" ,getpid ());
This TINFO is a misleading message to people. If the process receives a signal
but not been killed, how do you say that never received a signal? So I suggest deleting this line.
Quoted 22 lines
testcases/kernel/syscalls/kill/kill06.c +1
-19+exit (0 ); } - -cleanup (); -tst_exit (); -} - -/* -* do_child() -*/ -void do_child (void ) -{ -int exno =1 ; - -sleep (299 ); - -tst_resm (TINFO ,"%d never received a" " signal" ,getpid ()); -exit (exno); -} - -/*
testcases/kernel/syscalls/kill/kill06.c line 40
Quoted 10 lines
testcases/kernel/syscalls/kill/kill06.c +2
-8-* setup() - performs all ONE TIME setup for this test -*/ -void setup (void ) -{ -/* Setup default signal handling */ -tst_sig (FORK ,DEF_HANDLER , cleanup); - -TEST_PAUSE ; + +SAFE_WAITPID (pid, &status,0 );
What about waiting for any child process here?
SAFE_WAITPID(-1, &status, 0);
Quoted 9 lines
testcases/kernel/syscalls/kill/kill06.c +7
-0+ nsig =WTERMSIG (status); +if (nsig !=SIGKILL ) { +tst_res (TFAIL ,"wait: unexpected signal %d returned, " +"expected SIGKILL(9)" , nsig); +return ; + } +tst_res (TPASS ,"receive expected signal SIGKILL(9)" ); }
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200821/43a364ab/attachment-0001.htm>
PATCH 1/4 syscalls/kill01: Remove it
In reply to Feiyu ZhuHi!
Pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]