All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] clock_gettime04: relax the time diff in VM
@ 2020-09-15  3:14 Li Wang
  2020-09-15  8:10 ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Li Wang @ 2020-09-15  3:14 UTC (permalink / raw)
  To: ltp

To balance that the test inside a VM can NOT get enough CPU time, which
result in sporadically fails with the time comparing.

clock_gettime04.c:155: PASS: CLOCK_REALTIME: Difference between successive readings is reasonable
clock_gettime04.c:155: PASS: CLOCK_REALTIME_COARSE: Difference between successive readings is reasonable
clock_gettime04.c:148: FAIL: CLOCK_MONOTONIC: Difference between successive readings greater than 5 ms (2): 22
clock_gettime04.c:155: PASS: CLOCK_MONOTONIC_COARSE: Difference between successive readings is reasonable
clock_gettime04.c:148: FAIL: CLOCK_MONOTONIC_RAW: Difference between successive readings greater than 5 ms (1): 22
clock_gettime04.c:148: FAIL: CLOCK_BOOTTIME: Difference between successive readings greater than 5 ms (1): 29

Signed-off-by: Li Wang <liwang@redhat.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
---
 .../kernel/syscalls/clock_gettime/clock_gettime04.c      | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c b/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c
index 2f484c43f..5c4a5d751 100644
--- a/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c
+++ b/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c
@@ -92,6 +92,7 @@ static void run(unsigned int i)
 	struct test_variants *tv;
 	int count = 10000, ret;
 	unsigned int j;
+	int virt_env = tst_is_virt(VIRT_ANY);
 
 	do {
 		for (j = 0; j < ARRAY_SIZE(variants); j++) {
@@ -143,11 +144,17 @@ static void run(unsigned int i)
 
 			diff /= 1000000;
 
-			if (diff >= 5) {
+			if (!virt_env && diff >= 5) {
 				tst_res(TFAIL, "%s: Difference between successive readings greater than 5 ms (%d): %lld",
 					tst_clock_name(clks[i]), j, diff);
 				return;
 			}
+
+			if (virt_env && diff >= 50) {
+				tst_res(TFAIL, "%s: Difference between successive readings(in VM) greater than 50 ms (%d): %lld",
+					tst_clock_name(clks[i]), j, diff);
+				return;
+			}
 		}
 	} while (--count);
 
-- 
2.21.3


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

* [LTP] [PATCH] clock_gettime04: relax the time diff in VM
  2020-09-15  3:14 [LTP] [PATCH] clock_gettime04: relax the time diff in VM Li Wang
@ 2020-09-15  8:10 ` Cyril Hrubis
  2020-09-15  8:20   ` Li Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2020-09-15  8:10 UTC (permalink / raw)
  To: ltp

Hi!
> To balance that the test inside a VM can NOT get enough CPU time, which
> result in sporadically fails with the time comparing.
> 
> clock_gettime04.c:155: PASS: CLOCK_REALTIME: Difference between successive readings is reasonable
> clock_gettime04.c:155: PASS: CLOCK_REALTIME_COARSE: Difference between successive readings is reasonable
> clock_gettime04.c:148: FAIL: CLOCK_MONOTONIC: Difference between successive readings greater than 5 ms (2): 22
> clock_gettime04.c:155: PASS: CLOCK_MONOTONIC_COARSE: Difference between successive readings is reasonable
> clock_gettime04.c:148: FAIL: CLOCK_MONOTONIC_RAW: Difference between successive readings greater than 5 ms (1): 22
> clock_gettime04.c:148: FAIL: CLOCK_BOOTTIME: Difference between successive readings greater than 5 ms (1): 29
> 
> Signed-off-by: Li Wang <liwang@redhat.com>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>

The idea is good, but I think that the implementation could be better.

Why can't we just call the tst_is_virt() in test setup and if we detect
that we are running on virtual machine print a TINFO message that
maximal expected difference has been multiplied by 10?

> ---
>  .../kernel/syscalls/clock_gettime/clock_gettime04.c      | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c b/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c
> index 2f484c43f..5c4a5d751 100644
> --- a/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c
> +++ b/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c
> @@ -92,6 +92,7 @@ static void run(unsigned int i)
>  	struct test_variants *tv;
>  	int count = 10000, ret;
>  	unsigned int j;
> +	int virt_env = tst_is_virt(VIRT_ANY);
>  
>  	do {
>  		for (j = 0; j < ARRAY_SIZE(variants); j++) {
> @@ -143,11 +144,17 @@ static void run(unsigned int i)
>  
>  			diff /= 1000000;
>  
> -			if (diff >= 5) {
> +			if (!virt_env && diff >= 5) {
>  				tst_res(TFAIL, "%s: Difference between successive readings greater than 5 ms (%d): %lld",
>  					tst_clock_name(clks[i]), j, diff);
>  				return;
>  			}
> +
> +			if (virt_env && diff >= 50) {
> +				tst_res(TFAIL, "%s: Difference between successive readings(in VM) greater than 50 ms (%d): %lld",
> +					tst_clock_name(clks[i]), j, diff);
> +				return;
> +			}
>  		}
>  	} while (--count);
>  
> -- 
> 2.21.3
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH] clock_gettime04: relax the time diff in VM
  2020-09-15  8:10 ` Cyril Hrubis
@ 2020-09-15  8:20   ` Li Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Li Wang @ 2020-09-15  8:20 UTC (permalink / raw)
  To: ltp

> od, but I think that the implementation could be better.
>
> Why can't we just call the tst_is_virt() in test setup and if we detect
> that we are running on virtual machine print a TINFO message that
> maximal expected difference has been multiplied by 10?
>

Sounds good.

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200915/092fe1b8/attachment.htm>

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

end of thread, other threads:[~2020-09-15  8:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-15  3:14 [LTP] [PATCH] clock_gettime04: relax the time diff in VM Li Wang
2020-09-15  8:10 ` Cyril Hrubis
2020-09-15  8:20   ` Li Wang

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.