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 "hdf_uhdf_test.h"
17 #include "hdf_io_service_if.h"
18 #include "uart_test.h"
19
20 using namespace testing::ext;
21
22 class HdfLiteUartTest : public testing::Test {
23 public:
24 static void SetUpTestCase();
25 static void TearDownTestCase();
26 void SetUp();
27 void TearDown();
28 };
29
SetUpTestCase()30 void HdfLiteUartTest::SetUpTestCase()
31 {
32 HdfTestOpenService();
33 }
34
TearDownTestCase()35 void HdfLiteUartTest::TearDownTestCase()
36 {
37 HdfTestCloseService();
38 }
39
SetUp()40 void HdfLiteUartTest::SetUp()
41 {
42 }
43
TearDown()44 void HdfLiteUartTest::TearDown()
45 {
46 }
47
48 /**
49 * @tc.name: UartSetTransModeTest001
50 * @tc.desc: uart function test
51 * @tc.type: FUNC
52 * @tc.require: AR000F8689
53 */
54 HWTEST_F(HdfLiteUartTest, UartSetTransModeTest001, TestSize.Level1)
55 {
56 struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_TEST_CMD_SET_TRANSMODE, -1};
57 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
58 printf("%s: kernel test done, then for user...\n", __func__);
59
60 EXPECT_EQ(0, UartTestExecute(UART_TEST_CMD_SET_TRANSMODE));
61 printf("%s: exit!\n", __func__);
62 }
63
64 /**
65 * @tc.name: UartWriteTest001
66 * @tc.desc: uart function test
67 * @tc.type: FUNC
68 * @tc.require: AR000F8689
69 */
70 HWTEST_F(HdfLiteUartTest, UartWriteTest001, TestSize.Level1)
71 {
72 struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_TEST_CMD_WRITE, -1};
73 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
74 printf("%s: kernel test done, then for user...\n", __func__);
75
76 EXPECT_EQ(0, UartTestExecute(UART_TEST_CMD_WRITE));
77 printf("%s: exit!\n", __func__);
78 }
79
80 /**
81 * @tc.name: UartReadTest001
82 * @tc.desc: uart function test
83 * @tc.type: FUNC
84 * @tc.require: AR000F8689
85 */
86 HWTEST_F(HdfLiteUartTest, UartReadTest001, TestSize.Level1)
87 {
88 struct HdfTestMsg msg = { TEST_PAL_UART_TYPE, UART_TEST_CMD_READ, -1};
89 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
90 printf("%s: kernel test done, then for user...\n", __func__);
91
92 EXPECT_EQ(0, UartTestExecute(UART_TEST_CMD_READ));
93 printf("%s: exit!\n", __func__);
94 }
95
96 /**
97 * @tc.name: UartSetBaudTest001
98 * @tc.desc: uart function test
99 * @tc.type: FUNC
100 * @tc.require: AR000F8689
101 */
102 HWTEST_F(HdfLiteUartTest, UartSetBaudTest001, TestSize.Level1)
103 {
104 struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_TEST_CMD_SET_BAUD, -1};
105 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
106 printf("%s: kernel test done, then for user...\n", __func__);
107
108 EXPECT_EQ(0, UartTestExecute(UART_TEST_CMD_SET_BAUD));
109 printf("%s: exit!\n", __func__);
110 }
111
112 /**
113 * @tc.name: UartGetBaudTest001
114 * @tc.desc: uart function test
115 * @tc.type: FUNC
116 * @tc.require: AR000F8689
117 */
118 HWTEST_F(HdfLiteUartTest, UartGetBaudTest001, TestSize.Level1)
119 {
120 struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_TEST_CMD_GET_BAUD, -1};
121 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
122 printf("%s: kernel test done, then for user...\n", __func__);
123
124 EXPECT_EQ(0, UartTestExecute(UART_TEST_CMD_GET_BAUD));
125 printf("%s: exit!\n", __func__);
126 }
127
128 /**
129 * @tc.name: UartSetAttributeTest001
130 * @tc.desc: uart function test
131 * @tc.type: FUNC
132 * @tc.require: AR000F8689
133 */
134 HWTEST_F(HdfLiteUartTest, UartSetAttributeTest001, TestSize.Level1)
135 {
136 struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_TEST_CMD_SET_ATTRIBUTE, -1};
137 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
138 printf("%s: kernel test done, then for user...\n", __func__);
139
140 EXPECT_EQ(0, UartTestExecute(UART_TEST_CMD_SET_ATTRIBUTE));
141 printf("%s: exit!\n", __func__);
142 }
143
144 /**
145 * @tc.name: UartGetAttributeTest001
146 * @tc.desc: uart function test
147 * @tc.type: FUNC
148 * @tc.require: AR000F8689
149 */
150 HWTEST_F(HdfLiteUartTest, UartGetAttributeTest001, TestSize.Level1)
151 {
152 struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_TEST_CMD_GET_ATTRIBUTE, -1};
153 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
154 printf("%s: kernel test done, then for user...\n", __func__);
155
156 EXPECT_EQ(0, UartTestExecute(UART_TEST_CMD_GET_ATTRIBUTE));
157 printf("%s: exit!\n", __func__);
158 }
159
160 /**
161 * @tc.name: UartReliabilityTest001
162 * @tc.desc: uart function test
163 * @tc.type: FUNC
164 * @tc.require: AR000F8689
165 */
166 HWTEST_F(HdfLiteUartTest, UartReliabilityTest001, TestSize.Level1)
167 {
168 struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_TEST_CMD_RELIABILITY, -1};
169 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
170 printf("%s: kernel test done, then for user...\n", __func__);
171
172 EXPECT_EQ(0, UartTestExecute(UART_TEST_CMD_RELIABILITY));
173 printf("%s: exit!\n", __func__);
174 }
175
176 /**
177 * @tc.name: UartIfPerformanceTest001
178 * @tc.desc: uart user if performance test
179 * @tc.type: FUNC
180 * @tc.require:
181 */
182 HWTEST_F(HdfLiteUartTest, UartIfPerformanceTest001, TestSize.Level1)
183 {
184 EXPECT_EQ(0, UartTestExecute(UART_TEST_CMD_PERFORMANCE));
185 }
186