Skip to contentSkip to conversation

clock_gettime03: Fix issues with negative offset

PATCH New Viresh Kumar 3 participants 7 messages Jun 4, 2020 – Jun 22, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clock_gettime03: Fix issues with negative offset

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.

---
 testcases/kernel/syscalls/clock_gettime/clock_gettime03.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/clock_gettime/clock_gettime03.c +2 -2
index e6b9c9c7857c..8341051088d7 100644
@@ -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 {
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
#1 lore raw

PATCH 1/1 clock_gettime03: Fix issues with negative offset

Quoted 11 lines · Viresh Kumar

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.

Quoted 3 lines

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

#3 lore raw

PATCH 1/1 clock_gettime03: Fix issues with negative offset

In reply to Naresh Kamboju

Hi Naresh, Viresh,

Quoted 1 line

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

#4 lore raw

PATCH 1/1 clock_gettime03: Fix issues with negative offset

Quoted 6 lines · Petr Vorel

Hi Naresh, Viresh,

Quoted 1 line

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:

Quoted 6 lines

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

Signature · 1 line
viresh
#5 lore raw

PATCH 1/1 clock_gettime03: Fix issues with negative offset

Hi, Viresh,

Quoted 4 lines
Quoted 3 lines
Quoted 1 line

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:

Quoted 8 lines
Quoted 6 lines

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

#6 lore raw

PATCH 1/1 clock_gettime03: Fix issues with negative offset

In reply to Petr Vorel
Quoted 10 lines · Petr Vorel
Quoted 1 line

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

Signature · 1 line
viresh