syscalls/pause: Refactor tests
v3 cover syscalls/pause: Refactor tests
---
Changes in v3 (suggestions by Cyril):
- Removed pause02.
- Extended pause01 to cover other signals.
- Fixed the checkpoints usage.
- Used tst_strstatus in pause03.
- Renamed pause03 to pause02.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Added a cleanup commit for pause01
- Made use of LTP_ATTRIBUTE_UNUSED, TST_EXP_FAIL, TST_EXP_EXPR, SAFE_KILL
as suggested by Andrea.
- Fixed test descriptions
- Added 2025 copyright
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Ricardo B. Marlière (5):
syscalls/pause01: Clean up syscalls/pause01: Extend test to other signals syscalls/pause02: Delete duplicated test syscalls/pause03: Refactor into new API syscalls/pause03: Rename to pause02
runtest/syscalls | 1 - testcases/kernel/syscalls/pause/pause01.c | 64 ++++++------ testcases/kernel/syscalls/pause/pause02.c | 159 ++++++------------------------ testcases/kernel/syscalls/pause/pause03.c | 104 ------------------- 4 files changed, 63 insertions(+), 265 deletions(-)
---
base-commit: af4da3e436f891df500c552a1396925acf204457
change-id: 20250217-conversions-pause-4b9d4be3f876
Best regards,
Signature · 5 lines
Ricardo B. Marlière <[email protected]> -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 1/5 syscalls/pause01: Clean up
From: Ricardo B. Marlière <[email protected]>
Tidy up and add a description.
--- testcases/kernel/syscalls/pause/pause01.c | 41 +++++++++++-------------------- 1 file changed, 15 insertions(+), 26 deletions(-)
testcases/kernel/syscalls/pause/pause01.c +15 -26
@@ -1,10 +1,14 @@// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) 2016 Linux Test Project +* Copyright (c) 2025 Ricardo B. Marlière <[email protected]> */ -#include <errno.h> -#include <signal.h> -#include <stdlib.h> + +/*\ +* Verify that, pause() returns -1 and sets errno to EINTR after receipt of a +* signal which is caught by the calling process. +*/ +#include "tst_test.h" static void sig_handler(int sig LTP_ATTRIBUTE_UNUSED)
@@ -14,43 +18,28 @@ static void sig_handler(int sig LTP_ATTRIBUTE_UNUSED)static void do_child (void ) {SAFE_SIGNAL (SIGINT , sig_handler); -TST_CHECKPOINT_WAKE (0 ); - -TEST (pause ()); -if (TST_RET !=-1 ) -tst_res (TFAIL ,"pause() succeeded unexpectedly" ); -else if (TST_ERR ==EINTR ) -tst_res (TPASS ,"pause() interrupted with EINTR" ); -else -tst_res (TFAIL |TTERRNO ,"pause() unexpected errno" ); - -TST_CHECKPOINT_WAKE (0 ); -exit (0 ); +TST_EXP_FAIL (pause (),EINTR ); +tst_res (TPASS ,"Process resumed from pause()" ); } -static void do_test (void ) +static void run (void ) {int pid, status; pid =SAFE_FORK (); -if (pid ==0 ) +if (!pid) {do_child (); +exit (0 ); + }TST_CHECKPOINT_WAIT (0 );TST_PROCESS_STATE_WAIT (pid,'S' ,0 ); -kill (pid,SIGINT ); - -/* -* TST_CHECKPOINT_WAIT has built-in timeout, if pause() doesn't return, -* this checkpoint call will reliably end the test. -*/ -TST_CHECKPOINT_WAIT (0 ); -SAFE_WAIT (&status); +SAFE_KILL (pid,SIGINT ); }static struct tst_test test = { .forks_child =1 , .needs_checkpoints =1 , - .test_all = do_test, + .test_all = run, };
Signature · 5 lines
2.48.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 2/5 syscalls/pause01: Extend test to other signals
In reply to Ricardo B. Marlière via ltpFrom: Ricardo B. Marlière <[email protected]>
Currently, the test only covers SIGINT. Add more to the mix by parametrizing the main test function.
--- testcases/kernel/syscalls/pause/pause01.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-)
testcases/kernel/syscalls/pause/pause01.c +23 -8
@@ -11,35 +11,50 @@#include "tst_test.h" -static void sig_handler(int sig LTP_ATTRIBUTE_UNUSED) +static void sig_handler(int signal LTP_ATTRIBUTE_UNUSED) { } -static void do_child (void ) +static void do_child (int signal) { -SAFE_SIGNAL (SIGINT , sig_handler); +SAFE_SIGNAL (signal, sig_handler);TST_CHECKPOINT_WAKE (0 );TST_EXP_FAIL (pause (),EINTR );tst_res (TPASS ,"Process resumed from pause()" ); } -static void run (void ) +static void run (int signal) { -int pid, status; +int pid; pid =SAFE_FORK ();if (!pid) { -do_child (); +do_child (signal);exit (0 ); }TST_CHECKPOINT_WAIT (0 );TST_PROCESS_STATE_WAIT (pid,'S' ,0 ); -SAFE_KILL (pid,SIGINT ); +SAFE_KILL (pid, signal); +} + +static void run_all (void ) +{ +run (SIGHUP ); +run (SIGINT ); +run (SIGQUIT ); +run (SIGILL ); +run (SIGTRAP ); +run (SIGABRT ); +run (SIGFPE ); +run (SIGSEGV ); +run (SIGPIPE ); +run (SIGALRM ); +run (SIGTERM ); }static struct tst_test test = { .forks_child =1 , .needs_checkpoints =1 , - .test_all = run, + .test_all = run_all, };
Signature · 5 lines
2.48.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 3/5 syscalls/pause02: Delete duplicated test
In reply to Ricardo B. Marlière via ltpFrom: Ricardo B. Marlière <[email protected]>
This test is very similar to pause01, therefore delete it.
--- runtest/syscalls | 1 - testcases/kernel/syscalls/pause/pause02.c | 147 ------------------------------ 2 files changed, 148 deletions(-)
runtest/syscalls +0 -1
@@ -1010,7 +1010,6 @@ pathconf01 pathconf01 pathconf02 pathconf02 pause01 pause01 -pause02 pause02 pause03 pause03 personality01 personality01
testcases/kernel/syscalls/pause/pause02.c deleted +0 -147
147 lines not on this page · raw message
Signature · 5 lines
2.48.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 3/5] syscalls/pause02: Delete duplicated test
Quoted 15 lines · Ricardo B. Marlière
From: Ricardo B. Marlière <[email protected]>
This test is very similar to pause01, therefore delete it.
Signed-off-by Ricardo B. Marlière <[email protected]>--- runtest/syscalls | 1 - testcases/kernel/syscalls/pause/pause02.c | 147 ------------------------------ 2 files changed, 148 deletions(-)runtest/syscalls +0
-0
runtest/syscalls pathconf01 pathconf01 · line 1013
Quoted 5 lines
runtest/syscalls +0
-1@@ -1010,7 +1010,6 @@ pathconf01 pathconf01 pathconf02 pathconf02 pause01 pause01 -pause02 pause02 pause03 pause03
Should also have removed it in testcases/kernel/syscalls/pause/.gitignore
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 3/5] syscalls/pause02: Delete duplicated test
Hi!
I've fixed the .gitignore changes and pushed the patchset, thanks.
Will you also look into increasing the coverage for pause01.c as I described (make it loop over different signals)?
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 3/5] syscalls/pause02: Delete duplicated test
Hi Cyril,
Quoted 2 lines · Cyril Hrubis
Hi!
I've fixed the .gitignore changes and pushed the patchset, thanks.
Thanks for reviewing and merging!
Quoted 3 lines
Will you also look into increasing the coverage for
pause01.cas I described (make it loop over different signals)?
I gave it a shot here https://lore.kernel.org/all/[email protected]/
Is that similar to what you had in mind?
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 3/5] syscalls/pause02: Delete duplicated test
Hi!
Quoted 6 lines
Quoted 2 lines
Will you also look into increasing the coverage for
pause01.cas I described (make it loop over different signals)?I gave it a shot here https://lore.kernel.org/all/[email protected]/
Is that similar to what you had in mind?
Looks like I missed that one, sorry, merged now, thanks.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 3/5] syscalls/pause02: Delete duplicated test
Quoted 9 lines · Cyril Hrubis
Hi!
Quoted 6 lines
Quoted 2 lines
Will you also look into increasing the coverage for
pause01.cas I described (make it loop over different signals)?I gave it a shot here https://lore.kernel.org/all/[email protected]/
Is that similar to what you had in mind?
Looks like I missed that one, sorry, merged now, thanks.
BTW, there's one final modification needed, below.
Thank you,
- Ricardo.
testcases/kernel/syscalls/pause/.gitignore +1 -1
@@ -1,2 +1,2 @@ /pause01 -/pause03 +/pause02
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 3/5] syscalls/pause02: Delete duplicated test
Hi!
Quoted 1 line
BTW, there's one final modification needed, below.
I did the change locally, but failed to --amend properly, that's what I get for applying patches at the end of the day... I will push a fix.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 4/5 syscalls/pause03: Refactor into new API
In reply to Ricardo B. Marlière via ltpFrom: Ricardo B. Marlière <[email protected]>
--- testcases/kernel/syscalls/pause/pause03.c | 120 ++++++++---------------------- 1 file changed, 31 insertions(+), 89 deletions(-)
testcases/kernel/syscalls/pause/pause03.c +31 -89
@@ -1,104 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) International Business Machines Corp., 2001 -* 07/2001 Ported by Wayne Boyer -* -* 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 +* 07/2001 Ported by Wayne Boyer +* Copyright (c) 2025 Ricardo B. Marlière <[email protected]> */ -/* -* Test Description: -* pause() does not return due to receipt of SIGKILL signal and specified -* process should be terminated. -*/ -#include <unistd.h> -#include <errno.h> -#include <fcntl.h> -#include <sys/wait.h> - -#include "test.h" -#include "safe_macros.h" - -static pid_t cpid; - -char *TCID ="pause03" ; -int TST_TOTAL =1 ; - -static void do_child (void ); -static void setup (void ); -static void cleanup (void ); - -int main (int ac,char **av) -{ -int lc; -int status; - -tst_parse_opts (ac, av,NULL ,NULL ); - -setup (); - -for (lc =0 ;TEST_LOOPING (lc); lc++) { - tst_count =0 ; - -if ((cpid =tst_fork ()) ==-1 ) -tst_brkm (TBROK |TERRNO ,NULL ,"fork() failed" ); - -if (cpid ==0 ) -do_child (); - -TST_PROCESS_STATE_WAIT (cleanup, cpid,'S' ); -kill (cpid,SIGKILL ); - -SAFE_WAIT (NULL , &status); - -if (WIFSIGNALED (status) &&WTERMSIG (status) ==SIGKILL ) { -tst_resm (TPASS ,"pause() did not return after SIGKILL" ); -continue ; - } - -if (WIFSIGNALED (status)) { -tst_resm (TFAIL ,"child killed by %s unexpectedly" , -tst_strsig (WTERMSIG (status))); -continue ; - } - -tst_resm (TFAIL ,"child exited with %i" ,WEXITSTATUS (status)); - } - -cleanup (); -tst_exit (); +/*\ +* Verifies that pause() does not return after proccess receives a SIGKILL signal. +*/ -} +#include "tst_test.h" void do_child (void ) { -TEST (pause ()); - -tst_resm (TFAIL ,"Unexpected return from pause()" ); - -exit (0 ); +TST_CHECKPOINT_WAKE (0 ); +TST_EXP_PASS (pause ()); } -void setup (void ) +void run (void ) { -tst_sig (FORK ,DEF_HANDLER , cleanup); +int status; +pid_t pid; -TEST_PAUSE ; -} + pid =SAFE_FORK (); +if (!pid) { +do_child (); +exit (0 ); + } +TST_CHECKPOINT_WAIT (0 ); +TST_PROCESS_STATE_WAIT (pid,'S' ,10000 ); +SAFE_KILL (pid,SIGKILL ); +SAFE_WAITPID (pid, &status,0 ); -void cleanup (void ) -{ -kill (cpid,SIGKILL ); +if (WIFSIGNALED (status) &&WTERMSIG (status) ==SIGKILL ) +tst_res (TPASS ,"pause() did not return after SIGKILL" ); +else +tst_res (TFAIL ,"Child %s" ,tst_strstatus (status)); } + +static struct tst_test test = { + .test_all = run, + .needs_checkpoints =1 , + .forks_child =1 , +};
Signature · 5 lines
2.48.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 4/5] syscalls/pause03: Refactor into new API
Hi!
Applied with minor change, thanks:
testcases/kernel/syscalls/pause/pause03.c +3 -2
@@ -14,7 +14,8 @@void do_child (void ) {TST_CHECKPOINT_WAKE (0 ); -TST_EXP_PASS (pause ()); +pause (); +tst_res (TFAIL ,"pause() returned after SIGKILL" ); }void run (void )
@@ -34,7 +35,7 @@ void run(void)SAFE_WAITPID (pid, &status,0 );if (WIFSIGNALED (status) &&WTERMSIG (status) ==SIGKILL ) -tst_res (TPASS ,"pause() did not return after SIGKILL" ); +tst_res (TPASS ,"pause() killed by SIGKILL" );else tst_res (TFAIL ,"Child %s" ,tst_strstatus (status)); }
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 5/5 syscalls/pause03: Rename to pause02
In reply to Ricardo B. Marlière via ltpFrom: Ricardo B. Marlière <[email protected]>
Now that pause02 has been removed, rename pause03.
---
runtest/syscalls | 2 +-
testcases/kernel/syscalls/pause/{pause03.c => pause02.c} | 0
2 files changed, 1 insertion(+), 1 deletion(-)runtest/syscalls +1 -1
@@ -1010,7 +1010,7 @@ pathconf01 pathconf01 pathconf02 pathconf02 pause01 pause01 -pause03 pause03 +pause02 pause02 personality01 personality01 personality02 personality02
testcases/kernel/syscalls/pause/pause02.c renamed from testcases/kernel/syscalls/pause/pause03.c +0 -0
Signature · 5 lines
2.48.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp