* Re: [LTP] [PATCH] fix false alarm in pselect01
[not found] <1752311632.509001279437850417.JavaMail.root@zmail04.collab.prod.int.phx2.redhat.com>
@ 2010-07-18 7:25 ` Caspar Zhang
2010-07-18 7:32 ` Garrett Cooper
0 siblings, 1 reply; 11+ messages in thread
From: Caspar Zhang @ 2010-07-18 7:25 UTC (permalink / raw)
To: LTP List
[-- Attachment #1: Type: text/plain, Size: 1330 bytes --]
----- "Caspar Zhang" <czhang@redhat.com> wrote:
> Hi all,
>
> In my recent tests, not all desired time is equal to exact
> execution time,
> sometimes it is +/-1s, and in a few times it becomes +/-2s. In most
> cases,
> +/-2s is still a valid value between exact execute time and desired
> time.
>
> Signed-off-by: Caspar Zhang <czhang@redhat.com>
>
> --- a/testcases/kernel/syscalls/pselect/pselect01.c 2010-04-01
> 14:23:10.000000000 +0800
> +++ b/testcases/kernel/syscalls/pselect/pselect01.c 2010-07-15
> 16:03:40.969426078 +0800
> @@ -109,7 +109,8 @@
> NULL);
> end = time(&t);
>
> - if (((end - start) == total_sec) || ((end - start) ==
> total_sec + 1))
> + /* Is it still valid in range -2~2s? */
> + if ((end - start - total_sec <= 2) && (end - start -
> total_sec >= -2))
Sorry for mistake, since end, start are unsigned int, use
end-start-total_sec >= -2 will cause error, add (int)before
(end-start) instead. New patch attached.
Thanks,
Caspar
--
Kernel Associate Quality Engineer
Red Hat Inc. (Beijing R&D Branch)
Red Hat China R&D Branch Unit 907, North Tower C,
Raycom Infotech Park, No.2 Kexueyuan Nanlu,
Haidian District, Beijing 100190
TEL: +86-10-62608150
Web: http://www.redhat.com/
[-- Attachment #2: syscalls-pselect01-fix-false-alarm.patch --]
[-- Type: text/x-patch, Size: 850 bytes --]
Hi all,
In my recent tests, not all desired time is equal to exact execution time,
sometimes it is +/-1s, and in a few times it becomes +/-2s. In most cases,
+/-2s is still a valid value between exact execute time and desired time.
Signed-off-by: Caspar Zhang <czhang@redhat.com>
--- a/testcases/kernel/syscalls/pselect/pselect01.c 2010-04-01 14:23:10.000000000 +0800
+++ b/testcases/kernel/syscalls/pselect/pselect01.c 2010-07-15 16:03:40.969426078 +0800
@@ -109,7 +109,8 @@
NULL);
end = time(&t);
- if (((end - start) == total_sec) || ((end - start) == total_sec + 1))
+ /* Is it still valid in range -2~2s? */
+ if (((int)(end - start) - total_sec <= 2) && ((int)(end - start) - total_sec >= -2))
tst_resm(TPASS, "Sleep time was correct");
else
tst_resm(TFAIL, "Sleep time was incorrect:%d != %d",
[-- Attachment #3: Type: text/plain, Size: 235 bytes --]
------------------------------------------------------------------------------
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
[-- 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] 11+ messages in thread
* Re: [LTP] [PATCH] fix false alarm in pselect01
2010-07-18 7:25 ` [LTP] [PATCH] fix false alarm in pselect01 Caspar Zhang
@ 2010-07-18 7:32 ` Garrett Cooper
0 siblings, 0 replies; 11+ messages in thread
From: Garrett Cooper @ 2010-07-18 7:32 UTC (permalink / raw)
To: Caspar Zhang; +Cc: LTP List
On Sun, Jul 18, 2010 at 12:25 AM, Caspar Zhang <czhang@redhat.com> wrote:
>
> ----- "Caspar Zhang" <czhang@redhat.com> wrote:
>
>> Hi all,
>>
>> In my recent tests, not all desired time is equal to exact
>> execution time,
>> sometimes it is +/-1s, and in a few times it becomes +/-2s. In most
>> cases,
>> +/-2s is still a valid value between exact execute time and desired
>> time.
>>
>> Signed-off-by: Caspar Zhang <czhang@redhat.com>
>>
>> --- a/testcases/kernel/syscalls/pselect/pselect01.c 2010-04-01
>> 14:23:10.000000000 +0800
>> +++ b/testcases/kernel/syscalls/pselect/pselect01.c 2010-07-15
>> 16:03:40.969426078 +0800
>> @@ -109,7 +109,8 @@
>> NULL);
>> end = time(&t);
>>
>> - if (((end - start) == total_sec) || ((end - start) ==
>> total_sec + 1))
>> + /* Is it still valid in range -2~2s? */
>> + if ((end - start - total_sec <= 2) && (end - start -
>> total_sec >= -2))
>
> Sorry for mistake, since end, start are unsigned int, use
> end-start-total_sec >= -2 will cause error, add (int)before
> (end-start) instead. New patch attached.
The fact that the test is using time(3) to calculate the elapsed
period instead of clock_gettime is dubious at best, because the
precision of time is in seconds. Maybe it should be converted to
clock_gettime calls for improved precision?
Thanks,
-Garrett
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] fix false alarm in pselect01
[not found] <70998121.804501279787023401.JavaMail.root@zmail04.collab.prod.int.phx2.redhat.com>
@ 2010-07-22 8:24 ` Caspar Zhang
0 siblings, 0 replies; 11+ messages in thread
From: Caspar Zhang @ 2010-07-22 8:24 UTC (permalink / raw)
To: Garrett Cooper; +Cc: LTP List
[-- Attachment #1: Type: text/plain, Size: 2699 bytes --]
----- "Garrett Cooper" <yanegomi@gmail.com> wrote:
> On Wed, Jul 21, 2010 at 2:40 AM, Caspar Zhang <czhang@redhat.com>
> 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 <czhang@redhat.com>
--- 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/
[-- Attachment #2: pselect-error-range.patch --]
[-- Type: text/x-patch, Size: 1177 bytes --]
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 <czhang@redhat.com>
--- 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);
}
[-- Attachment #3: Type: text/plain, Size: 235 bytes --]
------------------------------------------------------------------------------
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
[-- 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] 11+ messages in thread
* Re: [LTP] [PATCH] fix false alarm in pselect01
2010-07-21 9:40 ` Caspar Zhang
@ 2010-07-21 9:54 ` Garrett Cooper
0 siblings, 0 replies; 11+ messages in thread
From: Garrett Cooper @ 2010-07-21 9:54 UTC (permalink / raw)
To: Caspar Zhang; +Cc: LTP List
On Wed, Jul 21, 2010 at 2:40 AM, Caspar Zhang <czhang@redhat.com> wrote:
>
> ----- "Garrett Cooper" <yanegomi@gmail.com> wrote:
>
>> ACK (and thanks for the hard work)!
>> -Garrett
>
> 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.
>
> 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.
Thanks!
-Garrett
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] fix false alarm in pselect01
[not found] <234306554.719221279705061623.JavaMail.root@zmail04.collab.prod.int.phx2.redhat.com>
@ 2010-07-21 9:40 ` Caspar Zhang
2010-07-21 9:54 ` Garrett Cooper
0 siblings, 1 reply; 11+ messages in thread
From: Caspar Zhang @ 2010-07-21 9:40 UTC (permalink / raw)
To: Garrett Cooper; +Cc: LTP List
[-- Attachment #1: Type: text/plain, Size: 791 bytes --]
----- "Garrett Cooper" <yanegomi@gmail.com> wrote:
> ACK (and thanks for the hard work)!
> -Garrett
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.
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.
Thanks,
Caspar
--
Quality Assurance Associate (Kernel) in
Red Hat Inc. (Beijing R&D Branch)
TEL: +86-10-62608150
Web: http://www.redhat.com/
[-- Attachment #2: syscalls-pselect01-fix-false-alarm.patch --]
[-- Type: text/x-patch, Size: 3854 bytes --]
Hi all,
1. In my recent tests, not all desired time be equal to exact execution
time in sec test part, use clock_gettime to improve precision, and allow
the error range to be 20%.
2. gettimeofday is marked as obsolete in POSIX.1-2008 according to
man gettimeofday, so change gettimeofday to clock_gettime in nsec test
part.
3. 10% range in nsec test part seems not enough.I ran the test for about
1000 times, the nsec test part failed twice. Changed the value to 20%.
Signed-off-by: Caspar Zhang <czhang@redhat.com>
diff -Naur a/testcases/kernel/syscalls/pselect/Makefile b/testcases/kernel/syscalls/pselect/Makefile
--- a/testcases/kernel/syscalls/pselect/Makefile 2010-04-01 14:23:10.000000000 +0800
+++ b/testcases/kernel/syscalls/pselect/Makefile 2010-07-20 16:59:45.983475123 +0800
@@ -21,6 +21,7 @@
include $(top_srcdir)/include/mk/testcases.mk
include $(abs_srcdir)/../utils/newer_64.mk
+LDLIBS += -lpthread -lrt
%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff -Naur a/testcases/kernel/syscalls/pselect/pselect01.c b/testcases/kernel/syscalls/pselect/pselect01.c
--- a/testcases/kernel/syscalls/pselect/pselect01.c 2010-04-01 14:23:10.000000000 +0800
+++ b/testcases/kernel/syscalls/pselect/pselect01.c 2010-07-20 17:00:01.498601028 +0800
@@ -61,14 +61,13 @@
int main()
{
- int ret_pselect, total_sec, fd, total_nsec;
+ int ret_pselect, fd;
fd_set readfds;
- struct timespec tv;
int retval;
- time_t t;
- unsigned start, end;
- struct timeval tv_start, tv_end;
- int real_usec;
+ struct timespec tv, tv_start, tv_end;
+ long real_nsec, total_nsec;
+ double real_sec;
+ int total_sec;
setup();
@@ -103,17 +102,20 @@
tst_resm(TINFO,
"Testing basic pselect sanity,Sleeping for %jd secs",
(intmax_t)tv.tv_sec);
- start = time(&t);
+ clock_gettime(CLOCK_REALTIME, &tv_start);
retval =
- pselect(0, &readfds, NULL, NULL, (struct timespec *)&tv,
+ pselect(0, &readfds, NULL, NULL, &tv,
NULL);
- end = time(&t);
+ clock_gettime(CLOCK_REALTIME, &tv_end);
- if (((end - start) == total_sec) || ((end - start) == total_sec + 1))
+ 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",
- total_sec, (end - start));
+ tst_resm(TFAIL, "Sleep time was incorrect:%d != %lf",
+ total_sec, real_sec);
}
#ifdef DEBUG
@@ -129,19 +131,19 @@
tst_resm(TINFO,
"Testing basic pselect sanity,Sleeping for %ld nano secs",
tv.tv_nsec);
- gettimeofday(&tv_start, NULL);
+ clock_gettime(CLOCK_REALTIME, &tv_start);
retval =
pselect(0, &readfds, NULL, NULL, &tv,
NULL);
- gettimeofday(&tv_end, NULL);
+ clock_gettime(CLOCK_REALTIME, &tv_end);
/* Changed total_sec compare to an at least vs an exact compare */
- real_usec = (tv_end.tv_sec - tv_start.tv_sec) * 1e6 +
- tv_end.tv_usec - tv_start.tv_usec;
+ real_nsec = (tv_end.tv_sec - tv_start.tv_sec) * 1e9 +
+ tv_end.tv_nsec - tv_start.tv_nsec;
- /* allow 10% error*/
- if (abs(real_usec - tv.tv_nsec / 1000) < 0.1 * total_nsec / 1000)
+ /* allow 20% error*/
+ if (abs(real_nsec - tv.tv_nsec) < 0.2 * total_nsec)
tst_resm(TPASS, "Sleep time was correct");
else {
tst_resm(TWARN,
@@ -150,8 +152,8 @@
"due to the limitation of the way it calculates the");
tst_resm(TWARN, "system call execution time.");
tst_resm(TFAIL,
- "Sleep time was incorrect:%d usec vs expected %d usec",
- real_usec, total_nsec / 1000);
+ "Sleep time was incorrect:%ld nsec vs expected %ld nsec",
+ real_nsec, total_nsec);
}
}
cleanup();
[-- Attachment #3: Type: text/plain, Size: 235 bytes --]
------------------------------------------------------------------------------
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
[-- 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] 11+ messages in thread
* Re: [LTP] [PATCH] fix false alarm in pselect01
2010-07-19 8:32 ` Caspar Zhang
@ 2010-07-21 9:26 ` Garrett Cooper
0 siblings, 0 replies; 11+ messages in thread
From: Garrett Cooper @ 2010-07-21 9:26 UTC (permalink / raw)
To: Caspar Zhang; +Cc: LTP List
On Mon, Jul 19, 2010 at 1:32 AM, Caspar Zhang <czhang@redhat.com> wrote:
>
> ----- "Garrett Cooper" <yanegomi@gmail.com> wrote:
>
>> On Sun, Jul 18, 2010 at 11:55 PM, Caspar Zhang <czhang@redhat.com>
>> wrote:
>> >
>> > ----- "Garrett Cooper" <yanegomi@gmail.com> wrote:
>> >
>> >>
>> >> The fact that the test is using time(3) to calculate the
>> elapsed
>> >> period instead of clock_gettime is dubious at best, because the
>> >> precision of time is in seconds. Maybe it should be converted to
>> >> clock_gettime calls for improved precision?
>> >
>> > Use clock_gettime instead of time(3), patch attached.
>>
>> Looks better, but being strict it's still buggy. POSIX defines struct
>> timespec as:
>>
>> The <time.h> header shall declare the structure timespec, which has
>> at
>> least the following members:
>>
>> time_t tv_sec Seconds.
>> long tv_nsec Nanoseconds.
>>
>> So you're losing precision in one case, and time_t can be variable
>> (the spec for types.h is rather fluid):
>>
>> time_t and clock_t shall be integer or real-floating types.
>>
>> The (struct timeval *) casts are also unnecessary because you're
>> getting the address of a struct timeval object (which is in both
>> cases
>> struct timeval*).
>>
>> > Another question, since POSIX.1-2008 marks gettimeofday() as
>> obsolete
>> > (man gettimeofday), should the usec test part be changed to
>> > clock_getime as well?
>>
>> Sure, if you want.
>
> Updated patch, FYI.
>
> Thanks,
> Caspar
>
>
>
> Hi all,
>
> 1. In my recent tests, not all desired time be equal to exact execution
> time in sec test part, use clock_gettime to improve precision.
> 2. gettimeofday is marked as obsolete in POSIX.1-2008 according to
> man gettimeofday, so change gettimeofday to clock_gettime in nsec test
> part.
>
> Signed-off-by: Caspar Zhang <czhang@redhat.com>
>
> diff -Naur a/testcases/kernel/syscalls/pselect/Makefile b/testcases/kernel/syscalls/pselect/Makefile
> --- a/testcases/kernel/syscalls/pselect/Makefile 2010-04-01 14:23:10.000000000 +0800
> +++ b/testcases/kernel/syscalls/pselect/Makefile 2010-07-19 14:54:38.984482305 +0800
> @@ -21,6 +21,7 @@
> include $(top_srcdir)/include/mk/testcases.mk
> include $(abs_srcdir)/../utils/newer_64.mk
>
> +LDLIBS += -lpthread -lrt
> %_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
>
> include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff -Naur a/testcases/kernel/syscalls/pselect/pselect01.c b/testcases/kernel/syscalls/pselect/pselect01.c
> --- a/testcases/kernel/syscalls/pselect/pselect01.c 2010-04-01 14:23:10.000000000 +0800
> +++ b/testcases/kernel/syscalls/pselect/pselect01.c 2010-07-19 16:08:32.402482397 +0800
> @@ -61,14 +61,12 @@
>
> int main()
> {
> - int ret_pselect, total_sec, fd, total_nsec;
> + int ret_pselect, fd;
> fd_set readfds;
> - struct timespec tv;
> int retval;
> - time_t t;
> - unsigned start, end;
> - struct timeval tv_start, tv_end;
> - int real_usec;
> + struct timespec tv, tv_start, tv_end;
> + long real_nsec, total_nsec;
> + int real_sec, total_sec;
>
> setup();
>
> @@ -103,17 +101,20 @@
> tst_resm(TINFO,
> "Testing basic pselect sanity,Sleeping for %jd secs",
> (intmax_t)tv.tv_sec);
> - start = time(&t);
> + clock_gettime(CLOCK_REALTIME, &tv_start);
> retval =
> - pselect(0, &readfds, NULL, NULL, (struct timespec *)&tv,
> + pselect(0, &readfds, NULL, NULL, &tv,
> NULL);
> - end = time(&t);
> + clock_gettime(CLOCK_REALTIME, &tv_end);
>
> - if (((end - start) == total_sec) || ((end - start) == total_sec + 1))
> + /* 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)
> tst_resm(TPASS, "Sleep time was correct");
> else
> tst_resm(TFAIL, "Sleep time was incorrect:%d != %d",
> - total_sec, (end - start));
> + total_sec, real_sec);
> }
>
> #ifdef DEBUG
> @@ -129,19 +130,19 @@
> tst_resm(TINFO,
> "Testing basic pselect sanity,Sleeping for %ld nano secs",
> tv.tv_nsec);
> - gettimeofday(&tv_start, NULL);
> + clock_gettime(CLOCK_REALTIME, &tv_start);
> retval =
> pselect(0, &readfds, NULL, NULL, &tv,
> NULL);
> - gettimeofday(&tv_end, NULL);
> + clock_gettime(CLOCK_REALTIME, &tv_end);
>
> /* Changed total_sec compare to an at least vs an exact compare */
>
> - real_usec = (tv_end.tv_sec - tv_start.tv_sec) * 1e6 +
> - tv_end.tv_usec - tv_start.tv_usec;
> + real_nsec = (tv_end.tv_sec - tv_start.tv_sec) * 1e9 +
> + tv_end.tv_nsec - tv_start.tv_nsec;
>
> /* allow 10% error*/
> - if (abs(real_usec - tv.tv_nsec / 1000) < 0.1 * total_nsec / 1000)
> + if (abs(real_nsec - tv.tv_nsec) < 0.1 * total_nsec)
> tst_resm(TPASS, "Sleep time was correct");
> else {
> tst_resm(TWARN,
> @@ -150,8 +151,8 @@
> "due to the limitation of the way it calculates the");
> tst_resm(TWARN, "system call execution time.");
> tst_resm(TFAIL,
> - "Sleep time was incorrect:%d usec vs expected %d usec",
> - real_usec, total_nsec / 1000);
> + "Sleep time was incorrect:%ld nsec vs expected %ld nsec",
> + real_nsec, total_nsec);
> }
> }
> cleanup();
ACK (and thanks for the hard work)!
-Garrett
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] fix false alarm in pselect01
[not found] <817263552.524511279528077317.JavaMail.root@zmail04.collab.prod.int.phx2.redhat.com>
@ 2010-07-19 8:32 ` Caspar Zhang
2010-07-21 9:26 ` Garrett Cooper
0 siblings, 1 reply; 11+ messages in thread
From: Caspar Zhang @ 2010-07-19 8:32 UTC (permalink / raw)
To: Garrett Cooper; +Cc: LTP List
[-- Attachment #1: Type: text/plain, Size: 6336 bytes --]
----- "Garrett Cooper" <yanegomi@gmail.com> wrote:
> On Sun, Jul 18, 2010 at 11:55 PM, Caspar Zhang <czhang@redhat.com>
> wrote:
> >
> > ----- "Garrett Cooper" <yanegomi@gmail.com> wrote:
> >
> >>
> >> The fact that the test is using time(3) to calculate the
> elapsed
> >> period instead of clock_gettime is dubious at best, because the
> >> precision of time is in seconds. Maybe it should be converted to
> >> clock_gettime calls for improved precision?
> >
> > Use clock_gettime instead of time(3), patch attached.
>
> Looks better, but being strict it's still buggy. POSIX defines struct
> timespec as:
>
> The <time.h> header shall declare the structure timespec, which has
> at
> least the following members:
>
> time_t tv_sec Seconds.
> long tv_nsec Nanoseconds.
>
> So you're losing precision in one case, and time_t can be variable
> (the spec for types.h is rather fluid):
>
> time_t and clock_t shall be integer or real-floating types.
>
> The (struct timeval *) casts are also unnecessary because you're
> getting the address of a struct timeval object (which is in both
> cases
> struct timeval*).
>
> > Another question, since POSIX.1-2008 marks gettimeofday() as
> obsolete
> > (man gettimeofday), should the usec test part be changed to
> > clock_getime as well?
>
> Sure, if you want.
Updated patch, FYI.
Thanks,
Caspar
Hi all,
1. In my recent tests, not all desired time be equal to exact execution
time in sec test part, use clock_gettime to improve precision.
2. gettimeofday is marked as obsolete in POSIX.1-2008 according to
man gettimeofday, so change gettimeofday to clock_gettime in nsec test
part.
Signed-off-by: Caspar Zhang <czhang@redhat.com>
diff -Naur a/testcases/kernel/syscalls/pselect/Makefile b/testcases/kernel/syscalls/pselect/Makefile
--- a/testcases/kernel/syscalls/pselect/Makefile 2010-04-01 14:23:10.000000000 +0800
+++ b/testcases/kernel/syscalls/pselect/Makefile 2010-07-19 14:54:38.984482305 +0800
@@ -21,6 +21,7 @@
include $(top_srcdir)/include/mk/testcases.mk
include $(abs_srcdir)/../utils/newer_64.mk
+LDLIBS += -lpthread -lrt
%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff -Naur a/testcases/kernel/syscalls/pselect/pselect01.c b/testcases/kernel/syscalls/pselect/pselect01.c
--- a/testcases/kernel/syscalls/pselect/pselect01.c 2010-04-01 14:23:10.000000000 +0800
+++ b/testcases/kernel/syscalls/pselect/pselect01.c 2010-07-19 16:08:32.402482397 +0800
@@ -61,14 +61,12 @@
int main()
{
- int ret_pselect, total_sec, fd, total_nsec;
+ int ret_pselect, fd;
fd_set readfds;
- struct timespec tv;
int retval;
- time_t t;
- unsigned start, end;
- struct timeval tv_start, tv_end;
- int real_usec;
+ struct timespec tv, tv_start, tv_end;
+ long real_nsec, total_nsec;
+ int real_sec, total_sec;
setup();
@@ -103,17 +101,20 @@
tst_resm(TINFO,
"Testing basic pselect sanity,Sleeping for %jd secs",
(intmax_t)tv.tv_sec);
- start = time(&t);
+ clock_gettime(CLOCK_REALTIME, &tv_start);
retval =
- pselect(0, &readfds, NULL, NULL, (struct timespec *)&tv,
+ pselect(0, &readfds, NULL, NULL, &tv,
NULL);
- end = time(&t);
+ clock_gettime(CLOCK_REALTIME, &tv_end);
- if (((end - start) == total_sec) || ((end - start) == total_sec + 1))
+ /* 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)
tst_resm(TPASS, "Sleep time was correct");
else
tst_resm(TFAIL, "Sleep time was incorrect:%d != %d",
- total_sec, (end - start));
+ total_sec, real_sec);
}
#ifdef DEBUG
@@ -129,19 +130,19 @@
tst_resm(TINFO,
"Testing basic pselect sanity,Sleeping for %ld nano secs",
tv.tv_nsec);
- gettimeofday(&tv_start, NULL);
+ clock_gettime(CLOCK_REALTIME, &tv_start);
retval =
pselect(0, &readfds, NULL, NULL, &tv,
NULL);
- gettimeofday(&tv_end, NULL);
+ clock_gettime(CLOCK_REALTIME, &tv_end);
/* Changed total_sec compare to an at least vs an exact compare */
- real_usec = (tv_end.tv_sec - tv_start.tv_sec) * 1e6 +
- tv_end.tv_usec - tv_start.tv_usec;
+ real_nsec = (tv_end.tv_sec - tv_start.tv_sec) * 1e9 +
+ tv_end.tv_nsec - tv_start.tv_nsec;
/* allow 10% error*/
- if (abs(real_usec - tv.tv_nsec / 1000) < 0.1 * total_nsec / 1000)
+ if (abs(real_nsec - tv.tv_nsec) < 0.1 * total_nsec)
tst_resm(TPASS, "Sleep time was correct");
else {
tst_resm(TWARN,
@@ -150,8 +151,8 @@
"due to the limitation of the way it calculates the");
tst_resm(TWARN, "system call execution time.");
tst_resm(TFAIL,
- "Sleep time was incorrect:%d usec vs expected %d usec",
- real_usec, total_nsec / 1000);
+ "Sleep time was incorrect:%ld nsec vs expected %ld nsec",
+ real_nsec, total_nsec);
}
}
cleanup();
--
Kernel Associate Quality Engineer
Red Hat Inc. (Beijing R&D Branch)
Red Hat China R&D Branch Unit 907, North Tower C,
Raycom Infotech Park, No.2 Kexueyuan Nanlu,
Haidian District, Beijing 100190
TEL: +86-10-62608150
Web: http://www.redhat.com/
[-- Attachment #2: syscalls-pselect01-fix-false-alarm.patch --]
[-- Type: text/x-patch, Size: 3550 bytes --]
Hi all,
1. In my recent tests, not all desired time be equal to exact execution
time in sec test part, use clock_gettime to improve precision.
2. gettimeofday is marked as obsolete in POSIX.1-2008 according to
man gettimeofday, so change gettimeofday to clock_gettime in nsec test
part.
Signed-off-by: Caspar Zhang <czhang@redhat.com>
diff -Naur a/testcases/kernel/syscalls/pselect/Makefile b/testcases/kernel/syscalls/pselect/Makefile
--- a/testcases/kernel/syscalls/pselect/Makefile 2010-04-01 14:23:10.000000000 +0800
+++ b/testcases/kernel/syscalls/pselect/Makefile 2010-07-19 14:54:38.984482305 +0800
@@ -21,6 +21,7 @@
include $(top_srcdir)/include/mk/testcases.mk
include $(abs_srcdir)/../utils/newer_64.mk
+LDLIBS += -lpthread -lrt
%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff -Naur a/testcases/kernel/syscalls/pselect/pselect01.c b/testcases/kernel/syscalls/pselect/pselect01.c
--- a/testcases/kernel/syscalls/pselect/pselect01.c 2010-04-01 14:23:10.000000000 +0800
+++ b/testcases/kernel/syscalls/pselect/pselect01.c 2010-07-19 16:08:32.402482397 +0800
@@ -61,14 +61,12 @@
int main()
{
- int ret_pselect, total_sec, fd, total_nsec;
+ int ret_pselect, fd;
fd_set readfds;
- struct timespec tv;
int retval;
- time_t t;
- unsigned start, end;
- struct timeval tv_start, tv_end;
- int real_usec;
+ struct timespec tv, tv_start, tv_end;
+ long real_nsec, total_nsec;
+ int real_sec, total_sec;
setup();
@@ -103,17 +101,20 @@
tst_resm(TINFO,
"Testing basic pselect sanity,Sleeping for %jd secs",
(intmax_t)tv.tv_sec);
- start = time(&t);
+ clock_gettime(CLOCK_REALTIME, &tv_start);
retval =
- pselect(0, &readfds, NULL, NULL, (struct timespec *)&tv,
+ pselect(0, &readfds, NULL, NULL, &tv,
NULL);
- end = time(&t);
+ clock_gettime(CLOCK_REALTIME, &tv_end);
- if (((end - start) == total_sec) || ((end - start) == total_sec + 1))
+ /* 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)
tst_resm(TPASS, "Sleep time was correct");
else
tst_resm(TFAIL, "Sleep time was incorrect:%d != %d",
- total_sec, (end - start));
+ total_sec, real_sec);
}
#ifdef DEBUG
@@ -129,19 +130,19 @@
tst_resm(TINFO,
"Testing basic pselect sanity,Sleeping for %ld nano secs",
tv.tv_nsec);
- gettimeofday(&tv_start, NULL);
+ clock_gettime(CLOCK_REALTIME, &tv_start);
retval =
pselect(0, &readfds, NULL, NULL, &tv,
NULL);
- gettimeofday(&tv_end, NULL);
+ clock_gettime(CLOCK_REALTIME, &tv_end);
/* Changed total_sec compare to an at least vs an exact compare */
- real_usec = (tv_end.tv_sec - tv_start.tv_sec) * 1e6 +
- tv_end.tv_usec - tv_start.tv_usec;
+ real_nsec = (tv_end.tv_sec - tv_start.tv_sec) * 1e9 +
+ tv_end.tv_nsec - tv_start.tv_nsec;
/* allow 10% error*/
- if (abs(real_usec - tv.tv_nsec / 1000) < 0.1 * total_nsec / 1000)
+ if (abs(real_nsec - tv.tv_nsec) < 0.1 * total_nsec)
tst_resm(TPASS, "Sleep time was correct");
else {
tst_resm(TWARN,
@@ -150,8 +151,8 @@
"due to the limitation of the way it calculates the");
tst_resm(TWARN, "system call execution time.");
tst_resm(TFAIL,
- "Sleep time was incorrect:%d usec vs expected %d usec",
- real_usec, total_nsec / 1000);
+ "Sleep time was incorrect:%ld nsec vs expected %ld nsec",
+ real_nsec, total_nsec);
}
}
cleanup();
[-- Attachment #3: Type: text/plain, Size: 235 bytes --]
------------------------------------------------------------------------------
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
[-- 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] 11+ messages in thread
* Re: [LTP] [PATCH] fix false alarm in pselect01
2010-07-19 6:55 ` Caspar Zhang
@ 2010-07-19 7:21 ` Garrett Cooper
0 siblings, 0 replies; 11+ messages in thread
From: Garrett Cooper @ 2010-07-19 7:21 UTC (permalink / raw)
To: Caspar Zhang; +Cc: LTP List
On Sun, Jul 18, 2010 at 11:55 PM, Caspar Zhang <czhang@redhat.com> wrote:
>
> ----- "Garrett Cooper" <yanegomi@gmail.com> wrote:
>
>>
>> The fact that the test is using time(3) to calculate the elapsed
>> period instead of clock_gettime is dubious at best, because the
>> precision of time is in seconds. Maybe it should be converted to
>> clock_gettime calls for improved precision?
>
> Use clock_gettime instead of time(3), patch attached.
Looks better, but being strict it's still buggy. POSIX defines struct
timespec as:
The <time.h> header shall declare the structure timespec, which has at
least the following members:
time_t tv_sec Seconds.
long tv_nsec Nanoseconds.
So you're losing precision in one case, and time_t can be variable
(the spec for types.h is rather fluid):
time_t and clock_t shall be integer or real-floating types.
The (struct timeval *) casts are also unnecessary because you're
getting the address of a struct timeval object (which is in both cases
struct timeval*).
> Another question, since POSIX.1-2008 marks gettimeofday() as obsolete
> (man gettimeofday), should the usec test part be changed to
> clock_getime as well?
Sure, if you want.
Thanks!
-Garrett
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] fix false alarm in pselect01
[not found] <1727427203.522661279523956538.JavaMail.root@zmail04.collab.prod.int.phx2.redhat.com>
@ 2010-07-19 7:19 ` Caspar Zhang
0 siblings, 0 replies; 11+ messages in thread
From: Caspar Zhang @ 2010-07-19 7:19 UTC (permalink / raw)
To: Garrett Cooper; +Cc: LTP List
[-- Attachment #1: Type: text/plain, Size: 905 bytes --]
----- "Caspar Zhang" <czhang@redhat.com> wrote:
> ----- "Garrett Cooper" <yanegomi@gmail.com> wrote:
>
> >
> > The fact that the test is using time(3) to calculate the elapsed
> > period instead of clock_gettime is dubious at best, because the
> > precision of time is in seconds. Maybe it should be converted to
> > clock_gettime calls for improved precision?
s/1e-6/1e-9 in the patch, my typo :-|
Thanks,
Caspar
>
> Use clock_gettime instead of time(3), patch attached.
>
> Another question, since POSIX.1-2008 marks gettimeofday() as obsolete
> (man gettimeofday), should the usec test part be changed to
> clock_getime as well?
>
--
Kernel Associate Quality Engineer
Red Hat Inc. (Beijing R&D Branch)
Red Hat China R&D Branch Unit 907, North Tower C,
Raycom Infotech Park, No.2 Kexueyuan Nanlu,
Haidian District, Beijing 100190
TEL: +86-10-62608150
Web: http://www.redhat.com/
[-- Attachment #2: syscalls-pselect01-fix-false-alarm.patch --]
[-- Type: text/x-patch, Size: 1795 bytes --]
Hi all,
In my recent tests, not all desired time be equal to exact execution time,
use clock_gettime to improve precision.
Signed-off-by: Caspar Zhang <czhang@redhat.com>
--- a/testcases/kernel/syscalls/pselect/Makefile 2010-04-01 14:23:10.000000000 +0800
+++ b/testcases/kernel/syscalls/pselect/Makefile 2010-07-19 14:54:38.984482305 +0800
@@ -21,6 +21,7 @@
include $(top_srcdir)/include/mk/testcases.mk
include $(abs_srcdir)/../utils/newer_64.mk
+LDLIBS += -lpthread -lrt
%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
include $(top_srcdir)/include/mk/generic_leaf_target.mk
--- a/testcases/kernel/syscalls/pselect/pselect01.c 2010-04-01 14:23:10.000000000 +0800
+++ b/testcases/kernel/syscalls/pselect/pselect01.c 2010-07-19 15:04:24.175607371 +0800
@@ -65,10 +65,9 @@
fd_set readfds;
struct timespec tv;
int retval;
- time_t t;
- unsigned start, end;
+ struct timespec tp_start, tp_end;
struct timeval tv_start, tv_end;
- int real_usec;
+ int real_usec, real_sec;
setup();
@@ -103,17 +102,20 @@
tst_resm(TINFO,
"Testing basic pselect sanity,Sleeping for %jd secs",
(intmax_t)tv.tv_sec);
- start = time(&t);
+ clock_gettime(CLOCK_REALTIME, &tp_start);
retval =
pselect(0, &readfds, NULL, NULL, (struct timespec *)&tv,
NULL);
- end = time(&t);
+ clock_gettime(CLOCK_REALTIME, &tp_end);
- if (((end - start) == total_sec) || ((end - start) == total_sec + 1))
+ /* do a rounding */
+ real_sec = (int)(0.5 + (tp_end.tv_sec - tp_start.tv_sec +
+ 1e-9 * (tp_end.tv_nsec - tp_start.tv_nsec)));
+ if (real_sec == total_sec)
tst_resm(TPASS, "Sleep time was correct");
else
tst_resm(TFAIL, "Sleep time was incorrect:%d != %d",
- total_sec, (end - start));
+ total_sec, real_sec);
}
#ifdef DEBUG
[-- Attachment #3: Type: text/plain, Size: 235 bytes --]
------------------------------------------------------------------------------
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
[-- 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] 11+ messages in thread
* Re: [LTP] [PATCH] fix false alarm in pselect01
[not found] <1686792840.522211279522425828.JavaMail.root@zmail04.collab.prod.int.phx2.redhat.com>
@ 2010-07-19 6:55 ` Caspar Zhang
2010-07-19 7:21 ` Garrett Cooper
0 siblings, 1 reply; 11+ messages in thread
From: Caspar Zhang @ 2010-07-19 6:55 UTC (permalink / raw)
To: Garrett Cooper; +Cc: LTP List
[-- Attachment #1: Type: text/plain, Size: 831 bytes --]
----- "Garrett Cooper" <yanegomi@gmail.com> wrote:
>
> The fact that the test is using time(3) to calculate the elapsed
> period instead of clock_gettime is dubious at best, because the
> precision of time is in seconds. Maybe it should be converted to
> clock_gettime calls for improved precision?
Use clock_gettime instead of time(3), patch attached.
Another question, since POSIX.1-2008 marks gettimeofday() as obsolete
(man gettimeofday), should the usec test part be changed to
clock_getime as well?
Thanks,
Caspar
--
/---------------------------------------\
| Name: Caspar Zhang |
| Team: Kernel-QE |
| IRC: caspar @ #kernel-qe, #eng-china |
| Phone: +86-10-6260-8150 |
| Cellphone: +86-1381-073-0090 |
\---------------------------------------/
[-- Attachment #2: syscalls-pselect01-fix-false-alarm.patch --]
[-- Type: text/x-patch, Size: 1797 bytes --]
Hi all,
In my recent tests, not all desired time be equal to exact execution time,
use clock_gettime to improve precision.
Signed-off-by: Caspar Zhang <czhang@redhat.com>
--- a/testcases/kernel/syscalls/pselect/Makefile 2010-04-01 14:23:10.000000000 +0800
+++ b/testcases/kernel/syscalls/pselect/Makefile 2010-07-19 14:54:38.984482305 +0800
@@ -21,6 +21,7 @@
include $(top_srcdir)/include/mk/testcases.mk
include $(abs_srcdir)/../utils/newer_64.mk
+LDLIBS += -lpthread -lrt
%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
include $(top_srcdir)/include/mk/generic_leaf_target.mk
--- a/testcases/kernel/syscalls/pselect/pselect01.c 2010-04-01 14:23:10.000000000 +0800
+++ b/testcases/kernel/syscalls/pselect/pselect01.c 2010-07-19 14:25:31.900419665 +0800
@@ -65,10 +65,8 @@
fd_set readfds;
struct timespec tv;
int retval;
- time_t t;
- unsigned start, end;
struct timeval tv_start, tv_end;
- int real_usec;
+ int real_usec, real_sec;
setup();
@@ -103,17 +101,20 @@
tst_resm(TINFO,
"Testing basic pselect sanity,Sleeping for %jd secs",
(intmax_t)tv.tv_sec);
- start = time(&t);
+ clock_gettime(CLOCK_REALTIME, (struct timespec *)&tv_start);
retval =
pselect(0, &readfds, NULL, NULL, (struct timespec *)&tv,
NULL);
- end = time(&t);
+ clock_gettime(CLOCK_REALTIME, (struct timespec *)&tv_end);
- if (((end - start) == total_sec) || ((end - start) == total_sec + 1))
+ /* do a rounding */
+ real_sec = (int)(0.5 + (tv_end.tv_sec - tv_start.tv_sec +
+ 1e-6 * (tv_end.tv_usec - tv_start.tv_usec)));
+ if (real_sec == total_sec)
tst_resm(TPASS, "Sleep time was correct");
else
tst_resm(TFAIL, "Sleep time was incorrect:%d != %d",
- total_sec, (end - start));
+ total_sec, real_sec);
}
#ifdef DEBUG
[-- Attachment #3: Type: text/plain, Size: 235 bytes --]
------------------------------------------------------------------------------
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
[-- 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] 11+ messages in thread
* [LTP] [PATCH] fix false alarm in pselect01
[not found] <113519118.329641279181694037.JavaMail.root@zmail04.collab.prod.int.phx2.redhat.com>
@ 2010-07-15 8:15 ` Caspar Zhang
0 siblings, 0 replies; 11+ messages in thread
From: Caspar Zhang @ 2010-07-15 8:15 UTC (permalink / raw)
To: LTP List
[-- Attachment #1: Type: text/plain, Size: 1226 bytes --]
Hi all,
In my recent tests, not all desired time is equal to exact execution time,
sometimes it is +/-1s, and in a few times it becomes +/-2s. In most cases,
+/-2s is still a valid value between exact execute time and desired time.
Signed-off-by: Caspar Zhang <czhang@redhat.com>
--- a/testcases/kernel/syscalls/pselect/pselect01.c 2010-04-01 14:23:10.000000000 +0800
+++ b/testcases/kernel/syscalls/pselect/pselect01.c 2010-07-15 16:03:40.969426078 +0800
@@ -109,7 +109,8 @@
NULL);
end = time(&t);
- if (((end - start) == total_sec) || ((end - start) == total_sec + 1))
+ /* Is it still valid in range -2~2s? */
+ if ((end - start - total_sec <= 2) && (end - start - total_sec >= -2))
tst_resm(TPASS, "Sleep time was correct");
else
tst_resm(TFAIL, "Sleep time was incorrect:%d != %d",
--
Kernel Associate Quality Engineer
Red Hat Inc. (Beijing R&D Branch)
Red Hat China R&D Branch Unit 907, North Tower C,
Raycom Infotech Park, No.2 Kexueyuan Nanlu,
Haidian District, Beijing 100190
TEL: +86-10-62608150
Web: http://www.redhat.com/
[-- Attachment #2: syscalls-pselect01-fix-false-alarm.patch --]
[-- Type: text/x-patch, Size: 836 bytes --]
Hi all,
In my recent tests, not all desired time is equal to exact execution time,
sometimes it is +/-1s, and in a few times it becomes +/-2s. In most cases,
+/-2s is still a valid value between exact execute time and desired time.
Signed-off-by: Caspar Zhang <czhang@redhat.com>
--- a/testcases/kernel/syscalls/pselect/pselect01.c 2010-04-01 14:23:10.000000000 +0800
+++ b/testcases/kernel/syscalls/pselect/pselect01.c 2010-07-15 16:03:40.969426078 +0800
@@ -109,7 +109,8 @@
NULL);
end = time(&t);
- if (((end - start) == total_sec) || ((end - start) == total_sec + 1))
+ /* Is it still valid in range -2~2s? */
+ if ((end - start - total_sec <= 2) && (end - start - total_sec >= -2))
tst_resm(TPASS, "Sleep time was correct");
else
tst_resm(TFAIL, "Sleep time was incorrect:%d != %d",
[-- Attachment #3: Type: text/plain, Size: 235 bytes --]
------------------------------------------------------------------------------
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
[-- 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] 11+ messages in thread
end of thread, other threads:[~2010-07-22 8:24 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1752311632.509001279437850417.JavaMail.root@zmail04.collab.prod.int.phx2.redhat.com>
2010-07-18 7:25 ` [LTP] [PATCH] fix false alarm in pselect01 Caspar Zhang
2010-07-18 7:32 ` Garrett Cooper
[not found] <70998121.804501279787023401.JavaMail.root@zmail04.collab.prod.int.phx2.redhat.com>
2010-07-22 8:24 ` Caspar Zhang
[not found] <234306554.719221279705061623.JavaMail.root@zmail04.collab.prod.int.phx2.redhat.com>
2010-07-21 9:40 ` Caspar Zhang
2010-07-21 9:54 ` Garrett Cooper
[not found] <817263552.524511279528077317.JavaMail.root@zmail04.collab.prod.int.phx2.redhat.com>
2010-07-19 8:32 ` Caspar Zhang
2010-07-21 9:26 ` Garrett Cooper
[not found] <1727427203.522661279523956538.JavaMail.root@zmail04.collab.prod.int.phx2.redhat.com>
2010-07-19 7:19 ` Caspar Zhang
[not found] <1686792840.522211279522425828.JavaMail.root@zmail04.collab.prod.int.phx2.redhat.com>
2010-07-19 6:55 ` Caspar Zhang
2010-07-19 7:21 ` Garrett Cooper
[not found] <113519118.329641279181694037.JavaMail.root@zmail04.collab.prod.int.phx2.redhat.com>
2010-07-15 8:15 ` Caspar Zhang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.