Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
watchdog_tests.cpp File Reference
#include <sysio/vm/watchdog.hpp>
#include <atomic>
#include <chrono>
#include <catch2/catch.hpp>
Include dependency graph for watchdog_tests.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("watchdog interrupt", "[watchdog_interrupt]")
 
 TEST_CASE ("watchdog no interrupt", "[watchdog_no_interrupt]")
 

Function Documentation

◆ TEST_CASE() [1/2]

TEST_CASE ( "watchdog interrupt" ,
"" [watchdog_interrupt] )

Definition at line 9 of file watchdog_tests.cpp.

9 {
10 std::atomic<bool> okay = false;
11 watchdog w{std::chrono::milliseconds(50)};
12 {
13 auto g = w.scoped_run([&]() { okay = true; });
14 std::this_thread::sleep_for(std::chrono::milliseconds(100));
15 }
16 CHECK(okay);
17}
Triggers a callback after a given time elapses.
Definition watchdog.hpp:13
#define CHECK(cond)
Definition util.h:80

◆ TEST_CASE() [2/2]

TEST_CASE ( "watchdog no interrupt" ,
"" [watchdog_no_interrupt] )

Definition at line 19 of file watchdog_tests.cpp.

19 {
20 std::atomic<bool> okay = true;
21 watchdog w{std::chrono::milliseconds(50)};
22 {
23 auto g = w.scoped_run([&]() { okay = false; });
24 } // the guard goes out of scope here, cancelling the timer
25 std::this_thread::sleep_for(std::chrono::milliseconds(100));
26 CHECK(okay);
27}