public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] fix "timer_create/10-1" and "timer_create/11-1" tests
@ 2010-11-29  6:21 Mitani
  2010-12-10 14:49 ` Cyril Hrubis
  0 siblings, 1 reply; 9+ messages in thread
From: Mitani @ 2010-11-29  6:21 UTC (permalink / raw)
  To: ltp-list; +Cc: 當座 健市

[-- Attachment #1: Type: text/plain, Size: 5337 bytes --]

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 <mitani@ryobi.co.jp>
============
---
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

[-- Attachment #2: timer_create.patch --]
[-- Type: application/octet-stream, Size: 2356 bytes --]

--- 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");

[-- Attachment #3: Type: text/plain, Size: 402 bytes --]

------------------------------------------------------------------------------
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

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 9+ messages in thread
* [LTP] [PATCH] fix \"timer_create/10-1\" and \"timer_create/11-1\" tests
@ 2010-12-07 10:08 Mitani
  0 siblings, 0 replies; 9+ messages in thread
From: Mitani @ 2010-12-07 10:08 UTC (permalink / raw)
  To: ltp-list

Hi,


How about my patch for "timer_create/10-1" and "11-1"?

I am glad if I get some opinion.

Regards--

-Tomonori Mitani



------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-01-24 16:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-29  6:21 [LTP] [PATCH] fix "timer_create/10-1" and "timer_create/11-1" tests Mitani
2010-12-10 14:49 ` Cyril Hrubis
     [not found]   ` <AANLkTimmkmk_H+AzYOGau6fr_BHChOCif7n=FOu2F14R@mail.gmail.com>
     [not found]     ` <AANLkTi=MnLYAt+Qdn9-_Pv8rze=Jcgy5c3n7r08UMthP@mail.gmail.com>
2010-12-13 18:06       ` Cyril Hrubis
2010-12-13 18:53     ` Cyril Hrubis
2010-12-30 14:47       ` Cyril Hrubis
2011-01-06 15:25       ` Cyril Hrubis
     [not found]         ` <AANLkTi=YcasSVsYCX7gmkt2m7uBDBf3u=XvAAn=x3vSy@mail.gmail.com>
2011-01-16 14:09           ` Cyril Hrubis
     [not found]             ` <AANLkTi=DyeO5E7MWR=SbB=N24PafZwmQFqS6d2mhbZiL@mail.gmail.com>
2011-01-24 16:59               ` Cyril Hrubis
  -- strict thread matches above, loose matches on Subject: below --
2010-12-07 10:08 [LTP] [PATCH] fix \"timer_create/10-1\" and \"timer_create/11-1\" tests Mitani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox