Re: [LTP] [PATCH] mq_timedsend/5-1: make parent has chance to sleep

Kang Kai
2012-01-10T02:14:49Z

On 2012年01月09日 13:19, Caspar Zhang wrote:

Hi Caspar,

> On 2011年12月31日 11:32, Kang Kai wrote:
>> Child process sends the last signal before parent process enter the
>> final sleep sometimes, so sleep in parent will not be interrupted then
>> the case fails.
>> Sleep 1 second before send the last signal in child to make sure parent
>> enter the final sleep.
>>
>> Signed-off-by: Kang Kai<kai.kang@windriver.com>
>> ---
>> .../conformance/interfaces/mq_timedsend/5-1.c | 5 ++++-
>> 1 files changed, 4 insertions(+), 1 deletions(-)
>>
>> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
>> index 96daf72..37993c8 100644
>> --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
>> +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
>> @@ -82,6 +82,9 @@ int main()
>> sleep(1); // give parent time to set up handler
>> for (i=0; i<MAXMSG+1; i++) {
>> mq_timedsend(gqueue, msgptr, strlen(msgptr), 1,&ts);
>> + /* make sure parent enter the final sleep */
>> + if (i == MAXMSG)
>> + sleep(1);
> You only make sure parent enters to the last iteration before child
> does, but same issue still might occur in previous iterations.
It needn't to care the sleep in parent iteration, because at last
mq_timedsend() will make child block when the message queue is full.
Then the in parent iteration, sleep(3) will return 0 then quit the
iteration. After mq_receive() child will be unblocked.
In my test, at this point the child is scheduled and call kill() before
call last sleep(3) in parent, so the test fails.
This patch could make parent call last sleep() before child call kill().

>
> Also, please use hard tab instead of 4/8 spaces for indentation. patch
> style-guide could be found at: doc/style-guide.txt

Sorry about the indentation.

Regards,
Kai

>
> Thanks,
> Caspar
>
>> /* send signal to parent each time message is sent */
>> kill(getppid(), SIGABRT);
>> }
>> @@ -138,4 +141,4 @@ int main()
>> }
>>
>> return PTS_UNRESOLVED;
>> -}
>> \ No newline at end of file
>> +}

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join