test2.c 854 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <software_watchdog.h>
  4. // in this test it is expected that the watchdog_timeout_cb not called
  5. int test_result = 0;
  6. void watchdog_timeout_cb(void *data)
  7. {
  8. SoftwareWatchdog *watchdog = data;
  9. printf("!! watchdog_timeout_cb called !! \n");
  10. fflush(stdout);
  11. test_result = -1;
  12. }
  13. int main(void){
  14. printHelloWorld();
  15. SoftwareWatchdog watchdog1;
  16. struct timespec timeout;
  17. timeout.tv_nsec = 100*1000000;
  18. timeout.tv_sec = 1;
  19. swd_setup(&watchdog1, "watchdog1", watchdog_timeout_cb, timeout, NULL);
  20. swd_enable(&watchdog1);
  21. printf("Main: Sleeping for some seconds:\n");
  22. for (int i = 3; i > 0; i--) {
  23. swd_kick(&watchdog1);
  24. printf("%d\n", i);
  25. fflush(stdout);
  26. sleep(1);
  27. }
  28. return test_result;
  29. }