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 <gtest/gtest.h>
24 #include <string>
25 #include <unistd.h>
26 #include "hdf_uhdf_test.h"
27 #include "hdf_io_service_if.h"
28 #include "spi_test.h"
29
30 using namespace testing::ext;
31
32 class HdfLiteSpiTest : public testing::Test {
33 public:
34 static void SetUpTestCase();
35 static void TearDownTestCase();
36 void SetUp();
37 void TearDown();
38 };
39
SetUpTestCase()40 void HdfLiteSpiTest::SetUpTestCase()
41 {
42 HdfTestOpenService();
43 }
44
TearDownTestCase()45 void HdfLiteSpiTest::TearDownTestCase()
46 {
47 HdfTestCloseService();
48 }
49
SetUp()50 void HdfLiteSpiTest::SetUp()
51 {
52 }
53
TearDown()54 void HdfLiteSpiTest::TearDown()
55 {
56 }
57
58 /**
59 * @tc.name: SpiTransferTest001
60 * @tc.desc: spi function test
61 * @tc.type: FUNC
62 * @tc.require: SR000DQ0VO
63 */
64 HWTEST_F(HdfLiteSpiTest, SpiTransferTest001, TestSize.Level1)
65 {
66 struct HdfTestMsg msg = {TEST_PAL_SPI_TYPE, SPI_TRANSFER_TEST, -1};
67 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
68 }
69
70 /**
71 * @tc.name: SpiMultiTransferTest001
72 * @tc.desc: spi function test
73 * @tc.type: FUNC
74 * @tc.require: SR000DQ0VO
75 */
76 #ifdef __LITEOS__
77 HWTEST_F(HdfLiteSpiTest, SpiMultiTransferTest001, TestSize.Level1)
78 {
79 struct HdfTestMsg msg = {TEST_PAL_SPI_TYPE, SPI_MULTI_TRANSFER_TEST, -1};
80 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
81
82 EXPECT_EQ(0, SpiTestExecute(SPI_MULTI_TRANSFER_TEST));
83 }
84 #endif
85
86 /**
87 * @tc.name: SpiDmaTransferTest001
88 * @tc.desc: Spi function test
89 * @tc.type: FUNC
90 * @tc.require: NA
91 */
92 HWTEST_F(HdfLiteSpiTest, SpiDmaTransferTest001, TestSize.Level1)
93 {
94 struct HdfTestMsg msg = {TEST_PAL_SPI_TYPE, SPI_DMA_TRANSFER_TEST, -1};
95 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
96 }
97
98 /**
99 * @tc.name: SpiIntTransferTest001
100 * @tc.desc: Spi function test
101 * @tc.type: FUNC
102 * @tc.require: NA
103 */
104 HWTEST_F(HdfLiteSpiTest, SpiIntTransferTest001, TestSize.Level1)
105 {
106 struct HdfTestMsg msg = {TEST_PAL_SPI_TYPE, SPI_INT_TRANSFER_TEST, -1};
107 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
108 }
109
110 /**
111 * @tc.name: SpiReliabilityTest001
112 * @tc.desc: spi function test
113 * @tc.type: FUNC
114 * @tc.require: SR000DQ0VO
115 */
116 HWTEST_F(HdfLiteSpiTest, SpiReliabilityTest001, TestSize.Level1)
117 {
118 struct HdfTestMsg msg = {TEST_PAL_SPI_TYPE, SPI_RELIABILITY_TEST, -1};
119 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
120 }
121