# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+CC = gcc
+CFLAGS = -Wall
+
all: watchdog-test
clean:
rm -f watchdog-test *~
watchdog-test: watchdog-test.o
- $(CC) -static $< -o $@
+ $(CC) $(CFLAGS) -static $< -o $@
+
+.c.o:
+ $(CC) $(CFLAGS) -c $< -o $@
action can be: 'reset', 'shutdown', 'poweroff', 'pause',
'none' or 'dump'
-(4) Install the statically linked watchdog-test binary in a Linux
+(4) Install the statically linked watchdog-test binary in the Linux
guest.
-(5) Boot up the guest. Log into the guest, run the watchdog-test
-binary (as root), and follow instructions.
+(5) Boot up the guest. Log into the guest.
+
+(6) [ib700 only] You have to load the ib700wdt kernel module manually
+since it's an ISA device:
+
+ sudo modprobe ib700wdt
+
+(7) Run the watchdog-test binary (as root), and follow instructions.
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <time.h>
#include <fcntl.h>
int
main ()
{
- int fd, i;
+ int fd;
int timeout;
char input[256];
time_t start_t, t;
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);
}
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");
}
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);