1 /* This tests the ux_host_class_hub_status_get.c API. */ 2 3 #include "usbx_ux_test_hub.h" 4 5 #ifdef CTEST test_application_define(void * first_unused_memory)6void test_application_define(void *first_unused_memory) 7 #else 8 void usbx_ux_host_class_hub_status_get_test_application_define(void *first_unused_memory) 9 #endif 10 { 11 12 /* Inform user. */ 13 printf("Running ux_host_class_hub_status_get Test........................... "); 14 15 stepinfo("\n"); 16 17 initialize_hub(first_unused_memory); 18 } 19 post_init_host()20static void post_init_host() 21 { 22 23 USHORT port_status; 24 USHORT port_change; 25 26 /** Test sending request to port 0 (hub itself). **/ 27 28 /* Make get port status action for returning immediately. */ 29 30 UX_TEST_SETUP get_port_status_setup = {0}; 31 get_port_status_setup.ux_test_setup_request = UX_HOST_CLASS_HUB_GET_STATUS; 32 get_port_status_setup.ux_test_setup_type = UX_REQUEST_IN | UX_REQUEST_TYPE_CLASS | UX_REQUEST_TARGET_DEVICE; 33 get_port_status_setup.ux_test_setup_index = 0; 34 35 UX_TEST_ACTION get_port_status_match_action = {0}; 36 get_port_status_match_action.usbx_function = UX_TEST_OVERRIDE_UX_HCD_SIM_HOST_ENTRY; 37 get_port_status_match_action.function = UX_HCD_TRANSFER_REQUEST; 38 get_port_status_match_action.req_action = UX_TEST_SETUP_MATCH_REQUEST | UX_TEST_SETUP_MATCH_INDEX; 39 get_port_status_match_action.req_setup = &get_port_status_setup; 40 get_port_status_match_action.no_return = 1; 41 42 ux_test_add_action_to_main_list(get_port_status_match_action); 43 44 UX_TEST_CHECK_SUCCESS(_ux_host_class_hub_status_get(g_hub_host, 0, &port_status, &port_change)); 45 46 UX_TEST_ASSERT(ux_test_check_actions_empty() == UX_TRUE); 47 48 /** Test memory allocation failure. **/ 49 50 ux_test_utility_sim_mem_allocate_until_flagged(0, UX_REGULAR_MEMORY); 51 ux_test_add_action_to_main_list(create_error_match_action(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_UTILITY, UX_MEMORY_INSUFFICIENT)); 52 UX_TEST_CHECK_NOT_SUCCESS(_ux_host_class_hub_status_get(g_hub_host, 0, &port_status, &port_change)); 53 } 54 post_init_device()55static void post_init_device() 56 { 57 }