Added fwd hook coverage test for Cadillac and created default_fwd_hook instead of nooutput and alloutput, which were teh same
parent
264de67fe8
commit
242b3305fe
|
@ -127,5 +127,5 @@ const safety_hooks cadillac_hooks = {
|
|||
.tx = cadillac_tx_hook,
|
||||
.tx_lin = nooutput_tx_lin_hook,
|
||||
.ignition = cadillac_ign_hook,
|
||||
.fwd = alloutput_fwd_hook,
|
||||
.fwd = default_fwd_hook,
|
||||
};
|
||||
|
|
|
@ -18,7 +18,7 @@ static int nooutput_tx_lin_hook(int lin_num, uint8_t *data, int len) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static int nooutput_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
|
||||
static int default_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ const safety_hooks nooutput_hooks = {
|
|||
.tx = nooutput_tx_hook,
|
||||
.tx_lin = nooutput_tx_lin_hook,
|
||||
.ignition = default_ign_hook,
|
||||
.fwd = nooutput_fwd_hook,
|
||||
.fwd = default_fwd_hook,
|
||||
};
|
||||
|
||||
// *** all output safety mode ***
|
||||
|
@ -45,15 +45,11 @@ static int alloutput_tx_lin_hook(int lin_num, uint8_t *data, int len) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static int alloutput_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
const safety_hooks alloutput_hooks = {
|
||||
.init = alloutput_init,
|
||||
.rx = default_rx_hook,
|
||||
.tx = alloutput_tx_hook,
|
||||
.tx_lin = alloutput_tx_lin_hook,
|
||||
.ignition = default_ign_hook,
|
||||
.fwd = alloutput_fwd_hook,
|
||||
.fwd = default_fwd_hook,
|
||||
};
|
||||
|
|
|
@ -31,5 +31,5 @@ const safety_hooks elm327_hooks = {
|
|||
.tx = elm327_tx_hook,
|
||||
.tx_lin = elm327_tx_lin_hook,
|
||||
.ignition = default_ign_hook,
|
||||
.fwd = nooutput_fwd_hook,
|
||||
.fwd = default_fwd_hook,
|
||||
};
|
||||
|
|
|
@ -89,5 +89,5 @@ const safety_hooks ford_hooks = {
|
|||
.tx = ford_tx_hook,
|
||||
.tx_lin = nooutput_tx_lin_hook,
|
||||
.ignition = default_ign_hook,
|
||||
.fwd = nooutput_fwd_hook,
|
||||
.fwd = default_fwd_hook,
|
||||
};
|
||||
|
|
|
@ -240,5 +240,5 @@ const safety_hooks gm_hooks = {
|
|||
.tx = gm_tx_hook,
|
||||
.tx_lin = nooutput_tx_lin_hook,
|
||||
.ignition = gm_ign_hook,
|
||||
.fwd = nooutput_fwd_hook,
|
||||
.fwd = default_fwd_hook,
|
||||
};
|
||||
|
|
|
@ -34,6 +34,13 @@ class TestCadillacSafety(unittest.TestCase):
|
|||
cls.safety.safety_set_mode(6, 0)
|
||||
cls.safety.init_tests_cadillac()
|
||||
|
||||
def _send_msg(self, bus, addr, length):
|
||||
to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *')
|
||||
to_send[0].RIR = addr << 21
|
||||
to_send[0].RDTR = length
|
||||
to_send[0].RDTR = bus << 4
|
||||
return to_send
|
||||
|
||||
def _set_prev_torque(self, t):
|
||||
self.safety.set_cadillac_desired_torque_last(t)
|
||||
self.safety.set_cadillac_rt_torque_last(t)
|
||||
|
@ -174,5 +181,16 @@ class TestCadillacSafety(unittest.TestCase):
|
|||
self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(sign * (MAX_RT_DELTA + 1))))
|
||||
|
||||
|
||||
def test_fwd_hook(self):
|
||||
# nothing allowed
|
||||
buss = range(0x0, 0x3)
|
||||
msgs = range(0x1, 0x800)
|
||||
|
||||
for b in buss:
|
||||
for m in msgs:
|
||||
# assume len 8
|
||||
self.assertEqual(-1, self.safety.safety_fwd_hook(b, self._send_msg(b, m, 8)))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue