From 059bfd7806753687448415ae1f1a096064120774 Mon Sep 17 00:00:00 2001 From: yangfl Date: Tue, 25 Jan 2022 21:21:38 +0800 Subject: [PATCH] test: use sleep() for mtime delay For filesystems without high-resolution time support, an usleep() is too short to alter mtime. Though 1s is quite safe, sleep for 2s in case it gets awaken right within that second. --- test/pidfile.c | 2 +- test/touch.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/pidfile.c b/test/pidfile.c index a627dc7..79fa92e 100644 --- a/test/pidfile.c +++ b/test/pidfile.c @@ -41,7 +41,7 @@ static int mtime() char buf[80]; /* Must sleep a while here otherwise we execute too fast => no mtime change :-( */ - usleep(10000); + sleep(2); PRINT("Calling pidfile() again to update mtime ...\n"); if (pidfile(pidfile_arg)) diff --git a/test/touch.c b/test/touch.c index f1630a9..d8d2cd6 100644 --- a/test/touch.c +++ b/test/touch.c @@ -23,7 +23,7 @@ static int mtime(char *file) stat(file, &before); /* Must sleep a while here otherwise we execute too fast => no mtime change :-( */ - usleep(10000); + sleep(2); PRINT("Calling touch() again to update mtime ...\n"); if (touch(file)) {