1 /*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <cstdio>
17 #include <cstring>
18 #include <unistd.h>
19 #include <gtest/gtest.h>
20 extern "C" {
21 #include "usb_host_sdk_if_test.h"
22 #include "hdf_base.h"
23 #include "hdf_log.h"
24 #include "osal_mem.h"
25 #include "osal_time.h"
26 #include "securec.h"
27 #include "usb_ddk_interface.h"
28 }
29
30 #define USB_PIPE_DIR_OFFSET 7
31
32 using namespace std;
33 using namespace testing::ext;
34
35 namespace {
36 class UsbHostSdkIfTest : public testing::Test {
37 public:
38 static void SetUpTestCase();
39 static void TearDownTestCase();
40 void SetUp();
41 void TearDown();
42 };
43
44 static struct UsbSession *g_session = NULL;
45 static struct AcmDevice g_deviceService;
46 static struct AcmDevice *g_acm = &g_deviceService;
47 static struct UsbInterface *g_ecmDataIface = NULL;
48 static struct UsbInterface *g_ecmIntIface = NULL;
49 static UsbInterfaceHandle *g_ecmDataDevHandle = NULL;
50 static UsbInterfaceHandle *g_ecmIntDevHandle = NULL;
51
SetUpTestCase()52 void UsbHostSdkIfTest::SetUpTestCase()
53 {
54 }
55
TearDownTestCase()56 void UsbHostSdkIfTest::TearDownTestCase()
57 {
58 }
59
SetUp()60 void UsbHostSdkIfTest::SetUp()
61 {
62 }
63
TearDown()64 void UsbHostSdkIfTest::TearDown()
65 {
66 }
67
AcmReadBulk(struct UsbRequest * req)68 static void AcmReadBulk(struct UsbRequest *req)
69 {
70 uint32_t size;
71 int32_t status = req->compInfo.status;
72 size = req->compInfo.actualLength;
73 printf("Bulk status:%d,actualLength:%d\n", status, size);
74 return;
75 }
76
AcmWriteBulk(struct UsbRequest * req)77 static void AcmWriteBulk(struct UsbRequest *req)
78 {
79 int32_t status;
80
81 if (req == NULL) {
82 printf("%s:%d req is NULL!", __func__, __LINE__);
83 return;
84 }
85
86 status = req->compInfo.status;
87 printf("Bulk Write status:%d\n", status);
88 struct AcmWb *wb = (struct AcmWb *)req->compInfo.userData;
89 switch (status) {
90 case 0:
91 wb->use = 0;
92 break;
93 case -ECONNRESET:
94 case -ENOENT:
95 case -ESHUTDOWN:
96 return;
97 default:
98 return;
99 }
100
101 return;
102 }
103
AcmWriteBufAlloc(struct AcmDevice * acm)104 static int32_t AcmWriteBufAlloc(struct AcmDevice *acm)
105 {
106 int32_t i;
107 struct AcmWb *wb;
108 for (wb = &acm->wb[0],i = 0; i < ACM_NW; i++,wb++) {
109 wb->buf = (uint8_t *)OsalMemCalloc(acm->writeSize);
110 if (!wb->buf) {
111 while (i != 0) {
112 --i;
113 --wb;
114 OsalMemFree(wb->buf);
115 wb->buf = NULL;
116 }
117 return -HDF_ERR_MALLOC_FAIL;
118 }
119 }
120 return 0;
121 }
122
AcmProcessNotification(struct AcmDevice * acm,unsigned char * buf)123 static void AcmProcessNotification(struct AcmDevice *acm, unsigned char *buf)
124 {
125 struct UsbCdcNotification *dr = (struct UsbCdcNotification *)buf;
126 switch (dr->bNotificationType) {
127 case USB_DDK_CDC_NOTIFY_NETWORK_CONNECTION:
128 printf("%s - network connection: %d\n", __func__, dr->wValue);
129 break;
130 case USB_DDK_CDC_NOTIFY_SERIAL_STATE:
131 printf("the serial State change\n");
132 break;
133 default:
134 printf("%s-%d received: index %d len %d\n",
135 __func__,
136 dr->bNotificationType, dr->wIndex, dr->wLength);
137 }
138 return;
139 }
140
AcmCtrlIrq(struct UsbRequest * req)141 static void AcmCtrlIrq(struct UsbRequest *req)
142 {
143 if (req == NULL) {
144 printf("%s:%d req is NULL!", __func__, __LINE__);
145 return;
146 }
147 int32_t retval, ret;
148 struct AcmDevice *acm = (struct AcmDevice *)req->compInfo.userData;
149 unsigned int expectedSize, copySize, allocSize;
150 int32_t status = req->compInfo.status;
151 struct UsbCdcNotification *dr = (struct UsbCdcNotification *)req->compInfo.buffer;
152 unsigned int currentSize = req->compInfo.actualLength;
153 printf("Irqstatus:%d,actualLength:%u\n", status, currentSize);
154 switch (status) {
155 case 0:
156 break;
157 default:
158 return;
159 }
160 if (acm->nbIndex) {
161 dr = (struct UsbCdcNotification *)acm->notificationBuffer;
162 }
163 if (dr == NULL) {
164 printf("%s:%d dr is NULL!", __func__, __LINE__);
165 return;
166 }
167 expectedSize = sizeof(struct UsbCdcNotification) + Le16ToCpu(dr->wLength);
168 if (currentSize < expectedSize) {
169 if (acm->nbSize < expectedSize) {
170 if (acm->nbSize) {
171 OsalMemFree(acm->notificationBuffer);
172 acm->nbSize = 0;
173 }
174 allocSize = expectedSize;
175 acm->notificationBuffer = (uint8_t *)OsalMemCalloc(allocSize);
176 if (!acm->notificationBuffer) {
177 return;
178 }
179 acm->nbSize = allocSize;
180 }
181 copySize = MIN(currentSize, expectedSize - acm->nbIndex);
182 ret = memcpy_s(&acm->notificationBuffer[acm->nbIndex], acm->nbSize - acm->nbIndex,
183 req->compInfo.buffer, copySize);
184 if (ret) {
185 printf("memcpy_s fail\n");
186 }
187 acm->nbIndex += copySize;
188 currentSize = acm->nbIndex;
189 }
190 if (currentSize >= expectedSize) {
191 AcmProcessNotification(acm, (unsigned char *)dr);
192 acm->nbIndex = 0;
193 }
194
195 retval = UsbSubmitRequestAsync(req);
196
197 printf("%s:%d exit", __func__, __LINE__);
198 }
199
UsbControlMsg(struct TestControlMsgData msgData)200 static struct UsbControlRequest UsbControlMsg(struct TestControlMsgData msgData)
201 {
202 struct UsbControlRequest dr;
203 dr.target = (UsbRequestTargetType)(msgData.requestType & TARGET_MASK);
204 dr.reqType = (UsbControlRequestType)((msgData.requestType >> USB_TYPE_OFFSET) & REQUEST_TYPE_MASK);
205 dr.directon = (UsbRequestDirection)((msgData.requestType >> USB_DIR_OFFSET) & DIRECTION_MASK);
206 dr.request = msgData.request;
207 dr.value = CpuToLe16(msgData.value);
208 dr.index = CpuToLe16(msgData.index);
209 dr.buffer = msgData.data;
210 dr.length = CpuToLe16(msgData.size);
211 return dr;
212 }
213
214 /**
215 * @tc.number : CheckHostSdkIfInit001
216 * @tc.name :
217 * @tc.type : PERF
218 * @tc.level : Level 1
219 */
220 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfInit001, TestSize.Level1)
221 {
222 int32_t ret;
223
224 ret = UsbInitHostSdk(&g_session);
225 EXPECT_EQ(HDF_SUCCESS, ret);
226 g_acm->session = g_session;
227 }
228
229 /**
230 * @tc.number : CheckHostSdkIfExit001
231 * @tc.name :
232 * @tc.type : PERF
233 * @tc.level : Level 1
234 */
235 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfExit001, TestSize.Level1)
236 {
237 int32_t ret;
238
239 ret = UsbExitHostSdk(g_acm->session);
240 EXPECT_EQ(HDF_SUCCESS, ret);
241 }
242
243 /**
244 * @tc.number : CheckHostSdkIfInit002
245 * @tc.name :
246 * @tc.type : PERF
247 * @tc.level : Level 1
248 */
249 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfInit002, TestSize.Level1)
250 {
251 int32_t ret;
252
253 ret = UsbInitHostSdk(NULL);
254 EXPECT_EQ(HDF_SUCCESS, ret);
255 }
256
257 /**
258 * @tc.number : CheckHostSdkIfExit002
259 * @tc.name :
260 * @tc.type : PERF
261 * @tc.level : Level 1
262 */
263 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfExit002, TestSize.Level1)
264 {
265 int32_t ret;
266
267 ret = UsbExitHostSdk(NULL);
268 EXPECT_EQ(HDF_SUCCESS, ret);
269 }
270
271 /**
272 * @tc.number : CheckHostSdkIfInit003
273 * @tc.name :
274 * @tc.type : PERF
275 * @tc.level : Level 1
276 */
277 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfInit003, TestSize.Level1)
278 {
279 int32_t ret;
280 int32_t i;
281
282 for (i = 0; i < 100; i++)
283 {
284 ret = UsbInitHostSdk(&g_session);
285 EXPECT_EQ(HDF_SUCCESS, ret);
286 g_acm->session = g_session;
287 ret = UsbExitHostSdk(g_acm->session);
288 EXPECT_EQ(HDF_SUCCESS, ret);
289 }
290 }
291
292 /**
293 * @tc.number : CheckHostSdkIfInit004
294 * @tc.name :
295 * @tc.type : PERF
296 * @tc.level : Level 1
297 */
298 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfInit004, TestSize.Level1)
299 {
300 int32_t ret;
301 int32_t i;
302
303 for (i = 0; i < 100; i++)
304 {
305 ret = UsbInitHostSdk(NULL);
306 EXPECT_EQ(HDF_SUCCESS, ret);
307 ret = UsbExitHostSdk(NULL);
308 EXPECT_EQ(HDF_SUCCESS, ret);
309 }
310 }
311
312 /**
313 * @tc.number : CheckHostSdkIfInit005
314 * @tc.name :
315 * @tc.type : PERF
316 * @tc.level : Level 1
317 */
318 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfInit005, TestSize.Level1)
319 {
320 int32_t ret;
321 int32_t i;
322
323 for (i = 0; i < 100; i++)
324 {
325 ret = UsbInitHostSdk(NULL);
326 EXPECT_EQ(HDF_SUCCESS, ret);
327 }
328 }
329
330 /**
331 * @tc.number : CheckHostSdkIfExit002
332 * @tc.name :
333 * @tc.type : PERF
334 * @tc.level : Level 1
335 */
336 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfExit003, TestSize.Level1)
337 {
338 int32_t ret;
339 int32_t i;
340 for (i = 0; i < 100; i++)
341 {
342 ret = UsbExitHostSdk(NULL);
343 EXPECT_EQ(HDF_SUCCESS, ret);
344 }
345 }
346
347
348 /**
349 * @tc.number : CheckHostSdkIfInit006
350 * @tc.name :
351 * @tc.type : PERF
352 * @tc.level : Level 1
353 */
354 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfInit006, TestSize.Level1)
355 {
356 int32_t ret;
357
358 ret = UsbInitHostSdk(&g_session);
359 EXPECT_EQ(HDF_SUCCESS, ret);
360 g_acm->session = g_session;
361 }
362
363 /**
364 * @tc.number : CheckHostSdkIfClaimInterface001
365 * @tc.name :
366 * @tc.type : PERF
367 * @tc.level : Level 1
368 */
369 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfClaimInterface001, TestSize.Level1)
370 {
371 g_acm->busNum = 1U;
372 g_acm->devAddr = 2U;
373 g_acm->interfaceIndex = 1U;
374
375 g_acm->dataIface = UsbClaimInterface(g_acm->session, g_acm->busNum, g_acm->devAddr, g_acm->interfaceIndex);
376 EXPECT_NE(nullptr, g_acm->dataIface);
377 }
378
379 /**
380 * @tc.number : CheckHostSdkIfReleaseInterface001
381 * @tc.name :
382 * @tc.type : PERF
383 * @tc.level : Level 1
384 */
385 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfReleaseInterface001, TestSize.Level1)
386 {
387 int32_t ret;
388
389 ret = UsbReleaseInterface(g_acm->dataIface);
390 EXPECT_EQ(HDF_SUCCESS, ret);
391 }
392
393 /**
394 * @tc.number : CheckHostSdkIfClaimInterface002
395 * @tc.name :
396 * @tc.type : PERF
397 * @tc.level : Level 1
398 */
399 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfClaimInterface002, TestSize.Level1)
400 {
401 g_acm->busNum = 1U;
402 g_acm->devAddr = 2U;
403 g_acm->interfaceIndex = 0U;
404
405 g_acm->intIface = UsbClaimInterface(g_acm->session, g_acm->busNum, g_acm->devAddr, g_acm->interfaceIndex);
406 EXPECT_NE(nullptr, g_acm->intIface);
407 }
408
409 /**
410 * @tc.number : CheckHostSdkIfReleaseInterface002
411 * @tc.name :
412 * @tc.type : PERF
413 * @tc.level : Level 1
414 */
415 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfReleaseInterface002, TestSize.Level1)
416 {
417 int32_t ret;
418
419 ret = UsbReleaseInterface(g_acm->intIface);
420 EXPECT_EQ(HDF_SUCCESS, ret);
421 }
422
423 /**
424 * @tc.number : CheckHostSdkIfClaimInterface003
425 * @tc.name :
426 * @tc.type : PERF
427 * @tc.level : Level 1
428 */
429 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfClaimInterface003, TestSize.Level1)
430 {
431 g_acm->busNum = 1U;
432 g_acm->devAddr = 2U;
433 g_acm->interfaceIndex = 255U;
434
435 g_acm->ctrIface = UsbClaimInterface(g_acm->session, g_acm->busNum, g_acm->devAddr, g_acm->interfaceIndex);
436 EXPECT_NE(nullptr, g_acm->ctrIface);
437 }
438
439 /**
440 * @tc.number : CheckHostSdkIfReleaseInterface003
441 * @tc.name :
442 * @tc.type : PERF
443 * @tc.level : Level 1
444 */
445 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfReleaseInterface003, TestSize.Level1)
446 {
447 int32_t ret;
448
449 ret = UsbReleaseInterface(g_acm->ctrIface);
450 EXPECT_EQ(HDF_SUCCESS, ret);
451 }
452
453 /**
454 * @tc.number : CheckHostSdkIfReleaseInterface004
455 * @tc.name :
456 * @tc.type : PERF
457 * @tc.level : Level 1
458 */
459 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfReleaseInterface004, TestSize.Level1)
460 {
461 int32_t ret;
462
463 ret = UsbReleaseInterface(NULL);
464 EXPECT_NE(HDF_SUCCESS, ret);
465 }
466
467
468 /**
469 * @tc.number : CheckHostSdkIfClaimInterface004
470 * @tc.name :
471 * @tc.type : PERF
472 * @tc.level : Level 1
473 */
474 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfClaimInterface004, TestSize.Level1)
475 {
476 g_acm->busNum = 1U;
477 g_acm->devAddr = 2U;
478 g_acm->interfaceIndex = 2U;
479
480 g_acm->dataIface = UsbClaimInterface(g_acm->session, g_acm->busNum, g_acm->devAddr, g_acm->interfaceIndex);
481 EXPECT_NE(nullptr, g_acm->dataIface);
482 }
483
484 /**
485 * @tc.number : CheckHostSdkIfClaimInterface005
486 * @tc.name :
487 * @tc.type : PERF
488 * @tc.level : Level 1
489 */
490 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfClaimInterface005, TestSize.Level1)
491 {
492 g_acm->busNum = 1U;
493 g_acm->devAddr = 2U;
494 g_acm->interfaceIndex = 3U;
495
496 g_acm->dataIface = UsbClaimInterface(g_acm->session, g_acm->busNum, g_acm->devAddr, g_acm->interfaceIndex);
497 EXPECT_NE(nullptr, g_acm->dataIface);
498 }
499
500 /**
501 * @tc.number : CheckHostSdkIfClaimInterface006
502 * @tc.name :
503 * @tc.type : PERF
504 * @tc.level : Level 1
505 */
506 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfClaimInterface006, TestSize.Level1)
507 {
508 g_acm = &g_deviceService;
509 g_acm->busNum = 1U;
510 g_acm->devAddr = 2U;
511
512 g_acm->interfaceIndex = 3U;
513 g_acm->dataIface = UsbClaimInterface(g_acm->session, g_acm->busNum, g_acm->devAddr, g_acm->interfaceIndex);
514 EXPECT_NE(nullptr, g_acm->dataIface);
515
516 g_acm->interfaceIndex = 2U;
517 g_acm->intIface = UsbClaimInterface(g_acm->session, g_acm->busNum, g_acm->devAddr, g_acm->interfaceIndex);
518 EXPECT_NE(nullptr, g_acm->intIface);
519
520 g_acm->interfaceIndex = 0U;
521 g_ecmIntIface = UsbClaimInterface(g_acm->session, g_acm->busNum, g_acm->devAddr, g_acm->interfaceIndex);
522 EXPECT_NE(nullptr, g_ecmIntIface);
523
524 g_acm->interfaceIndex = 1U;
525 g_ecmDataIface = UsbClaimInterface(g_acm->session, g_acm->busNum, g_acm->devAddr, g_acm->interfaceIndex);
526 EXPECT_NE(nullptr, g_ecmDataIface);
527
528 g_acm->interfaceIndex = 255U;
529 g_acm->ctrIface = UsbClaimInterface(g_acm->session, g_acm->busNum, g_acm->devAddr, g_acm->interfaceIndex);
530 EXPECT_NE(nullptr, g_acm->ctrIface);
531 }
532
533 /**
534 * @tc.number : CheckHostSdkIfOpenInterface001
535 * @tc.name :
536 * @tc.type : PERF
537 * @tc.level : Level 1
538 */
539 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfOpenInterface001, TestSize.Level1)
540 {
541 g_acm->data_devHandle = UsbOpenInterface(g_acm->dataIface);
542 EXPECT_NE(nullptr, g_acm->data_devHandle);
543 }
544
545 /**
546 * @tc.number : CheckHostSdkIfCloseInterface001
547 * @tc.name :
548 * @tc.type : PERF
549 * @tc.level : Level 1
550 */
551 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfCloseInterface001, TestSize.Level1)
552 {
553 int32_t ret;
554
555 ret = UsbCloseInterface(g_acm->data_devHandle);
556 EXPECT_EQ(HDF_SUCCESS, ret);
557 }
558
559 /**
560 * @tc.number : CheckHostSdkIfOpenInterface002
561 * @tc.name :
562 * @tc.type : PERF
563 * @tc.level : Level 1
564 */
565 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfOpenInterface002, TestSize.Level1)
566 {
567 g_acm->int_devHandle = UsbOpenInterface(g_acm->intIface);
568 EXPECT_NE(nullptr, g_acm->int_devHandle);
569 }
570
571 /**
572 * @tc.number : CheckHostSdkIfCloseInterface002
573 * @tc.name :
574 * @tc.type : PERF
575 * @tc.level : Level 1
576 */
577 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfCloseInterface002, TestSize.Level1)
578 {
579 int32_t ret;
580
581 ret = UsbCloseInterface(g_acm->int_devHandle);
582 EXPECT_EQ(HDF_SUCCESS, ret);
583 }
584
585 /**
586 * @tc.number : CheckHostSdkIfOpenInterface003
587 * @tc.name :
588 * @tc.type : PERF
589 * @tc.level : Level 1
590 */
591 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfOpenInterface003, TestSize.Level1)
592 {
593 g_acm->ctrl_devHandle = UsbOpenInterface(g_acm->ctrIface);
594 EXPECT_NE(nullptr, g_acm->ctrl_devHandle);
595 }
596
597 /**
598 * @tc.number : CheckHostSdkIfCloseInterface003
599 * @tc.name :
600 * @tc.type : PERF
601 * @tc.level : Level 1
602 */
603 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfCloseInterface003, TestSize.Level1)
604 {
605 int32_t ret;
606
607 ret = UsbCloseInterface(NULL);
608 EXPECT_NE(HDF_SUCCESS, ret);
609 }
610
611 /**
612 * @tc.number : CheckHostSdkIfCloseInterface003
613 * @tc.name :
614 * @tc.type : PERF
615 * @tc.level : Level 1
616 */
617 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfCloseInterface004, TestSize.Level1)
618 {
619 int32_t ret;
620
621 ret = UsbCloseInterface(g_acm->ctrl_devHandle);
622 EXPECT_EQ(HDF_SUCCESS, ret);
623 }
624
625 /**
626 * @tc.number : CheckHostSdkIfOpenInterface004
627 * @tc.name :
628 * @tc.type : PERF
629 * @tc.level : Level 1
630 */
631 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfOpenInterface004, TestSize.Level1)
632 {
633 g_acm->data_devHandle = UsbOpenInterface(NULL);
634 EXPECT_EQ(nullptr, g_acm->data_devHandle);
635 }
636
637 /**
638 * @tc.number : CheckHostSdkIfOpenInterface005
639 * @tc.name :
640 * @tc.type : PERF
641 * @tc.level : Level 1
642 */
643 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfOpenInterface005, TestSize.Level1)
644 {
645 int32_t i;
646
647 for (i = 0; i < 100; i++)
648 {
649 g_acm->data_devHandle = UsbOpenInterface(g_acm->dataIface);
650 EXPECT_NE(nullptr, g_acm->data_devHandle);
651 }
652 }
653
654 /**
655 * @tc.number : CheckHostSdkIfOpenInterface006
656 * @tc.name :
657 * @tc.type : PERF
658 * @tc.level : Level 1
659 */
660 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfOpenInterface006, TestSize.Level1)
661 {
662 g_acm->data_devHandle = UsbOpenInterface(g_acm->dataIface);
663 EXPECT_NE(nullptr, g_acm->data_devHandle);
664 g_acm->int_devHandle = UsbOpenInterface(g_acm->intIface);
665 EXPECT_NE(nullptr, g_acm->int_devHandle);
666 g_acm->ctrl_devHandle = UsbOpenInterface(g_acm->ctrIface);
667 EXPECT_NE(nullptr, g_acm->ctrl_devHandle);
668 g_ecmDataDevHandle = UsbOpenInterface(g_ecmDataIface);
669 EXPECT_NE(nullptr, g_ecmDataDevHandle);
670 g_ecmIntDevHandle = UsbOpenInterface(g_ecmIntIface);
671 EXPECT_NE(nullptr, g_ecmIntDevHandle);
672 }
673
674 /**
675 * @tc.number : CheckHostSdkIfSelectInterfaceSetting001
676 * @tc.name :
677 * @tc.type : PERF
678 * @tc.level : Level 1
679 */
680 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfSelectInterfaceSetting001, TestSize.Level1)
681 {
682 int32_t ret;
683 int32_t settingIndex = 0;
684
685 ret = UsbSelectInterfaceSetting(g_ecmDataDevHandle, settingIndex, &g_ecmDataIface);
686 EXPECT_EQ(HDF_SUCCESS, ret);
687 }
688
689 /**
690 * @tc.number : CheckHostSdkIfSelectInterfaceSetting002
691 * @tc.name :
692 * @tc.type : PERF
693 * @tc.level : Level 1
694 */
695 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfSelectInterfaceSetting002, TestSize.Level1)
696 {
697 int32_t ret;
698 int32_t settingIndex = 10;
699
700 ret = UsbSelectInterfaceSetting(g_ecmDataDevHandle, settingIndex, &g_ecmDataIface);
701 EXPECT_EQ(HDF_FAILURE, ret);
702 }
703
704 /**
705 * @tc.number : CheckHostSdkIfSelectInterfaceSetting003
706 * @tc.name :
707 * @tc.type : PERF
708 * @tc.level : Level 1
709 */
710 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfSelectInterfaceSetting003, TestSize.Level1)
711 {
712 int32_t ret;
713 int32_t settingIndex = 100;
714
715 ret = UsbSelectInterfaceSetting(g_ecmDataDevHandle, settingIndex, &g_ecmDataIface);
716 EXPECT_EQ(HDF_FAILURE, ret);
717 }
718
719 /**
720 * @tc.number : CheckHostSdkIfSelectInterfaceSetting004
721 * @tc.name :
722 * @tc.type : PERF
723 * @tc.level : Level 1
724 */
725 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfSelectInterfaceSetting004, TestSize.Level1)
726 {
727 int32_t ret;
728 int32_t settingIndex = 200;
729
730 ret = UsbSelectInterfaceSetting(g_ecmDataDevHandle, settingIndex, &g_ecmDataIface);
731 EXPECT_EQ(HDF_FAILURE, ret);
732 }
733
734 /**
735 * @tc.number : CheckHostSdkIfSelectInterfaceSetting005
736 * @tc.name :
737 * @tc.type : PERF
738 * @tc.level : Level 1
739 */
740 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfSelectInterfaceSetting005, TestSize.Level1)
741 {
742 int32_t ret;
743 int32_t settingIndex = 255;
744
745 ret = UsbSelectInterfaceSetting(g_ecmDataDevHandle, settingIndex, &g_ecmDataIface);
746 EXPECT_EQ(HDF_FAILURE, ret);
747 }
748
749 /**
750 * @tc.number : CheckHostSdkIfSelectInterfaceSetting006
751 * @tc.name :
752 * @tc.type : PERF
753 * @tc.level : Level 1
754 */
755 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfSelectInterfaceSetting006, TestSize.Level1)
756 {
757 int32_t ret;
758 int32_t settingIndex = 1;
759
760 ret = UsbSelectInterfaceSetting(g_ecmDataDevHandle, settingIndex, &g_ecmDataIface);
761 EXPECT_EQ(HDF_SUCCESS, ret);
762 }
763
764 /**
765 * @tc.number : CheckHostSdkIfClaimInterface007
766 * @tc.name :
767 * @tc.type : PERF
768 * @tc.level : Level 1
769 */
770 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfClaimInterface007, TestSize.Level1)
771 {
772 g_acm->busNum = 1U;
773 g_acm->devAddr = 2U;
774 g_acm->interfaceIndex = 0U;
775
776 g_ecmIntIface = UsbClaimInterface(g_acm->session, g_acm->busNum, g_acm->devAddr, g_acm->interfaceIndex);
777 EXPECT_NE(nullptr, g_ecmIntIface);
778 }
779
780 /**
781 * @tc.number : CheckHostSdkIfClaimInterface008
782 * @tc.name :
783 * @tc.type : PERF
784 * @tc.level : Level 1
785 */
786 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfClaimInterface008, TestSize.Level1)
787 {
788 g_acm->busNum = 100U;
789 g_acm->devAddr = 200U;
790 g_acm->interfaceIndex = 100U;
791
792 g_ecmDataIface = UsbClaimInterface(g_acm->session, g_acm->busNum, g_acm->devAddr, g_acm->interfaceIndex);
793 EXPECT_EQ(nullptr, g_ecmDataIface);
794 }
795
796 /**
797 * @tc.number : CheckHostSdkIfClaimInterface009
798 * @tc.name :
799 * @tc.type : PERF
800 * @tc.level : Level 1
801 */
802 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfClaimInterface009, TestSize.Level1)
803 {
804 g_acm->busNum = 1U;
805 g_acm->devAddr = 2U;
806 g_acm->interfaceIndex = 1U;
807
808 g_ecmDataIface = UsbClaimInterface(g_acm->session, g_acm->busNum, g_acm->devAddr, g_acm->interfaceIndex);
809 EXPECT_NE(nullptr, g_ecmDataIface);
810 }
811
812 /**
813 * @tc.number : CheckHostSdkIfGetPipe001
814 * @tc.name :
815 * @tc.type : PERF
816 * @tc.level : Level 1
817 */
818 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfGetPipe001, TestSize.Level1)
819 {
820 int32_t ret;
821 struct UsbPipeInfo p;
822 int32_t i;
823
824 for (i = 0; i <= g_acm->dataIface->info.pipeNum; i++) {
825 ret = UsbGetPipeInfo(NULL, g_acm->dataIface->info.curAltSetting, i, &p);
826 if (ret < 0) {
827 continue;
828 }
829 if ((p.pipeDirection == USB_PIPE_DIRECTION_IN) && (p.pipeType == USB_PIPE_TYPE_BULK)) {
830 struct UsbPipeInfo *pi = (UsbPipeInfo *)OsalMemCalloc(sizeof(*pi));
831 EXPECT_NE(nullptr, pi);
832 p.interfaceId = g_acm->dataIface->info.interfaceIndex;
833 *pi = p;
834 g_acm->dataInPipe = pi;
835 break;
836 }
837 }
838 EXPECT_EQ(nullptr, g_acm->dataInPipe);
839 }
840
841 /**
842 * @tc.number : CheckHostSdkIfGetPipe002
843 * @tc.name :
844 * @tc.type : PERF
845 * @tc.level : Level 1
846 */
847 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfGetPipe002, TestSize.Level1)
848 {
849 int32_t ret;
850 struct UsbPipeInfo p;
851 int32_t i;
852
853 for (i = 0; i <= g_acm->dataIface->info.pipeNum; i++) {
854 ret = UsbGetPipeInfo(g_acm->data_devHandle, g_acm->dataIface->info.curAltSetting, i, &p);
855 if (ret < 0) {
856 continue;
857 }
858 if ((p.pipeDirection == USB_PIPE_DIRECTION_IN) && (p.pipeType == USB_PIPE_TYPE_BULK)) {
859 struct UsbPipeInfo *pi = (UsbPipeInfo *)OsalMemCalloc(sizeof(*pi));
860 EXPECT_NE(nullptr, pi);
861 p.interfaceId = g_acm->dataIface->info.interfaceIndex;
862 *pi = p;
863 g_acm->dataInPipe = pi;
864 break;
865 }
866 }
867 EXPECT_NE(nullptr, g_acm->dataInPipe);
868 }
869
870 /**
871 * @tc.number : CheckHostSdkIfGetPipe003
872 * @tc.name :
873 * @tc.type : PERF
874 * @tc.level : Level 1
875 */
876 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfGetPipe003, TestSize.Level1)
877 {
878 int32_t ret;
879 struct UsbPipeInfo p;
880 int32_t i;
881
882 for (i = 0; i <= g_acm->dataIface->info.pipeNum; i++) {
883 ret = UsbGetPipeInfo(NULL, g_acm->dataIface->info.curAltSetting, i, &p);
884 if (ret < 0) {
885 continue;
886 }
887 if ((p.pipeDirection == USB_PIPE_DIRECTION_OUT) && (p.pipeType == USB_PIPE_TYPE_BULK)) {
888 struct UsbPipeInfo *pi = (UsbPipeInfo *)OsalMemCalloc(sizeof(*pi));
889 EXPECT_NE(nullptr, pi);
890 p.interfaceId = g_acm->dataIface->info.interfaceIndex;
891 *pi = p;
892 g_acm->dataOutPipe = pi;
893 break;
894 }
895 }
896 EXPECT_EQ(nullptr, g_acm->dataOutPipe);
897 }
898
899 /**
900 * @tc.number : CheckHostSdkIfGetPipe004
901 * @tc.name :
902 * @tc.type : PERF
903 * @tc.level : Level 1
904 */
905 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfGetPipe004, TestSize.Level1)
906 {
907 int32_t ret;
908 struct UsbPipeInfo p;
909 int32_t i;
910
911 for (i = 0; i <= g_acm->dataIface->info.pipeNum; i++) {
912 ret = UsbGetPipeInfo(g_acm->data_devHandle, g_acm->dataIface->info.curAltSetting, i, &p);
913 if (ret < 0) {
914 continue;
915 }
916 if ((p.pipeDirection == USB_PIPE_DIRECTION_OUT) && (p.pipeType == USB_PIPE_TYPE_BULK)) {
917 struct UsbPipeInfo *pi = (UsbPipeInfo *)OsalMemCalloc(sizeof(*pi));
918 EXPECT_NE(nullptr, pi);
919 p.interfaceId = g_acm->dataIface->info.interfaceIndex;
920 *pi = p;
921 g_acm->dataOutPipe = pi;
922 break;
923 }
924 }
925 EXPECT_NE(nullptr, g_acm->dataOutPipe);
926 }
927
928 /**
929 * @tc.number : CheckHostSdkIfGetPipe005
930 * @tc.name :
931 * @tc.type : PERF
932 * @tc.level : Level 1
933 */
934 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfGetPipe005, TestSize.Level1)
935 {
936 int32_t ret;
937 struct UsbPipeInfo p;
938 int32_t i;
939
940 for (i = 0; i <= g_acm->intIface->info.pipeNum; i++) {
941 ret = UsbGetPipeInfo(NULL, g_acm->intIface->info.curAltSetting, i, &p);
942 if (ret < 0) {
943 continue;
944 }
945 if ((p.pipeDirection == USB_PIPE_DIRECTION_IN) && (p.pipeType == USB_PIPE_TYPE_INTERRUPT)) {
946 struct UsbPipeInfo *pi = (UsbPipeInfo *)OsalMemCalloc(sizeof(*pi));
947 p.interfaceId = g_acm->intIface->info.interfaceIndex;
948 *pi = p;
949 g_acm->intPipe = pi;
950 break;
951 }
952 }
953 EXPECT_EQ(nullptr, g_acm->intPipe);
954 }
955
956 /**
957 * @tc.number : CheckHostSdkIfGetPipe006
958 * @tc.name :
959 * @tc.type : PERF
960 * @tc.level : Level 1
961 */
962 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfGetPipe006, TestSize.Level1)
963 {
964 int32_t ret;
965 struct UsbPipeInfo p;
966 int32_t i;
967
968 for (i = 0; i <= g_acm->intIface->info.pipeNum; i++) {
969 ret = UsbGetPipeInfo(g_acm->int_devHandle, g_acm->intIface->info.curAltSetting, i, &p);
970 if (ret < 0) {
971 continue;
972 }
973 if ((p.pipeDirection == USB_PIPE_DIRECTION_IN) && (p.pipeType == USB_PIPE_TYPE_INTERRUPT)) {
974 struct UsbPipeInfo *pi = (UsbPipeInfo *)OsalMemCalloc(sizeof(*pi));
975 p.interfaceId = g_acm->intIface->info.interfaceIndex;
976 *pi = p;
977 g_acm->intPipe = pi;
978 break;
979 }
980 }
981 EXPECT_NE(nullptr, g_acm->intPipe);
982 }
983
984 /**
985 * @tc.number : CheckHostSdkIfGetPipe007
986 * @tc.name :
987 * @tc.type : PERF
988 * @tc.level : Level 1
989 */
990 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfGetPipe007, TestSize.Level1)
991 {
992 int32_t ret;
993 struct UsbPipeInfo p;
994 int32_t i;
995
996 g_acm->interfaceIndex = 255;
997
998 for (i = 0; i <= g_acm->ctrIface->info.pipeNum; i++) {
999 ret = UsbGetPipeInfo(NULL, g_acm->ctrIface->info.curAltSetting, i, &p);
1000 if (ret < 0) {
1001 continue;
1002 }
1003 if ((p.pipeDirection == USB_PIPE_DIRECTION_OUT) && (p.pipeType == USB_PIPE_TYPE_CONTROL)) {
1004 struct UsbPipeInfo *pi = (UsbPipeInfo *)OsalMemCalloc(sizeof(*pi));
1005 p.interfaceId = g_acm->interfaceIndex;
1006 *pi = p;
1007 g_acm->ctrPipe = pi;
1008 break;
1009 }
1010 }
1011 EXPECT_EQ(nullptr, g_acm->ctrPipe);
1012 }
1013
1014 /**
1015 * @tc.number : CheckHostSdkIfGetPipe008
1016 * @tc.name :
1017 * @tc.type : PERF
1018 * @tc.level : Level 1
1019 */
1020 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfGetPipe008, TestSize.Level1)
1021 {
1022 int32_t ret;
1023 struct UsbPipeInfo p;
1024 int32_t i;
1025
1026 g_acm->interfaceIndex = 255;
1027
1028 for (i = 0; i <= g_acm->ctrIface->info.pipeNum; i++) {
1029 ret = UsbGetPipeInfo(g_acm->ctrl_devHandle, g_acm->ctrIface->info.curAltSetting, i, &p);
1030 if (ret < 0) {
1031 continue;
1032 }
1033 if ((p.pipeDirection == USB_PIPE_DIRECTION_OUT) && (p.pipeType == USB_PIPE_TYPE_CONTROL)) {
1034 struct UsbPipeInfo *pi = (UsbPipeInfo *)OsalMemCalloc(sizeof(*pi));
1035 p.interfaceId = g_acm->interfaceIndex;
1036 *pi = p;
1037 g_acm->ctrPipe = pi;
1038 break;
1039 }
1040 }
1041 EXPECT_NE(nullptr, g_acm->ctrPipe);
1042 }
1043
1044 /**
1045 * @tc.number : CheckHostSdkIfGetPipe009
1046 * @tc.name :
1047 * @tc.type : PERF
1048 * @tc.level : Level 1
1049 */
1050 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfGetPipe009, TestSize.Level1)
1051 {
1052 int32_t ret;
1053 struct UsbPipeInfo p;
1054
1055 ret = UsbGetPipeInfo(NULL, 0, 0, &p);
1056 EXPECT_NE(HDF_SUCCESS, ret);
1057 }
1058
1059 /**
1060 * @tc.number : CheckHostSdkIfGetPipe010
1061 * @tc.name :
1062 * @tc.type : PERF
1063 * @tc.level : Level 1
1064 */
1065 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfGetPipe010, TestSize.Level1)
1066 {
1067 int32_t ret;
1068
1069 ret = UsbGetPipeInfo(g_acm->ctrl_devHandle, 0, 0, NULL);
1070 EXPECT_NE(HDF_SUCCESS, ret);
1071
1072 }
1073
1074 /**
1075 * @tc.number : CheckHostSdkIfGetPipe0011
1076 * @tc.name :
1077 * @tc.type : PERF
1078 * @tc.level : Level 1
1079 */
1080 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfGetPipe011, TestSize.Level1)
1081 {
1082 int32_t ret;
1083 struct UsbPipeInfo p;
1084
1085 ret = UsbGetPipeInfo(g_acm->ctrl_devHandle, 0, 0, &p);
1086 EXPECT_EQ(HDF_SUCCESS, ret);
1087 }
1088
1089 /**
1090 * @tc.number : CheckHostSdkIfAllocRequest001
1091 * @tc.name :
1092 * @tc.type : PERF
1093 * @tc.level : Level 1
1094 */
1095 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfAllocRequest001, TestSize.Level1)
1096 {
1097 int32_t i;
1098
1099 g_acm->readSize = g_acm->dataInPipe->maxPacketSize;
1100 printf("------readSize = [%d]------\n", g_acm->readSize);
1101 for (i = 0; i < ACM_NR; i++) {
1102 g_acm->readReq[i] = UsbAllocRequest(NULL, 0, g_acm->readSize);
1103 EXPECT_EQ(nullptr, g_acm->readReq[i]);
1104 }
1105 }
1106
1107 /**
1108 * @tc.number : CheckHostSdkIfAllocRequest002
1109 * @tc.name :
1110 * @tc.type : PERF
1111 * @tc.level : Level 1
1112 */
1113 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfAllocRequest002, TestSize.Level1)
1114 {
1115 int32_t i;
1116
1117 g_acm->readSize = g_acm->dataInPipe->maxPacketSize;
1118 printf("------readSize = [%d]------\n", g_acm->readSize);
1119 for (i = 0; i < ACM_NR; i++) {
1120 g_acm->readReq[i] = UsbAllocRequest(g_acm->data_devHandle, 0, g_acm->readSize);
1121 EXPECT_NE(nullptr, g_acm->readReq[i]);
1122 }
1123 }
1124
1125 /**
1126 * @tc.number : CheckHostSdkIfFreeRequest001
1127 * @tc.name :
1128 * @tc.type : PERF
1129 * @tc.level : Level 1
1130 */
1131 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFreeRequest001, TestSize.Level1)
1132 {
1133 int32_t ret;
1134 int32_t i;
1135
1136 for (i = 0; i < ACM_NR; i++) {
1137 ret = UsbFreeRequest(g_acm->readReq[i]);
1138 EXPECT_EQ(HDF_SUCCESS, ret);
1139 }
1140 }
1141
1142 /**
1143 * @tc.number : CheckHostSdkIfAllocRequest003
1144 * @tc.name :
1145 * @tc.type : PERF
1146 * @tc.level : Level 1
1147 */
1148 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfAllocRequest003, TestSize.Level1)
1149 {
1150 int32_t i;
1151 int32_t ret;
1152
1153 g_acm->writeSize = g_acm->dataOutPipe->maxPacketSize;
1154 ret = AcmWriteBufAlloc(g_acm);
1155 EXPECT_EQ(HDF_SUCCESS, ret);
1156
1157 for (i = 0; i < ACM_NW; i++) {
1158 g_acm->wb[i].request = UsbAllocRequest(NULL, 0, g_acm->writeSize);
1159 g_acm->wb[i].instance = g_acm;
1160 EXPECT_EQ(nullptr, g_acm->wb[i].request);
1161 }
1162 }
1163
1164 /**
1165 * @tc.number : CheckHostSdkIfAllocRequest004
1166 * @tc.name :
1167 * @tc.type : PERF
1168 * @tc.level : Level 1
1169 */
1170 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfAllocRequest004, TestSize.Level1)
1171 {
1172 int32_t i;
1173 int32_t ret;
1174
1175 g_acm->writeSize = g_acm->dataOutPipe->maxPacketSize;
1176 ret = AcmWriteBufAlloc(g_acm);
1177 EXPECT_EQ(HDF_SUCCESS, ret);
1178
1179 for (i = 0; i < ACM_NW; i++) {
1180 g_acm->wb[i].request = UsbAllocRequest(g_acm->data_devHandle, 0, g_acm->writeSize);
1181 g_acm->wb[i].instance = g_acm;
1182 EXPECT_NE(nullptr, g_acm->wb[i].request);
1183 }
1184 }
1185
1186 /**
1187 * @tc.number : CheckHostSdkIfFreeRequest002
1188 * @tc.name :
1189 * @tc.type : PERF
1190 * @tc.level : Level 1
1191 */
1192 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFreeRequest002, TestSize.Level1)
1193 {
1194 int32_t ret;
1195 int32_t i;
1196
1197 for (i = 0; i < ACM_NR; i++) {
1198 ret = UsbFreeRequest(g_acm->wb[i].request);
1199 EXPECT_EQ(HDF_SUCCESS, ret);
1200 }
1201 }
1202
1203 /**
1204 * @tc.number : CheckHostSdkIfAllocRequest005
1205 * @tc.name :
1206 * @tc.type : PERF
1207 * @tc.level : Level 1
1208 */
1209 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfAllocRequest005, TestSize.Level1)
1210 {
1211 g_acm->intSize = g_acm->intPipe->maxPacketSize;
1212 g_acm->notifyReq = UsbAllocRequest(NULL, 0, g_acm->intSize);
1213 EXPECT_EQ(nullptr, g_acm->notifyReq);
1214 }
1215
1216 /**
1217 * @tc.number : CheckHostSdkIfAllocRequest006
1218 * @tc.name :
1219 * @tc.type : PERF
1220 * @tc.level : Level 1
1221 */
1222 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfAllocRequest006, TestSize.Level1)
1223 {
1224 g_acm->intSize = g_acm->intPipe->maxPacketSize;
1225 g_acm->notifyReq = UsbAllocRequest(g_acm->int_devHandle, 0, g_acm->intSize);
1226 EXPECT_NE(nullptr, g_acm->notifyReq);
1227 }
1228
1229 /**
1230 * @tc.number : CheckHostSdkIfFreeRequest003
1231 * @tc.name :
1232 * @tc.type : PERF
1233 * @tc.level : Level 1
1234 */
1235 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFreeRequest003, TestSize.Level1)
1236 {
1237 int32_t ret;
1238
1239 ret = UsbFreeRequest(g_acm->notifyReq);
1240 EXPECT_EQ(HDF_SUCCESS, ret);
1241 }
1242
1243 /**
1244 * @tc.number : CheckHostSdkIfAllocRequest007
1245 * @tc.name :
1246 * @tc.type : PERF
1247 * @tc.level : Level 1
1248 */
1249 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfAllocRequest007, TestSize.Level1)
1250 {
1251 g_acm->ctrlSize = sizeof (struct UsbCdcLineCoding);
1252 g_acm->ctrlReq = UsbAllocRequest(NULL, 0, g_acm->ctrlSize);
1253 EXPECT_EQ(nullptr, g_acm->ctrlReq);
1254 }
1255
1256 /**
1257 * @tc.number : CheckHostSdkIfAllocRequest008
1258 * @tc.name :
1259 * @tc.type : PERF
1260 * @tc.level : Level 1
1261 */
1262 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfAllocRequest008, TestSize.Level1)
1263 {
1264 g_acm->ctrlSize = sizeof (struct UsbCdcLineCoding);
1265 g_acm->ctrlReq = UsbAllocRequest(g_acm->ctrl_devHandle, 0, g_acm->ctrlSize);
1266 EXPECT_NE(nullptr, g_acm->ctrlReq);
1267 }
1268
1269 /**
1270 * @tc.number : CheckHostSdkIfFreeRequest004
1271 * @tc.name :
1272 * @tc.type : PERF
1273 * @tc.level : Level 1
1274 */
1275 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFreeRequest004, TestSize.Level1)
1276 {
1277 int32_t ret;
1278
1279 ret = UsbFreeRequest(g_acm->ctrlReq);
1280 EXPECT_EQ(HDF_SUCCESS, ret);
1281 }
1282
1283 /**
1284 * @tc.number : CheckHostSdkIfFreeRequest005
1285 * @tc.name :
1286 * @tc.type : PERF
1287 * @tc.level : Level 1
1288 */
1289 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFreeRequest005, TestSize.Level1)
1290 {
1291 int32_t ret;
1292
1293 ret = UsbFreeRequest(NULL);
1294 EXPECT_NE(HDF_SUCCESS, ret);
1295 }
1296
1297 /**
1298 * @tc.number : CheckHostSdkIfAllocRequest009
1299 * @tc.name :
1300 * @tc.type : PERF
1301 * @tc.level : Level 1
1302 */
1303 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfAllocRequest009, TestSize.Level1)
1304 {
1305 int32_t i;
1306
1307 g_acm->readSize = g_acm->dataInPipe->maxPacketSize;
1308 for (i = 0; i < ACM_NR; i++) {
1309 g_acm->readReq[i] = UsbAllocRequest(g_acm->data_devHandle, 0, g_acm->readSize);
1310 EXPECT_NE(nullptr, g_acm->readReq[i]);
1311 }
1312
1313 g_acm->writeSize = g_acm->dataOutPipe->maxPacketSize;
1314 for (int32_t i = 0; i < ACM_NW; i++) {
1315 g_acm->wb[i].request = UsbAllocRequest(g_acm->data_devHandle, 0, g_acm->writeSize);
1316 g_acm->wb[i].instance = g_acm;
1317 EXPECT_NE(nullptr, g_acm->wb[i].request);
1318 }
1319
1320 g_acm->intSize = g_acm->intPipe->maxPacketSize;
1321 g_acm->notifyReq = UsbAllocRequest(g_acm->int_devHandle, 0, g_acm->intSize);
1322 EXPECT_NE(nullptr, g_acm->notifyReq);
1323 g_acm->ctrlSize = sizeof (struct UsbCdcLineCoding);
1324 g_acm->ctrlReq = UsbAllocRequest(g_acm->ctrl_devHandle, 0, g_acm->ctrlSize);
1325 EXPECT_NE(nullptr, g_acm->ctrlReq);
1326 }
1327
1328 /**
1329 * @tc.number : CheckHostSdkIfAllocRequest010
1330 * @tc.name :
1331 * @tc.type : PERF
1332 * @tc.level : Level 1
1333 */
1334 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfAllocRequest010, TestSize.Level1)
1335 {
1336 struct UsbRequest *req = UsbAllocRequest(NULL, 0, 0);
1337 EXPECT_EQ(nullptr, req);
1338 }
1339
1340 /**
1341 * @tc.number : CheckHostSdkIfFillRequest001
1342 * @tc.name :
1343 * @tc.type : PERF
1344 * @tc.level : Level 1
1345 */
1346 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFillRequest001, TestSize.Level1)
1347 {
1348 int32_t ret;
1349 struct UsbRequestParams readParmas;
1350 int32_t i;
1351
1352 for (i = 0; i < 1; i++) {
1353 readParmas.userData = (void *)g_acm;
1354 readParmas.pipeAddress = g_acm->dataInPipe->pipeAddress;
1355 readParmas.pipeId = g_acm->dataInPipe->pipeId;
1356 readParmas.interfaceId = g_acm->dataInPipe->interfaceId;
1357 readParmas.callback = AcmReadBulk;
1358 readParmas.requestType = USB_REQUEST_PARAMS_DATA_TYPE;
1359 readParmas.timeout = USB_CTRL_SET_TIMEOUT;
1360 readParmas.dataReq.numIsoPackets = 0;
1361 readParmas.dataReq.directon = (UsbRequestDirection)((g_acm->dataInPipe->pipeDirection >> USB_DIR_OFFSET) \
1362 & 0x1);
1363 readParmas.dataReq.length = g_acm->readSize;
1364 ret = UsbFillRequest(g_acm->readReq[i], g_acm->data_devHandle, &readParmas);
1365 EXPECT_EQ(HDF_SUCCESS, ret);
1366 }
1367 }
1368
1369 /**
1370 * @tc.number : CheckHostSdkIfFillRequest002
1371 * @tc.name :
1372 * @tc.type : PERF
1373 * @tc.level : Level 1
1374 */
1375 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFillRequest002, TestSize.Level1)
1376 {
1377 int32_t ret;
1378 struct UsbRequestParams parmas;
1379 int32_t i;
1380 char sendData[] = {"abcde\0"};
1381 uint32_t size = strlen(sendData) + 1;
1382
1383 g_acm->writeSize = g_acm->dataOutPipe->maxPacketSize;
1384 size = (size > g_acm->writeSize) ? g_acm->writeSize : size;
1385
1386 for (i = 0; i < 1; i++) {
1387 g_acm->wb[i].len = size;
1388 ret = memcpy_s(g_acm->wb[i].buf, g_acm->writeSize, sendData, size);
1389 if (ret) {
1390 printf("memcpy_s fial");
1391 }
1392
1393 parmas.interfaceId = g_acm->dataOutPipe->interfaceId;
1394 parmas.pipeAddress = g_acm->dataOutPipe->pipeAddress;
1395 parmas.pipeId = g_acm->dataOutPipe->pipeId;
1396 parmas.callback = AcmWriteBulk;
1397 parmas.requestType = USB_REQUEST_PARAMS_DATA_TYPE;
1398 parmas.timeout = USB_CTRL_SET_TIMEOUT;
1399 parmas.dataReq.numIsoPackets = 0;
1400 parmas.userData = (void *)&g_acm->wb[i];
1401 parmas.dataReq.length = g_acm->wb[i].len;
1402 parmas.dataReq.buffer = g_acm->wb[i].buf;
1403 ret = UsbFillRequest(g_acm->wb[i].request, g_acm->data_devHandle, &parmas);
1404 EXPECT_EQ(HDF_SUCCESS, ret);
1405 }
1406 }
1407
1408 /**
1409 * @tc.number : CheckHostSdkIfFillRequest003
1410 * @tc.name :
1411 * @tc.type : PERF
1412 * @tc.level : Level 1
1413 */
1414 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFillRequest003, TestSize.Level1)
1415 {
1416 int32_t ret;
1417 struct UsbRequestParams intParmas;
1418
1419 intParmas.userData = (void *)g_acm;
1420 intParmas.pipeAddress = g_acm->intPipe->pipeAddress;
1421 intParmas.pipeId = g_acm->intPipe->pipeId;
1422 intParmas.interfaceId = g_acm->intPipe->interfaceId;
1423 intParmas.callback = AcmCtrlIrq;
1424 intParmas.requestType = USB_REQUEST_PARAMS_DATA_TYPE;
1425 intParmas.timeout = USB_CTRL_SET_TIMEOUT;
1426 intParmas.dataReq.numIsoPackets = 0;
1427 intParmas.dataReq.directon = (UsbRequestDirection)((g_acm->intPipe->pipeDirection >> USB_PIPE_DIR_OFFSET) \
1428 & DIRECTION_MASK);
1429 intParmas.dataReq.length = g_acm->intSize;
1430 ret = UsbFillRequest(g_acm->notifyReq, g_acm->int_devHandle, &intParmas);
1431 EXPECT_EQ(HDF_SUCCESS, ret);
1432 }
1433
1434 /**
1435 * @tc.number : CheckHostSdkIfFillRequest004
1436 * @tc.name :
1437 * @tc.type : PERF
1438 * @tc.level : Level 1
1439 */
1440 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFillRequest004, TestSize.Level1)
1441 {
1442 int32_t ret;
1443 struct UsbRequestParams parmas;
1444 uint16_t index = 0;
1445 uint16_t value = 0;
1446 struct TestControlMsgData msgData = {0};
1447
1448 parmas.interfaceId = USB_CTRL_INTERFACE_ID;
1449 parmas.pipeAddress = 0;
1450 parmas.pipeId = 0;
1451 parmas.callback = AcmCtrlIrq;
1452 parmas.requestType = USB_REQUEST_PARAMS_CTRL_TYPE;
1453 parmas.timeout = USB_CTRL_SET_TIMEOUT;
1454
1455 g_acm->lineCoding.dwDTERate = CpuToLe32(DATARATE);
1456 g_acm->lineCoding.bCharFormat = USB_CDC_1_STOP_BITS;
1457 g_acm->lineCoding.bParityType = USB_CDC_NO_PARITY;
1458 g_acm->lineCoding.bDataBits = DATA_BITS_LENGTH;
1459
1460 msgData.request = USB_DDK_CDC_REQ_SET_LINE_CODING;
1461 msgData.requestType = USB_DDK_TYPE_CLASS | USB_DDK_RECIP_INTERFACE;
1462 msgData.value = value;
1463 msgData.index = index;
1464 msgData.data = &g_acm->lineCoding;
1465 msgData.size = sizeof (struct UsbCdcLineCoding);
1466 parmas.ctrlReq = UsbControlMsg(msgData);
1467 ret = UsbFillRequest(g_acm->ctrlReq, g_acm->ctrl_devHandle, &parmas);
1468 EXPECT_EQ(HDF_SUCCESS, ret);
1469 }
1470
1471
1472 /**
1473 * @tc.number : CheckHostSdkIfFillRequest005
1474 * @tc.name :
1475 * @tc.type : PERF
1476 * @tc.level : Level 1
1477 */
1478 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFillRequest005, TestSize.Level1)
1479 {
1480 int32_t ret;
1481 struct UsbRequestParams readParmas;
1482 int32_t i;
1483
1484 for (i = 0; i < ACM_NR; i++) {
1485 readParmas.userData = (void *)g_acm;
1486 readParmas.pipeAddress = g_acm->dataInPipe->pipeAddress;
1487 readParmas.pipeId = g_acm->dataInPipe->pipeId;
1488 readParmas.interfaceId = g_acm->dataInPipe->interfaceId;
1489 readParmas.callback = AcmReadBulk;
1490 readParmas.requestType = USB_REQUEST_PARAMS_DATA_TYPE;
1491 readParmas.timeout = USB_CTRL_SET_TIMEOUT;
1492 readParmas.dataReq.numIsoPackets = 0;
1493 readParmas.dataReq.directon = (UsbRequestDirection)((g_acm->dataInPipe->pipeDirection >> USB_DIR_OFFSET) \
1494 & 0x1);
1495 readParmas.dataReq.length = g_acm->readSize;
1496 ret = UsbFillRequest(g_acm->readReq[i], g_acm->data_devHandle, &readParmas);
1497 EXPECT_EQ(HDF_SUCCESS, ret);
1498 }
1499 }
1500
1501 /**
1502 * @tc.number : CheckHostSdkIfFillRequest006
1503 * @tc.name :
1504 * @tc.type : PERF
1505 * @tc.level : Level 1
1506 */
1507 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFillRequest006, TestSize.Level1)
1508 {
1509 int32_t ret;
1510 struct UsbRequestParams parmas;
1511 int32_t i;
1512 char sendData[] = {"abcde\0"};
1513 uint32_t size = strlen(sendData) + 1;
1514
1515 g_acm->writeSize = g_acm->dataOutPipe->maxPacketSize;
1516 size = (size > g_acm->writeSize) ? g_acm->writeSize : size;
1517
1518 for (i = 0; i < ACM_NR; i++) {
1519 g_acm->wb[i].len = size;
1520 ret = memcpy_s(g_acm->wb[i].buf, g_acm->writeSize, sendData, size);
1521 if (ret) {
1522 printf("memcpy_s fial");
1523 }
1524
1525 parmas.interfaceId = g_acm->dataOutPipe->interfaceId;
1526 parmas.pipeAddress = g_acm->dataOutPipe->pipeAddress;
1527 parmas.pipeId = g_acm->dataOutPipe->pipeId;
1528 parmas.callback = AcmWriteBulk;
1529 parmas.requestType = USB_REQUEST_PARAMS_DATA_TYPE;
1530 parmas.timeout = USB_CTRL_SET_TIMEOUT;
1531 parmas.dataReq.numIsoPackets = 0;
1532 parmas.userData = (void *)&g_acm->wb[i];
1533 parmas.dataReq.length = g_acm->wb[i].len;
1534 parmas.dataReq.buffer = g_acm->wb[i].buf;
1535 ret = UsbFillRequest(g_acm->wb[i].request, g_acm->data_devHandle, &parmas);
1536 EXPECT_EQ(HDF_SUCCESS, ret);
1537 }
1538 }
1539
1540 /**
1541 * @tc.number : CheckHostSdkIfFillRequest007
1542 * @tc.name :
1543 * @tc.type : PERF
1544 * @tc.level : Level 1
1545 */
1546 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFillRequest007, TestSize.Level1)
1547 {
1548 int32_t ret;
1549 struct UsbRequestParams intParmas;
1550
1551 intParmas.userData = (void *)g_acm;
1552 intParmas.pipeAddress = g_acm->intPipe->pipeAddress;
1553 intParmas.pipeId = g_acm->intPipe->pipeId;
1554 intParmas.interfaceId = g_acm->intPipe->interfaceId;
1555 intParmas.callback = AcmCtrlIrq;
1556 intParmas.requestType = USB_REQUEST_PARAMS_DATA_TYPE;
1557 intParmas.timeout = USB_CTRL_SET_TIMEOUT;
1558 intParmas.dataReq.numIsoPackets = 0;
1559 intParmas.dataReq.directon = (UsbRequestDirection)((g_acm->intPipe->pipeDirection >> USB_PIPE_DIR_OFFSET) \
1560 & DIRECTION_MASK);
1561 intParmas.dataReq.length = g_acm->intSize;
1562 ret = UsbFillRequest(g_acm->notifyReq, g_acm->int_devHandle, &intParmas);
1563 EXPECT_EQ(HDF_SUCCESS, ret);
1564 }
1565
1566 /**
1567 * @tc.number : CheckHostSdkIfFillRequest008
1568 * @tc.name :
1569 * @tc.type : PERF
1570 * @tc.level : Level 1
1571 */
1572 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFillRequest008, TestSize.Level1)
1573 {
1574 int32_t ret;
1575 struct UsbRequestParams parmas;
1576 uint16_t index = 0;
1577 uint16_t value = 0;
1578 struct TestControlMsgData msgData = {0};
1579
1580 parmas.interfaceId = USB_CTRL_INTERFACE_ID;
1581 parmas.pipeAddress = 0;
1582 parmas.pipeId = 0;
1583 parmas.callback = AcmCtrlIrq;
1584 parmas.requestType = USB_REQUEST_PARAMS_CTRL_TYPE;
1585 parmas.timeout = USB_CTRL_SET_TIMEOUT;
1586
1587 g_acm->lineCoding.dwDTERate = CpuToLe32(DATARATE);
1588 g_acm->lineCoding.bCharFormat = USB_CDC_1_STOP_BITS;
1589 g_acm->lineCoding.bParityType = USB_CDC_NO_PARITY;
1590 g_acm->lineCoding.bDataBits = DATA_BITS_LENGTH;
1591
1592 msgData.request = USB_DDK_CDC_REQ_SET_LINE_CODING;
1593 msgData.requestType = USB_DDK_TYPE_CLASS | USB_DDK_RECIP_INTERFACE;
1594 msgData.value = value;
1595 msgData.index = index;
1596 msgData.data = &g_acm->lineCoding;
1597 msgData.size = sizeof (struct UsbCdcLineCoding);
1598 parmas.ctrlReq = UsbControlMsg(msgData);
1599 ret = UsbFillRequest(g_acm->ctrlReq, g_acm->ctrl_devHandle, &parmas);
1600 EXPECT_EQ(HDF_SUCCESS, ret);
1601 }
1602
1603 /**
1604 * @tc.number : CheckHostSdkIfFillRequest009
1605 * @tc.name :
1606 * @tc.type : PERF
1607 * @tc.level : Level 1
1608 */
1609 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFillRequest009, TestSize.Level1)
1610 {
1611 int32_t ret;
1612
1613 ret = UsbFillRequest(NULL, NULL, NULL);
1614 EXPECT_NE(HDF_SUCCESS, ret);
1615 }
1616
1617 /**
1618 * @tc.number : CheckHostSdkIfFillRequest010
1619 * @tc.name :
1620 * @tc.type : PERF
1621 * @tc.level : Level 1
1622 */
1623 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFillRequest010, TestSize.Level1)
1624 {
1625 int32_t ret;
1626 struct UsbRequestParams params;
1627
1628 ret = UsbFillRequest(NULL, NULL, ¶ms);
1629 EXPECT_NE(HDF_SUCCESS, ret);
1630 }
1631
1632 /**
1633 * @tc.number : CheckHostSdkIfFillRequest011
1634 * @tc.name :
1635 * @tc.type : PERF
1636 * @tc.level : Level 1
1637 */
1638 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFillRequest011, TestSize.Level1)
1639 {
1640 int32_t ret;
1641 UsbInterfaceHandle interfaceHandle;
1642
1643 ret = UsbFillRequest(NULL, &interfaceHandle, NULL);
1644 EXPECT_NE(HDF_SUCCESS, ret);
1645 }
1646
1647 /**
1648 * @tc.number : CheckHostSdkIfFillRequest012
1649 * @tc.name :
1650 * @tc.type : PERF
1651 * @tc.level : Level 1
1652 */
1653 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFillRequest012, TestSize.Level1)
1654 {
1655 int32_t ret;
1656 struct UsbRequest request;
1657
1658 ret = UsbFillRequest(&request, NULL, NULL);
1659 EXPECT_NE(HDF_SUCCESS, ret);
1660 }
1661
1662 /**
1663 * @tc.number : CheckHostSdkIfFillRequest013
1664 * @tc.name :
1665 * @tc.type : PERF
1666 * @tc.level : Level 1
1667 */
1668 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFillRequest013, TestSize.Level1)
1669 {
1670 int32_t ret;
1671 struct UsbRequestParams params;
1672 UsbInterfaceHandle interfaceHandle;
1673
1674 ret = UsbFillRequest(NULL, &interfaceHandle, ¶ms);
1675 EXPECT_NE(HDF_SUCCESS, ret);
1676 }
1677
1678 /**
1679 * @tc.number : CheckHostSdkIfFillRequest014
1680 * @tc.name :
1681 * @tc.type : PERF
1682 * @tc.level : Level 1
1683 */
1684 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFillRequest014, TestSize.Level1)
1685 {
1686 int32_t ret;
1687 UsbInterfaceHandle interfaceHandle;
1688 struct UsbRequest request;
1689
1690 ret = UsbFillRequest(&request, &interfaceHandle, NULL);
1691 EXPECT_NE(HDF_SUCCESS, ret);
1692 }
1693
1694 /**
1695 * @tc.number : CheckHostSdkIfFillRequest015
1696 * @tc.name :
1697 * @tc.type : PERF
1698 * @tc.level : Level 1
1699 */
1700 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfFillRequest015, TestSize.Level1)
1701 {
1702 int32_t ret;
1703 struct UsbRequestParams params;
1704 struct UsbRequest request;
1705
1706 ret = UsbFillRequest(&request, NULL, ¶ms);
1707 EXPECT_NE(HDF_SUCCESS, ret);
1708 }
1709
1710
1711
1712 /**
1713 * @tc.number : CheckHostSdkIfClearInterfaceHalt001
1714 * @tc.name :
1715 * @tc.type : PERF
1716 * @tc.level : Level 1
1717 */
1718 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfClearInterfaceHalt001, TestSize.Level1)
1719 {
1720 int32_t ret;
1721
1722 ret = UsbClearInterfaceHalt(g_acm->data_devHandle, g_acm->dataInPipe->pipeAddress);
1723 EXPECT_EQ(HDF_SUCCESS, ret);
1724 }
1725
1726 /**
1727 * @tc.number : CheckHostSdkIfClearInterfaceHalt002
1728 * @tc.name :
1729 * @tc.type : PERF
1730 * @tc.level : Level 1
1731 */
1732 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfClearInterfaceHalt002, TestSize.Level1)
1733 {
1734 int32_t ret;
1735
1736 ret = UsbClearInterfaceHalt(g_acm->data_devHandle, g_acm->dataOutPipe->pipeAddress);
1737 EXPECT_EQ(HDF_SUCCESS, ret);
1738 }
1739
1740 /**
1741 * @tc.number : CheckHostSdkIfClearInterfaceHalt003
1742 * @tc.name :
1743 * @tc.type : PERF
1744 * @tc.level : Level 1
1745 */
1746 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfClearInterfaceHalt003, TestSize.Level1)
1747 {
1748 int32_t ret;
1749
1750 ret = UsbClearInterfaceHalt(g_acm->int_devHandle, g_acm->intPipe->pipeAddress);
1751 EXPECT_NE(HDF_SUCCESS, ret);
1752 }
1753
1754 /**
1755 * @tc.number : CheckHostSdkIfClearInterfaceHalt004
1756 * @tc.name :
1757 * @tc.type : PERF
1758 * @tc.level : Level 1
1759 */
1760 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfClearInterfaceHalt004, TestSize.Level1)
1761 {
1762 int32_t ret;
1763
1764 ret = UsbClearInterfaceHalt(g_acm->ctrl_devHandle, g_acm->ctrPipe->pipeAddress);
1765 EXPECT_NE(HDF_SUCCESS, ret);
1766 }
1767
1768 /**
1769 * @tc.number : CheckHostSdkIfClearInterfaceHalt005
1770 * @tc.name :
1771 * @tc.type : PERF
1772 * @tc.level : Level 1
1773 */
1774 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfClearInterfaceHalt005, TestSize.Level1)
1775 {
1776 int32_t ret;
1777
1778 ret = UsbClearInterfaceHalt(NULL, 0);
1779 EXPECT_NE(HDF_SUCCESS, ret);
1780 }
1781
1782 /**
1783 * @tc.number : CheckHostSdkIfRemoveInterface001
1784 * @tc.name :
1785 * @tc.type : PERF
1786 * @tc.level : Level 1
1787 */
1788 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfRemoveInterface001, TestSize.Level1)
1789 {
1790 int32_t ret;
1791 UsbInterfaceStatus status = USB_INTERFACE_STATUS_REMOVE;
1792
1793 ret = UsbAddOrRemoveInterface(g_acm->session, g_acm->busNum, g_acm->devAddr,
1794 g_acm->dataIface->info.interfaceIndex, status);
1795 EXPECT_EQ(HDF_SUCCESS, ret);
1796 }
1797
1798 /**
1799 * @tc.number : CheckHostSdkIfAddInterface001
1800 * @tc.name :
1801 * @tc.type : PERF
1802 * @tc.level : Level 1
1803 */
1804 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfAddInterface001, TestSize.Level1)
1805 {
1806 int32_t ret;
1807 UsbInterfaceStatus status = USB_INTERFACE_STATUS_ADD;
1808
1809 sleep(1);
1810
1811 ret = UsbAddOrRemoveInterface(g_acm->session, g_acm->busNum, g_acm->devAddr,
1812 g_acm->dataIface->info.interfaceIndex, status);
1813 EXPECT_EQ(HDF_SUCCESS, ret);
1814 }
1815
1816 /**
1817 * @tc.number : CheckHostSdkIfRemoveInterface002
1818 * @tc.name :
1819 * @tc.type : PERF
1820 * @tc.level : Level 1
1821 */
1822 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfRemoveInterface002, TestSize.Level1)
1823 {
1824 int32_t ret;
1825 UsbInterfaceStatus status = USB_INTERFACE_STATUS_REMOVE;
1826
1827 sleep(1);
1828
1829 ret = UsbAddOrRemoveInterface(g_acm->session, g_acm->busNum, g_acm->devAddr,
1830 g_acm->intIface->info.interfaceIndex, status);
1831 EXPECT_EQ(HDF_SUCCESS, ret);
1832 }
1833
1834 /**
1835 * @tc.number : CheckHostSdkIfAddInterface002
1836 * @tc.name :
1837 * @tc.type : PERF
1838 * @tc.level : Level 1
1839 */
1840 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfAddInterface002, TestSize.Level1)
1841 {
1842 int32_t ret;
1843 UsbInterfaceStatus status = USB_INTERFACE_STATUS_ADD;
1844
1845 sleep(1);
1846
1847 ret = UsbAddOrRemoveInterface(g_acm->session, g_acm->busNum, g_acm->devAddr,
1848 g_acm->intIface->info.interfaceIndex, status);
1849 EXPECT_EQ(HDF_SUCCESS, ret);
1850 }
1851
1852 /**
1853 * @tc.number : CheckHostSdkIfRemoveInterface003
1854 * @tc.name :
1855 * @tc.type : PERF
1856 * @tc.level : Level 1
1857 */
1858 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfRemoveInterface003, TestSize.Level1)
1859 {
1860 int32_t ret;
1861 UsbInterfaceStatus status = USB_INTERFACE_STATUS_REMOVE;
1862
1863 ret = UsbAddOrRemoveInterface(g_acm->session, g_acm->busNum, g_acm->devAddr,
1864 g_acm->ctrIface->info.interfaceIndex, status);
1865 EXPECT_EQ(HDF_SUCCESS, ret);
1866 }
1867
1868 /**
1869 * @tc.number : CheckHostSdkIfAddInterface003
1870 * @tc.name :
1871 * @tc.type : PERF
1872 * @tc.level : Level 1
1873 */
1874 HWTEST_F(UsbHostSdkIfTest, CheckHostSdkIfAddInterface003, TestSize.Level1)
1875 {
1876 int32_t ret;
1877 UsbInterfaceStatus status = USB_INTERFACE_STATUS_ADD;
1878
1879 ret = UsbAddOrRemoveInterface(g_acm->session, g_acm->busNum, g_acm->devAddr,
1880 g_acm->ctrIface->info.interfaceIndex, status);
1881 EXPECT_EQ(HDF_SUCCESS, ret);
1882 }
1883
1884 }
1885