• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #include "usb_device_lite_cdcacm_test.h"
10 
11 #define HDF_LOG_TAG usb_device_sdk_test
12 
13 struct AcmDevice *g_acmDevice = NULL;
14 extern struct UsbFnDeviceDesc g_acmFnDevice;
15 
UsbGetAcmDevice(void)16 struct AcmDevice *UsbGetAcmDevice(void)
17 {
18     return g_acmDevice;
19 }
20 
UsbFnDviceTestCreate(void)21 int32_t UsbFnDviceTestCreate(void)
22 {
23     dprintf("%s: start\n", __func__);
24     RemoveUsbDevice();
25     g_acmDevice = SetUpAcmDevice();
26     if (g_acmDevice == NULL || g_acmDevice->fnDev == NULL) {
27         HDF_LOGE("%s: UsbFnDviceTestCreate fail", __func__);
28         return HDF_FAILURE;
29     }
30     return HDF_SUCCESS;
31 }
32 
UsbFnDviceTestCreate002(void)33 int32_t UsbFnDviceTestCreate002(void)
34 {
35     struct UsbFnDevice *fnDev = NULL;
36     struct UsbFnDescriptorData descData;
37 
38     descData.type = USBFN_DESC_DATA_TYPE_DESC;
39     descData.descriptor = NULL;
40     fnDev = (struct UsbFnDevice *)UsbFnCreateDevice("100e0000.hidwc3_0", &descData);
41     if (fnDev != NULL) {
42         HDF_LOGE("%s: UsbFnDviceTestCreate success!!", __func__);
43         return HDF_FAILURE;
44     }
45     return HDF_SUCCESS;
46 }
47 
UsbFnDviceTestCreate003(void)48 int32_t UsbFnDviceTestCreate003(void)
49 {
50     struct UsbFnDevice *fnDev = NULL;
51     struct UsbFnDescriptorData descData;
52 
53     descData.type = USBFN_DESC_DATA_TYPE_PROP;
54     descData.property = NULL;
55     fnDev = (struct UsbFnDevice *)UsbFnCreateDevice("100e0000.hidwc3_0", &descData);
56     if (fnDev != NULL) {
57         HDF_LOGE("%s: UsbFnDviceTestCreate success!!", __func__);
58         return HDF_FAILURE;
59     }
60     return HDF_SUCCESS;
61 }
62 
UsbFnDviceTestCreate004(void)63 int32_t UsbFnDviceTestCreate004(void)
64 {
65     struct UsbFnDevice *fnDev = NULL;
66     struct UsbFnDescriptorData descData;
67 
68     descData.type = USBFN_DESC_DATA_TYPE_DESC;
69     descData.descriptor = &g_acmFnDevice;
70     fnDev = (struct UsbFnDevice *)UsbFnCreateDevice("100e0000.hidwc3_0", &descData);
71     if (fnDev != NULL) {
72         HDF_LOGE("%s: UsbFnDviceTestCreate success!!", __func__);
73         return HDF_FAILURE;
74     }
75     return HDF_SUCCESS;
76 }
77 
UsbFnDviceTestCreate005(void)78 int32_t UsbFnDviceTestCreate005(void)
79 {
80     struct UsbFnDevice *fnDev = NULL;
81     struct UsbFnDescriptorData descData;
82 
83     descData.type = USBFN_DESC_DATA_TYPE_DESC;
84     descData.descriptor = &g_acmFnDevice;
85     fnDev = (struct UsbFnDevice *)UsbFnCreateDevice("100e0000.hidwc3_1", &descData);
86     if (fnDev != NULL) {
87         HDF_LOGE("%s: UsbFnDviceTestCreate success!!", __func__);
88         return HDF_FAILURE;
89     }
90     return HDF_SUCCESS;
91 }
92 
UsbFnDviceTestCreate006(void)93 int32_t UsbFnDviceTestCreate006(void)
94 {
95     struct UsbFnDevice *fnDev = NULL;
96     struct UsbFnDescriptorData descData;
97     const char *udcName = NULL;
98 
99     descData.type = USBFN_DESC_DATA_TYPE_DESC;
100     descData.descriptor = &g_acmFnDevice;
101     fnDev = (struct UsbFnDevice *)UsbFnCreateDevice(udcName, &descData);
102     if (fnDev != NULL) {
103         HDF_LOGE("%s: UsbFnDviceTestCreate success!!", __func__);
104         return HDF_FAILURE;
105     }
106     return HDF_SUCCESS;
107 }
108 
UsbFnDviceTestStatus(void)109 int32_t UsbFnDviceTestStatus(void)
110 {
111     if (g_acmDevice == NULL || g_acmDevice->fnDev == NULL) {
112         HDF_LOGE("%s: fnDev is invail", __func__);
113         return HDF_FAILURE;
114     }
115 
116     UsbFnDeviceState devState;
117     int32_t ret = UsbFnGetDeviceState(g_acmDevice->fnDev, &devState);
118     if (ret != HDF_SUCCESS) {
119         HDF_LOGE("%s: get status error", __func__);
120         return HDF_FAILURE;
121     }
122     if (!(devState >= USBFN_STATE_BIND && devState <= USBFN_STATE_RESUME)) {
123         HDF_LOGE("%s: device status error", __func__);
124         return HDF_FAILURE;
125     }
126     return HDF_SUCCESS;
127 }
128 
UsbFnDviceTestStatus002(void)129 int32_t UsbFnDviceTestStatus002(void)
130 {
131     UsbFnDeviceState devState;
132     int32_t ret = UsbFnGetDeviceState(NULL, &devState);
133     if (ret == HDF_SUCCESS) {
134         HDF_LOGE("%s: get status success!!", __func__);
135         return HDF_FAILURE;
136     }
137     return HDF_SUCCESS;
138 }
139 
UsbFnDviceTestStatus003(void)140 int32_t UsbFnDviceTestStatus003(void)
141 {
142     UsbFnDeviceState devState;
143     if (g_acmDevice == NULL || g_acmDevice->fnDev == NULL) {
144         HDF_LOGE("%s: fnDev is invail", __func__);
145         return HDF_FAILURE;
146     }
147     for (int32_t i = 0; i < TEST_TIMES; i++) {
148         int32_t ret = UsbFnGetDeviceState(g_acmDevice->fnDev, &devState);
149         if (ret != HDF_SUCCESS) {
150             HDF_LOGE("%s: get status error", __func__);
151             return HDF_FAILURE;
152         }
153         if (!(devState >= USBFN_STATE_BIND && devState <= USBFN_STATE_RESUME)) {
154             HDF_LOGE("%s: device status error", __func__);
155             return HDF_FAILURE;
156         }
157     }
158     return HDF_SUCCESS;
159 }
160 
UsbFnDviceTestStatus004(void)161 int32_t UsbFnDviceTestStatus004(void)
162 {
163     int32_t ret = UsbFnGetDeviceState(NULL, NULL);
164     if (ret == HDF_SUCCESS) {
165         HDF_LOGE("%s: get status success!!", __func__);
166         return HDF_FAILURE;
167     }
168     return HDF_SUCCESS;
169 }
170 
UsbFnDviceTestStatus005(void)171 int32_t UsbFnDviceTestStatus005(void)
172 {
173     if (g_acmDevice == NULL || g_acmDevice->fnDev == NULL) {
174         HDF_LOGE("%s: fnDev is invail", __func__);
175         return HDF_FAILURE;
176     }
177 
178     UsbFnDeviceState *devState = NULL;
179     int32_t ret = UsbFnGetDeviceState(g_acmDevice->fnDev, devState);
180     if (ret == HDF_SUCCESS) {
181         HDF_LOGE("%s: get status success!!", __func__);
182         return HDF_FAILURE;
183     }
184     return HDF_SUCCESS;
185 }
186 
UsbFnDviceTestGetDevice(void)187 int32_t UsbFnDviceTestGetDevice(void)
188 {
189     const struct UsbFnDevice *device = NULL;
190     const char *udcName = "100e0000.hidwc3_0";
191     device = UsbFnGetDevice(udcName);
192     if (device == NULL) {
193         HDF_LOGE("%s: get device failed", __func__);
194         return HDF_FAILURE;
195     }
196     return HDF_SUCCESS;
197 }
198 
UsbFnDviceTestGetDevice002(void)199 int32_t UsbFnDviceTestGetDevice002(void)
200 {
201     const struct UsbFnDevice *device = NULL;
202     const char *udcName = "100e0000.hidwc3_1";
203     device = UsbFnGetDevice(udcName);
204     if (device != NULL) {
205         HDF_LOGE("%s: get device success!!", __func__);
206         return HDF_FAILURE;
207     }
208     return HDF_SUCCESS;
209 }
210 
UsbFnDviceTestGetDevice003(void)211 int32_t UsbFnDviceTestGetDevice003(void)
212 {
213     const struct UsbFnDevice *device = NULL;
214     const char *udcName = NULL;
215     device = UsbFnGetDevice(udcName);
216     if (device != NULL) {
217         HDF_LOGE("%s: get device success!!", __func__);
218         return HDF_FAILURE;
219     }
220     return HDF_SUCCESS;
221 }
222 
UsbFnDviceTestGetDevice004(void)223 int32_t UsbFnDviceTestGetDevice004(void)
224 {
225     const struct UsbFnDevice *device = NULL;
226     const char *udcName = "100e0000.hidwc3_0 ";
227     device = UsbFnGetDevice(udcName);
228     if (device != NULL) {
229         HDF_LOGE("%s: get device success!!", __func__);
230         return HDF_FAILURE;
231     }
232     return HDF_SUCCESS;
233 }
234 
UsbFnDviceTestGetDevice005(void)235 int32_t UsbFnDviceTestGetDevice005(void)
236 {
237     const struct UsbFnDevice *device = NULL;
238     const char *udcName = "100e0000.hidwc3_0\0100e0000.hidwc3_0";
239     device = UsbFnGetDevice(udcName);
240     if (device != NULL) {
241         HDF_LOGE("%s: get device success!!", __func__);
242         return HDF_FAILURE;
243     }
244     return HDF_SUCCESS;
245 }
246 
UsbFnDviceTestGetDevice006(void)247 int32_t UsbFnDviceTestGetDevice006(void)
248 {
249     const struct UsbFnDevice *device = NULL;
250     const char *udcName = " 100e0000.hidwc3_0";
251     device = UsbFnGetDevice(udcName);
252     if (device != NULL) {
253         HDF_LOGE("%s: get device success!!", __func__);
254         return HDF_FAILURE;
255     }
256     return HDF_SUCCESS;
257 }
258 
UsbFnDviceTestGetInterface(void)259 int32_t UsbFnDviceTestGetInterface(void)
260 {
261     if (g_acmDevice == NULL || g_acmDevice->fnDev == NULL) {
262         HDF_LOGE("%s: fnDev is invail", __func__);
263         return HDF_FAILURE;
264     }
265 
266     struct UsbFnInterface *fnInterface = (struct UsbFnInterface *)UsbFnGetInterface(g_acmDevice->fnDev, 0);
267     if (fnInterface == NULL) {
268         HDF_LOGE("%s: get interface failed", __func__);
269         return HDF_FAILURE;
270     }
271     return HDF_SUCCESS;
272 }
273 
UsbFnDviceTestGetInterface002(void)274 int32_t UsbFnDviceTestGetInterface002(void)
275 {
276     if (g_acmDevice == NULL || g_acmDevice->fnDev == NULL) {
277         HDF_LOGE("%s: fnDev is invail", __func__);
278         return HDF_FAILURE;
279     }
280 
281     struct UsbFnInterface *fnInterface = (struct UsbFnInterface *)UsbFnGetInterface(g_acmDevice->fnDev, 1);
282     if (fnInterface == NULL) {
283         HDF_LOGE("%s: get interface fail", __func__);
284         return HDF_FAILURE;
285     }
286     return HDF_SUCCESS;
287 }
288 
UsbFnDviceTestGetInterface003(void)289 int32_t UsbFnDviceTestGetInterface003(void)
290 {
291     if (g_acmDevice == NULL || g_acmDevice->fnDev == NULL) {
292         HDF_LOGE("%s: fnDev is invail", __func__);
293         dprintf("%s, %d\n", __func__, __LINE__);
294         return HDF_FAILURE;
295     }
296 
297     struct UsbFnInterface *fnInterface = (struct UsbFnInterface *)UsbFnGetInterface(g_acmDevice->fnDev, 0xA);
298     if (fnInterface != NULL) {
299         HDF_LOGE("%s: get interface success!!", __func__);
300         return HDF_FAILURE;
301     }
302     return HDF_SUCCESS;
303 }
304 
UsbFnDviceTestGetInterface004(void)305 int32_t UsbFnDviceTestGetInterface004(void)
306 {
307     if (g_acmDevice == NULL || g_acmDevice->fnDev == NULL) {
308         HDF_LOGE("%s: fnDev is invail", __func__);
309         return HDF_FAILURE;
310     }
311 
312     struct UsbFnInterface *fnInterface = (struct UsbFnInterface *)UsbFnGetInterface(g_acmDevice->fnDev, 0x20);
313     if (fnInterface != NULL) {
314         HDF_LOGE("%s: get interface success!!", __func__);
315         return HDF_FAILURE;
316     }
317     return HDF_SUCCESS;
318 }
319 
UsbFnDviceTestGetInterface005(void)320 int32_t UsbFnDviceTestGetInterface005(void)
321 {
322     struct UsbFnDevice *fnDevice = NULL;
323     struct UsbFnInterface *fnInterface = (struct UsbFnInterface *)UsbFnGetInterface(fnDevice, 0);
324     if (fnInterface != NULL) {
325         HDF_LOGE("%s: get interface success!!", __func__);
326         return HDF_FAILURE;
327     }
328     return HDF_SUCCESS;
329 }
330 
UsbFnDviceTestGetInterface006(void)331 int32_t UsbFnDviceTestGetInterface006(void)
332 {
333     if (g_acmDevice == NULL || g_acmDevice->fnDev == NULL) {
334         HDF_LOGE("%s: fnDev is invail", __func__);
335         return HDF_FAILURE;
336     }
337 
338     struct UsbFnInterface *fnInterface = NULL;
339     for (int32_t idCount = 0; idCount < 0x2; idCount++) {
340         fnInterface = (struct UsbFnInterface *)UsbFnGetInterface(g_acmDevice->fnDev, idCount);
341         if (fnInterface == NULL) {
342             HDF_LOGE("%s: get interface failed", __func__);
343             return HDF_FAILURE;
344         }
345     }
346     return HDF_SUCCESS;
347 }
348 
UsbFnDviceTestGetPipeInfo(void)349 int32_t UsbFnDviceTestGetPipeInfo(void)
350 {
351     if (g_acmDevice == NULL || g_acmDevice->dataIface.fn == NULL) {
352         HDF_LOGE("%s: dataIface.fn is invail", __func__);
353         return HDF_FAILURE;
354     }
355 
356     struct UsbFnPipeInfo info;
357     int32_t ret = UsbFnGetInterfacePipeInfo(g_acmDevice->dataIface.fn, 0, &info);
358     if (ret != HDF_SUCCESS) {
359         HDF_LOGE("%s: get pipe info error", __func__);
360         return HDF_FAILURE;
361     }
362     if (info.id != 0) {
363         HDF_LOGE("%s: get pipe id error", __func__);
364         return HDF_FAILURE;
365     }
366     return HDF_SUCCESS;
367 }
368 
UsbFnDviceTestGetPipeInfo002(void)369 int32_t UsbFnDviceTestGetPipeInfo002(void)
370 {
371     if (g_acmDevice == NULL || g_acmDevice->dataIface.fn == NULL) {
372         HDF_LOGE("%s: dataIface.fn is invail", __func__);
373         return HDF_FAILURE;
374     }
375 
376     struct UsbFnPipeInfo info;
377     int32_t ret = UsbFnGetInterfacePipeInfo(g_acmDevice->dataIface.fn, 1, &info);
378     if (ret != HDF_SUCCESS) {
379         HDF_LOGE("%s: get pipe info error", __func__);
380         return HDF_FAILURE;
381     }
382     if (info.id != 1) {
383         HDF_LOGE("%s: get pipe id error", __func__);
384         return HDF_FAILURE;
385     }
386     return HDF_SUCCESS;
387 }
388 
UsbFnDviceTestGetPipeInfo003(void)389 int32_t UsbFnDviceTestGetPipeInfo003(void)
390 {
391     if (g_acmDevice == NULL || g_acmDevice->dataIface.fn == NULL) {
392         HDF_LOGE("%s: dataIface.fn is invail", __func__);
393         return HDF_FAILURE;
394     }
395 
396     struct UsbFnPipeInfo info;
397     int32_t ret = UsbFnGetInterfacePipeInfo(g_acmDevice->dataIface.fn, 0xF, &info);
398     if (ret == HDF_SUCCESS) {
399         HDF_LOGE("%s: get pipe info success!!", __func__);
400         return HDF_FAILURE;
401     }
402     return HDF_SUCCESS;
403 }
404 
UsbFnDviceTestGetPipeInfo004(void)405 int32_t UsbFnDviceTestGetPipeInfo004(void)
406 {
407     if (g_acmDevice == NULL || g_acmDevice->dataIface.fn == NULL) {
408         HDF_LOGE("%s: dataIface.fn is invail", __func__);
409         return HDF_FAILURE;
410     }
411 
412     struct UsbFnPipeInfo *info = NULL;
413     int32_t ret = UsbFnGetInterfacePipeInfo(g_acmDevice->dataIface.fn, 0, info);
414     if (ret == HDF_SUCCESS) {
415         HDF_LOGE("%s: get pipe info success!!", __func__);
416         return HDF_FAILURE;
417     }
418     return HDF_SUCCESS;
419 }
420 
UsbFnDviceTestGetPipeInfo005(void)421 int32_t UsbFnDviceTestGetPipeInfo005(void)
422 {
423     struct UsbFnPipeInfo info;
424     struct UsbFnInterface *fn = NULL;
425     int32_t ret = UsbFnGetInterfacePipeInfo(fn, 0, &info);
426     if (ret == HDF_SUCCESS) {
427         HDF_LOGE("%s: get pipe info success!!", __func__);
428         return HDF_FAILURE;
429     }
430     return HDF_SUCCESS;
431 }
432 
UsbFnDviceTestGetPipeInfo006(void)433 int32_t UsbFnDviceTestGetPipeInfo006(void)
434 {
435     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
436         HDF_LOGE("%s: dataIface.fn is invail", __func__);
437         return HDF_FAILURE;
438     }
439 
440     struct UsbFnPipeInfo info;
441     int32_t ret = UsbFnGetInterfacePipeInfo(g_acmDevice->ctrlIface.fn, 0, &info);
442     if (ret != HDF_SUCCESS) {
443         HDF_LOGE("%s: get pipe info error", __func__);
444         return HDF_FAILURE;
445     }
446     if (info.id != 0) {
447         HDF_LOGE("%s: get pipe id error", __func__);
448         return HDF_FAILURE;
449     }
450     return HDF_SUCCESS;
451 }
452 
PropCallBack(const struct UsbFnInterface * intf,const char * name,const char * value)453 static int32_t PropCallBack(const struct UsbFnInterface *intf, const char *name, const char *value)
454 {
455     if (intf == NULL || name == NULL || value == NULL) {
456         return HDF_FAILURE;
457     }
458     return HDF_SUCCESS;
459 }
460 
UsbFnDviceTestRegistProp(void)461 int32_t UsbFnDviceTestRegistProp(void)
462 {
463     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
464         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
465         return HDF_FAILURE;
466     }
467 
468     struct UsbFnRegistInfo info = {"name_test", "test_value", PropCallBack, PropCallBack};
469     int32_t ret = UsbFnRegistInterfaceProp(g_acmDevice->ctrlIface.fn, &info);
470     if (ret != HDF_SUCCESS) {
471         HDF_LOGE("%s: Regist Prop error", __func__);
472         return HDF_FAILURE;
473     }
474     return HDF_SUCCESS;
475 }
476 
UsbFnDviceTestRegistProp002(void)477 int32_t UsbFnDviceTestRegistProp002(void)
478 {
479     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
480         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
481         return HDF_FAILURE;
482     }
483 
484     struct UsbFnRegistInfo info = {"name_test", "test_value", PropCallBack, PropCallBack};
485     int32_t ret = UsbFnRegistInterfaceProp(g_acmDevice->ctrlIface.fn, &info);
486     if (ret == HDF_SUCCESS) {
487         HDF_LOGE("%s: Regist Prop success!!", __func__);
488         return HDF_FAILURE;
489     }
490     return HDF_SUCCESS;
491 }
492 
UsbFnDviceTestRegistProp003(void)493 int32_t UsbFnDviceTestRegistProp003(void)
494 {
495     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
496         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
497         return HDF_FAILURE;
498     }
499 
500     struct UsbFnRegistInfo info = {NULL, "test_value", PropCallBack, PropCallBack};
501     int32_t ret = UsbFnRegistInterfaceProp(g_acmDevice->ctrlIface.fn, &info);
502     if (ret == HDF_SUCCESS) {
503         HDF_LOGE("%s: Regist Prop success!!", __func__);
504         return HDF_FAILURE;
505     }
506     return HDF_SUCCESS;
507 }
508 
UsbFnDviceTestRegistProp004(void)509 int32_t UsbFnDviceTestRegistProp004(void)
510 {
511     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
512         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
513         return HDF_FAILURE;
514     }
515 
516     struct UsbFnRegistInfo info = {"name_test4", "test_value", NULL, PropCallBack};
517     int32_t ret = UsbFnRegistInterfaceProp(g_acmDevice->ctrlIface.fn, &info);
518     if (ret != HDF_SUCCESS) {
519         HDF_LOGE("%s: Regist Prop error", __func__);
520         return HDF_FAILURE;
521     }
522     return HDF_SUCCESS;
523 }
524 
UsbFnDviceTestRegistProp005(void)525 int32_t UsbFnDviceTestRegistProp005(void)
526 {
527     struct UsbFnInterface *fn = NULL;
528     struct UsbFnRegistInfo info = {"name_test5", "test_value", PropCallBack, PropCallBack};
529     int32_t ret = UsbFnRegistInterfaceProp(fn, &info);
530     if (ret == HDF_SUCCESS) {
531         HDF_LOGE("%s: Regist Prop success!!", __func__);
532         return HDF_FAILURE;
533     }
534     return HDF_SUCCESS;
535 }
536 
UsbFnDviceTestRegistProp006(void)537 int32_t UsbFnDviceTestRegistProp006(void)
538 {
539     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
540         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
541         return HDF_FAILURE;
542     }
543 
544     struct UsbFnRegistInfo *info = NULL;
545     int32_t ret = UsbFnRegistInterfaceProp(g_acmDevice->ctrlIface.fn, info);
546     if (ret == HDF_SUCCESS) {
547         HDF_LOGE("%s: Regist Prop success!!", __func__);
548         return HDF_FAILURE;
549     }
550     return HDF_SUCCESS;
551 }
552 
UsbFnDviceTestRegistProp007(void)553 int32_t UsbFnDviceTestRegistProp007(void)
554 {
555     if (g_acmDevice == NULL || g_acmDevice->dataIface.fn == NULL) {
556         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
557         return HDF_FAILURE;
558     }
559 
560     struct UsbFnRegistInfo info = {"name_test", "test_value", PropCallBack, PropCallBack};
561     int32_t ret = UsbFnRegistInterfaceProp(g_acmDevice->dataIface.fn, &info);
562     if (ret != HDF_SUCCESS) {
563         HDF_LOGE("%s: Regist Prop error", __func__);
564         return HDF_FAILURE;
565     }
566     return HDF_SUCCESS;
567 }
568 
UsbFnDviceTestGetProp(void)569 int32_t UsbFnDviceTestGetProp(void)
570 {
571     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
572         HDF_LOGE("%s: ctrlIface.fn is invail", __func__);
573         return HDF_FAILURE;
574     }
575 
576     char buffer[BUFFER_LEN] = {0};
577     char *buff = buffer;
578     int32_t ret = UsbFnGetInterfaceProp(g_acmDevice->ctrlIface.fn, "name_test", buff);
579     if (ret != HDF_SUCCESS) {
580         HDF_LOGE("%s: Get Prop error", __func__);
581         return HDF_FAILURE;
582     }
583     if (strcmp(buffer, "test_value") != 0) {
584         HDF_LOGE("%s: Get Prop value error", __func__);
585         return HDF_FAILURE;
586     }
587     return HDF_SUCCESS;
588 }
589 
UsbFnDviceTestGetProp002(void)590 int32_t UsbFnDviceTestGetProp002(void)
591 {
592     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
593         HDF_LOGE("%s: ctrlIface.fn is invail", __func__);
594         return HDF_FAILURE;
595     }
596 
597     char buffer[BUFFER_LEN] = {0};
598     char *buff = buffer;
599     int32_t ret = UsbFnGetInterfaceProp(g_acmDevice->ctrlIface.fn, "unknown", buff);
600     if (ret == HDF_SUCCESS) {
601         HDF_LOGE("%s: Get Prop success!!", __func__);
602         return HDF_FAILURE;
603     }
604     return HDF_SUCCESS;
605 }
606 
UsbFnDviceTestGetProp003(void)607 int32_t UsbFnDviceTestGetProp003(void)
608 {
609     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
610         HDF_LOGE("%s: ctrlIface.fn is invail", __func__);
611         return HDF_FAILURE;
612     }
613 
614     char buffer[BUFFER_LEN] = {0};
615     char *buff = buffer;
616     int32_t ret = UsbFnGetInterfaceProp(g_acmDevice->ctrlIface.fn, "idProduct", buff);
617     if (ret != HDF_SUCCESS) {
618         HDF_LOGE("%s: Get Prop error", __func__);
619         return HDF_FAILURE;
620     }
621     return HDF_SUCCESS;
622 }
623 
UsbFnDviceTestGetProp004(void)624 int32_t UsbFnDviceTestGetProp004(void)
625 {
626     char buffer[BUFFER_LEN] = {0};
627     char *buff = buffer;
628     struct UsbFnInterface *fn = NULL;
629     int32_t ret = UsbFnGetInterfaceProp(fn, "idProduct", buff);
630     if (ret == HDF_SUCCESS) {
631         HDF_LOGE("%s: Get Prop success!!", __func__);
632         return HDF_FAILURE;
633     }
634     return HDF_SUCCESS;
635 }
636 
UsbFnDviceTestGetProp005(void)637 int32_t UsbFnDviceTestGetProp005(void)
638 {
639     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
640         HDF_LOGE("%s: ctrlIface.fn is invail", __func__);
641         return HDF_FAILURE;
642     }
643 
644     char buffer[BUFFER_LEN] = {0};
645     char *buff = buffer;
646     int32_t ret = UsbFnGetInterfaceProp(g_acmDevice->ctrlIface.fn, "idVendor", buff);
647     if (ret != HDF_SUCCESS) {
648         HDF_LOGE("%s: Get Prop error", __func__);
649         return HDF_FAILURE;
650     }
651     return HDF_SUCCESS;
652 }
653 
UsbFnDviceTestGetProp006(void)654 int32_t UsbFnDviceTestGetProp006(void)
655 {
656     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
657         HDF_LOGE("%s: ctrlIface.fn is invail", __func__);
658         return HDF_FAILURE;
659     }
660 
661     int32_t ret = UsbFnGetInterfaceProp(g_acmDevice->ctrlIface.fn, "name_test", NULL);
662     if (ret == HDF_SUCCESS) {
663         HDF_LOGE("%s: Get Prop success!!", __func__);
664         return HDF_FAILURE;
665     }
666     return HDF_SUCCESS;
667 }
668 
UsbFnDviceTestGetProp007(void)669 int32_t UsbFnDviceTestGetProp007(void)
670 {
671     if (g_acmDevice == NULL || g_acmDevice->dataIface.fn == NULL) {
672         HDF_LOGE("%s: ctrlIface.fn is invail", __func__);
673         return HDF_FAILURE;
674     }
675 
676     char buffer[BUFFER_LEN] = {0};
677     char *buff = buffer;
678     int32_t ret = UsbFnGetInterfaceProp(g_acmDevice->dataIface.fn, "name_test", buff);
679     if (ret != HDF_SUCCESS) {
680         HDF_LOGE("%s: Get Prop error", __func__);
681         return HDF_FAILURE;
682     }
683     if (strcmp(buffer, "test_value") != 0) {
684         HDF_LOGE("%s: Get Prop value error", __func__);
685         return HDF_FAILURE;
686     }
687     return HDF_SUCCESS;
688 }
689 
UsbFnDviceTestGetProp008(void)690 int32_t UsbFnDviceTestGetProp008(void)
691 {
692     if (g_acmDevice == NULL || g_acmDevice->dataIface.fn == NULL) {
693         HDF_LOGE("%s: ctrlIface.fn is invail", __func__);
694         return HDF_FAILURE;
695     }
696 
697     char buffer[BUFFER_LEN] = {0};
698     char *buff = buffer;
699     int32_t ret = UsbFnGetInterfaceProp(g_acmDevice->dataIface.fn, "idVendor", buff);
700     if (ret != HDF_SUCCESS) {
701         HDF_LOGE("%s: Get Prop error", __func__);
702         return HDF_FAILURE;
703     }
704     return HDF_SUCCESS;
705 }
706 
UsbFnDviceTestSetProp(void)707 int32_t UsbFnDviceTestSetProp(void)
708 {
709     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
710         HDF_LOGE("%s: ctrlIface.fn is invail", __func__);
711         return HDF_FAILURE;
712     }
713 
714     int32_t ret = UsbFnSetInterfaceProp(g_acmDevice->ctrlIface.fn, "name_test", "hello");
715     if (ret != HDF_SUCCESS) {
716         HDF_LOGE("%s: Set Prop error", __func__);
717         return HDF_FAILURE;
718     }
719     return HDF_SUCCESS;
720 }
721 
UsbFnDviceTestSetProp002(void)722 int32_t UsbFnDviceTestSetProp002(void)
723 {
724     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
725         HDF_LOGE("%s: ctrlIface.fn is invail", __func__);
726         return HDF_FAILURE;
727     }
728 
729     int32_t ret = UsbFnSetInterfaceProp(g_acmDevice->ctrlIface.fn, "unknown", "hello");
730     if (ret == HDF_SUCCESS) {
731         HDF_LOGE("%s: Set Prop success!!", __func__);
732         return HDF_FAILURE;
733     }
734     return HDF_SUCCESS;
735 }
736 
UsbFnDviceTestSetProp003(void)737 int32_t UsbFnDviceTestSetProp003(void)
738 {
739     struct UsbFnInterface *fn = NULL;
740     int32_t ret = UsbFnSetInterfaceProp(fn, "name_test", "hellotest");
741     if (ret == HDF_SUCCESS) {
742         HDF_LOGE("%s: Set Prop success!!", __func__);
743         return HDF_FAILURE;
744     }
745     return HDF_SUCCESS;
746 }
747 
UsbFnDviceTestSetProp004(void)748 int32_t UsbFnDviceTestSetProp004(void)
749 {
750     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
751         HDF_LOGE("%s: ctrlIface.fn is invail", __func__);
752         return HDF_FAILURE;
753     }
754 
755     const char *propName = NULL;
756     int32_t ret = UsbFnSetInterfaceProp(g_acmDevice->ctrlIface.fn, propName, "hellotest");
757     if (ret == HDF_SUCCESS) {
758         HDF_LOGE("%s: Set Prop success!!", __func__);
759         return HDF_FAILURE;
760     }
761     return HDF_SUCCESS;
762 }
763 
UsbFnDviceTestSetProp005(void)764 int32_t UsbFnDviceTestSetProp005(void)
765 {
766     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
767         HDF_LOGE("%s: ctrlIface.fn is invail", __func__);
768         return HDF_FAILURE;
769     }
770 
771     int32_t ret = UsbFnSetInterfaceProp(g_acmDevice->ctrlIface.fn, "idVendor", "0x625");
772     if (ret != HDF_SUCCESS) {
773         HDF_LOGE("%s: Set Prop error!!", __func__);
774         return HDF_FAILURE;
775     }
776     return HDF_SUCCESS;
777 }
778 
UsbFnDviceTestSetProp006(void)779 int32_t UsbFnDviceTestSetProp006(void)
780 {
781     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
782         HDF_LOGE("%s: ctrlIface.fn is invail", __func__);
783         return HDF_FAILURE;
784     }
785 
786     int32_t ret = UsbFnSetInterfaceProp(g_acmDevice->ctrlIface.fn, "bLength", "0x14");
787     if (ret == HDF_SUCCESS) {
788         HDF_LOGE("%s: Set Prop success!!", __func__);
789         return HDF_FAILURE;
790     }
791     return HDF_SUCCESS;
792 }
793 
UsbFnDviceTestSetProp007(void)794 int32_t UsbFnDviceTestSetProp007(void)
795 {
796     if (g_acmDevice == NULL || g_acmDevice->dataIface.fn == NULL) {
797         HDF_LOGE("%s: ctrlIface.fn is invail", __func__);
798         return HDF_FAILURE;
799     }
800 
801     int32_t ret = UsbFnSetInterfaceProp(g_acmDevice->dataIface.fn, "name_test", "hello");
802     if (ret != HDF_SUCCESS) {
803         HDF_LOGE("%s: Set Prop error", __func__);
804         return HDF_FAILURE;
805     }
806     return HDF_SUCCESS;
807 }
808 
UsbFnDviceTestAllocCtrlRequest(void)809 int32_t UsbFnDviceTestAllocCtrlRequest(void)
810 {
811     if (g_acmDevice == NULL || g_acmDevice->dataIface.handle == NULL) {
812         HDF_LOGE("%s: dataIface.handle is invail", __func__);
813         return HDF_FAILURE;
814     }
815 
816     struct UsbFnRequest *req =
817         UsbFnAllocCtrlRequest(g_acmDevice->dataIface.handle, g_acmDevice->dataOutPipe.maxPacketSize);
818     if (req == NULL) {
819         HDF_LOGE("%s: alloc req fail", __func__);
820         return HDF_FAILURE;
821     }
822 
823     int32_t ret = UsbFnFreeRequest(req);
824     if (ret != HDF_SUCCESS) {
825         HDF_LOGE("%s: free Request error", __func__);
826         return HDF_FAILURE;
827     }
828     return HDF_SUCCESS;
829 }
830 
UsbFnDviceTestAllocCtrlRequest002(void)831 int32_t UsbFnDviceTestAllocCtrlRequest002(void)
832 {
833     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.handle == NULL) {
834         HDF_LOGE("%s: dataIface.handle is invail", __func__);
835         return HDF_FAILURE;
836     }
837 
838     struct UsbFnRequest *req = UsbFnAllocCtrlRequest(
839         g_acmDevice->ctrlIface.handle, sizeof(struct UsbCdcLineCoding) + sizeof(struct UsbCdcLineCoding));
840     if (req == NULL) {
841         HDF_LOGE("%s: alloc req fail", __func__);
842         return HDF_FAILURE;
843     }
844 
845     int32_t ret = UsbFnFreeRequest(req);
846     if (ret != HDF_SUCCESS) {
847         HDF_LOGE("%s: free Request error", __func__);
848         return HDF_FAILURE;
849     }
850     return HDF_SUCCESS;
851 }
852 
UsbFnDviceTestAllocCtrlRequest003(void)853 int32_t UsbFnDviceTestAllocCtrlRequest003(void)
854 {
855     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.handle == NULL) {
856         HDF_LOGE("%s: dataIface.handle is invail", __func__);
857         return HDF_FAILURE;
858     }
859 
860     struct UsbFnRequest *req = UsbFnAllocCtrlRequest(g_acmDevice->ctrlIface.handle, 0);
861     if (req == NULL) {
862         HDF_LOGE("%s: alloc req failed", __func__);
863         return HDF_FAILURE;
864     }
865 
866     int32_t ret = UsbFnFreeRequest(req);
867     if (ret != HDF_SUCCESS) {
868         HDF_LOGE("%s: FreeRequest failed", __func__);
869         return HDF_FAILURE;
870     }
871     return HDF_SUCCESS;
872 }
873 
UsbFnDviceTestAllocCtrlRequest004(void)874 int32_t UsbFnDviceTestAllocCtrlRequest004(void)
875 {
876     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.handle == NULL) {
877         HDF_LOGE("%s: dataIface.handle is invail", __func__);
878         return HDF_FAILURE;
879     }
880 
881     // 0x801: Represents the length of the requested data, testing greater than 2048.
882     struct UsbFnRequest *req = UsbFnAllocCtrlRequest(g_acmDevice->ctrlIface.handle, 0x801);
883     if (req == NULL) {
884         HDF_LOGE("%s: alloc req failed", __func__);
885         return HDF_FAILURE;
886     }
887 
888     int32_t ret = UsbFnFreeRequest(req);
889     if (ret != HDF_SUCCESS) {
890         HDF_LOGE("%s: free Request error", __func__);
891         return HDF_FAILURE;
892     }
893     return HDF_SUCCESS;
894 }
895 
UsbFnDviceTestAllocCtrlRequest005(void)896 int32_t UsbFnDviceTestAllocCtrlRequest005(void)
897 {
898     if (g_acmDevice == NULL) {
899         HDF_LOGE("%s: dataIface.handle is invail", __func__);
900         return HDF_FAILURE;
901     }
902 
903     UsbFnInterfaceHandle handle = NULL;
904     struct UsbFnRequest *req = UsbFnAllocCtrlRequest(handle, g_acmDevice->notifyPipe.maxPacketSize);
905     if (req == NULL) {
906         HDF_LOGE("%s: alloc req failed", __func__);
907         return HDF_FAILURE;
908     }
909 
910     int32_t ret = UsbFnFreeRequest(req);
911     if (ret != HDF_SUCCESS) {
912         HDF_LOGE("%s: free Request error", __func__);
913         return HDF_FAILURE;
914     }
915     return HDF_SUCCESS;
916 }
917 
UsbFnDviceTestAllocCtrlRequest006(void)918 int32_t UsbFnDviceTestAllocCtrlRequest006(void)
919 {
920     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.handle == NULL) {
921         HDF_LOGE("%s: dataIface.handle is invail", __func__);
922         return HDF_FAILURE;
923     }
924 
925     // 0x800: Represents the length of the requested data, testing equal to 2048.
926     struct UsbFnRequest *req = UsbFnAllocCtrlRequest(g_acmDevice->ctrlIface.handle, 0x800);
927     if (req == NULL) {
928         HDF_LOGE("%s: alloc req fail", __func__);
929         return HDF_FAILURE;
930     }
931 
932     int32_t ret = UsbFnFreeRequest(req);
933     if (ret != HDF_SUCCESS) {
934         HDF_LOGE("%s: free Request error", __func__);
935         return HDF_FAILURE;
936     }
937     return HDF_SUCCESS;
938 }
939 
UsbFnDviceTestAllocCtrlRequest007(void)940 int32_t UsbFnDviceTestAllocCtrlRequest007(void)
941 {
942     if (g_acmDevice == NULL || g_acmDevice->dataIface.handle == NULL) {
943         HDF_LOGE("%s: dataIface.handle is invail", __func__);
944         return HDF_FAILURE;
945     }
946 
947     struct UsbFnRequest *req = UsbFnAllocCtrlRequest(g_acmDevice->dataIface.handle, 0);
948     if (req == NULL) {
949         HDF_LOGE("%s: alloc req failed", __func__);
950         return HDF_FAILURE;
951     }
952 
953     int32_t ret = UsbFnFreeRequest(req);
954     if (ret != HDF_SUCCESS) {
955         HDF_LOGE("%s: free Request error", __func__);
956         return HDF_FAILURE;
957     }
958     return HDF_SUCCESS;
959 }
960 
UsbFnDviceTestAllocCtrlRequest008(void)961 int32_t UsbFnDviceTestAllocCtrlRequest008(void)
962 {
963     UsbFnInterfaceHandle handle = NULL;
964     struct UsbFnRequest *req = UsbFnAllocCtrlRequest(handle, 0);
965     if (req == NULL) {
966         HDF_LOGE("%s: alloc req failed", __func__);
967         return HDF_FAILURE;
968     }
969 
970     int32_t ret = UsbFnFreeRequest(req);
971     if (ret != HDF_SUCCESS) {
972         HDF_LOGE("%s: free Request error", __func__);
973         return HDF_FAILURE;
974     }
975     return HDF_SUCCESS;
976 }
977 
UsbFnDviceTestAllocRequest(void)978 int32_t UsbFnDviceTestAllocRequest(void)
979 {
980     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.handle == NULL) {
981         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
982         return HDF_FAILURE;
983     }
984 
985     struct UsbFnRequest *req =
986         UsbFnAllocRequest(g_acmDevice->ctrlIface.handle, g_acmDevice->notifyPipe.id, sizeof(struct UsbCdcNotification));
987     if (req == NULL) {
988         HDF_LOGE("%s: alloc req fail", __func__);
989         return HDF_FAILURE;
990     }
991 
992     int32_t ret = UsbFnFreeRequest(req);
993     if (ret != HDF_SUCCESS) {
994         HDF_LOGE("%s: free Request error", __func__);
995         return HDF_FAILURE;
996     }
997     return HDF_SUCCESS;
998 }
999 
UsbFnDviceTestAllocRequest002(void)1000 int32_t UsbFnDviceTestAllocRequest002(void)
1001 {
1002     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.handle == NULL) {
1003         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1004         return HDF_FAILURE;
1005     }
1006 
1007     struct UsbFnRequest *req = UsbFnAllocRequest(g_acmDevice->ctrlIface.handle, g_acmDevice->notifyPipe.id, 0);
1008     if (req == NULL) {
1009         HDF_LOGE("%s: alloc req failed", __func__);
1010         return HDF_FAILURE;
1011     }
1012     int32_t ret = UsbFnFreeRequest(req);
1013     if (ret != HDF_SUCCESS) {
1014         HDF_LOGE("%s: free Request error", __func__);
1015         return HDF_FAILURE;
1016     }
1017     return HDF_SUCCESS;
1018 }
1019 
UsbFnDviceTestAllocRequest003(void)1020 int32_t UsbFnDviceTestAllocRequest003(void)
1021 {
1022     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.handle == NULL) {
1023         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1024         return HDF_FAILURE;
1025     }
1026 
1027     struct UsbFnRequest *req = UsbFnAllocRequest(g_acmDevice->ctrlIface.handle, g_acmDevice->notifyPipe.id, 0x800);
1028     if (req == NULL) {
1029         HDF_LOGE("%s: alloc req fail", __func__);
1030         return HDF_FAILURE;
1031     }
1032     int32_t ret = UsbFnFreeRequest(req);
1033     if (ret != HDF_SUCCESS) {
1034         HDF_LOGE("%s: free Request error", __func__);
1035         return HDF_FAILURE;
1036     }
1037     return HDF_SUCCESS;
1038 }
1039 
UsbFnDviceTestAllocRequest004(void)1040 int32_t UsbFnDviceTestAllocRequest004(void)
1041 {
1042     if (g_acmDevice == NULL) {
1043         HDF_LOGE("%s: dataIface.handle is invail", __func__);
1044         return HDF_FAILURE;
1045     }
1046 
1047     UsbFnInterfaceHandle handle = NULL;
1048     struct UsbFnRequest *req = UsbFnAllocRequest(handle, g_acmDevice->notifyPipe.id, 0x800);
1049     if (req == NULL) {
1050         HDF_LOGE("%s: alloc req failed", __func__);
1051         return HDF_FAILURE;
1052     }
1053 
1054     int32_t ret = UsbFnFreeRequest(req);
1055     if (ret != HDF_SUCCESS) {
1056         HDF_LOGE("%s: free Request error", __func__);
1057         return HDF_FAILURE;
1058     }
1059     return HDF_SUCCESS;
1060 }
1061 
UsbFnDviceTestAllocRequest005(void)1062 int32_t UsbFnDviceTestAllocRequest005(void)
1063 {
1064     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.handle == NULL) {
1065         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1066         return HDF_FAILURE;
1067     }
1068 
1069     struct UsbFnRequest *req =
1070         UsbFnAllocRequest(g_acmDevice->ctrlIface.handle, REQUEST_ALLOC_PIPE, REQUEST_ALLOC_LENGTH);
1071     if (req == NULL) {
1072         HDF_LOGE("%s: alloc req failed", __func__);
1073         return HDF_FAILURE;
1074     }
1075 
1076     int32_t ret = UsbFnFreeRequest(req);
1077     if (ret != HDF_SUCCESS) {
1078         HDF_LOGE("%s: free Request error", __func__);
1079         return HDF_FAILURE;
1080     }
1081     return HDF_SUCCESS;
1082 }
1083 
UsbFnDviceTestAllocRequest006(void)1084 int32_t UsbFnDviceTestAllocRequest006(void)
1085 {
1086     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.handle == NULL) {
1087         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1088         return HDF_FAILURE;
1089     }
1090 
1091     struct UsbFnRequest *req = UsbFnAllocRequest(g_acmDevice->ctrlIface.handle, g_acmDevice->notifyPipe.id, 0x801);
1092     if (req == NULL) {
1093         HDF_LOGE("%s: alloc req failed", __func__);
1094         return HDF_FAILURE;
1095     }
1096 
1097     int32_t ret = UsbFnFreeRequest(req);
1098     if (ret != HDF_SUCCESS) {
1099         HDF_LOGE("%s: free Request error", __func__);
1100         return HDF_FAILURE;
1101     }
1102     return HDF_SUCCESS;
1103 }
1104 
UsbFnDviceTestAllocRequest007(void)1105 int32_t UsbFnDviceTestAllocRequest007(void)
1106 {
1107     if (g_acmDevice == NULL || g_acmDevice->dataIface.handle == NULL) {
1108         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1109         return HDF_FAILURE;
1110     }
1111 
1112     struct UsbFnRequest *req = UsbFnAllocRequest(g_acmDevice->dataIface.handle, g_acmDevice->dataOutPipe.id, 0);
1113     if (req == NULL) {
1114         HDF_LOGE("%s: alloc req failed", __func__);
1115         return HDF_FAILURE;
1116     }
1117 
1118     int32_t ret = UsbFnFreeRequest(req);
1119     if (ret != HDF_SUCCESS) {
1120         HDF_LOGE("%s: free Request error", __func__);
1121         return HDF_FAILURE;
1122     }
1123     return HDF_SUCCESS;
1124 }
1125 
UsbFnDviceTestAllocRequest008(void)1126 int32_t UsbFnDviceTestAllocRequest008(void)
1127 {
1128     if (g_acmDevice == NULL || g_acmDevice->dataIface.handle == NULL) {
1129         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1130         return HDF_FAILURE;
1131     }
1132 
1133     uint32_t length = g_acmDevice->dataOutPipe.maxPacketSize;
1134     struct UsbFnRequest *req = UsbFnAllocRequest(g_acmDevice->dataIface.handle, REQUEST_ALLOC_PIPE, length);
1135     if (req == NULL) {
1136         HDF_LOGE("%s: alloc req failed", __func__);
1137         return HDF_FAILURE;
1138     }
1139 
1140     int32_t ret = UsbFnFreeRequest(req);
1141     if (ret != HDF_SUCCESS) {
1142         HDF_LOGE("%s: free Request error", __func__);
1143         return HDF_FAILURE;
1144     }
1145     return HDF_SUCCESS;
1146 }
1147 
UsbFnDviceTestAllocRequest009(void)1148 int32_t UsbFnDviceTestAllocRequest009(void)
1149 {
1150     if (g_acmDevice == NULL || g_acmDevice->dataIface.handle == NULL) {
1151         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1152         return HDF_FAILURE;
1153     }
1154 
1155     struct UsbFnRequest *req = UsbFnAllocRequest(
1156         g_acmDevice->dataIface.handle, g_acmDevice->dataOutPipe.id, g_acmDevice->dataOutPipe.maxPacketSize);
1157     if (req == NULL) {
1158         HDF_LOGE("%s: alloc req failed", __func__);
1159         return HDF_FAILURE;
1160     }
1161 
1162     int32_t ret = UsbFnFreeRequest(req);
1163     if (ret != HDF_SUCCESS) {
1164         HDF_LOGE("%s: free Request error", __func__);
1165         return HDF_FAILURE;
1166     }
1167     return HDF_SUCCESS;
1168 }
1169 
UsbFnDviceTestFreeRequest(void)1170 int32_t UsbFnDviceTestFreeRequest(void)
1171 {
1172     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.handle == NULL) {
1173         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1174         return HDF_FAILURE;
1175     }
1176 
1177     struct UsbFnRequest *req = UsbFnAllocRequest(
1178         g_acmDevice->ctrlIface.handle, g_acmDevice->notifyPipe.id, g_acmDevice->notifyPipe.maxPacketSize);
1179     if (req == NULL) {
1180         HDF_LOGE("%s: alloc req fail", __func__);
1181         return HDF_FAILURE;
1182     }
1183 
1184     int32_t ret = UsbFnFreeRequest(req);
1185     if (ret != HDF_SUCCESS) {
1186         HDF_LOGE("%s: free Request error", __func__);
1187         return HDF_FAILURE;
1188     }
1189     return HDF_SUCCESS;
1190 }
1191 
UsbFnDviceTestFreeRequest002(void)1192 int32_t UsbFnDviceTestFreeRequest002(void)
1193 {
1194     if (g_acmDevice == NULL || g_acmDevice->dataIface.handle == NULL) {
1195         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1196         return HDF_FAILURE;
1197     }
1198 
1199     struct UsbFnRequest *req = UsbFnAllocRequest(
1200         g_acmDevice->dataIface.handle, g_acmDevice->dataInPipe.id, g_acmDevice->dataInPipe.maxPacketSize);
1201     if (req == NULL) {
1202         HDF_LOGE("%s: alloc req fail", __func__);
1203         return HDF_FAILURE;
1204     }
1205 
1206     int32_t ret = UsbFnFreeRequest(req);
1207     if (ret != HDF_SUCCESS) {
1208         HDF_LOGE("%s: free Request error", __func__);
1209         return HDF_FAILURE;
1210     }
1211     return HDF_SUCCESS;
1212 }
1213 
UsbFnDviceTestFreeRequest003(void)1214 int32_t UsbFnDviceTestFreeRequest003(void)
1215 {
1216     if (g_acmDevice == NULL || g_acmDevice->dataIface.handle == NULL) {
1217         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1218         return HDF_FAILURE;
1219     }
1220 
1221     struct UsbFnRequest *req = UsbFnAllocRequest(
1222         g_acmDevice->dataIface.handle, g_acmDevice->dataOutPipe.id, g_acmDevice->dataOutPipe.maxPacketSize);
1223     if (req == NULL) {
1224         HDF_LOGE("%s: alloc req fail", __func__);
1225         return HDF_FAILURE;
1226     }
1227 
1228     int32_t ret = UsbFnFreeRequest(req);
1229     if (ret != HDF_SUCCESS) {
1230         HDF_LOGE("%s: free Request error", __func__);
1231         return HDF_FAILURE;
1232     }
1233     return HDF_SUCCESS;
1234 }
1235 
UsbFnDviceTestFreeRequest004(void)1236 int32_t UsbFnDviceTestFreeRequest004(void)
1237 {
1238     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.handle == NULL) {
1239         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1240         return HDF_FAILURE;
1241     }
1242 
1243     struct UsbFnRequest *req =
1244         UsbFnAllocCtrlRequest(g_acmDevice->ctrlIface.handle, g_acmDevice->notifyPipe.maxPacketSize);
1245     if (req == NULL) {
1246         HDF_LOGE("%s: alloc req fail", __func__);
1247         return HDF_FAILURE;
1248     }
1249 
1250     int32_t ret = UsbFnFreeRequest(req);
1251     if (ret != HDF_SUCCESS) {
1252         HDF_LOGE("%s: free Request error", __func__);
1253         return HDF_FAILURE;
1254     }
1255     return HDF_SUCCESS;
1256 }
1257 
UsbFnDviceTestFreeRequest005(void)1258 int32_t UsbFnDviceTestFreeRequest005(void)
1259 {
1260     struct UsbFnRequest *req = NULL;
1261     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.handle == NULL) {
1262         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1263         return HDF_FAILURE;
1264     }
1265     for (int32_t i = 0; i < TEST_TIMES; i++) {
1266         req = UsbFnAllocCtrlRequest(g_acmDevice->ctrlIface.handle, g_acmDevice->notifyPipe.maxPacketSize);
1267         if (req == NULL) {
1268             HDF_LOGE("%s: alloc req fail", __func__);
1269             return HDF_FAILURE;
1270         }
1271         int32_t ret = UsbFnFreeRequest(req);
1272         if (ret != HDF_SUCCESS) {
1273             HDF_LOGE("%s: free Request error", __func__);
1274             return HDF_FAILURE;
1275         }
1276     }
1277     return HDF_SUCCESS;
1278 }
1279 
UsbFnDviceTestFreeRequest006(void)1280 int32_t UsbFnDviceTestFreeRequest006(void)
1281 {
1282     struct UsbFnRequest *req = NULL;
1283     int32_t ret = UsbFnFreeRequest(req);
1284     if (ret != HDF_SUCCESS) {
1285         HDF_LOGE("%s: free Request failed", __func__);
1286         return HDF_FAILURE;
1287     }
1288     return HDF_SUCCESS;
1289 }
1290 
UsbFnDviceTestGetRequestStatus(void)1291 int32_t UsbFnDviceTestGetRequestStatus(void)
1292 {
1293     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.handle == NULL) {
1294         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1295         return HDF_FAILURE;
1296     }
1297 
1298     struct UsbFnRequest *notifyReq =
1299         UsbFnAllocRequest(g_acmDevice->ctrlIface.handle, g_acmDevice->notifyPipe.id, sizeof(struct UsbCdcNotification));
1300     if (notifyReq == NULL) {
1301         HDF_LOGE("%s: alloc req fail", __func__);
1302         return HDF_FAILURE;
1303     }
1304 
1305     UsbRequestStatus status = 0;
1306     int32_t ret = UsbFnGetRequestStatus(notifyReq, &status);
1307     if (ret != HDF_SUCCESS) {
1308         HDF_LOGE("%s: get status error", __func__);
1309         return HDF_FAILURE;
1310     }
1311     if (!(status >= USB_REQUEST_COMPLETED && status <= USB_REQUEST_OVERFLOW)) {
1312         HDF_LOGE("%s: device status error", __func__);
1313         return HDF_FAILURE;
1314     }
1315     ret = UsbFnFreeRequest(notifyReq);
1316     if (ret != HDF_SUCCESS) {
1317         HDF_LOGE("%s: free Request error", __func__);
1318         return HDF_FAILURE;
1319     }
1320     return HDF_SUCCESS;
1321 }
1322 
UsbFnDviceTestGetRequestStatus002(void)1323 int32_t UsbFnDviceTestGetRequestStatus002(void)
1324 {
1325     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.handle == NULL) {
1326         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1327         return HDF_FAILURE;
1328     }
1329 
1330     struct UsbFnRequest *notifyReq =
1331         UsbFnAllocCtrlRequest(g_acmDevice->ctrlIface.handle, sizeof(struct UsbCdcNotification));
1332     if (notifyReq == NULL) {
1333         HDF_LOGE("%s: alloc req fail", __func__);
1334         return HDF_FAILURE;
1335     }
1336 
1337     UsbRequestStatus status = 0;
1338     int32_t ret = UsbFnGetRequestStatus(notifyReq, &status);
1339     if (ret != HDF_SUCCESS) {
1340         HDF_LOGE("%s: get status error", __func__);
1341         dprintf("%s: get status error", __func__);
1342         return HDF_FAILURE;
1343     }
1344     if (!(status >= USB_REQUEST_COMPLETED && status <= USB_REQUEST_OVERFLOW)) {
1345         HDF_LOGE("%s: device status error", __func__);
1346         return HDF_FAILURE;
1347     }
1348     ret = UsbFnFreeRequest(notifyReq);
1349     if (ret != HDF_SUCCESS) {
1350         HDF_LOGE("%s: free Request error", __func__);
1351         return HDF_FAILURE;
1352     }
1353     return HDF_SUCCESS;
1354 }
1355 
UsbFnDviceTestGetRequestStatus003(void)1356 int32_t UsbFnDviceTestGetRequestStatus003(void)
1357 {
1358     if (g_acmDevice == NULL || g_acmDevice->dataIface.handle == NULL) {
1359         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1360         return HDF_FAILURE;
1361     }
1362 
1363     struct UsbFnRequest *req = UsbFnAllocRequest(
1364         g_acmDevice->dataIface.handle, g_acmDevice->dataOutPipe.id, g_acmDevice->dataOutPipe.maxPacketSize);
1365     if (req == NULL) {
1366         HDF_LOGE("%s: alloc req fail", __func__);
1367         return HDF_FAILURE;
1368     }
1369 
1370     int32_t ret = UsbFnGetRequestStatus(req, NULL);
1371     if (ret != HDF_SUCCESS) {
1372         HDF_LOGE("%s: get status failed", __func__);
1373         ret = UsbFnFreeRequest(req);
1374         if (ret != HDF_SUCCESS) {
1375             HDF_LOGE("%s: free Request error", __func__);
1376             return HDF_FAILURE;
1377         }
1378     }
1379 
1380     return HDF_SUCCESS;
1381 }
1382 
UsbFnDviceTestGetRequestStatus004(void)1383 int32_t UsbFnDviceTestGetRequestStatus004(void)
1384 {
1385     if (g_acmDevice == NULL || g_acmDevice->dataIface.handle == NULL) {
1386         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1387         return HDF_FAILURE;
1388     }
1389 
1390     struct UsbFnRequest *notifyReq = UsbFnAllocRequest(
1391         g_acmDevice->dataIface.handle, g_acmDevice->dataOutPipe.id, g_acmDevice->dataOutPipe.maxPacketSize);
1392     if (notifyReq == NULL) {
1393         HDF_LOGE("%s: alloc req fail", __func__);
1394         return HDF_FAILURE;
1395     }
1396 
1397     UsbRequestStatus status = 0;
1398     int32_t ret = UsbFnSubmitRequestAsync(notifyReq);
1399     if (ret != HDF_SUCCESS) {
1400         HDF_LOGE("%s: get status error", __func__);
1401         return HDF_FAILURE;
1402     }
1403     ret = UsbFnGetRequestStatus(notifyReq, &status);
1404     if (ret != HDF_SUCCESS) {
1405         HDF_LOGE("%s: get status error", __func__);
1406         return HDF_FAILURE;
1407     }
1408     if (!(status >= USB_REQUEST_COMPLETED && status <= USB_REQUEST_OVERFLOW)) {
1409         HDF_LOGE("%s: device status error", __func__);
1410         return HDF_FAILURE;
1411     }
1412     ret = UsbFnFreeRequest(notifyReq);
1413     if (ret != HDF_SUCCESS) {
1414         HDF_LOGE("%s: free Request error", __func__);
1415         return HDF_FAILURE;
1416     }
1417     return HDF_SUCCESS;
1418 }
1419 
UsbFnDviceTestGetRequestStatus005(void)1420 int32_t UsbFnDviceTestGetRequestStatus005(void)
1421 {
1422     UsbRequestStatus status = 0;
1423     struct UsbFnRequest *notifyReq = NULL;
1424     int32_t ret = UsbFnGetRequestStatus(notifyReq, &status);
1425     if (ret == HDF_SUCCESS) {
1426         HDF_LOGE("%s: get status success!!", __func__);
1427         return HDF_FAILURE;
1428     }
1429     return HDF_SUCCESS;
1430 }
1431 
UsbFnDviceTestGetRequestStatus006(void)1432 int32_t UsbFnDviceTestGetRequestStatus006(void)
1433 {
1434     UsbRequestStatus *status = NULL;
1435     struct UsbFnRequest *notifyReq = NULL;
1436     int32_t ret = UsbFnGetRequestStatus(notifyReq, status);
1437     if (ret == HDF_SUCCESS) {
1438         HDF_LOGE("%s: get status success!!", __func__);
1439         return HDF_FAILURE;
1440     }
1441     return HDF_SUCCESS;
1442 }
1443 
UsbFnDviceTestStopReceEvent(void)1444 int32_t UsbFnDviceTestStopReceEvent(void)
1445 {
1446     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
1447         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1448         return HDF_FAILURE;
1449     }
1450 
1451     int32_t ret = UsbFnStopRecvInterfaceEvent(g_acmDevice->ctrlIface.fn);
1452     if (ret != HDF_SUCCESS) {
1453         HDF_LOGE("%s: stop receive event error", __func__);
1454         return HDF_FAILURE;
1455     }
1456     return HDF_SUCCESS;
1457 }
1458 
UsbFnDviceTestStopReceEvent002(void)1459 int32_t UsbFnDviceTestStopReceEvent002(void)
1460 {
1461     struct UsbFnInterface *fn = NULL;
1462     int32_t ret = UsbFnStopRecvInterfaceEvent(fn);
1463     if (ret == HDF_SUCCESS) {
1464         HDF_LOGE("%s: stop receive event success!!", __func__);
1465         return HDF_FAILURE;
1466     }
1467     return HDF_SUCCESS;
1468 }
1469 
UsbFnDviceTestStopReceEvent003(void)1470 int32_t UsbFnDviceTestStopReceEvent003(void)
1471 {
1472     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
1473         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1474         return HDF_FAILURE;
1475     }
1476 
1477     int32_t ret = UsbFnStopRecvInterfaceEvent(g_acmDevice->ctrlIface.fn);
1478     if (ret == HDF_SUCCESS) {
1479         HDF_LOGE("%s: stop receive event success!!", __func__);
1480         return HDF_FAILURE;
1481     }
1482     return HDF_SUCCESS;
1483 }
1484 
UsbFnDviceTestStopReceEvent004(void)1485 int32_t UsbFnDviceTestStopReceEvent004(void)
1486 {
1487     if (g_acmDevice == NULL || g_acmDevice->dataIface.fn == NULL) {
1488         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1489         return HDF_FAILURE;
1490     }
1491 
1492     int32_t ret = UsbFnStopRecvInterfaceEvent(g_acmDevice->dataIface.fn);
1493     if (ret == HDF_SUCCESS) {
1494         HDF_LOGE("%s: stop receive event success!!", __func__);
1495         return HDF_FAILURE;
1496     }
1497     return HDF_SUCCESS;
1498 }
1499 
EventCallBack(struct UsbFnEvent * event)1500 static void EventCallBack(struct UsbFnEvent *event)
1501 {
1502     (void)event;
1503 }
1504 
UsbFnDviceTestStartReceEvent(void)1505 int32_t UsbFnDviceTestStartReceEvent(void)
1506 {
1507     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
1508         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1509         return HDF_FAILURE;
1510     }
1511 
1512     // 0xff: Represents the type of event to handle and can receive all events.
1513     int32_t ret = UsbFnStartRecvInterfaceEvent(g_acmDevice->ctrlIface.fn, 0xff, NULL, g_acmDevice);
1514     if (ret == HDF_SUCCESS) {
1515         HDF_LOGE("%s: start receive event success!!", __func__);
1516         return HDF_FAILURE;
1517     }
1518     return HDF_SUCCESS;
1519 }
1520 
UsbFnDviceTestStartReceEvent002(void)1521 int32_t UsbFnDviceTestStartReceEvent002(void)
1522 {
1523     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
1524         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1525         return HDF_FAILURE;
1526     }
1527 
1528     int32_t ret = UsbFnStartRecvInterfaceEvent(g_acmDevice->ctrlIface.fn, 0x0, EventCallBack, g_acmDevice);
1529     if (ret == HDF_SUCCESS) {
1530         HDF_LOGE("%s: start receive event success!!", __func__);
1531         return HDF_FAILURE;
1532     }
1533     return HDF_SUCCESS;
1534 }
1535 
UsbFnDviceTestStartReceEvent003(void)1536 int32_t UsbFnDviceTestStartReceEvent003(void)
1537 {
1538     if (g_acmDevice == NULL) {
1539         HDF_LOGE("%s: dataIface.handle is invail", __func__);
1540         return HDF_FAILURE;
1541     }
1542 
1543     struct UsbFnInterface *fn = NULL;
1544     int32_t ret = UsbFnStartRecvInterfaceEvent(fn, 0xff, EventCallBack, g_acmDevice);
1545     if (ret == HDF_SUCCESS) {
1546         HDF_LOGE("%s: start receive event success!!", __func__);
1547         return HDF_FAILURE;
1548     }
1549     return HDF_SUCCESS;
1550 }
1551 
UsbFnDviceTestStartReceEvent004(void)1552 int32_t UsbFnDviceTestStartReceEvent004(void)
1553 {
1554     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
1555         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1556         return HDF_FAILURE;
1557     }
1558 
1559     int32_t ret = UsbFnStartRecvInterfaceEvent(g_acmDevice->ctrlIface.fn, 0xff, EventCallBack, g_acmDevice);
1560     if (ret != HDF_SUCCESS) {
1561         HDF_LOGE("%s: start receive event error", __func__);
1562         return HDF_FAILURE;
1563     }
1564     return HDF_SUCCESS;
1565 }
1566 
UsbFnDviceTestStartReceEvent005(void)1567 int32_t UsbFnDviceTestStartReceEvent005(void)
1568 {
1569     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
1570         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1571         return HDF_FAILURE;
1572     }
1573     for (int32_t i = 0; i < TEST_TIMES; i++) {
1574         int32_t ret = UsbFnStopRecvInterfaceEvent(g_acmDevice->ctrlIface.fn);
1575         if (ret != HDF_SUCCESS) {
1576             HDF_LOGE("%s: stop receive event error", __func__);
1577             return HDF_FAILURE;
1578         }
1579         ret = UsbFnStartRecvInterfaceEvent(g_acmDevice->ctrlIface.fn, 0xff, EventCallBack, g_acmDevice);
1580         if (ret != HDF_SUCCESS) {
1581             HDF_LOGE("%s: stop receive event error", __func__);
1582             return HDF_FAILURE;
1583         }
1584     }
1585     return HDF_SUCCESS;
1586 }
1587 
UsbFnDviceTestStartReceEvent006(void)1588 int32_t UsbFnDviceTestStartReceEvent006(void)
1589 {
1590     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
1591         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1592         return HDF_FAILURE;
1593     }
1594 
1595     int32_t ret = UsbFnStartRecvInterfaceEvent(g_acmDevice->ctrlIface.fn, 0xff, EventCallBack, g_acmDevice);
1596     if (ret == HDF_SUCCESS) {
1597         HDF_LOGE("%s: start receive event success!!", __func__);
1598         return HDF_FAILURE;
1599     }
1600     return HDF_SUCCESS;
1601 }
1602 
UsbFnDviceTestStartReceEvent007(void)1603 int32_t UsbFnDviceTestStartReceEvent007(void)
1604 {
1605     if (g_acmDevice == NULL || g_acmDevice->dataIface.fn == NULL) {
1606         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1607         return HDF_FAILURE;
1608     }
1609 
1610     int32_t ret = UsbFnStartRecvInterfaceEvent(g_acmDevice->dataIface.fn, 0xff, EventCallBack, g_acmDevice);
1611     if (ret == HDF_SUCCESS) {
1612         HDF_LOGE("%s: start receive event success!!", __func__);
1613         return HDF_FAILURE;
1614     }
1615     return HDF_SUCCESS;
1616 }
1617 
UsbFnDviceTestOpenInterface(void)1618 int32_t UsbFnDviceTestOpenInterface(void)
1619 {
1620     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
1621         HDF_LOGE("%s: ctrlIface.fn is invail", __func__);
1622         return HDF_FAILURE;
1623     }
1624     if (g_acmDevice->ctrlIface.handle == NULL) {
1625         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1626         return HDF_FAILURE;
1627     }
1628 
1629     UsbFnInterfaceHandle handle = UsbFnOpenInterface(g_acmDevice->ctrlIface.fn);
1630     if (handle == NULL) {
1631         HDF_LOGE("%s: open interface failed", __func__);
1632         return HDF_FAILURE;
1633     }
1634     return HDF_SUCCESS;
1635 }
1636 
UsbFnDviceTestOpenInterface002(void)1637 int32_t UsbFnDviceTestOpenInterface002(void)
1638 {
1639     if (g_acmDevice == NULL || g_acmDevice->dataIface.fn == NULL) {
1640         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1641         return HDF_FAILURE;
1642     }
1643     if (g_acmDevice->dataIface.handle == NULL) {
1644         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1645         return HDF_FAILURE;
1646     }
1647 
1648     UsbFnInterfaceHandle handle = UsbFnOpenInterface(g_acmDevice->dataIface.fn);
1649     if (handle != NULL) {
1650         HDF_LOGE("%s: open interface success!!", __func__);
1651         return HDF_FAILURE;
1652     }
1653     return HDF_SUCCESS;
1654 }
1655 
UsbFnDviceTestOpenInterface003(void)1656 int32_t UsbFnDviceTestOpenInterface003(void)
1657 {
1658     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.fn == NULL) {
1659         HDF_LOGE("%s: ctrlIface.fn is invail", __func__);
1660         return HDF_FAILURE;
1661     }
1662     if (g_acmDevice->ctrlIface.handle == NULL) {
1663         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1664         return HDF_FAILURE;
1665     }
1666 
1667     int32_t ret = UsbFnCloseInterface(g_acmDevice->ctrlIface.handle);
1668     if (ret != HDF_SUCCESS) {
1669         HDF_LOGE("%s: close interface failed", __func__);
1670         return HDF_FAILURE;
1671     }
1672     g_acmDevice->ctrlIface.handle = NULL;
1673     UsbFnInterfaceHandle handle = UsbFnOpenInterface(g_acmDevice->ctrlIface.fn);
1674     if (handle == NULL) {
1675         HDF_LOGE("%s: open interface failed", __func__);
1676         return HDF_FAILURE;
1677     }
1678     g_acmDevice->ctrlIface.handle = handle;
1679     return HDF_SUCCESS;
1680 }
1681 
UsbFnDviceTestOpenInterface004(void)1682 int32_t UsbFnDviceTestOpenInterface004(void)
1683 {
1684     if (g_acmDevice == NULL || g_acmDevice->dataIface.fn == NULL) {
1685         HDF_LOGE("%s: dataIface.handle is invail", __func__);
1686         return HDF_FAILURE;
1687     }
1688     if (g_acmDevice->dataIface.handle == NULL) {
1689         HDF_LOGE("%s: dataIface.handle is invail", __func__);
1690         return HDF_FAILURE;
1691     }
1692 
1693     int32_t ret = UsbFnCloseInterface(g_acmDevice->dataIface.handle);
1694     if (ret != HDF_SUCCESS) {
1695         HDF_LOGE("%s: close interface failed", __func__);
1696         return HDF_FAILURE;
1697     }
1698     g_acmDevice->dataIface.handle = NULL;
1699     UsbFnInterfaceHandle handle = UsbFnOpenInterface(g_acmDevice->dataIface.fn);
1700     if (handle == NULL) {
1701         HDF_LOGE("%s: open interface failed", __func__);
1702         return HDF_FAILURE;
1703     }
1704     g_acmDevice->dataIface.handle = handle;
1705     return HDF_SUCCESS;
1706 }
1707 
UsbFnDviceTestOpenInterface005(void)1708 int32_t UsbFnDviceTestOpenInterface005(void)
1709 {
1710     struct UsbFnInterface *fn = NULL;
1711     UsbFnInterfaceHandle handle = UsbFnOpenInterface(fn);
1712     if (handle != NULL) {
1713         HDF_LOGE("%s: open interface success!!", __func__);
1714         return HDF_FAILURE;
1715     }
1716     return HDF_SUCCESS;
1717 }
1718 
UsbFnDviceTestCloseInterface(void)1719 int32_t UsbFnDviceTestCloseInterface(void)
1720 {
1721     if (g_acmDevice == NULL || g_acmDevice->ctrlIface.handle == NULL) {
1722         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1723         return HDF_FAILURE;
1724     }
1725 
1726     int32_t ret = UsbFnCloseInterface(g_acmDevice->ctrlIface.handle);
1727     if (ret != HDF_SUCCESS) {
1728         HDF_LOGE("%s: close interface error", __func__);
1729         return HDF_FAILURE;
1730     }
1731     g_acmDevice->ctrlIface.handle = NULL;
1732     return HDF_SUCCESS;
1733 }
1734 
UsbFnDviceTestCloseInterface002(void)1735 int32_t UsbFnDviceTestCloseInterface002(void)
1736 {
1737     if (g_acmDevice == NULL || g_acmDevice->dataIface.handle == NULL) {
1738         HDF_LOGE("%s: ctrlIface.handle is invail", __func__);
1739         return HDF_FAILURE;
1740     }
1741 
1742     int32_t ret = UsbFnCloseInterface(g_acmDevice->dataIface.handle);
1743     if (ret != HDF_SUCCESS) {
1744         HDF_LOGE("%s: close interface error", __func__);
1745         return HDF_FAILURE;
1746     }
1747     g_acmDevice->dataIface.handle = NULL;
1748     return HDF_SUCCESS;
1749 }
1750 
UsbFnDviceTestCloseInterface003(void)1751 int32_t UsbFnDviceTestCloseInterface003(void)
1752 {
1753     if (g_acmDevice == NULL) {
1754         HDF_LOGE("%s: dataIface.handle is invail", __func__);
1755         return HDF_FAILURE;
1756     }
1757 
1758     int32_t ret = UsbFnCloseInterface(g_acmDevice->ctrlIface.handle);
1759     if (ret == HDF_SUCCESS) {
1760         HDF_LOGE("%s: close interface success!!", __func__);
1761         return HDF_FAILURE;
1762     }
1763     g_acmDevice->ctrlIface.handle = NULL;
1764     return HDF_SUCCESS;
1765 }
1766 
UsbFnDviceTestCloseInterface004(void)1767 int32_t UsbFnDviceTestCloseInterface004(void)
1768 {
1769     if (g_acmDevice == NULL) {
1770         HDF_LOGE("%s: dataIface.handle is invail", __func__);
1771         return HDF_FAILURE;
1772     }
1773 
1774     int32_t ret = UsbFnCloseInterface(g_acmDevice->dataIface.handle);
1775     if (ret == HDF_SUCCESS) {
1776         HDF_LOGE("%s: close interface success!!", __func__);
1777         return HDF_FAILURE;
1778     }
1779     g_acmDevice->dataIface.handle = NULL;
1780     return HDF_SUCCESS;
1781 }
1782 
UsbFnDviceTestRemove(void)1783 int32_t UsbFnDviceTestRemove(void)
1784 {
1785     struct UsbFnDevice *fnDev = NULL;
1786     int32_t ret = UsbFnRemoveDevice(fnDev);
1787     if (ret == HDF_SUCCESS) {
1788         HDF_LOGE("%s: UsbFnRemoveDevice success!!", __func__);
1789         return HDF_FAILURE;
1790     }
1791     return HDF_SUCCESS;
1792 }
1793 
UsbFnDviceTestRemove002(void)1794 int32_t UsbFnDviceTestRemove002(void)
1795 {
1796     if (g_acmDevice == NULL || g_acmDevice->fnDev == NULL) {
1797         HDF_LOGE("%s: fndev is null", __func__);
1798         return HDF_FAILURE;
1799     }
1800 
1801     ReleaseAcmDevice(g_acmDevice);
1802     int32_t ret = UsbFnRemoveDevice(g_acmDevice->fnDev);
1803     if (ret != HDF_SUCCESS) {
1804         HDF_LOGE("%s: UsbFnRemoveDevice failed, ret = %d", __func__, ret);
1805         return HDF_FAILURE;
1806     }
1807     OsalMemFree(g_acmDevice);
1808     return HDF_SUCCESS;
1809 }
1810