From 081397e56067c0c5bca6d1c45796cb21e51d6537 Mon Sep 17 00:00:00 2001 From: Fancy code <258828110.@qq.com> Date: Mon, 13 May 2024 16:28:10 +0800 Subject: [PATCH] Backup. --- test/middleware/McuManager/CMakeLists.txt | 2 - .../McuManager/src/McuManager_Test.cpp | 85 +++++++++++++++++++ .../src_mock/McuManager_Mock_Test.cpp | 14 +++ test/test_develop.md | 2 +- 4 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 test/middleware/McuManager/src/McuManager_Test.cpp diff --git a/test/middleware/McuManager/CMakeLists.txt b/test/middleware/McuManager/CMakeLists.txt index 2751c35a..7cbe45a3 100644 --- a/test/middleware/McuManager/CMakeLists.txt +++ b/test/middleware/McuManager/CMakeLists.txt @@ -27,8 +27,6 @@ link_directories( ${EXTERNAL_LIBS_OUTPUT_PATH} ) - - if (DEFINED MCU_UART_DEVICE) add_definitions(-DMCU_UART_DEVICE=\"${MCU_UART_DEVICE}\") else() diff --git a/test/middleware/McuManager/src/McuManager_Test.cpp b/test/middleware/McuManager/src/McuManager_Test.cpp new file mode 100644 index 00000000..b2cddbef --- /dev/null +++ b/test/middleware/McuManager/src/McuManager_Test.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2023 Fancy Code. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "ILog.h" +#include "IMcuManager.h" +#include "McuAskBase.h" +#include "McuAskBaseTestTool.h" +#include +#include +#include +namespace McuManagerTest +{ +class McuManagerTest : public testing::Test +{ +public: + McuManagerTest() + { + } + virtual ~McuManagerTest() + { + } + static void SetUpTestCase() + { + CreateLogModule(); + ILogInit(LOG_INSTANCE_TYPE_END); + } + static void TearDownTestCase() + { + ILogUnInit(); + } + virtual void SetUp() + { + CreateMcuManager(); + IMcuManager::GetInstance()->Init(); + } + virtual void TearDown() + { + IMcuManager::GetInstance()->UnInit(); + DestroyMcuManager(); + } +}; +// ../output_files/test/bin/McuManagerTest +// --gtest_filter=McuManagerTest.INTEGRATION_McuManager_AUTO_GetIpcMission +TEST_F(McuManagerTest, RH_INTEGRATION_McuManager_AUTO_GetIpcMission) +{ + class McuAskTest : public McuAsk, public McuAskBaseTestTool + { + public: + McuAskTest() : McuAskBaseTestTool(McuAskBlock::BLOCK, McuAskReply::NEED_REPLY) + { + mDataReply = IpcMission::END; + } + virtual ~McuAskTest() = default; + void ReplyFinished(const bool result) override + { + McuAskBaseTestTool::ReplyFinished(result); + if (result) { + LogInfo("Ask data succeed, mDataReply = %d.\n", static_cast(mDataReply)); + // Do something here. + EXPECT_GT(static_cast(mDataReply), 0); + EXPECT_LT(static_cast(mDataReply), static_cast(IpcMission::END)); + } + else { + LogError("Ask data falied.\n"); + } + } + }; + std::shared_ptr ask = std::make_shared(); + std::shared_ptr testTool = std::dynamic_pointer_cast(ask); + testTool->McuAskDefaultFeatures(testTool); + IMcuManager::GetInstance()->GetIpcMission(ask); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); +} +} // namespace McuManagerTest \ No newline at end of file diff --git a/test/middleware/McuManager/src_mock/McuManager_Mock_Test.cpp b/test/middleware/McuManager/src_mock/McuManager_Mock_Test.cpp index 62f8cb07..797707e9 100644 --- a/test/middleware/McuManager/src_mock/McuManager_Mock_Test.cpp +++ b/test/middleware/McuManager/src_mock/McuManager_Mock_Test.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2023 Fancy Code. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include "ILog.h" #include "IMcuManager.h" #include "LinuxApiMock.h" diff --git a/test/test_develop.md b/test/test_develop.md index 039a057f..ab1afdeb 100644 --- a/test/test_develop.md +++ b/test/test_develop.md @@ -24,7 +24,7 @@ ### 1.1.2. 测试用例命名: -1. 仿真:硬件仿真,使用hardware simulation的缩写:HS;真实接口使用real interface的缩写:RA; +1. 仿真:硬件仿真,使用hardware simulation的缩写:**HS**,硬件仿真只能运行在Ubuntu系统进行仿真测试;真实硬件接口使用real hardware的缩写:**RH**,真实硬件接口测试用例只能运行在开发板进行真机测试;不涉及使用NOT INVOLVED的缩写:**NI**,即可执行在Ubuntu也可以运行在开发板; 2. 测试用例类型:含单元测试(UNIT)和集成测试(INTEGRATION); 3. 用例所属模块:大小驼峰; 4. 测试用例属性:EXAMPLE/AUTO/STRESS