1 /* This tests the case where the mac address string is too long. This is an
2 error. */
3
4 #include "usbx_ux_test_cdc_ecm.h"
5
6 static unsigned char invalid_mac_address_string_length[] = {
7
8 /* Manufacturer string descriptor : Index 1 - "Express Logic" */
9 0x09, 0x04, 0x01, 0x0c,
10 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x20, 0x4c,
11 0x6f, 0x67, 0x69, 0x63,
12
13 /* Product string descriptor : Index 2 - "EL CDCECM Device" */
14 0x09, 0x04, 0x02, 0x10,
15 0x45, 0x4c, 0x20, 0x43, 0x44, 0x43, 0x45, 0x43,
16 0x4d, 0x20, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65,
17
18 /* Serial Number string descriptor : Index 3 - "0001" */
19 0x09, 0x04, 0x03, 0x04,
20 0x30, 0x30, 0x30, 0x31,
21
22 /* MAC Address string descriptor : Index 4 - "001E5841B878" */
23 0x09, 0x04, 0x04,
24 0x1b, /* This byte is the length of the string. It just needs to be greater than 26 (look in mac_address_get.c). */
25 0x30, 0x30, 0x31, 0x45, 0x35, 0x38,
26 0x34, 0x31, 0x42, 0x38, 0x37, 0x38,
27 0x30, 0x30, 0x31, 0x45, 0x35, 0x38,
28 0x34, 0x31, 0x42, 0x38, 0x37, 0x38,
29 0x37, 0x38, 0x37,
30
31 };
32
33 static DEVICE_INIT_DATA device_init_data = {
34 .string_framework = invalid_mac_address_string_length,
35 .string_framework_length = sizeof(invalid_mac_address_string_length),
36 .dont_register_hcd = 1,
37 };
38
39 /* Define what the initial system looks like. */
40 #ifdef CTEST
test_application_define(void * first_unused_memory)41 void test_application_define(void *first_unused_memory)
42 #else
43 void usbx_cdc_ecm_mac_address_invalid_length_test_application_define(void *first_unused_memory)
44 #endif
45 {
46
47 /* Inform user. */
48 printf("Running CDC-ECM Mac Address Invalid Length Test..................... ");
49
50 stepinfo("\n");
51
52 ux_test_cdc_ecm_initialize_use_framework(first_unused_memory, &device_init_data);
53 }
54
post_init_host()55 static void post_init_host()
56 {
57
58 int i;
59
60 /* We expect this to fail multiple times since enumeration tries multiple times. */
61 for (i = 0; i < UX_RH_ENUMERATION_RETRY; i++)
62 {
63
64 ux_test_add_action_to_main_list(create_error_match_action(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_DESCRIPTOR_CORRUPTED));
65 }
66 ux_test_add_action_to_main_list(create_error_match_action(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ROOT_HUB, UX_DEVICE_ENUMERATION_FAILURE));
67
68 /* Enumerate. */
69 UX_TEST_CHECK_SUCCESS(ux_host_stack_hcd_register(_ux_system_host_hcd_simulator_name, _ux_test_hcd_sim_host_initialize, 0, 0));
70
71 /* The HCD init function put()s the HCD semaphore, so we can do this here. */
72 ux_test_wait_for_enum_thread_completion();
73
74 /* Enumeration should've failed. */
75 UX_TEST_ASSERT(ux_test_check_actions_empty());
76 UX_TEST_ASSERT(cdc_ecm_host_from_system_change_function == UX_NULL);
77 }
78
post_init_device()79 static void post_init_device()
80 {
81 }