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 <gtest/gtest.h>
14 #include <string>
15 #include <unistd.h>
16 #include "hdf_uhdf_test.h"
17 #include "hdf_io_service_if.h"
18
19 using namespace testing::ext;
20
21 enum SdioTestCmd {
22 SDIO_DISABLE_FUNC_01 = 0,
23 SDIO_ENABLE_FUNC_01,
24 SDIO_SET_BLOCK_SIZE_01,
25 SDIO_INCR_ADDR_READ_AND_WRITE_BYTES_01,
26 SDIO_FIXED_ADDR_READ_AND_WRITE_BYTES_01,
27 SDIO_FUNC0_READ_AND_WRITE_BYTES_01,
28 SDIO_SET_AND_GET_COMMON_INFO_01,
29 };
30
31 class HdfLiteSdioTest : public testing::Test {
32 public:
33 static void SetUpTestCase();
34 static void TearDownTestCase();
35 void SetUp();
36 void TearDown();
37 };
38
SetUpTestCase()39 void HdfLiteSdioTest::SetUpTestCase()
40 {
41 HdfTestOpenService();
42 }
43
TearDownTestCase()44 void HdfLiteSdioTest::TearDownTestCase()
45 {
46 HdfTestCloseService();
47 }
48
SetUp()49 void HdfLiteSdioTest::SetUp()
50 {
51 }
52
TearDown()53 void HdfLiteSdioTest::TearDown()
54 {
55 }
56
57 /**
58 * @tc.name: SdioDisableFunc001
59 * @tc.desc: SdioDisableFunc Interface test
60 * @tc.type: FUNC
61 * @tc.require: AR000F868B
62 */
63 HWTEST_F(HdfLiteSdioTest, SdioDisableFunc001, TestSize.Level1)
64 {
65 struct HdfTestMsg msg = {TEST_PAL_SDIO_TYPE, SDIO_DISABLE_FUNC_01, -1};
66 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
67 }
68
69 /**
70 * @tc.name: SdioEnableFunc001
71 * @tc.desc: SdioEnableFunc Interface test
72 * @tc.type: FUNC
73 * @tc.require: AR000F868B
74 */
75 HWTEST_F(HdfLiteSdioTest, SdioEnableFunc001, TestSize.Level1)
76 {
77 struct HdfTestMsg msg = {TEST_PAL_SDIO_TYPE, SDIO_ENABLE_FUNC_01, -1};
78 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
79 }
80
81 /**
82 * @tc.name: SdioSetBlockSize001
83 * @tc.desc: SdioSetBlockSize Interface test
84 * @tc.type: FUNC
85 * @tc.require: AR000F868B
86 */
87 HWTEST_F(HdfLiteSdioTest, SdioSetBlockSize001, TestSize.Level1)
88 {
89 struct HdfTestMsg msg = {TEST_PAL_SDIO_TYPE, SDIO_SET_BLOCK_SIZE_01, -1};
90 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
91 }
92
93 /**
94 * @tc.name: SdioIncrAddrReadAndWriteBytes001
95 * @tc.desc: SdioReadBytes and SdioWriteBytes Interface test
96 * @tc.type: FUNC
97 * @tc.require: AR000F868B
98 */
99 HWTEST_F(HdfLiteSdioTest, SdioIncrAddrReadAndWriteBytes001, TestSize.Level1)
100 {
101 struct HdfTestMsg msg = {TEST_PAL_SDIO_TYPE, SDIO_INCR_ADDR_READ_AND_WRITE_BYTES_01, -1};
102 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
103 }
104
105 /**
106 * @tc.name: SdioFixedAddrReadAndWriteBytes001
107 * @tc.desc: SdioReadBytesFromFixedAddr and SdioWriteBytesToFixedAddr Interface test
108 * @tc.type: FUNC
109 * @tc.require: AR000F868B
110 */
111 HWTEST_F(HdfLiteSdioTest, SdioFixedAddrReadAndWriteBytes001, TestSize.Level1)
112 {
113 struct HdfTestMsg msg = {TEST_PAL_SDIO_TYPE, SDIO_FIXED_ADDR_READ_AND_WRITE_BYTES_01, -1};
114 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
115 }
116
117 /**
118 * @tc.name: SdioFunc0ReadAndWriteBytes001
119 * @tc.desc: SdioReadBytesFromFunc0 and SdioWriteBytesToFunc0 Interface test
120 * @tc.type: FUNC
121 * @tc.require: AR000F868B
122 */
123 HWTEST_F(HdfLiteSdioTest, SdioFunc0ReadAndWriteBytes001, TestSize.Level1)
124 {
125 struct HdfTestMsg msg = { TEST_PAL_SDIO_TYPE, SDIO_FUNC0_READ_AND_WRITE_BYTES_01, -1};
126 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
127 }
128
129 /**
130 * @tc.name: SdioSetAndGetCommonInfo001
131 * @tc.desc: SdioGetCommonInfo and SdioSetCommonInfo Interface test
132 * @tc.type: FUNC
133 * @tc.require: AR000F868B
134 */
135 HWTEST_F(HdfLiteSdioTest, SdioSetAndGetCommonInfo001, TestSize.Level1)
136 {
137 struct HdfTestMsg msg = {TEST_PAL_SDIO_TYPE, SDIO_SET_AND_GET_COMMON_INFO_01, -1};
138 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
139 }
140