From: Richard W.M. Jones Date: Tue, 4 Aug 2015 06:51:56 +0000 (+0100) Subject: Maximum ping time should be 120 seconds. X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=watchdog-test-framework.git Maximum ping time should be 120 seconds. Not watchdog_timeout * 2, which for long timeouts means waiting for ages. --- diff --git a/watchdog-test.c b/watchdog-test.c index 77ee178..326160c 100644 --- a/watchdog-test.c +++ b/watchdog-test.c @@ -30,6 +30,8 @@ #define WATCHDOG_DEVICE "/dev/watchdog" #define WATCHDOG_TIMEOUT_DEFAULT 30 +#define MIN(a,b) ((a)<(b)?(a):(b)) + enum { HELP_OPTION = CHAR_MAX + 1 }; static const char *options = ""; @@ -50,6 +52,7 @@ int main (int argc, char *argv[]) { int watchdog_timeout = WATCHDOG_TIMEOUT_DEFAULT; + int ping_time; int fd; int timeout; char input[256]; @@ -85,6 +88,8 @@ main (int argc, char *argv[]) } } + ping_time = MIN (watchdog_timeout * 2, 120); + setvbuf (stdout, NULL, _IONBF, 0); printf ("\n"); @@ -97,7 +102,7 @@ main (int argc, char *argv[]) watchdog_timeout); printf ("(2) I will ping the watchdog for %d seconds. During this time\n" " the guest should run normally.\n", - watchdog_timeout * 2); + ping_time); printf ("(3) I will stop pinging the watchdog and just count up. If the\n" " virtual watchdog device is set correctly, then the watchdog\n" " action (eg. reboot) should happen around the %d second mark.\n", @@ -141,13 +146,13 @@ main (int argc, char *argv[]) } printf ("\n"); - printf ("Pinging the watchdog for %d seconds ...\n", watchdog_timeout*2); + printf ("Pinging the watchdog for %d seconds ...\n", ping_time); printf ("\n"); time (&start_t); for (;;) { time (&t); - if (t - start_t > watchdog_timeout * 2) + if (t - start_t > ping_time) break; printf ("%d...\n", (int) (t - start_t));