• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021–2022 Beijing OSWare Technology Co., Ltd
3  * This file contains confidential and proprietary information of
4  * OSWare Technology Co., Ltd
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #include <cstdint>
20 #include <cstdio>
21 #include <cstdlib>
22 #include <fcntl.h>
23 #include <string>
24 #include <unistd.h>
25 #include <gtest/gtest.h>
26 #include "hdf_uhdf_test.h"
27 #include "hdf_io_service_if.h"
28 #include "uart_test.h"
29 
30 using namespace testing::ext;
31 
32 class HdfLiteUartTest : public testing::Test {
33 public:
34     static void SetUpTestCase();
35     static void TearDownTestCase();
36     void SetUp();
37     void TearDown();
38 };
39 
SetUpTestCase()40 void HdfLiteUartTest::SetUpTestCase()
41 {
42     HdfTestOpenService();
43 }
44 
TearDownTestCase()45 void HdfLiteUartTest::TearDownTestCase()
46 {
47     HdfTestCloseService();
48 }
49 
SetUp()50 void HdfLiteUartTest::SetUp()
51 {
52 }
53 
TearDown()54 void HdfLiteUartTest::TearDown()
55 {
56 }
57 
58 #ifdef HDF_LITEOS_TEST
59 /**
60  * @tc.name: UartSetTransModeTest001
61  * @tc.desc: uart function test
62  * @tc.type: FUNC
63  * @tc.require: AR000F8689
64  */
65 HWTEST_F(HdfLiteUartTest, UartSetTransModeTest001, TestSize.Level1)
66 {
67     struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_TEST_CMD_SET_TRANSMODE, -1};
68     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
69 }
70 #endif
71 
72 /**
73   * @tc.name: UartWriteTest001
74   * @tc.desc: uart function test
75   * @tc.type: FUNC
76   * @tc.require: AR000F8689
77   */
78 HWTEST_F(HdfLiteUartTest, UartWriteTest001, TestSize.Level1)
79 {
80     struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_TEST_CMD_WRITE, -1};
81     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
82 }
83 
84 /**
85   * @tc.name: UartReadTest001
86   * @tc.desc: uart function test
87   * @tc.type: FUNC
88   * @tc.require: AR000F8689
89   */
90 HWTEST_F(HdfLiteUartTest, UartReadTest001, TestSize.Level1)
91 {
92     struct HdfTestMsg msg = { TEST_PAL_UART_TYPE, UART_TEST_CMD_READ, -1};
93     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
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 }
107 
108 /**
109   * @tc.name: UartGetBaudTest001
110   * @tc.desc: uart function test
111   * @tc.type: FUNC
112   * @tc.require: AR000F8689
113   */
114 HWTEST_F(HdfLiteUartTest, UartGetBaudTest001, TestSize.Level1)
115 {
116     struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_TEST_CMD_GET_BAUD, -1};
117     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
118 }
119 
120 /**
121   * @tc.name: UartSetAttributeTest001
122   * @tc.desc: uart function test
123   * @tc.type: FUNC
124   * @tc.require: AR000F8689
125   */
126 HWTEST_F(HdfLiteUartTest, UartSetAttributeTest001, TestSize.Level1)
127 {
128     struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_TEST_CMD_SET_ATTRIBUTE, -1};
129     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
130 }
131 
132 /**
133   * @tc.name: UartGetAttributeTest001
134   * @tc.desc: uart function test
135   * @tc.type: FUNC
136   * @tc.require: AR000F8689
137   */
138 HWTEST_F(HdfLiteUartTest, UartGetAttributeTest001, TestSize.Level1)
139 {
140     struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_TEST_CMD_GET_ATTRIBUTE, -1};
141     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
142 }
143 
144 /**
145   * @tc.name: UartReliabilityTest001
146   * @tc.desc: uart function test
147   * @tc.type: FUNC
148   * @tc.require: AR000F8689
149   */
150 HWTEST_F(HdfLiteUartTest, UartReliabilityTest001, TestSize.Level1)
151 {
152     struct HdfTestMsg msg = {TEST_PAL_UART_TYPE, UART_TEST_CMD_RELIABILITY, -1};
153     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
154 }
155