diff options
Diffstat (limited to 'test/usb_prl_old.c')
-rw-r--r-- | test/usb_prl_old.c | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/test/usb_prl_old.c b/test/usb_prl_old.c index 8a2dea0fd0..e75b81fde2 100644 --- a/test/usb_prl_old.c +++ b/test/usb_prl_old.c @@ -71,6 +71,13 @@ enum usb_prl_hr_state prl_hr_get_state(const int port); enum usb_rch_state rch_get_state(const int port); enum usb_tch_state tch_get_state(const int port); +#ifndef CONFIG_USB_PD_EXTENDED_MESSAGES +enum usb_rch_state rch_get_state(const int port) +{ + return RCH_WAIT_FOR_MESSAGE_FROM_PROTOCOL_LAYER; +} +#endif + static uint32_t test_data[] = { 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, @@ -379,7 +386,8 @@ static int simulate_receive_extended_data(int port, return 0; } - if (pd_port[port].mock_pe_message_received) { + if (IS_ENABLED(CONFIG_USB_PD_EXTENDED_MESSAGES) && + pd_port[port].mock_pe_message_received) { ccprintf("Mock pe msg received iteration (%d)\n", j); return 0; } @@ -402,6 +410,12 @@ static int simulate_receive_extended_data(int port, cycle_through_state_machine(port, 1, MSEC); inc_rx_id(port); + if (!IS_ENABLED(CONFIG_USB_PD_EXTENDED_MESSAGES)) { + if (pd_port[port].mock_pe_message_received) + return 1; + return 0; + } + /* * If no more data, do expected to get a chunk request */ @@ -1049,6 +1063,11 @@ static int test_send_extended_data_msg(void) int i; int port = PORT0; + if (!IS_ENABLED(CONFIG_USB_PD_EXTENDED_MESSAGES)) { + ccprints("CONFIG_USB_PD_EXTENDED_MESSAGES disabled; skipping"); + return EC_SUCCESS; + } + enable_prl(port, 1); /* @@ -1199,19 +1218,36 @@ static int test_receive_extended_data_msg(void) enable_prl(port, 1); - /* - * TEST: Receiving extended data message with 29 to 260 bytes - */ + if (IS_ENABLED(CONFIG_USB_PD_EXTENDED_MESSAGES)) { + /* + * TEST: Receiving extended data message with 29 to 260 bytes + */ - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); + task_wake(PD_PORT_TO_TASK_ID(port)); + task_wait_event(40 * MSEC); - TEST_EQ(rch_get_state(port), - RCH_WAIT_FOR_MESSAGE_FROM_PROTOCOL_LAYER, "%u"); + TEST_EQ(rch_get_state(port), + RCH_WAIT_FOR_MESSAGE_FROM_PROTOCOL_LAYER, "%u"); - for (len = 29; len <= 260; len++) + for (len = 29; len <= 260; len++) { + TEST_NE(simulate_receive_extended_data(port, + PD_DATA_BATTERY_STATUS, len), 0, "%d"); + } + } else { + /* + * TEST: Receiving unsupported extended data message and then + * subsequently receiving a support non-extended data message. + */ + task_wake(PD_PORT_TO_TASK_ID(port)); + task_wait_event(40 * MSEC); TEST_NE(simulate_receive_extended_data(port, - PD_DATA_BATTERY_STATUS, len), 0, "%d"); + PD_DATA_BATTERY_STATUS, 29), 0, "%d"); + + task_wake(PD_PORT_TO_TASK_ID(port)); + task_wait_event(40 * MSEC); + TEST_NE(simulate_receive_data(port, + PD_DATA_BATTERY_STATUS, 28), 0, "%d"); + } enable_prl(port, 0); @@ -1392,6 +1428,8 @@ void run_test(int argc, char **argv) /* TODO(shurst): More PD 2.0 Tests */ + ccprints("Starting PD 3.0 tests"); + /* Test PD 3.0 Protocol */ init_port(PORT0, PD_REV30); RUN_TEST(test_prl_reset); @@ -1418,4 +1456,3 @@ void run_test(int argc, char **argv) test_print_result(); } - |