1 /* This tests general cases in the mac address string like hexadecimal values. */
2 
3 #include "usbx_ux_test_cdc_ecm.h"
4 
5 static unsigned char mac_address_test_string_framework[] = {
6 
7     /* Manufacturer string descriptor : Index 1 - "Express Logic" */
8         0x09, 0x04, 0x01, 0x0c,
9         0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x20, 0x4c,
10         0x6f, 0x67, 0x69, 0x63,
11 
12     /* Product string descriptor : Index 2 - "EL CDCECM Device" */
13         0x09, 0x04, 0x02, 0x10,
14         0x45, 0x4c, 0x20, 0x43, 0x44, 0x43, 0x45, 0x43,
15         0x4d, 0x20, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65,
16 
17     /* Serial Number string descriptor : Index 3 - "0001" */
18         0x09, 0x04, 0x03, 0x04,
19         0x30, 0x30, 0x30, 0x31,
20 
21     /* MAC Address string descriptor : Index 4 - "001E5841B878" */
22         0x09, 0x04, 0x04, 0x0C,
23         'A', 'A', /* Test capital upper and lower element. */
24         '0', '1',
25         '2', '3',
26         '4', 'b',
27         'c', 'D',
28         'e', 'f',
29 
30 };
31 
32 static DEVICE_INIT_DATA device_init_data = {
33     .string_framework = mac_address_test_string_framework,
34     .string_framework_length = sizeof(mac_address_test_string_framework),
35 };
36 
37 /* Define what the initial system looks like.  */
38 #ifdef CTEST
test_application_define(void * first_unused_memory)39 void test_application_define(void *first_unused_memory)
40 #else
41 void usbx_cdc_ecm_mac_address_test_application_define(void *first_unused_memory)
42 #endif
43 {
44 
45     /* Inform user.  */
46     printf("Running CDC-ECM Mac Address Test.................................... ");
47 
48     stepinfo("\n");
49 
50     ux_test_cdc_ecm_initialize_use_framework(first_unused_memory, &device_init_data);
51 }
52 
post_init_host()53 static void post_init_host()
54 {
55     /* Ensure the mac address is correct. */
56     UX_TEST_ASSERT(cdc_ecm_host->ux_host_class_cdc_ecm_node_id[0] == 0xaa);
57     UX_TEST_ASSERT(cdc_ecm_host->ux_host_class_cdc_ecm_node_id[1] == 0x01);
58     UX_TEST_ASSERT(cdc_ecm_host->ux_host_class_cdc_ecm_node_id[2] == 0x23);
59     UX_TEST_ASSERT(cdc_ecm_host->ux_host_class_cdc_ecm_node_id[3] == 0x4b);
60     UX_TEST_ASSERT(cdc_ecm_host->ux_host_class_cdc_ecm_node_id[4] == 0xcd);
61     UX_TEST_ASSERT(cdc_ecm_host->ux_host_class_cdc_ecm_node_id[5] == 0xef);
62 
63     /* Configuration descriptor invalid while parsing MAC address */
64     /* descriptor_length < 3  */
65     default_device_framework[18] = 0;
66     UX_TEST_ASSERT(UX_DESCRIPTOR_CORRUPTED == _ux_host_class_cdc_ecm_mac_address_get(cdc_ecm_host));
67     /* descriptor_length > total_configuration_length  */
68     default_device_framework[18] = 0xFF;
69     UX_TEST_ASSERT(UX_DESCRIPTOR_CORRUPTED == _ux_host_class_cdc_ecm_mac_address_get(cdc_ecm_host));
70     /* Restore.  */
71     default_device_framework[18] = 9;
72     UX_TEST_ASSERT(UX_SUCCESS == _ux_host_class_cdc_ecm_mac_address_get(cdc_ecm_host));
73 
74 }
75 
post_init_device()76 static void post_init_device()
77 {
78 }