All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] clock_gettime03: Fix issues with negative offset
@ 2020-06-04 11:41 Viresh Kumar
  2020-06-08 17:59 ` Naresh Kamboju
  0 siblings, 1 reply; 7+ messages in thread
From: Viresh Kumar @ 2020-06-04 11:41 UTC (permalink / raw)
  To: ltp

The tests takes difference between two time readings and check it
against the offset set by the test. When the offset is set to a positive
value (eg 10000 ms), then the diff comes to a value >= 10000 ms (eg
10001 ms), and with divided by 1000, both sides evaluate to 10.

But when the offset is set to -10000 ms, then the delta is >= -10000 ms
(eg -9999) ms. And when divided by 1000, it comes to -9 != -10 and the
test reports error. Over that we are comparing value in seconds, which
is too large of a value. Change the test to compare delta in ms and fix
the false failures.

Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 testcases/kernel/syscalls/clock_gettime/clock_gettime03.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/clock_gettime/clock_gettime03.c b/testcases/kernel/syscalls/clock_gettime/clock_gettime03.c
index e6b9c9c7857c..8341051088d7 100644
--- a/testcases/kernel/syscalls/clock_gettime/clock_gettime03.c
+++ b/testcases/kernel/syscalls/clock_gettime/clock_gettime03.c
@@ -76,7 +76,7 @@ static void child(struct test_variants *tv, struct tcase *tc)
 
 	diff = tst_ts_diff_ms(then, now);
 
-	if (diff/1000 != tc->off) {
+	if (diff - tc->off * 1000 > 10) {
 		tst_res(TFAIL, "Wrong offset (%s) read %llims",
 		        tst_clock_name(tc->clk_id), diff);
 	} else {
@@ -86,7 +86,7 @@ static void child(struct test_variants *tv, struct tcase *tc)
 
 	diff = tst_ts_diff_ms(parent_then, now);
 
-	if (diff/1000) {
+	if (diff > 10) {
 		tst_res(TFAIL, "Wrong offset (%s) read %llims",
 		        tst_clock_name(tc->clk_id), diff);
 	} else {
-- 
2.25.0.rc1.19.g042ed3e048af


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

* [LTP] [PATCH] clock_gettime03: Fix issues with negative offset
  2020-06-04 11:41 [LTP] [PATCH] clock_gettime03: Fix issues with negative offset Viresh Kumar
@ 2020-06-08 17:59 ` Naresh Kamboju
  2020-06-18 13:35   ` Petr Vorel
  2020-06-18 13:42   ` Petr Vorel
  0 siblings, 2 replies; 7+ messages in thread
From: Naresh Kamboju @ 2020-06-08 17:59 UTC (permalink / raw)
  To: ltp

On Thu, 4 Jun 2020 at 17:11, Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> The tests takes difference between two time readings and check it
> against the offset set by the test. When the offset is set to a positive
> value (eg 10000 ms), then the diff comes to a value >= 10000 ms (eg
> 10001 ms), and with divided by 1000, both sides evaluate to 10.
>
> But when the offset is set to -10000 ms, then the delta is >= -10000 ms
> (eg -9999) ms. And when divided by 1000, it comes to -9 != -10 and the
> test reports error. Over that we are comparing value in seconds, which
> is too large of a value. Change the test to compare delta in ms and fix
> the false failures.

Test ran for 100 iterations on x86 device and confirmed test getting pass.

>
> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

Tested-by:  Naresh Kamboju <naresh.kamboju@linaro.org>

ref:
https://bugs.linaro.org/show_bug.cgi?id=5640
- Naresh

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

* [LTP] [PATCH] clock_gettime03: Fix issues with negative offset
  2020-06-08 17:59 ` Naresh Kamboju
@ 2020-06-18 13:35   ` Petr Vorel
  2020-06-18 13:42   ` Petr Vorel
  1 sibling, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2020-06-18 13:35 UTC (permalink / raw)
  To: ltp

Hi Viresh, Naresh,

> Tested-by:  Naresh Kamboju <naresh.kamboju@linaro.org>
Thanks for your fix, testing.
Pushed.

Kind regards,
Petr

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

* [LTP] [PATCH] clock_gettime03: Fix issues with negative offset
  2020-06-08 17:59 ` Naresh Kamboju
  2020-06-18 13:35   ` Petr Vorel
@ 2020-06-18 13:42   ` Petr Vorel
  2020-06-19  3:32     ` Viresh Kumar
  2020-06-22  5:11     ` Viresh Kumar
  1 sibling, 2 replies; 7+ messages in thread
From: Petr Vorel @ 2020-06-18 13:42 UTC (permalink / raw)
  To: ltp

Hi Naresh, Viresh,

> Test ran for 100 iterations on x86 device and confirmed test getting pass.
FYI with very high number of the tests it still can fail, but it's
much less likely:

./clock_gettime03 -i 100000
Summary:
passed   3599972
failed   28
skipped  0
warnings 0

Kind regards,
Petr

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

* [LTP] [PATCH] clock_gettime03: Fix issues with negative offset
  2020-06-18 13:42   ` Petr Vorel
@ 2020-06-19  3:32     ` Viresh Kumar
  2020-06-19  9:38       ` Petr Vorel
  2020-06-22  5:11     ` Viresh Kumar
  1 sibling, 1 reply; 7+ messages in thread
From: Viresh Kumar @ 2020-06-19  3:32 UTC (permalink / raw)
  To: ltp

On 18-06-20, 15:42, Petr Vorel wrote:
> Hi Naresh, Viresh,
> 
> > Test ran for 100 iterations on x86 device and confirmed test getting pass.
> FYI with very high number of the tests it still can fail, but it's
> much less likely:
> 
> ./clock_gettime03 -i 100000
> Summary:
> passed   3599972
> failed   28
> skipped  0
> warnings 0

I am wondering why delta will be over 10 ms in any case.

-- 
viresh

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

* [LTP] [PATCH] clock_gettime03: Fix issues with negative offset
  2020-06-19  3:32     ` Viresh Kumar
@ 2020-06-19  9:38       ` Petr Vorel
  0 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2020-06-19  9:38 UTC (permalink / raw)
  To: ltp

Hi, Viresh,

> > > Test ran for 100 iterations on x86 device and confirmed test getting pass.
> > FYI with very high number of the tests it still can fail, but it's
> > much less likely:

> > ./clock_gettime03 -i 100000
> > Summary:
> > passed   3599972
> > failed   28
> > skipped  0
> > warnings 0

> I am wondering why delta will be over 10 ms in any case.
No idea, I hoped you'd know :).

Kind regards,
Petr

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

* [LTP] [PATCH] clock_gettime03: Fix issues with negative offset
  2020-06-18 13:42   ` Petr Vorel
  2020-06-19  3:32     ` Viresh Kumar
@ 2020-06-22  5:11     ` Viresh Kumar
  1 sibling, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2020-06-22  5:11 UTC (permalink / raw)
  To: ltp

On 18-06-20, 15:42, Petr Vorel wrote:
> > Test ran for 100 iterations on x86 device and confirmed test getting pass.
> FYI with very high number of the tests it still can fail, but it's
> much less likely:
> 
> ./clock_gettime03 -i 100000
> Summary:
> passed   3599972
> failed   28
> skipped  0
> warnings 0

I am not able to hit it on my x86 box, even after suppressing all the print
messages (in order to get rid of any delays). Looks like a hardware/platform bug
to me. I tried a loop of 100,00,000 as well :)

-- 
viresh

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

end of thread, other threads:[~2020-06-22  5:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-04 11:41 [LTP] [PATCH] clock_gettime03: Fix issues with negative offset Viresh Kumar
2020-06-08 17:59 ` Naresh Kamboju
2020-06-18 13:35   ` Petr Vorel
2020-06-18 13:42   ` Petr Vorel
2020-06-19  3:32     ` Viresh Kumar
2020-06-19  9:38       ` Petr Vorel
2020-06-22  5:11     ` Viresh Kumar

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.