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