rt_sigtimedwait01 failed in armv7l
Hi, These is a fail about rt_sigtimedwait01(armv7l GNU/Linux and linux 3.10):
root@arma9el:/tmp# ./rt_sigtimedwait01 rt_sigtimedwait01 0 TINFO : 0x9fd0, 10 rt_sigtimedwait01 1 TPASS : Test passed rt_sigtimedwait01 0 TINFO : 0x9fd0, 10 rt_sigtimedwait01 2 TPASS : Test passed ... rt_sigtimedwait01 0 TINFO : 0x9fd0, 12 rt_sigtimedwait01 11 TPASS : Test passed rt_sigtimedwait01 0 TINFO : 0x9fd0, 15 rt_sigtimedwait01 12 TPASS : Test passed rt_sigtimedwait01 12 TPASS : sigwaitinfo restored the original mask rt_sigtimedwait01 0 TINFO : 0x9fd0, -1
rt_sigtimedwait01 13 TFAIL : /home/cuibixuan/ltp/testcases/kernel/syscalls/rt_sigtimedwait/../sigwaitinfo/sigwaitinfo01.c:56:test_masked_matching_rt (/home/cuibixuan/ltp/testcases/kernel/syscalls/rt_sigtimedwait/../sigwaitinfo/sigwaitinfo01.c: 274): Unexpected return value; expected 35, got 36rt_sigtimedwait01 13 TFAIL : /home/cuibixuan/ltp/testcases/kernel/syscalls/rt_sigtimedwait/../sigwaitinfo/sigwaitinfo01.c:56:test_masked_matching_rt (/home/cuibixuan/ltp/testcases/kernel/syscalls/rt_sigtimedwait/../sigwaitinfo/sigwaitinfo01.c: 282): Unexpected return value; expected 36, got 35rt_sigtimedwait01 13 TPASS : sigwaitinfo restored the original mask
I add 'sleep(1)' into test_masked_matching_rt() of ltp/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c:268
void test_masked_matching_rt(swi_func sigwaitinfo, int signo)
...
/* Run a child that will wake us up */
child[0] = create_sig_proc(0, signo, 1);
+ sleep(1);
child[1] = create_sig_proc(0, signo + 1, 1);Then the case pass:
rt_sigtimedwait01 13 TPASS : Test passed rt_sigtimedwait01 13 TPASS : Test passed rt_sigtimedwait01 13 TPASS : sigwaitinfo restored the original mask
Or run it by 'chrt 10 ./rt_sigtimedwait01' then pass.
Why? Can someone give me a hand.
Thanks,
Cui Bixuan
Hi!
Quoted 30 lines
Hi, These is a fail about
rt_sigtimedwait01(armv7l GNU/Linux and linux 3.10):root@arma9el:/tmp# ./rt_sigtimedwait01 rt_sigtimedwait01 0 TINFO : 0x9fd0, 10 rt_sigtimedwait01 1 TPASS : Test passed rt_sigtimedwait01 0 TINFO : 0x9fd0, 10 rt_sigtimedwait01 2 TPASS : Test passed ... rt_sigtimedwait01 0 TINFO : 0x9fd0, 12 rt_sigtimedwait01 11 TPASS : Test passed rt_sigtimedwait01 0 TINFO : 0x9fd0, 15 rt_sigtimedwait01 12 TPASS : Test passed rt_sigtimedwait01 12 TPASS : sigwaitinfo restored the original mask rt_sigtimedwait01 0 TINFO : 0x9fd0, -1
rt_sigtimedwait0113 TFAIL :/home/cuibixuan/ltp/testcases/kernel/syscalls/rt_sigtimedwait/../sigwaitinfo/sigwaitinfo01.c:56:test_masked_matching_rt(/home/cuibixuan/ltp/testcases/kernel/syscalls/rt_sigtimedwait/../sigwaitinfo/sigwaitinfo01.c: 274): Unexpected return value; expected 35, got 36rt_sigtimedwait0113 TFAIL :/home/cuibixuan/ltp/testcases/kernel/syscalls/rt_sigtimedwait/../sigwaitinfo/sigwaitinfo01.c:56:test_masked_matching_rt(/home/cuibixuan/ltp/testcases/kernel/syscalls/rt_sigtimedwait/../sigwaitinfo/sigwaitinfo01.c: 282): Unexpected return value; expected 36, got 35rt_sigtimedwait0113 TPASS : sigwaitinfo restored the original maskI add 'sleep(1)' into
test_masked_matching_rt()ofltp/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c:268void
test_masked_matching_rt(swi_func sigwaitinfo, int signo)
...
/* Run a child that will wake us up */child[0] = create_sig_proc(0, signo, 1); + sleep(1); child[1] = create_sig_proc(0, signo + 1, 1);
Quoted 8 lines
Then the case pass:
rt_sigtimedwait01 13 TPASS : Test passed rt_sigtimedwait01 13 TPASS : Test passed rt_sigtimedwait01 13 TPASS : sigwaitinfo restored the original maskOr run it by 'chrt 10 ./rt_sigtimedwait01' then pass.
Why? Can someone give me a hand.
I guess that the problem here is that the order in which the test children and parent are executed is undefined.
The signals should be delivered starting from lowest numbered but that applies only when both signals are pending at the point we call sigwaitinfo(). If, by a chance, the first child haven't had chance to finish until we get to the sigwaitinfo() call we will get the signo+1 signal first, since that is the only one pending at that point.
So the fix here would be making sure that both children are finished before we call the sigwaitinfo(). Quite possibly doing waitpid() for both of them will suffice.
Signature · 2 lines
Cyril Hrubis [email protected]
Quoted 9 lines · Cyril Hrubis
I guess that the problem here is that the order in which the test children and parent are executed is undefined.
The signals should be delivered starting from lowest numbered but that applies only when both signals are pending at the point we call
sigwaitinfo(). If, by a chance, the first child haven't had chance to finish until we get to thesigwaitinfo()call we will get the signo+1 signal first, since that is the only one pending at that point.
Quoted 3 lines
So the fix here would be making sure that both children are finished before we call the
sigwaitinfo(). Quite possibly doingwaitpid()for both of them will suffice.
Thank you. I will try to fix it.
Thanks,
Cui Bixuan
PATCH 1/1 rt_sigtimedwait01: fix probability of failure
If child[0] of test_masked_matching_rt() haven't had chance to finish until we get to the sigwaitinfo() call, the case will fail.
So we should add waitpid() to make sure that both children are finished.
--- testcases/kernel/syscalls/utils/common_j_h.c | 3 +++ 1 file changed, 3 insertions(+)
testcases/kernel/syscalls/utils/common_j_h.c +3 -0
@@ -119,6 +119,7 @@ static void sigterm_handler(int sig)pid_t create_sig_proc (unsigned long usec,int sig,unsigned count) {pid_t pid, cpid; +int status; pid =getpid (); WITH_SIGNALS_BLOCKED(if ((cpid = fork()) == 0) {
@@ -138,6 +139,8 @@ pid_t create_sig_proc(unsigned long usec, int sig, unsigned count)EPRINTF ("fork failed.\n" );return cpid;default : +/* wait cpid finish */ +waitpid (cpid, &status,0 );return cpid; } }
Signature · 1 line
1.8.3.4
PATCH 1/1 rt_sigtimedwait01: fix probability of failure
Hi!
testcases/kernel/syscalls/utils/common_j_h.c pid_t create_sig_proc(unsigned long usec, int sig, unsigned count) · line 142
Quoted 7 lines
testcases/kernel/syscalls/utils/common_j_h.c +1
-0pid =getpid (); WITH_SIGNALS_BLOCKED(if ((cpid = fork()) == 0) {@@ -138,6 +139,8 @@ pid_t create_sig_proc(unsigned long usec, int sig, unsigned count)EPRINTF ("fork failed.\n" );return cpid;default : +/* wait cpid finish */
The comment here is redundant and useless.
Quoted 8 lines
testcases/kernel/syscalls/utils/common_j_h.c +1
-0+waitpid (cpid, &status,0 );return cpid; } }Signature · 1 line
1.8.3.4
Signature · 2 lines
Cyril Hrubis [email protected]