waitid10: raise SIGFPE directly
PATCH v2 1/1 waitid10: raise SIGFPE directly
The SIGFPE for division by zero is actually not send for quite a few architectures (ARM for instance) and even on x86 and x86_64 we need to work around compiler to make it generate code that actually triggers the condition.
So this patch fixes the test in the simplest way possible. the child just directly raises SIGFPE instead.
--- testcases/kernel/syscalls/waitid/waitid10.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
testcases/kernel/syscalls/waitid/waitid10.c +2 -6
@@ -24,12 +24,8 @@ static void run(void)pid_t pidchild; pidchild =SAFE_FORK (); -if (!pidchild) { -volatile int a, zero =0 ; - - a =1 / zero; -exit (a); - } +if (!pidchild) +raise (SIGFPE );TST_EXP_PASS (waitid (P_ALL ,0 , infop,WEXITED ));TST_EXP_EQ_LI (infop->si_pid, pidchild);
Signature · 5 lines
2.35.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 10 lines · Cyril Hrubis
The SIGFPE for division by zero is actually not send for quite a few architectures (ARM for instance) and even on x86 and
x86_64we need to work around compiler to make it generate code that actually triggers the condition.So this patch fixes the test in the simplest way possible. the child just directly raises SIGFPE instead.
Signed-off-by Cyril Hrubis <[email protected]>
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 21 lines · Cyril Hrubis
The SIGFPE for division by zero is actually not send for quite a few architectures (ARM for instance) and even on x86 and
x86_64we need to work around compiler to make it generate code that actually triggers the condition.So this patch fixes the test in the simplest way possible. the child just directly raises SIGFPE instead.
Signed-off-by Cyril Hrubis <[email protected]>--- testcases/kernel/syscalls/waitid/waitid10.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)testcases/kernel/syscalls/waitid/waitid10.c +0
-0@@ -24,12 +24,8 @@ static void run(void)pid_t pidchild;
testcases/kernel/syscalls/waitid/waitid10.c static void run(void) · line 29
Quoted 10 lines
testcases/kernel/syscalls/waitid/waitid10.c +2
-6pidchild =SAFE_FORK (); -if (!pidchild) { -volatile int a, zero =0 ; - - a =1 / zero; -exit (a); - } +if (!pidchild) +raise (SIGFPE );
Better to have code comments to explain the reason here, just for better readability.
And vote for merging before the new release as well.
Quoted 11 lines
testcases/kernel/syscalls/waitid/waitid10.c +0
-1TST_EXP_PASS (waitid (P_ALL ,0 , infop,WEXITED ));TST_EXP_EQ_LI (infop->si_pid, pidchild); --2.35.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Regards, Li Wang
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 2 lines
Better to have code comments to explain the reason here, just for better readability.
What exactly should we comment there, something as:
Triggering SIGFPE by invalid instruction is not always possible, some architectures does not trap division-by-zero at all and even when it's possible we would have to fight the compiler optimizations that have tendency to remove undefined operations.
Quoted 1 line
And vote for merging before the new release as well.
That's what I'm aiming for.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 5 lines
Triggering SIGFPE by invalid instruction is not always possible, some architectures does not trap division-by-zero at all and even when it's possible we would have to fight the compiler optimizations that have tendency to remove undefined operations.
Looks good.
Signature · 2 lines
Regards, Li Wang
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Added comment and pushed, thanks for the reviews.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp