1 /* This tests the case where the CDC-ECM thread creation fails. */
2
3 #include "usbx_ux_test_cdc_ecm.h"
4
5 static DEVICE_INIT_DATA device_init_data = {
6 .framework = default_device_framework,
7 .framework_length = sizeof(default_device_framework),
8 .dont_register_hcd = 1,
9 };
10
11 /* Define what the initial system looks like. */
12 #ifdef CTEST
test_application_define(void * first_unused_memory)13 void test_application_define(void *first_unused_memory)
14 #else
15 void usbx_cdc_ecm_host_packet_pool_create_fail_test_application_define(void *first_unused_memory)
16 #endif
17 {
18
19 /* Inform user. */
20 printf("Running CDC-ECM Host Packet Pool Create Test........................ ");
21 printf("Deprecated\n");
22 test_control_return(0);
23 return;
24
25 stepinfo("\n");
26
27 ux_test_cdc_ecm_initialize_use_framework(first_unused_memory, &device_init_data);
28 }
29
post_init_host()30 static void post_init_host()
31 {
32
33 int i;
34
35 /* Enumerate first so we can initialize memory test. */
36 UX_TEST_CHECK_SUCCESS(ux_host_stack_hcd_register(_ux_system_host_hcd_simulator_name, _ux_test_hcd_sim_host_initialize, 0, 0));
37
38 /* The HCD init function put()s the HCD semaphore, so we can do this here. */
39 ux_test_wait_for_enum_thread_completion();
40
41 /* We want at least one memory test. */
42 ux_test_memory_test_initialize();
43
44 /* Disconnect so we can setup test. */
45 ux_test_disconnect_host_wait_for_enum_completion();
46
47 UX_TEST_ACTION packet_pool_create_fail_action = {0};
48 packet_pool_create_fail_action.usbx_function = UX_TEST_OVERRIDE_NX_PACKET_POOL_CREATE;
49 packet_pool_create_fail_action.name_ptr = "host CDC-ECM packet pool";
50 packet_pool_create_fail_action.no_return = 0;
51 packet_pool_create_fail_action.status = UX_ERROR;
52
53 for (i = 0; i < UX_RH_ENUMERATION_RETRY; i++)
54 {
55 ux_test_add_action_to_main_list(packet_pool_create_fail_action);
56 ux_test_add_action_to_main_list(create_error_match_action(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ENUMERATOR, UX_ERROR));
57 }
58 ux_test_add_action_to_main_list(create_error_match_action(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ROOT_HUB, UX_DEVICE_ENUMERATION_FAILURE));
59
60 /* Start enumeration. */
61 ux_test_connect_slave_and_host_wait_for_enum_completion();
62
63 /* Disconnect. Note that this also does the memory check. */
64 ux_test_disconnect_slave_and_host_wait_for_enum_completion();
65
66 UX_TEST_ASSERT(ux_test_check_actions_empty());
67 UX_TEST_ASSERT(cdc_ecm_host_from_system_change_function == UX_NULL);
68 }
69
post_init_device()70 static void post_init_device()
71 {
72 }