public inbox for ltp@lists.linux.it
 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

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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox