• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 <gtest/gtest.h>
14 #include <string>
15 #include <unistd.h>
16 #include "hdf_io_service_if.h"
17 #include "hdf_uhdf_test.h"
18 #include "i3c_test.h"
19 
20 using namespace testing::ext;
21 
22 class HdfI3cTest : public testing::Test {
23 public:
24     static void SetUpTestCase();
25     static void TearDownTestCase();
26     void SetUp();
27     void TearDown();
28 };
29 
SetUpTestCase()30 void HdfI3cTest::SetUpTestCase()
31 {
32     struct HdfTestMsg msg = {TEST_PAL_I3C_TYPE, I3C_TEST_CMD_SETUP_ALL, -1};
33     HdfTestOpenService();
34     HdfTestSendMsgToService(&msg);
35 }
36 
TearDownTestCase()37 void HdfI3cTest::TearDownTestCase()
38 {
39     struct HdfTestMsg msg = {TEST_PAL_I3C_TYPE, I3C_TEST_CMD_TEARDOWN_ALL, -1};
40     HdfTestSendMsgToService(&msg);
41     HdfTestCloseService();
42 }
43 
SetUp()44 void HdfI3cTest::SetUp()
45 {
46 }
47 
TearDown()48 void HdfI3cTest::TearDown()
49 {
50 }
51 
52 /**
53   * @tc.name: HdfI3cTestTransfer001
54   * @tc.desc: i3c transfer test
55   * @tc.type: FUNC
56   * @tc.require: N/A
57   */
58 HWTEST_F(HdfI3cTest, HdfI3cTestTransfer001, TestSize.Level1)
59 {
60     struct HdfTestMsg msg = {TEST_PAL_I3C_TYPE, I3C_TEST_CMD_TRANSFER, -1};
61     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
62 }
63 
64 /**
65   * @tc.name: HdfI3cTestSetConfig001
66   * @tc.desc: i3c set config test
67   * @tc.type: FUNC
68   * @tc.require: N/A
69   */
70 HWTEST_F(HdfI3cTest, HdfI3cTestSetConfig001, TestSize.Level1)
71 {
72     struct HdfTestMsg msg = {TEST_PAL_I3C_TYPE, I3C_TEST_CMD_SET_CONFIG, -1};
73     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
74 }
75 
76 /**
77   * @tc.name: HdfI3cTestGetConfig001
78   * @tc.desc: i3c get config test
79   * @tc.type: FUNC
80   * @tc.require: N/A
81   */
82 HWTEST_F(HdfI3cTest, HdfI3cTestGetConfig001, TestSize.Level1)
83 {
84     struct HdfTestMsg msg = {TEST_PAL_I3C_TYPE, I3C_TEST_CMD_GET_CONFIG, -1};
85     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
86 }
87 
88 /**
89   * @tc.name: HdfI3cTestRequestIbi001
90   * @tc.desc: i3c request ibi test
91   * @tc.type: FUNC
92   * @tc.require: N/A
93   */
94 HWTEST_F(HdfI3cTest, HdfI3cTestRequestIbi001, TestSize.Level1)
95 {
96     struct HdfTestMsg msg = {TEST_PAL_I3C_TYPE, I3C_TEST_CMD_REQUEST_IBI, -1};
97     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
98 }
99 
100 /**
101   * @tc.name: HdfI3cTestRreeIbi001
102   * @tc.desc: i3c free ibi test
103   * @tc.type: FUNC
104   * @tc.require: N/A
105   */
106 HWTEST_F(HdfI3cTest, HdfI3cTestRreeIbi001, TestSize.Level1)
107 {
108     struct HdfTestMsg msg = {TEST_PAL_I3C_TYPE, I3C_TEST_CMD_FREE_IBI, -1};
109     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
110 }
111 
112 /**
113   * @tc.name: HdfI3cTestMultiThread001
114   * @tc.desc: i3c multithreading test
115   * @tc.type: FUNC
116   * @tc.require: N/A
117   */
118 HWTEST_F(HdfI3cTest, HdfI3cTestMultiThread001, TestSize.Level1)
119 {
120     struct HdfTestMsg msg = {TEST_PAL_I3C_TYPE, I3C_TEST_CMD_MULTI_THREAD, -1};
121     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
122 }
123 
124 /**
125   * @tc.name: HdfI3cTestReliability001
126   * @tc.desc: i3c reliability test
127   * @tc.type: FUNC
128   * @tc.require: N/A
129   */
130 HWTEST_F(HdfI3cTest, HdfI3cTestReliability001, TestSize.Level1)
131 {
132     struct HdfTestMsg msg = {TEST_PAL_I3C_TYPE, I3C_TEST_CMD_RELIABILITY, -1};
133     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
134 }
135