MCU
Loading...
Searching...
No Matches
safety_system_test.h
Go to the documentation of this file.
1#ifndef __SAFETY_SYSTEM_TEST_H__
2#define __SAFETY_SYSTEM_TEST_H__
3
4#include <gtest/gtest.h>
5#include "AMSInterface.h"
6#include "WatchdogInterface.h"
7#include "SafetySystem.h"
8#include "SysClock.h"
9
10
11TEST(SafetySystemTest, test_software_shutdown) {
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}
59
60
61
62
63#endif /* __SAFETY_SYSTEM_TEST_H__ */
this class is for interfacing with the AMS (accumulator management system)
Definition: AMSInterface.h:27
void software_shutdown(const SysTick_s &tick)
bool get_software_is_ok()
void init(unsigned long curr_millis)
TEST(SafetySystemTest, test_software_shutdown)
WatchdogInterface wd_interface(WATCHDOG_INPUT)
SafetySystem safety_system & ams_interface
Definition: main.cpp:219