[ARM-SIGNAL]open_posix_testcase-nanosleep+SIGCONT+SIGSTOP+Failed

From: naresh kamboju
Date: Wed Jun 17 2009 - 09:40:53 EST


Hi,

I want to inform 2.6.29 signal issues of ARM.
this issue is noticed only on ARM.

As per my understanding I have noticed that when there is a delay
(sleep/nanosleep/usleep) in the child process. Child could not
reporting exit status to parent at this situation parent is waiting
for ever by combinations of SIGSTOP and SIGCONT. So test cases are
reporting as HUNG.

Here I have attached open posix test cases which are reported as HUNG
with 2.6.29 kernels.
1. ltp/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/1-5.c
2. ltp/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/3-2.c



ARCH: ARM
KERNEL: 2.6.29.1-alp_nl-kzm-arm11
Glibc: 2.9
Gcc: 4.3.3

/*****************************************************************/
open_posix_testsuite/conformance/interfaces/clock_nanosleep/1-5.c

/*****************************************************************/
/*
* Copyright (c) 2002-3, Intel Corporation. All rights reserved.
* Created by: julie.n.fleischer REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.

* Test that clock_nanosleep() does not stop if a signal is received
* that has no signal handler. clock_nanosleep() should still respond
* to the signal, but should resume after a SIGCONT signal is received.
*
* SIGSTOP will be used to stop the sleep.
*/
#include <stdio.h>
#include <time.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdlib.h>
#include "posixtest.h"

#define SLEEPSEC 5

#define CHILDPASS 1
#define CHILDFAIL 0

int main(int argc, char *argv[])
{
int pid, slepts;
struct timespec tsbefore, tsafter;

if (clock_gettime(CLOCK_REALTIME, &tsbefore) != 0) {
perror("clock_gettime() did not return success\n");
return PTS_UNRESOLVED;
}


if ((pid = fork()) == 0) {
/* child here */
struct timespec tssleep;

tssleep.tv_sec=SLEEPSEC;
tssleep.tv_nsec=0;
if (clock_nanosleep(CLOCK_REALTIME, 0, &tssleep, NULL) == 0) {
printf("clock_nanosleep() returned success\n");
return CHILDPASS;
} else {
printf("clock_nanosleep() did not return success\n");
return CHILDFAIL;
}
return CHILDFAIL;
} else {
/* parent here */
int i;

sleep(1);

if (kill(pid, SIGSTOP) != 0) {
printf("Could not raise SIGSTOP\n");
return PTS_UNRESOLVED;
}

if (kill(pid, SIGCONT) != 0) {
printf("Could not raise SIGCONT\n");
return PTS_UNRESOLVED;
}

if (wait(&i) == -1) {
perror("Error waiting for child to exit\n");
return PTS_UNRESOLVED;
}

if (!WIFEXITED(i) || !WEXITSTATUS(i)) {
printf("Test FAILED\n");
return PTS_FAIL;
}

if (clock_gettime(CLOCK_REALTIME, &tsafter) == -1) {
perror("Error in clock_gettime()\n");
return PTS_UNRESOLVED;
}

slepts=tsafter.tv_sec-tsbefore.tv_sec;

#ifdef DEBUG
printf("Start %d sec; End %d sec\n", (int) tsbefore.tv_sec,
(int) tsafter.tv_sec);
#endif
if (slepts >= SLEEPSEC) {
printf("Test PASSED\n");
return PTS_PASS;
} else {
printf("clock_nanosleep() did not sleep long enough\n");
return PTS_FAIL;
}

} //end fork

return PTS_UNRESOLVED;
}



/*****************************************************************/
open_posix_testsuite/conformance/interfaces/nanosleep/3-2.c

/*****************************************************************/
/*
* Copyright (c) 2002, Intel Corporation. All rights reserved.
* Created by: julie.n.fleischer REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
*
* Regression test motivated by an LKML discussion. Test that nanosleep()
* can be interrupted and then continue.
*/
#include <stdio.h>
#include <time.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdlib.h>

#define PTS_PASS 0
#define PTS_FAIL 1
#define PTS_UNRESOLVED 2
#define PTS_UNSUPPORTED 4
#define PTS_UNTESTED 5

#define SLEEPSEC 5

#define CHILDPASS 0 //if interrupted, child will return 0
#define CHILDFAIL 1

int main(int argc, char *argv[])
{
int pid, slepts;
struct timespec tsbefore, tsafter;

if (clock_gettime(CLOCK_REALTIME, &tsbefore) != 0) {
perror("clock_gettime() did not return success\n");
return PTS_UNRESOLVED;
}


if ((pid = fork()) == 0) {
/* child here */
struct timespec tssleep;

tssleep.tv_sec=SLEEPSEC;
tssleep.tv_nsec=0;
if (nanosleep(&tssleep, NULL) == 0) {
printf("nanosleep() returned success\n");
return CHILDPASS;
} else {
printf("nanosleep() did not return success\n");
return CHILDFAIL;
}
return CHILDFAIL;
} else {
/* parent here */
int i;

sleep(1);

if (kill(pid, SIGSTOP) != 0) {
printf("Could not raise SIGSTOP\n");
return PTS_UNRESOLVED;
}

if (kill(pid, SIGCONT) != 0) {
printf("Could not raise SIGCONT\n");
return PTS_UNRESOLVED;
}

if (wait(&i) == -1) {
perror("Error waiting for child to exit\n");
return PTS_UNRESOLVED;
}

if (!WIFEXITED(i)) {
printf("nanosleep() did not return 0\n");
return PTS_FAIL;
}

if (clock_gettime(CLOCK_REALTIME, &tsafter) == -1) {
perror("Error in clock_gettime()\n");
return PTS_UNRESOLVED;
}

slepts=tsafter.tv_sec-tsbefore.tv_sec;

printf("Start %d sec; End %d sec\n", (int) tsbefore.tv_sec,
(int) tsafter.tv_sec);
if (slepts >= SLEEPSEC) {
printf("Test PASSED\n");
return PTS_PASS;
} else {
printf("nanosleep() did not sleep long enough\n");
return PTS_FAIL;
}

} //end fork

return PTS_UNRESOLVED;
}


/*****************************************************************/



Best regards,
Naresh Kamboju
-bash-3.2# uname -a
Linux 2.6.29.2
-bash-3.2# cat proc/464/status
Name: 3-2.test
State: T (tracing stop)
Tgid: 464
Pid: 464
PPid: 462
TracerPid: 462
Uid: 0 0 0 0
Gid: 0 0 0 0
FDSize: 32
Groups: 0
VmPeak: 2332 kB
VmSize: 2316 kB
VmLck: 0 kB
VmHWM: 404 kB
VmRSS: 404 kB
VmData: 32 kB
VmStk: 84 kB
VmExe: 4 kB
VmLib: 2032 kB
VmPTE: 8 kB
Threads: 1
SigQ: 0/1024
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000000000
SigCgt: 0000000180000000
CapInh: 0000000000000000
CapPrm: fffffffffffffeff
CapEff: fffffffffffffeff
CapBnd: fffffffffffffeff
voluntary_ctxt_switches: 126
nonvoluntary_ctxt_switches: 31
-bash-3.2#
-bash-3.2# cat proc/465/status
Name: 3-2.test
State: R (running)
Tgid: 465
Pid: 465
PPid: 464
TracerPid: 462
Uid: 0 0 0 0
Gid: 0 0 0 0
FDSize: 32
Groups: 0
VmPeak: 2316 kB
VmSize: 2316 kB
VmLck: 0 kB
VmHWM: 164 kB
VmRSS: 164 kB
VmData: 32 kB
VmStk: 84 kB
VmExe: 4 kB
VmLib: 2032 kB
VmPTE: 8 kB
Threads: 1
SigQ: 0/1024
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000000000
SigCgt: 0000000180000000
CapInh: 0000000000000000
CapPrm: fffffffffffffeff
CapEff: fffffffffffffeff
CapBnd: fffffffffffffeff
voluntary_ctxt_switches: 7
nonvoluntary_ctxt_switches: 36623
-bash-3.2#

Attachment: 3-2.c
Description: Binary data

Attachment: 1-5.c
Description: Binary data

Attachment: nano_sleep_3-2.log
Description: Binary data