test2.c 833 B

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