MCU
Loading...
Searching...
No Matches
test
test_systems
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
11
TEST
(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);
18
WatchdogInterface
wd_interface
(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__ */
SafetySystem.h
AMSInterface
this class is for interfacing with the AMS (accumulator management system)
Definition:
AMSInterface.h:27
SafetySystem
Definition:
SafetySystem.h:9
SafetySystem::software_shutdown
void software_shutdown(const SysTick_s &tick)
Definition:
SafetySystem.cpp:16
SafetySystem::init
void init()
Definition:
SafetySystem.cpp:7
SafetySystem::get_software_is_ok
bool get_software_is_ok()
Definition:
SafetySystem.cpp:37
WatchdogInterface
Definition:
WatchdogInterface.h:9
WatchdogInterface::init
void init(unsigned long curr_millis)
Definition:
WatchdogInterface.cpp:4
TEST
TEST(SafetySystemTest, test_software_shutdown)
Definition:
safety_system_test.h:11
wd_interface
WatchdogInterface wd_interface(WATCHDOG_INPUT)
ams_interface
SafetySystem safety_system & ams_interface
Definition:
main.cpp:219
Generated by
1.9.5