• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "hctest.h"
17 #include "iot_errno.h"
18 #include "iot_gpio.h"
19 
20 #define TEST_GPIO_SIZE 8
21 const unsigned int COMPILABILITY_TEST_GPIO = 0xFFFFFFFF;
22 
23 /**
24  * @tc.desc      : register a test suite, this suite is used to test basic flow and interface dependency
25  * @param        : subsystem name is wifiiot
26  * @param        : module name is wifiiotlite
27  * @param        : test suit name is UtilsFileFuncTestSuite
28  */
29 LITE_TEST_SUIT(wifiiot, wifiiotlite, IotGpioTestSuite);
30 
31 /**
32  * @tc.setup     : setup for all testcases
33  * @return       : setup result, TRUE is success, FALSE is fail
34  */
IotGpioTestSuiteSetUp(void)35 static BOOL IotGpioTestSuiteSetUp(void)
36 {
37     return TRUE;
38 }
39 
40 /**
41  * @tc.teardown  : teardown for all testcases
42  * @return       : teardown result, TRUE is success, FALSE is fail
43  */
IotGpioTestSuiteTearDown(void)44 static BOOL IotGpioTestSuiteTearDown(void)
45 {
46     printf("+-------------------------------------------+\n");
47     return TRUE;
48 }
49 
50 /**
51  * @tc.number    : SUB_UTILS_WIFIIOT_API_1800
52  * @tc.name      : GPIO operation with IoTGpioInit
53  * @tc.desc      : [C- SOFTWARE -0200]
54  */
55 LITE_TEST_CASE(IotGpioTestSuite, testIoTGpio001, Function | MediumTest | Level1)
56 {
57     IoTGpioInit(COMPILABILITY_TEST_GPIO);
58 };
59 
60 /**
61  * @tc.number    : SUB_UTILS_WIFIIOT_API_1900
62  * @tc.name      : GPIO operation with IoTGpioSetDir
63  * @tc.desc      : [C- SOFTWARE -0200]
64  */
65 LITE_TEST_CASE(IotGpioTestSuite, testIoTGpio002, Function | MediumTest | Level1)
66 {
67     IoTGpioSetDir(COMPILABILITY_TEST_GPIO, IOT_GPIO_DIR_OUT);
68 
69 };
70 
71 /**
72  * @tc.number    : SUB_UTILS_WIFIIOT_API_2000
73  * @tc.name      : GPIO operation with IoTGpioGetDir
74  * @tc.desc      : [C- SOFTWARE -0200]
75  */
76 LITE_TEST_CASE(IotGpioTestSuite, testIoTGpio003, Function | MediumTest | Level1)
77 {
78     IotGpioDir dir = {0};
79     IoTGpioGetDir(COMPILABILITY_TEST_GPIO, &dir);
80 };
81 
82 /**
83  * @tc.number    : SUB_UTILS_WIFIIOT_API_2100
84  * @tc.name      : GPIO operation with IoTGpioSetOutputVal
85  * @tc.desc      : [C- SOFTWARE -0200]
86  */
87 LITE_TEST_CASE(IotGpioTestSuite, testIoTGpio004, Function | MediumTest | Level1)
88 {
89     IoTGpioSetOutputVal(COMPILABILITY_TEST_GPIO, IOT_GPIO_VALUE1);
90 };
91 
92 /**
93  * @tc.number    : SUB_UTILS_WIFIIOT_API_2200
94  * @tc.name      : GPIO operation with IoTGpioGetOutputVal
95  * @tc.desc      : [C- SOFTWARE -0200]
96  */
97 LITE_TEST_CASE(IotGpioTestSuite, testIoTGpio005, Function | MediumTest | Level1)
98 {
99     IotGpioValue val = {0};
100     IoTGpioGetOutputVal(COMPILABILITY_TEST_GPIO, &val);
101 };
102 
103 /**
104  * @tc.number    : SUB_UTILS_WIFIIOT_API_2300
105  * @tc.name      : GPIO operation with IoTGpioGetInputVal
106  * @tc.desc      : [C- SOFTWARE -0200]
107  */
108 LITE_TEST_CASE(IotGpioTestSuite, testIoTGpio006, Function | MediumTest | Level1)
109 {
110     IotGpioValue val = {0};
111     IoTGpioGetInputVal(COMPILABILITY_TEST_GPIO, &val);
112 };
113 
IOT_GPIO_CALLBACK_Func(char * arg)114 void IOT_GPIO_CALLBACK_Func(char *arg)
115 {
116     if (arg == NULL) {
117         printf("arg is null\n");
118     } else {
119         arg = "iot_gpio";
120         printf("arg exist\n");
121     }
122     printf("GpioIsrFunc callback successfully\n");
123 }
124 
125 /**
126  * @tc.number    : SUB_UTILS_WIFIIOT_API_2400
127  * @tc.name      : GPIO operation with IoTGpioRegisterIsrFunc
128  * @tc.desc      : [C- SOFTWARE -0200]
129  */
130 LITE_TEST_CASE(IotGpioTestSuite, testIoTGpio007, Function | MediumTest | Level1)
131 {
132     IoTGpioRegisterIsrFunc(COMPILABILITY_TEST_GPIO,
133                            IOT_INT_TYPE_LEVEL,
134                            IOT_GPIO_EDGE_FALL_LEVEL_LOW,
135                            IOT_GPIO_CALLBACK_Func,
136                            (char *)(unsigned int)COMPILABILITY_TEST_GPIO);
137 };
138 
139 /**
140  * @tc.number    : SUB_UTILS_WIFIIOT_API_2500
141  * @tc.name      : GPIO operation with IoTGpioUnregisterIsrFunc
142  * @tc.desc      : [C- SOFTWARE -0200]
143  */
144 LITE_TEST_CASE(IotGpioTestSuite, testIoTGpio008, Function | MediumTest | Level1)
145 {
146     IoTGpioUnregisterIsrFunc(COMPILABILITY_TEST_GPIO);
147 };
148 
149 /**
150  * @tc.number    : SUB_UTILS_WIFIIOT_API_2600
151  * @tc.name      : GPIO operation with IoTGpioSetIsrMask
152  * @tc.desc      : [C- SOFTWARE -0200]
153  */
154 LITE_TEST_CASE(IotGpioTestSuite, testIoTGpio09, Function | MediumTest | Level1)
155 {
156     IoTGpioSetIsrMask(COMPILABILITY_TEST_GPIO, 0);
157 };
158 
159 /**
160  * @tc.number    : SUB_UTILS_WIFIIOT_API_2700
161  * @tc.name      : GPIO operation with IoTGpioSetIsrMode
162  * @tc.desc      : [C- SOFTWARE -0200]
163  */
164 LITE_TEST_CASE(IotGpioTestSuite, testIoTGpio010, Function | MediumTest | Level1)
165 {
166     IoTGpioSetIsrMode(COMPILABILITY_TEST_GPIO, IOT_INT_TYPE_LEVEL, IOT_GPIO_EDGE_FALL_LEVEL_LOW);
167 };
168 
169 /**
170  * @tc.number    : SUB_UTILS_WIFIIOT_API_2800
171  * @tc.name      : GPIO operation with IoTGpioDeinit
172  * @tc.desc      : [C- SOFTWARE -0200]
173  */
174 LITE_TEST_CASE(IotGpioTestSuite, testIoTGpio011, Function | MediumTest | Level1)
175 {
176     IoTGpioDeinit(COMPILABILITY_TEST_GPIO);
177 };
178 
179 RUN_TEST_SUITE(IotGpioTestSuite);
180