]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-watchdog: use watchdog_runtime_wait() to determine sleep interval
authorMike Gilbert <floppym@gentoo.org>
Thu, 6 Jan 2022 19:09:30 +0000 (14:09 -0500)
committerMike Gilbert <floppym@gentoo.org>
Thu, 6 Jan 2022 19:09:30 +0000 (14:09 -0500)
As sugggested in
https://github.com/systemd/systemd/issues/22001#issuecomment-1006755438.

src/test/test-watchdog.c

index 074ed1e451ba29924cfafa253b2dfe459f11abe7..78151beff65a8c40e9c56c65a6f7784bad1b0f84 100644 (file)
@@ -27,12 +27,13 @@ int main(int argc, char *argv[]) {
                 t = 0;
 
         for (i = 0; i < count; i++) {
+                t = watchdog_runtime_wait();
+                log_info("Sleeping " USEC_FMT " microseconds...", t);
+                usleep(t);
                 log_info("Pinging...");
                 r = watchdog_ping();
                 if (r < 0)
                         log_warning_errno(r, "Failed to ping watchdog: %m");
-
-                usleep(t/2);
         }
 
         watchdog_close(true);