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