Various fixes.
[watchdog-test-framework.git] / watchdog-test.c
index de855a8..d4e6305 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 #include <time.h>
 #include <fcntl.h>
@@ -30,7 +31,7 @@
 int
 main ()
 {
-  int fd, i;
+  int fd;
   int timeout;
   char input[256];
   time_t start_t, t;
@@ -56,7 +57,7 @@ main ()
   printf ("Do you want to start the test?  Type \"yes\" without quotes:\n");
 
   if (fgets (input, sizeof input, stdin) == NULL ||
-      strcmp (input, "yes") != 0) {
+      strncmp (input, "yes", 3) != 0) {
     printf ("Exiting the program.\n");
     exit (EXIT_SUCCESS);
   }
@@ -81,7 +82,7 @@ main ()
   if (ioctl (fd, WDIOC_GETTIMEOUT, &timeout) == -1)
     perror ("ioctl: WDIOC_GETTIMEOUT");
   else {
-    printf ("Timeout is set to %d seconds.\n");
+    printf ("Timeout is set to %d seconds.\n", timeout);
     if (timeout != WATCHDOG_TIMEOUT)
       printf ("Note: some watchdog devices don't support setting exact timeout values.\n");
   }
@@ -101,14 +102,16 @@ main ()
 
     sleep (3);
 
+    printf ("ping ");
     if (ioctl (fd, WDIOC_KEEPALIVE, 0) == -1)
-      perror ("ioctl: WDIOC_KEEPALIVE");
-    printf ("* ");
+      perror ("\nioctl: WDIOC_KEEPALIVE");
   }
 
   printf ("\n");
+  printf ("\n");
   printf ("Stopping pings.\n");
-  printf ("The watchdog action should happen at around %d mark.\n");
+  printf ("The watchdog action should happen at approximately %d second mark.\n",
+          WATCHDOG_TIMEOUT);
   printf ("\n");
 
   time (&start_t);