GCC Code Coverage Report


Directory: ./
File: tests/libsafety/safety_helpers.h
Date: 2025-02-27 09:09:49
Exec Total Coverage
Lines: 85 115 73.9%
Functions: 31 41 75.6%
Branches: 4 16 25.0%

Line Branch Exec Source
1 72 void safety_tick_current_safety_config() {
2 72 safety_tick(&current_safety_config);
3 72 }
4
5 72 bool safety_config_valid() {
6
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if (current_safety_config.rx_checks_len <= 0) {
7 printf("missing RX checks\n");
8 return false;
9 }
10
11
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 for (int i = 0; i < current_safety_config.rx_checks_len; i++) {
12 72 const RxCheck addr = current_safety_config.rx_checks[i];
13
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
72 bool valid = addr.status.msg_seen && !addr.status.lagging && addr.status.valid_checksum && (addr.status.wrong_counters < MAX_WRONG_COUNTERS) && addr.status.valid_quality_flag;
14
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if (!valid) {
15 // printf("i %d seen %d lagging %d valid checksum %d wrong counters %d valid quality flag %d\n", i, addr.status.msg_seen, addr.status.lagging, addr.status.valid_checksum, addr.status.wrong_counters, addr.status.valid_quality_flag);
16 72 return false;
17 }
18 }
19 return true;
20 }
21
22 930361 void set_controls_allowed(bool c){
23 930361 controls_allowed = c;
24 930361 }
25
26 12232 void set_alternative_experience(int mode){
27 12232 alternative_experience = mode;
28 12232 }
29
30 608328 void set_relay_malfunction(bool c){
31 608328 relay_malfunction = c;
32 608328 }
33
34 56878 bool get_controls_allowed(void){
35 56878 return controls_allowed;
36 }
37
38 int get_alternative_experience(void){
39 return alternative_experience;
40 }
41
42 608344 bool get_relay_malfunction(void){
43 608344 return relay_malfunction;
44 }
45
46 334 bool get_gas_pressed_prev(void){
47 334 return gas_pressed_prev;
48 }
49
50 void set_gas_pressed_prev(bool c){
51 gas_pressed_prev = c;
52 }
53
54 553 bool get_brake_pressed_prev(void){
55 553 return brake_pressed_prev;
56 }
57
58 15 bool get_regen_braking_prev(void){
59 15 return regen_braking_prev;
60 }
61
62 404 bool get_cruise_engaged_prev(void){
63 404 return cruise_engaged_prev;
64 }
65
66 void set_cruise_engaged_prev(bool engaged){
67 cruise_engaged_prev = engaged;
68 }
69
70 291 bool get_vehicle_moving(void){
71 291 return vehicle_moving;
72 }
73
74 bool get_acc_main_on(void){
75 return acc_main_on;
76 }
77
78 2236 int get_vehicle_speed_min(void){
79 2236 return vehicle_speed.min;
80 }
81
82 2236 int get_vehicle_speed_max(void){
83 2236 return vehicle_speed.max;
84 }
85
86 int get_vehicle_speed_last(void){
87 return vehicle_speed.values[0];
88 }
89
90 7927 int get_current_safety_mode(void){
91 7927 return current_safety_mode;
92 }
93
94 7927 int get_current_safety_param(void){
95 7927 return current_safety_param;
96 }
97
98 15025 void set_timer(uint32_t t){
99 15025 timer.CNT = t;
100 15025 }
101
102 45268 void set_torque_meas(int min, int max){
103 45268 torque_meas.min = min;
104 45268 torque_meas.max = max;
105 45268 }
106
107 30 int get_torque_meas_min(void){
108 30 return torque_meas.min;
109 }
110
111 30 int get_torque_meas_max(void){
112 30 return torque_meas.max;
113 }
114
115 void set_torque_driver(int min, int max){
116 torque_driver.min = min;
117 torque_driver.max = max;
118 }
119
120 106 int get_torque_driver_min(void){
121 106 return torque_driver.min;
122 }
123
124 106 int get_torque_driver_max(void){
125 106 return torque_driver.max;
126 }
127
128 215246 void set_rt_torque_last(int t){
129 215246 rt_torque_last = t;
130 215246 }
131
132 215246 void set_desired_torque_last(int t){
133 215246 desired_torque_last = t;
134 215246 }
135
136 67384 void set_desired_angle_last(int t){
137 67384 desired_angle_last = t;
138 67384 }
139
140 int get_desired_angle_last(void){
141 return desired_angle_last;
142 }
143
144 void set_angle_meas(int min, int max){
145 angle_meas.min = min;
146 angle_meas.max = max;
147 }
148
149 30012 int get_angle_meas_min(void){
150 30012 return angle_meas.min;
151 }
152
153 30012 int get_angle_meas_max(void){
154 30012 return angle_meas.max;
155 }
156
157
158 // ***** car specific helpers *****
159
160 14 void set_honda_alt_brake_msg(bool c){
161 14 honda_alt_brake_msg = c;
162 14 }
163
164 void set_honda_bosch_long(bool c){
165 honda_bosch_long = c;
166 }
167
168 int get_honda_hw(void) {
169 return honda_hw;
170 }
171
172 8 void set_honda_fwd_brake(bool c){
173 8 honda_fwd_brake = c;
174 8 }
175
176 1028 bool get_honda_fwd_brake(void){
177 1028 return honda_fwd_brake;
178 }
179
180 8685 void init_tests(void){
181 8685 safety_mode_cnt = 2U; // avoid ignoring relay_malfunction logic
182 8685 alternative_experience = 0;
183 8685 set_timer(0);
184 8685 ts_steer_req_mismatch_last = 0;
185 8685 valid_steer_req_count = 0;
186 8685 invalid_steer_req_count = 0;
187 8685 }
188