1 /* This test tests the case where there is no control interface. */
2
3 #include "usbx_ux_test_cdc_ecm.h"
4
5 static unsigned char no_control_interface_framework[] = {
6
7 /* Device Descriptor */
8 0x12, /* bLength */
9 0x01, /* bDescriptorType */
10 0x10, 0x01, /* bcdUSB */
11 0xef, /* bDeviceClass - Depends on bDeviceSubClass */
12 0x02, /* bDeviceSubClass - Depends on bDeviceProtocol */
13 0x01, /* bDeviceProtocol - There's an IAD */
14 0x40, /* bMaxPacketSize0 */
15 0x70, 0x07, /* idVendor */
16 0x42, 0x10, /* idProduct */
17 0x00, 0x01, /* bcdDevice */
18 0x01, /* iManufacturer */
19 0x02, /* iProduct */
20 0x03, /* iSerialNumber */
21 0x01, /* bNumConfigurations */
22
23 /* Configuration Descriptor */
24 0x09, /* bLength */
25 0x02, /* bDescriptorType */
26 0x29, 0x00, /* wTotalLength */
27 0x02, /* bNumInterfaces */
28 0x01, /* bConfigurationValue */
29 0x00, /* iConfiguration */
30 0xc0, /* bmAttributes - Self-powered */
31 0x00, /* bMaxPower */
32
33 /* Interface Descriptor */
34 0x09, /* bLength */
35 0x04, /* bDescriptorType */
36 0x01, /* bInterfaceNumber */
37 0x00, /* bAlternateSetting */
38 0x00, /* bNumEndpoints */
39 0x0a, /* bInterfaceClass - CDC - Data */
40 0x00, /* bInterfaceSubClass - Should be 0x00 */
41 0x00, /* bInterfaceProtocol - No class specific protocol required */
42 0x00, /* iInterface */
43
44 /* Interface Descriptor */
45 0x09, /* bLength */
46 0x04, /* bDescriptorType */
47 0x01, /* bInterfaceNumber */
48 0x01, /* bAlternateSetting */
49 0x02, /* bNumEndpoints */
50 0x0a, /* bInterfaceClass - CDC - Data */
51 0x00, /* bInterfaceSubClass - Should be 0x00 */
52 0x00, /* bInterfaceProtocol - No class specific protocol required */
53 0x00, /* iInterface */
54
55 /* Endpoint Descriptor */
56 0x07, /* bLength */
57 0x05, /* bDescriptorType */
58 0x05, /* bEndpointAddress */
59 0x02, /* bmAttributes - Bulk */
60 0x40, 0x00, /* wMaxPacketSize */
61 0x00, /* bInterval */
62
63 /* Endpoint Descriptor */
64 0x07, /* bLength */
65 0x05, /* bDescriptorType */
66 0x86, /* bEndpointAddress */
67 0x02, /* bmAttributes - Bulk */
68 0x40, 0x00, /* wMaxPacketSize */
69 0x00, /* bInterval */
70
71 };
72
73 static DEVICE_INIT_DATA device_init_data = { no_control_interface_framework, sizeof(no_control_interface_framework), .dont_register_hcd = 1 };
74
75 /* Define what the initial system looks like. */
76 #ifdef CTEST
test_application_define(void * first_unused_memory)77 void test_application_define(void *first_unused_memory)
78 #else
79 void usbx_cdc_ecm_no_control_interface_test_application_define(void *first_unused_memory)
80 #endif
81 {
82
83 /* Inform user. */
84 printf("Running CDC-ECM No Control Interface Test........................... ");
85
86 stepinfo("\n");
87
88 ux_test_cdc_ecm_initialize_use_framework(first_unused_memory, &device_init_data);
89 }
90
post_init_host()91 static void post_init_host()
92 {
93
94 /* We expect this to fail multiple times since enumeration tries multiple times. */
95 ux_test_add_action_to_main_list_multiple(create_error_match_action(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_DESCRIPTOR_CORRUPTED), 3);
96 ux_test_add_action_to_main_list(create_error_match_action(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ROOT_HUB, UX_DEVICE_ENUMERATION_FAILURE));
97
98 /* Begin enumeration. */
99 UX_TEST_CHECK_SUCCESS(ux_host_stack_hcd_register(_ux_system_host_hcd_simulator_name, _ux_test_hcd_sim_host_initialize, 0, 0));
100
101 /* The HCD init function put()s the HCD semaphore, so we can do this here. */
102 ux_test_wait_for_enum_thread_completion();
103
104 /* Enumeration should've failed. */
105 UX_TEST_ASSERT(ux_test_check_actions_empty());
106 UX_TEST_ASSERT(cdc_ecm_host_from_system_change_function == UX_NULL);
107 }
108
post_init_device()109 static void post_init_device()
110 {
111 }