----- "Garrett Cooper" <[email protected]> wrote:

> On Wed, Jul 21, 2010 at 2:40 AM, Caspar Zhang <[email protected]>
> wrote:
> > Hi Garrett, I tested my patch yesterday but the result
> > is not so good. After 1000 times running, the fix:
> >
> > +               /* do a rounding */
> > +               real_sec = (int)(0.5 + (tv_end.tv_sec -
> tv_start.tv_sec +
> > +                               1e-9 * (tv_end.tv_nsec -
> tv_start.tv_nsec)));
> > +               if (real_sec == total_sec)
> >
> > got failed for once. so I set the allowed error to 20%(see the
> > attached patch). Then re-ran it for over 5000 times, without
> > a failure.

Hi, seems that this changing not ACKed or committed, re-attach
the patch .

Thanks,
Caspar

> >
> > Then the nsec part, 10% allowed error seems not enough,
> > the test failed for twice among 1000 times. So I set the
> > range to 20%, too.
> 
> Fair enough... change committed.



Hi,
        Tests can be easily failing when using real_sec == total_sec.
        Changed to the similar way as in nsec part does, allow 20%
        error.

        Signed-off-by: Caspar Zhang <[email protected]>

--- a/testcases/kernel/syscalls/pselect/pselect01.c     2010-07-21 
18:08:25.139600055 +0800
+++ b/testcases/kernel/syscalls/pselect/pselect01.c     2010-07-22 
16:17:06.552474774 +0800
@@ -66,7 +66,8 @@
        int retval;
        struct timespec tv, tv_start, tv_end;
        long real_nsec, total_nsec;
-       int real_sec, total_sec;
+       double real_sec;
+       int total_sec;
 
        setup();
 
@@ -107,13 +108,13 @@
                            NULL);
                clock_gettime(CLOCK_REALTIME, &tv_end);
 
-               /* do a rounding */
-               real_sec = (int)(0.5 + (tv_end.tv_sec - tv_start.tv_sec + 
-                               1e-9 * (tv_end.tv_nsec - tv_start.tv_nsec)));
-               if (real_sec == total_sec)
+               real_sec = (tv_end.tv_sec - tv_start.tv_sec + 
+                               1e-9 * (tv_end.tv_nsec - tv_start.tv_nsec));
+               /* allow about 20% error */
+               if (abs(real_sec - total_sec) < 0.2 * total_sec)
                        tst_resm(TPASS, "Sleep time was correct");
                else
-                       tst_resm(TFAIL, "Sleep time was incorrect:%d != %d",
+                       tst_resm(TFAIL, "Sleep time was incorrect:%d != %lf",
                                 total_sec, real_sec);
        }

-- 
Quality Assurance Associate (Kernel) in
Red Hat Inc. (Beijing R&D Branch)

TEL: +86-10-62608150
Web: http://www.redhat.com/
Hi,
	Tests can be easily failing when using real_sec == total_sec.
	Changed to the similar way as in nsec part does, allow 20%
	error.

	Signed-off-by: Caspar Zhang <[email protected]>

--- a/testcases/kernel/syscalls/pselect/pselect01.c	2010-07-21 18:08:25.139600055 +0800
+++ b/testcases/kernel/syscalls/pselect/pselect01.c	2010-07-22 16:17:06.552474774 +0800
@@ -66,7 +66,8 @@
 	int retval;
 	struct timespec tv, tv_start, tv_end;
 	long real_nsec, total_nsec;
-	int real_sec, total_sec;
+	double real_sec;
+	int total_sec;
 
 	setup();
 
@@ -107,13 +108,13 @@
 			    NULL);
 		clock_gettime(CLOCK_REALTIME, &tv_end);
 
-		/* do a rounding */
-		real_sec = (int)(0.5 + (tv_end.tv_sec - tv_start.tv_sec + 
-				1e-9 * (tv_end.tv_nsec - tv_start.tv_nsec)));
-		if (real_sec == total_sec)
+		real_sec = (tv_end.tv_sec - tv_start.tv_sec + 
+				1e-9 * (tv_end.tv_nsec - tv_start.tv_nsec));
+		/* allow about 20% error */
+		if (abs(real_sec - total_sec) < 0.2 * total_sec)
 			tst_resm(TPASS, "Sleep time was correct");
 		else
-			tst_resm(TFAIL, "Sleep time was incorrect:%d != %d",
+			tst_resm(TFAIL, "Sleep time was incorrect:%d != %lf",
 				 total_sec, real_sec);
 	}
 
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to