diff mbox series

clock_gettime03: multiply the timediff if test in VM

Message ID e5f8d6b684e4ee5733768442a7378c94fc963632.1643278075.git.jstancek@redhat.com
State Accepted
Headers show
Series clock_gettime03: multiply the timediff if test in VM | expand

Commit Message

Jan Stancek Jan. 27, 2022, 10:09 a.m. UTC
Similar to 59e73f295dc7 ("clock_gettime04: multiply the
timediff if test in VM"), extend tolerance for this test too.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 .../kernel/syscalls/clock_gettime/clock_gettime03.c    | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Petr Vorel Jan. 27, 2022, 1:52 p.m. UTC | #1
Hi Jan,

> Similar to 59e73f295dc7 ("clock_gettime04: multiply the
> timediff if test in VM"), extend tolerance for this test too.

Reviewed-by: Petr Vorel <pvorel@suse.cz>
Makes sense, thanks!

Kind regards,
Petr
Li Wang Jan. 28, 2022, 3:03 a.m. UTC | #2
On Thu, Jan 27, 2022 at 9:52 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Jan,
>
> > Similar to 59e73f295dc7 ("clock_gettime04: multiply the
> > timediff if test in VM"), extend tolerance for this test too.
>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> Makes sense, thanks!

Patch merged, thanks~
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/clock_gettime/clock_gettime03.c b/testcases/kernel/syscalls/clock_gettime/clock_gettime03.c
index 83e97d90726d..f185977d36df 100644
--- a/testcases/kernel/syscalls/clock_gettime/clock_gettime03.c
+++ b/testcases/kernel/syscalls/clock_gettime/clock_gettime03.c
@@ -37,6 +37,7 @@  static struct tcase {
 
 static struct tst_ts now, then, parent_then;
 static int parent_ns;
+static long long delta = 10;
 
 static struct time64_variants variants[] = {
 	{ .clock_gettime = libc_clock_gettime, .ts_type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"},
@@ -70,7 +71,7 @@  static void child(struct time64_variants *tv, struct tcase *tc)
 
 	diff = tst_ts_diff_ms(then, now);
 
-	if (diff - tc->off * 1000 > 10) {
+	if (diff - tc->off * 1000 > delta) {
 		tst_res(TFAIL, "Wrong offset (%s) read %llims",
 		        tst_clock_name(tc->clk_id), diff);
 	} else {
@@ -80,7 +81,7 @@  static void child(struct time64_variants *tv, struct tcase *tc)
 
 	diff = tst_ts_diff_ms(parent_then, now);
 
-	if (diff > 10) {
+	if (diff > delta) {
 		tst_res(TFAIL, "Wrong offset (%s) read %llims",
 		        tst_clock_name(tc->clk_id), diff);
 	} else {
@@ -113,6 +114,11 @@  static void setup(void)
 {
 	struct time64_variants *tv = &variants[tst_variant];
 
+	if (tst_is_virt(VIRT_ANY)) {
+		tst_res(TINFO, "Running in a VM, multiply the delta by 10.");
+		delta *= 10;
+	}
+
 	now.type = then.type = parent_then.type = tv->ts_type;
 	tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc);
 	parent_ns = SAFE_OPEN("/proc/self/ns/time_for_children", O_RDONLY);