1 /*
2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3 *
4 * HDF is dual licensed: you can use it either under the terms of
5 * the GPL, or the BSD license, at your option.
6 * See the LICENSE file in the root of this repository for complete details.
7 */
8
9 #include <cstdint>
10 #include <cstdio>
11 #include <cstdlib>
12 #include <fcntl.h>
13 #include <string>
14 #include <unistd.h>
15 #include <gtest/gtest.h>
16 #include "gpio_test.h"
17 #include "hdf_uhdf_test.h"
18 #include "hdf_io_service_if.h"
19
20 using namespace testing::ext;
21
22 class HdfLiteGpioTest : public testing::Test {
23 public:
24 static void SetUpTestCase();
25 static void TearDownTestCase();
26 void SetUp();
27 void TearDown();
28 };
29
SetUpTestCase()30 void HdfLiteGpioTest::SetUpTestCase()
31 {
32 HdfTestOpenService();
33 }
34
TearDownTestCase()35 void HdfLiteGpioTest::TearDownTestCase()
36 {
37 HdfTestCloseService();
38 }
39
SetUp()40 void HdfLiteGpioTest::SetUp()
41 {
42 }
43
TearDown()44 void HdfLiteGpioTest::TearDown()
45 {
46 }
47
48 /**
49 * @tc.name: GpioTestSetGetDir001
50 * @tc.desc: gpio set and get dir test
51 * @tc.type: FUNC
52 * @tc.require: AR000F868H
53 */
54 HWTEST_F(HdfLiteGpioTest, GpioTestSetGetDir001, TestSize.Level1)
55 {
56 struct HdfTestMsg msg = {TEST_PAL_GPIO_TYPE, GPIO_TEST_SET_GET_DIR, -1};
57 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
58 printf("%s: kernel test done, then for user...\n", __func__);
59
60 EXPECT_EQ(0, GpioTestExecute(GPIO_TEST_SET_GET_DIR));
61 printf("%s: exit!\n", __func__);
62 }
63
64 /**
65 * @tc.name: GpioTestWriteRead001
66 * @tc.desc: gpio write and read test
67 * @tc.type: FUNC
68 * @tc.require: AR000F868H
69 */
70 HWTEST_F(HdfLiteGpioTest, GpioTestWriteRead001, TestSize.Level1)
71 {
72 struct HdfTestMsg msg = {TEST_PAL_GPIO_TYPE, GPIO_TEST_WRITE_READ, -1};
73 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
74 printf("%s: kernel test done, then for user...\n", __func__);
75
76 EXPECT_EQ(0, GpioTestExecute(GPIO_TEST_WRITE_READ));
77 printf("%s: exit!\n", __func__);
78 }
79
80 /**
81 * @tc.name: GpioTestIrqLevel001
82 * @tc.desc: gpio level irq trigger test
83 * @tc.type: FUNC
84 * @tc.require: AR000F868H
85 */
86 HWTEST_F(HdfLiteGpioTest, GpioTestIrqLevel001, TestSize.Level1)
87 {
88 struct HdfTestMsg msg = {TEST_PAL_GPIO_TYPE, GPIO_TEST_IRQ_LEVEL, -1};
89 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
90 printf("%s: kernel test done, then for user...\n", __func__);
91
92 EXPECT_EQ(0, GpioTestExecute(GPIO_TEST_IRQ_LEVEL));
93 printf("%s: exit!\n", __func__);
94 }
95
96 /**
97 * @tc.name: GpioTestIrqEdge001
98 * @tc.desc: gpio edge irq trigger test
99 * @tc.type: FUNC
100 * @tc.require: AR000F868H
101 */
102 HWTEST_F(HdfLiteGpioTest, GpioTestIrqEdge001, TestSize.Level1)
103 {
104 struct HdfTestMsg msg = {TEST_PAL_GPIO_TYPE, GPIO_TEST_IRQ_EDGE, -1};
105 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
106 printf("%s: kernel test done, then for user...\n", __func__);
107
108 EXPECT_EQ(0, GpioTestExecute(GPIO_TEST_IRQ_EDGE));
109 printf("%s: exit!\n", __func__);
110 }
111
112 /**
113 * @tc.name: GpioTestIrqThread001
114 * @tc.desc: gpio thread irq trigger test
115 * @tc.type: FUNC
116 * @tc.require: AR000F868H
117 */
118 HWTEST_F(HdfLiteGpioTest, GpioTestIrqThread001, TestSize.Level1)
119 {
120 struct HdfTestMsg msg = {TEST_PAL_GPIO_TYPE, GPIO_TEST_IRQ_THREAD, -1};
121 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
122 printf("%s: kernel test done, then for user...\n", __func__);
123
124 EXPECT_EQ(0, GpioTestExecute(GPIO_TEST_IRQ_THREAD));
125 printf("%s: exit!\n", __func__);
126 }
127
128 /**
129 * @tc.name: GpioTestReliability001
130 * @tc.desc: gpio reliability test
131 * @tc.type: FUNC
132 * @tc.require: AR000F868H
133 */
134 HWTEST_F(HdfLiteGpioTest, GpioTestReliability001, TestSize.Level1)
135 {
136 struct HdfTestMsg msg = {TEST_PAL_GPIO_TYPE, GPIO_TEST_RELIABILITY, -1};
137 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
138 printf("%s: kernel test done, then for user...\n", __func__);
139
140 EXPECT_EQ(0, GpioTestExecute(GPIO_TEST_RELIABILITY));
141 printf("%s: exit!\n", __func__);
142 }
143
144 /**
145 * @tc.name: GpioIfPerformanceTest001
146 * @tc.desc: gpio user if performance test
147 * @tc.type: FUNC
148 * @tc.require:
149 */
150 HWTEST_F(HdfLiteGpioTest, GpioIfPerformanceTest001, TestSize.Level1)
151 {
152 EXPECT_EQ(0, GpioTestExecute(GPIO_TEST_PERFORMANCE));
153 }