test1.c 801 B

12345678910111213141516171819202122232425262728293031323334
  1. #include <stdio.h>
  2. #include <software_watchdog.h>
  3. // in this test it is expected that the watchdog_timeout_cb is called
  4. int test_result = -1;
  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 = 0;
  11. }
  12. int main(void){
  13. printHelloWorld();
  14. SoftwareWatchdog watchdog1;
  15. struct timespec timeout;
  16. timeout.tv_nsec = 100*1000000;
  17. timeout.tv_sec = 2;
  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. printf("%d\n", i);
  23. fflush(stdout);
  24. sleep(1);
  25. }
  26. return test_result;
  27. }