MCU
Loading...
Searching...
No Matches
Functions
safety_system_test.h File Reference
#include <gtest/gtest.h>
#include "AMSInterface.h"
#include "WatchdogInterface.h"
#include "SafetySystem.h"
#include "SysClock.h"
Include dependency graph for safety_system_test.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 TEST (SafetySystemTest, test_software_shutdown)
 

Function Documentation

◆ TEST()

TEST ( SafetySystemTest  ,
test_software_shutdown   
)

Definition at line 11 of file safety_system_test.h.

11 {
12 // Initial tick
13 SysTick_s tick_zero;
14 tick_zero.millis = 100L;
15 tick_zero.micros = 100000L;
16
17 AMSInterface ams_interface(0, 0, 0, 0, 0, 0);
19 SafetySystem safety_system(&ams_interface, &wd_interface);
20
21 ams_interface.init(tick_zero);
22 wd_interface.init(tick_zero.millis);
23 safety_system.init();
24
25 ASSERT_EQ(safety_system.get_software_is_ok(), true);
26
27 // 10 milliseconds later
28 SysTick_s tick_one;
29 tick_one.millis = 110L;
30 tick_one.micros = 110000L;
31 ams_interface.set_heartbeat(tick_one.millis);
32
33 safety_system.software_shutdown(tick_one);
34
35 ASSERT_EQ(safety_system.get_software_is_ok(), true);
36
37 // 1999 milliseconds later (should be within 2000ms window)
38 SysTick_s tick_two;
39 tick_two.millis = 2109L;
40 tick_two.micros = 2109000L;
41
42 safety_system.software_shutdown(tick_two);
43
44 ASSERT_EQ(ams_interface.heartbeat_received(tick_two.millis), true);
45
46
47 // 1999 milliseconds later (should fail)
48 SysTick_s tick_three;
49 tick_three.millis = 2110L;
50 tick_three.micros = 2110000L;
51
52 safety_system.software_shutdown(tick_three);
53
54 ASSERT_EQ(ams_interface.heartbeat_received(tick_three.millis), false);
55
56 ASSERT_EQ(safety_system.get_software_is_ok(), false);
57
58}
this class is for interfacing with the AMS (accumulator management system)
Definition: AMSInterface.h:27
void software_shutdown(const SysTick_s &tick)
void init(unsigned long curr_millis)
WatchdogInterface wd_interface(WATCHDOG_INPUT)
SafetySystem safety_system & ams_interface
Definition: main.cpp:219