Hi, "timer_create/10-1", "timer_create/11-1" failed in my system (RHEL5.5): ------------ conformance/interfaces/timer_create/6-1: execution: PASS conformance/interfaces/timer_create/10-1: execution: FAILED: Output: nanosleep() not interrupted: Success sysconf(_SC_CPUTIME) returns: 200112 conformance/interfaces/timer_create/11-1: execution: FAILED: Output: nanosleep() not interrupted: Success rc = 200112 conformance/interfaces/timer_create/8-1: execution: PASS conformance/interfaces/timer_create/14-1: execution: PASS conformance/interfaces/timer_create/3-1: execution: PASS conformance/interfaces/timer_create/1-1: execution: PASS conformance/interfaces/timer_create/4-1: execution: PASS conformance/interfaces/timer_create/9-1: execution: PASS ------------
"timer_create/10-1" failed in following line:
------------
if (timer_create(CLOCK_PROCESS_CPUTIME_ID, &ev, &tid) != 0) {
perror("timer_create() did not return success");
return PTS_UNRESOLVED;
}
if (timer_settime(tid, 0, &its, NULL) != 0) {
perror("timer_settime() did not return success");
return PTS_UNRESOLVED;
}
if (nanosleep(&ts, &tsleft) != -1) {
perror("nanosleep() not interrupted"); <---
failed line
return PTS_FAIL;
}
------------
It seems to be not able to catch timer's signal.
Manual
(http://www.kernel.org/doc/man-pages/online/pages/man2/timer_create.2.html)
says:
------------
[...]
timer_create() creates a new per-process interval timer. The ID of
the new
timer is returned in the buffer pointed to by timerid, which must be
a non-
NULL pointer. This ID is unique within the process, until the timer
is
deleted. The new timer is initially disarmed.
The clockid argument specifies the clock that the new timer uses to
measure
time. It can be specified as one of the following values:
CLOCK_REALTIME
A settable system-wide real-time clock.
CLOCK_MONOTONIC
A nonsettable monotonically increasing clock that measures
time from
some unspecified point in the past that does not change after
system
startup.
CLOCK_PROCESS_CPUTIME_ID (since Linux 2.6.12)
A clock that measures (user and system) CPU time consumed by
(all of
the threads in) the calling process.
CLOCK_THREAD_CPUTIME_ID (since Linux 2.6.12)
A clock that measures (user and system) CPU time consumed by
the
calling thread.
[...]
------------
It says that "CLOCK_REALTIME" measures "real-time clock" but
"CLOCK_PROCESS_CPUTIME_ID" and "CLOCK_THREAD_CPUTIME_ID" measure "CPU time".
But "nanosleep()" doesn't count up cpu time. And "timer_settime()" cannot
send signal.
"timer_create/11-1" is same.
I revised "timer_create/10-1" and "timer_create/11-1", and they succeeded.
Signed-off-by: Tomonori Mitani <[email protected]>
============
---
a/testcases/open_posix_testsuite/conformance/interfaces/timer_create/10-1.c
2010-11-24 17:44:59.000000000 +0900
+++
b/testcases/open_posix_testsuite/conformance/interfaces/timer_create/10-1.c
2010-11-29 12:14:27.000000000 +0900
@@ -24,8 +24,10 @@
#define SLEEPDELTA 3
#define ACCEPTABLEDELTA 1
+int endflg = 0;
void handler(int signo)
{
+ endflg = 1;
printf("Caught signal\n");
}
@@ -81,13 +83,24 @@
return PTS_UNRESOLVED;
}
- if (nanosleep(&ts, &tsleft) != -1) {
- perror("nanosleep() not interrupted");
- return PTS_FAIL;
+ int n = 0;
+ int i = 0;
+ struct timespec ts1, ts2;
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts1);
+ while (1)
+ {
+ for (i = 0; i < 100000; i++)
+ n += i;
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts2);
+ tsleft.tv_sec = ts.tv_sec - (ts2.tv_sec - ts1.tv_sec);
+ if (tsleft.tv_sec < 0)
+ tsleft.tv_sec = 0;
+ if ((tsleft.tv_sec == 0) || (endflg == 1))
+ break;
}
if ( abs(tsleft.tv_sec-SLEEPDELTA) <= ACCEPTABLEDELTA) {
- printf("Test PASSED");
+ printf("Test PASSED\n");
return PTS_PASS;
} else {
printf("Timer did not last for correct amount of time\n");
---
a/testcases/open_posix_testsuite/conformance/interfaces/timer_create/11-1.c
2010-11-24 17:44:59.000000000 +0900
+++
b/testcases/open_posix_testsuite/conformance/interfaces/timer_create/11-1.c
2010-11-29 14:19:42.000000000 +0900
@@ -22,8 +22,10 @@
#define SLEEPDELTA 3
#define ACCEPTABLEDELTA 1
+int endflg = 0;
void handler(int signo)
{
+ endflg = 1;
printf("Caught signal\n");
}
@@ -78,13 +80,24 @@
return PTS_UNRESOLVED;
}
- if (nanosleep(&ts, &tsleft) != -1) {
- perror("nanosleep() not interrupted");
- return PTS_FAIL;
+ int n = 0;
+ int i = 0;
+ struct timespec ts1, ts2;
+ clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts1);
+ while (1)
+ {
+ for (i = 0; i < 100000; i++)
+ n += i;
+ clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts2);
+ tsleft.tv_sec = ts.tv_sec - (ts2.tv_sec - ts1.tv_sec);
+ if (tsleft.tv_sec < 0)
+ tsleft.tv_sec = 0;
+ if ((tsleft.tv_sec == 0) || (endflg == 1))
+ break;
}
if ( abs(tsleft.tv_sec-SLEEPDELTA) <= ACCEPTABLEDELTA) {
- printf("Test PASSED");
+ printf("Test PASSED\n");
return PTS_PASS;
} else {
printf("Timer did not last for correct amount of time\n");
============
Regards--
-Tomonori Mitani
timer_create.patch
Description: Binary data
------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
