summaryrefslogtreecommitdiff
path: root/common/usbc/usb_tc_ctvpd_sm.c
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2019-08-07 12:49:34 -0600
committerCommit Bot <commit-bot@chromium.org>2019-08-20 16:05:47 +0000
commit7a07137ff8861509b5942a82de1c46b376c6057a (patch)
tree40ec190a005c76d7be409ac20367486270e7b848 /common/usbc/usb_tc_ctvpd_sm.c
parent72405bceb4f8234ad1dc4a64041c0037abd57a21 (diff)
downloadchrome-ec-7a07137ff8861509b5942a82de1c46b376c6057a.tar.gz
test: add sanity check for existing state machines
We want to ensure that our usb state machines - do not have any cycles - do not have any completely empty states - have names for every print statement if called These new unit tests allow us to have build-times checks for the above. BRANCH=none BUG=none TEST=tests pass. Made each test fail locally to ensure that tests were actually working. Change-Id: Idd2c4d69e83cf38c97278edd1727d86b52a85db9 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1744657 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'common/usbc/usb_tc_ctvpd_sm.c')
-rw-r--r--common/usbc/usb_tc_ctvpd_sm.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/common/usbc/usb_tc_ctvpd_sm.c b/common/usbc/usb_tc_ctvpd_sm.c
index f837b27dbc..46be033514 100644
--- a/common/usbc/usb_tc_ctvpd_sm.c
+++ b/common/usbc/usb_tc_ctvpd_sm.c
@@ -231,7 +231,7 @@ static enum usb_tc_state get_last_state_tc(const int port)
return tc[port].ctx.previous - &tc_states[0];
}
-static void print_current_state(const int port)
+test_mockable_static void print_current_state(const int port)
{
CPRINTS("C%d: %s", port, tc_state_names[get_state_tc(port)]);
}
@@ -1684,3 +1684,15 @@ static const struct usb_state tc_states[] = {
.parent = &tc_states[TC_HOST_RP3_CT_RD],
},
};
+
+#ifdef TEST_BUILD
+const struct test_sm_data test_tc_sm_data[] = {
+ {
+ .base = tc_states,
+ .size = ARRAY_SIZE(tc_states),
+ .names = tc_state_names,
+ .names_size = ARRAY_SIZE(tc_state_names),
+ },
+};
+const int test_tc_sm_data_size = ARRAY_SIZE(test_tc_sm_data);
+#endif