1 /* This tests the case where the hub device's enumeration keeps failing. The
2    specific test case is in ux_host_class_hub_port_change_connection_process.c. */
3 
4 #include "usbx_ux_test_hub.h"
5 
6 static UINT num_insertions;
7 static UINT num_removals;
8 
9 /* Define what the initial system looks like.  */
10 
11 #ifdef CTEST
test_application_define(void * first_unused_memory)12 void test_application_define(void *first_unused_memory)
13 #else
14 void usbx_hub_hub_device_enumeration_keeps_failing_test_application_define(void *first_unused_memory)
15 #endif
16 {
17 
18     /* Inform user.  */
19     printf("Running Hub Hub Device Enumeration Kepps Failing Test............... ");
20 
21     stepinfo("\n");
22 
23     initialize_hub(first_unused_memory);
24 }
25 
post_init_host()26 static void post_init_host()
27 {
28 #if UX_MAX_DEVICES > 1
29 int i;
30 
31     /* We do this by having the semaphore create for EP0 fail multiple times. */
32 
33     /* Create action to make semaphore creation fail. */
34     UX_TEST_ACTION sem_create_fail_action = {0};
35     sem_create_fail_action.usbx_function = UX_TEST_OVERRIDE_TX_SEMAPHORE_CREATE;
36     sem_create_fail_action.semaphore_name = "ux_host_endpoint0_semaphore";
37     sem_create_fail_action.no_return = 0;
38     sem_create_fail_action.status = UX_ERROR;
39 
40     for (i = 0; i < UX_HOST_CLASS_HUB_ENUMERATION_RETRY; i++)
41     {
42         ux_test_add_action_to_main_list(sem_create_fail_action);
43         ux_test_add_action_to_main_list(create_error_match_action(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_UTILITY, UX_ERROR));
44     }
45     ux_test_add_action_to_main_list(create_error_match_action(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ROOT_HUB, UX_DEVICE_ENUMERATION_FAILURE));
46 
47     /* Tell the host that there's a device connection. */
48     connect_device_to_hub();
49 
50     /* Wait for empty actions. */
51     UX_TEST_CHECK_SUCCESS(ux_test_wait_for_empty_actions());
52 #endif
53 }
54 
post_init_device()55 static void post_init_device()
56 {
57 }