1 /* This tests the case where the GET_STATUS request has an invalid actual length. */
2 
3 #include "usbx_ux_test_hub.h"
4 
5 static DEVICE_INIT_DATA device_init_data = {
6     .dont_enumerate = 1
7 };
8 
9 #ifdef CTEST
test_application_define(void * first_unused_memory)10 void test_application_define(void *first_unused_memory)
11 #else
12 void usbx_hub_get_status_fails_during_configuration_test_application_define(void *first_unused_memory)
13 #endif
14 {
15 
16     /* Inform user.  */
17     printf("Running Hub Get Status Fails During Configuration Test.............. ");
18 
19     stepinfo("\n");
20 
21     initialize_hub_with_device_init_data(first_unused_memory, &device_init_data);
22 }
23 
post_init_host()24 static void post_init_host()
25 {
26 
27 int i;
28 
29     /* Setup setup for matching the GET_STATUS request. */
30     UX_TEST_SETUP setup = {0};
31     setup.ux_test_setup_request = UX_GET_STATUS;
32     setup.ux_test_setup_type = UX_REQUEST_IN | UX_REQUEST_TYPE_STANDARD | UX_REQUEST_TARGET_DEVICE;
33     setup.ux_test_setup_value = 0;
34     setup.ux_test_setup_index = 0;
35 
36     /* Make action to make transfer fail. */
37     UX_TEST_ACTION action = {0};
38     action.usbx_function = UX_TEST_OVERRIDE_UX_HCD_SIM_HOST_ENTRY;
39     action.function = UX_HCD_TRANSFER_REQUEST;
40     action.req_action = UX_TEST_SETUP_MATCH_REQUEST | UX_TEST_SIM_REQ_ANSWER;
41     action.req_setup = &setup;
42     action.req_ep_address = 0x81;
43     action.req_actual_len = 1;
44     action.no_return = 0;
45     action.status = UX_SUCCESS;
46 
47     /* We expect error to happen multiple times. */
48     for (i = 0; i < UX_RH_ENUMERATION_RETRY; i++)
49     {
50         ux_test_add_action_to_main_list(action);
51         ux_test_add_action_to_main_list(create_error_match_action(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_HUB, UX_CONNECTION_INCOMPATIBLE));
52     }
53     ux_test_add_action_to_main_list(create_error_match_action(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ROOT_HUB, UX_DEVICE_ENUMERATION_FAILURE));
54 
55     /* Enumerate. */
56     UX_TEST_CHECK_SUCCESS(ux_host_stack_hcd_register(_ux_system_host_hcd_simulator_name, _ux_test_hcd_sim_host_initialize, 0, 0));
57     ux_test_wait_for_enum_thread_completion();
58 
59     /* Ensure all expected actions occurred. */
60     UX_TEST_ASSERT(ux_test_check_actions_empty());
61     UX_TEST_ASSERT(g_hub_host_from_system_change_function == UX_NULL);
62 }
63 
post_init_device()64 static void post_init_device()
65 {
66 }