From 75bd13b7a6e86fbf1bb987bf37026465827d9dc1 Mon Sep 17 00:00:00 2001 From: Fancy code <258828110.@qq.com> Date: Tue, 7 May 2024 13:18:21 +0800 Subject: [PATCH] Fixed:Wrong word. --- application/CMakeLists.txt | 2 +- .../CMakeLists.txt | 20 ++-- .../build/hunting_camera.cmake} | 2 +- .../main.cpp | 0 .../src/MainThread.cpp | 0 .../src/MainThread.h | 0 middleware/CMakeLists.txt | 3 +- middleware/HuntingUpgrade/CMakeLists.txt | 56 ++++++++++ .../HuntingUpgrade/include/HuntingUpgrade.h | 26 +++++ .../HuntingUpgrade/src/HuntingUpgrade.cpp | 19 ++++ test/application/CMakeLists.txt | 2 +- .../CMakeLists.txt | 8 +- .../mainTest.cpp | 0 .../src/HuntingCamera_Test.cpp} | 4 +- .../src_mock/AppMonitor_Mock_Test.cpp | 104 +++++++++--------- .../src_mock/HuntingCameraTest.cpp} | 18 +-- .../src_mock/HuntingCameraTest.h} | 10 +- .../src_mock/MediaManager_Mock_Test.cpp | 8 +- test/utils/TestManager/CMakeLists.txt | 2 +- utils/CMakeLists.txt | 3 +- utils/UpgradeBase/CMakeLists.txt | 54 +++++++++ utils/UpgradeBase/README.md | 23 ++++ utils/UpgradeBase/include/UpgradeBase.h | 44 ++++++++ utils/UpgradeBase/src/UpgradeBase.cpp | 87 +++++++++++++++ 24 files changed, 403 insertions(+), 92 deletions(-) rename application/{HunttingCamera => HuntingCamera}/CMakeLists.txt (75%) rename application/{HunttingCamera/build/huntting_camera.cmake => HuntingCamera/build/hunting_camera.cmake} (98%) rename application/{HunttingCamera => HuntingCamera}/main.cpp (100%) rename application/{HunttingCamera => HuntingCamera}/src/MainThread.cpp (100%) rename application/{HunttingCamera => HuntingCamera}/src/MainThread.h (100%) create mode 100644 middleware/HuntingUpgrade/CMakeLists.txt create mode 100644 middleware/HuntingUpgrade/include/HuntingUpgrade.h create mode 100644 middleware/HuntingUpgrade/src/HuntingUpgrade.cpp rename test/application/{HunttingCamera => HuntingCamera}/CMakeLists.txt (91%) rename test/application/{HunttingCamera => HuntingCamera}/mainTest.cpp (100%) rename test/application/{HunttingCamera/src/HunttingCamera_Test.cpp => HuntingCamera/src/HuntingCamera_Test.cpp} (92%) rename test/application/{HunttingCamera => HuntingCamera}/src_mock/AppMonitor_Mock_Test.cpp (58%) rename test/application/{HunttingCamera/src_mock/HunttingCameraTest.cpp => HuntingCamera/src_mock/HuntingCameraTest.cpp} (85%) rename test/application/{HunttingCamera/src_mock/HunttingCameraTest.h => HuntingCamera/src_mock/HuntingCameraTest.h} (90%) rename test/application/{HunttingCamera => HuntingCamera}/src_mock/MediaManager_Mock_Test.cpp (83%) create mode 100644 utils/UpgradeBase/CMakeLists.txt create mode 100644 utils/UpgradeBase/README.md create mode 100644 utils/UpgradeBase/include/UpgradeBase.h create mode 100644 utils/UpgradeBase/src/UpgradeBase.cpp diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index a3f2acc..b4a994c 100644 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -1,3 +1,3 @@ add_subdirectory(main) -add_subdirectory(HunttingCamera) +add_subdirectory(HuntingCamera) add_subdirectory(MissionManager) \ No newline at end of file diff --git a/application/HunttingCamera/CMakeLists.txt b/application/HuntingCamera/CMakeLists.txt similarity index 75% rename from application/HunttingCamera/CMakeLists.txt rename to application/HuntingCamera/CMakeLists.txt index 33b10ae..5e922ed 100644 --- a/application/HunttingCamera/CMakeLists.txt +++ b/application/HuntingCamera/CMakeLists.txt @@ -1,5 +1,5 @@ include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake) -include(${APPLICATION_SOURCE_PATH}/HunttingCamera/build/huntting_camera.cmake) +include(${APPLICATION_SOURCE_PATH}/HuntingCamera/build/hunting_camera.cmake) set(EXECUTABLE_OUTPUT_PATH ${EXEC_OUTPUT_PATH}) set(LIBRARY_OUTPUT_PATH ${LIBS_OUTPUT_PATH}) @@ -19,9 +19,9 @@ aux_source_directory(./src MAIN_SRC_FILE_THIS) # file(GLOB_RECURSE MAIN_SRC_FILE_THIS src/*.cpp src/*.c) # set(MAIN_SRC_FILE "${MAIN_SRC_FILE_THIS}" CACHE STRING INTERNAL FORCE) -set(TARGET_LIB HunttingMainLib) +set(TARGET_LIB HuntingMainLib) add_library(${TARGET_LIB} STATIC ${MAIN_SRC_FILE_THIS}) -set(TARGET_NAME HunttingCamera_x86) +set(TARGET_NAME HuntingCamera_x86) add_executable(${TARGET_NAME} ${SRC_FILES}) target_link_libraries(${TARGET_LIB} ${HUNTTING_LINK_LIB}) @@ -32,7 +32,7 @@ endif() if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true") add_custom_target( - HunttingCamera_code_check + HuntingCamera_code_check COMMAND ${CLANG_TIDY_EXE} -checks='${CLANG_TIDY_CHECKS}' --header-filter=.* @@ -41,27 +41,27 @@ add_custom_target( ${MAIN_SRC_FILE_THIS} ${CLANG_TIDY_CONFIG} -p ${PLATFORM_PATH}/cmake-shell - WORKING_DIRECTORY ${APPLICATION_SOURCE_PATH}/HunttingCamera + WORKING_DIRECTORY ${APPLICATION_SOURCE_PATH}/HuntingCamera ) add_custom_command( TARGET ${TARGET_NAME} PRE_BUILD - COMMAND make HunttingCamera_code_check + COMMAND make HuntingCamera_code_check WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ ) file(GLOB_RECURSE HEADER_FILES *.h) add_custom_target( - HunttingCamera_code_format + HuntingCamera_code_format COMMAND ${CLANG_FORMAT_EXE} -style=file -i ${SRC_FILES} ${MAIN_SRC_FILE_THIS} ${HEADER_FILES} - WORKING_DIRECTORY ${APPLICATION_SOURCE_PATH}/HunttingCamera + WORKING_DIRECTORY ${APPLICATION_SOURCE_PATH}/HuntingCamera ) add_custom_command( TARGET ${TARGET_NAME} PRE_BUILD - COMMAND make HunttingCamera_code_check - COMMAND make HunttingCamera_code_format + COMMAND make HuntingCamera_code_check + COMMAND make HuntingCamera_code_format WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ ) endif() diff --git a/application/HunttingCamera/build/huntting_camera.cmake b/application/HuntingCamera/build/hunting_camera.cmake similarity index 98% rename from application/HunttingCamera/build/huntting_camera.cmake rename to application/HuntingCamera/build/hunting_camera.cmake index ad2b6b1..c2556aa 100644 --- a/application/HunttingCamera/build/huntting_camera.cmake +++ b/application/HuntingCamera/build/hunting_camera.cmake @@ -1,4 +1,4 @@ -set(HUNTTING_MAIN_INCLUDE_PATH "${APPLICATION_SOURCE_PATH}/HunttingCamera/src") +set(HUNTTING_MAIN_INCLUDE_PATH "${APPLICATION_SOURCE_PATH}/HuntingCamera/src") set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${APPLICATION_SOURCE_PATH}/MissionManager/include") set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/StateMachine/include") set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/McuManager/include") diff --git a/application/HunttingCamera/main.cpp b/application/HuntingCamera/main.cpp similarity index 100% rename from application/HunttingCamera/main.cpp rename to application/HuntingCamera/main.cpp diff --git a/application/HunttingCamera/src/MainThread.cpp b/application/HuntingCamera/src/MainThread.cpp similarity index 100% rename from application/HunttingCamera/src/MainThread.cpp rename to application/HuntingCamera/src/MainThread.cpp diff --git a/application/HunttingCamera/src/MainThread.h b/application/HuntingCamera/src/MainThread.h similarity index 100% rename from application/HunttingCamera/src/MainThread.h rename to application/HuntingCamera/src/MainThread.h diff --git a/middleware/CMakeLists.txt b/middleware/CMakeLists.txt index 12ea522..c3df1c1 100644 --- a/middleware/CMakeLists.txt +++ b/middleware/CMakeLists.txt @@ -6,4 +6,5 @@ add_subdirectory(McuAskBase) add_subdirectory(MediaManager) add_subdirectory(AppManager) add_subdirectory(StorageManager) -add_subdirectory(FilesManager) \ No newline at end of file +add_subdirectory(FilesManager) +add_subdirectory(HuntingUpgrade) \ No newline at end of file diff --git a/middleware/HuntingUpgrade/CMakeLists.txt b/middleware/HuntingUpgrade/CMakeLists.txt new file mode 100644 index 0000000..7d2c234 --- /dev/null +++ b/middleware/HuntingUpgrade/CMakeLists.txt @@ -0,0 +1,56 @@ + +include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake) +set(EXECUTABLE_OUTPUT_PATH ${EXEC_OUTPUT_PATH}) +set(LIBRARY_OUTPUT_PATH ${LIBS_OUTPUT_PATH}) + +include_directories( + ./src + ./include + ${UTILS_SOURCE_PATH}/StatusCode/include + ${UTILS_SOURCE_PATH}/Log/include + ${UTILS_SOURCE_PATH}/UpgradeBase/include +) +#do not rely on any other library +#link_directories( +#) + +aux_source_directory(./src SRC_FILES) + +set(TARGET_NAME HuntingUpgrade) +add_library(${TARGET_NAME} STATIC ${SRC_FILES}) + +target_link_libraries(${TARGET_NAME} UpgradeBase Hal StatusCode Log) + +if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true") +add_custom_target( + HuntingUpgrade_code_check + COMMAND ${CLANG_TIDY_EXE} + -checks='${CLANG_TIDY_CHECKS}' + --header-filter=.* + --system-headers=false + ${SRC_FILES} + ${CLANG_TIDY_CONFIG} + -p ${PLATFORM_PATH}/cmake-shell + WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/HuntingUpgrade +) +file(GLOB_RECURSE HEADER_FILES *.h) +add_custom_target( + HuntingUpgrade_code_format + COMMAND ${CLANG_FORMAT_EXE} + -style=file + -i ${SRC_FILES} ${HEADER_FILES} + WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/HuntingUpgrade +) +add_custom_command( + TARGET ${TARGET_NAME} + PRE_BUILD + COMMAND make HuntingUpgrade_code_check + COMMAND make HuntingUpgrade_code_format + WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ +) +endif() + +define_file_name(${TARGET_NAME}) + +file(GLOB_RECURSE INSTALL_HEADER_FILES include/*.h) +install(FILES ${INSTALL_HEADER_FILES} DESTINATION include) \ No newline at end of file diff --git a/middleware/HuntingUpgrade/include/HuntingUpgrade.h b/middleware/HuntingUpgrade/include/HuntingUpgrade.h new file mode 100644 index 0000000..79620a1 --- /dev/null +++ b/middleware/HuntingUpgrade/include/HuntingUpgrade.h @@ -0,0 +1,26 @@ +/* + * 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. + */ +#ifndef HUNTING_UPGRADE_H +#define HUNTING_UPGRADE_H +#include "StatusCode.h" +#include "UpgradeBase.h" +class HuntingUpgrade : public UpgradeBase +{ +public: + HuntingUpgrade() = default; + virtual ~HuntingUpgrade() = default; + StatusCode CheckFileHeader(const UpgradeFileHeader &head) override; +}; +#endif \ No newline at end of file diff --git a/middleware/HuntingUpgrade/src/HuntingUpgrade.cpp b/middleware/HuntingUpgrade/src/HuntingUpgrade.cpp new file mode 100644 index 0000000..0c0e1b3 --- /dev/null +++ b/middleware/HuntingUpgrade/src/HuntingUpgrade.cpp @@ -0,0 +1,19 @@ +/* + * 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 "HuntingUpgrade.h" +StatusCode HuntingUpgrade::CheckFileHeader(const UpgradeFileHeader &head) +{ + return CreateStatusCode(STATUS_CODE_OK); +} \ No newline at end of file diff --git a/test/application/CMakeLists.txt b/test/application/CMakeLists.txt index dff2f93..9a2fbdb 100644 --- a/test/application/CMakeLists.txt +++ b/test/application/CMakeLists.txt @@ -1,3 +1,3 @@ -add_subdirectory(HunttingCamera) +add_subdirectory(HuntingCamera) add_subdirectory(MissionManager) \ No newline at end of file diff --git a/test/application/HunttingCamera/CMakeLists.txt b/test/application/HuntingCamera/CMakeLists.txt similarity index 91% rename from test/application/HunttingCamera/CMakeLists.txt rename to test/application/HuntingCamera/CMakeLists.txt index 8a329c6..f30e66a 100644 --- a/test/application/HunttingCamera/CMakeLists.txt +++ b/test/application/HuntingCamera/CMakeLists.txt @@ -1,6 +1,6 @@ # include(${CMAKE_SOURCE_DIR}/build/independent_source.cmake) include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake) -include(${APPLICATION_SOURCE_PATH}/HunttingCamera/build/huntting_camera.cmake) +include(${APPLICATION_SOURCE_PATH}/HuntingCamera/build/hunting_camera.cmake) set(EXECUTABLE_OUTPUT_PATH ${TEST_OUTPUT_PATH}/bin) include_directories( @@ -36,7 +36,7 @@ if(${TARGET_PLATFORM} MATCHES ${DEFINE_LINUX}) aux_source_directory(./src_mock SRC_FILES) endif() -set(TARGET_NAME HunttingCameraTest) +set(TARGET_NAME HuntingCameraTest) add_executable(${TARGET_NAME} ${SRC_FILES_MAIN} ${SRC_FILES}) target_link_libraries(${TARGET_NAME} HunttingMainLib MissionManagerTestTool McuManagerTestTool McuAskBaseTestTool AppManagerTestTool HalTestTool TestManager gtest gmock pthread) if(${TEST_COVERAGE} MATCHES "true") @@ -56,7 +56,7 @@ add_custom_target( # --line-filter='[{\"name\":\"${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include/getest/gtest.h\"}]' --line-filter='[{\"name\":\"${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include/getest/*.h\"}]' -p ${PLATFORM_PATH}/cmake-shell - WORKING_DIRECTORY ${TEST_SOURCE_PATH}/application/HunttingCamera + WORKING_DIRECTORY ${TEST_SOURCE_PATH}/application/HuntingCamera ) add_custom_command( TARGET ${TARGET_NAME} @@ -71,7 +71,7 @@ add_custom_target( COMMAND ${CLANG_FORMAT_EXE} -style=file -i ${SRC_FILES} ${SRC_FILES_MAIN} ${HEADER_FILES} - WORKING_DIRECTORY ${TEST_SOURCE_PATH}/application/HunttingCamera + WORKING_DIRECTORY ${TEST_SOURCE_PATH}/application/HuntingCamera ) add_custom_command( TARGET ${TARGET_NAME} diff --git a/test/application/HunttingCamera/mainTest.cpp b/test/application/HuntingCamera/mainTest.cpp similarity index 100% rename from test/application/HunttingCamera/mainTest.cpp rename to test/application/HuntingCamera/mainTest.cpp diff --git a/test/application/HunttingCamera/src/HunttingCamera_Test.cpp b/test/application/HuntingCamera/src/HuntingCamera_Test.cpp similarity index 92% rename from test/application/HunttingCamera/src/HunttingCamera_Test.cpp rename to test/application/HuntingCamera/src/HuntingCamera_Test.cpp index 177ba71..8490917 100644 --- a/test/application/HunttingCamera/src/HunttingCamera_Test.cpp +++ b/test/application/HuntingCamera/src/HuntingCamera_Test.cpp @@ -18,6 +18,6 @@ #include "McuManagerTestTool.h" #include "TestManager.h" #include -namespace HunttingCameraTest +namespace HuntingCameraTest { -} // namespace HunttingCameraTest \ No newline at end of file +} // namespace HuntingCameraTest \ No newline at end of file diff --git a/test/application/HunttingCamera/src_mock/AppMonitor_Mock_Test.cpp b/test/application/HuntingCamera/src_mock/AppMonitor_Mock_Test.cpp similarity index 58% rename from test/application/HunttingCamera/src_mock/AppMonitor_Mock_Test.cpp rename to test/application/HuntingCamera/src_mock/AppMonitor_Mock_Test.cpp index 4f84f10..830bcea 100644 --- a/test/application/HunttingCamera/src_mock/AppMonitor_Mock_Test.cpp +++ b/test/application/HuntingCamera/src_mock/AppMonitor_Mock_Test.cpp @@ -15,7 +15,7 @@ #include "AppManagerTestTool.h" #include "GtestUsing.h" #include "HalTestTool.h" -#include "HunttingCameraTest.h" +#include "HuntingCameraTest.h" #include "ILog.h" #include "MainThread.h" #include "McuManagerTestTool.h" @@ -24,9 +24,9 @@ #include namespace AppMonitor_Mock_Test { -// ../output_files/test/bin/HunttingCameraTest -// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetProductInfo -TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetProductInfo) +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetProductInfo +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetProductInfo) { MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); @@ -34,9 +34,9 @@ TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetProductInfo) MockGetProductInfo(); MainThread::GetInstance()->Runing(); } -// ../output_files/test/bin/HunttingCameraTest -// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetDeviceAttr -TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetDeviceAttr) +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetDeviceAttr +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetDeviceAttr) { MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); @@ -44,9 +44,9 @@ TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetDeviceAttr) MockGetDeviceAttr(); MainThread::GetInstance()->Runing(); } -// ../output_files/test/bin/HunttingCameraTest -// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetMediaInfo -TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetMediaInfo) +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetMediaInfo +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetMediaInfo) { MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); @@ -54,9 +54,9 @@ TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetMediaInfo) MockGetMediaInfo(); MainThread::GetInstance()->Runing(); } -// ../output_files/test/bin/HunttingCameraTest -// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetSdCardInfo -TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetSdCardInfo) +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetSdCardInfo +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetSdCardInfo) { MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); @@ -64,9 +64,9 @@ TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetSdCardInfo) MockGetSdCardInfo(); MainThread::GetInstance()->Runing(); } -// ../output_files/test/bin/HunttingCameraTest -// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetBatteryInfo -TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetBatteryInfo) +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetBatteryInfo +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetBatteryInfo) { MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); @@ -74,9 +74,9 @@ TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetBatteryInfo) MockGetBatteryInfo(); MainThread::GetInstance()->Runing(); } -// ../output_files/test/bin/HunttingCameraTest -// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_SetDateTime -TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_SetDateTime) +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_SetDateTime +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_SetDateTime) { MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); @@ -84,9 +84,9 @@ TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_SetDateTime) MockSetDateTime(); MainThread::GetInstance()->Runing(); } -// ../output_files/test/bin/HunttingCameraTest -// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_SetTimeZone -TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_SetTimeZone) +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_SetTimeZone +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_SetTimeZone) { MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); @@ -94,9 +94,9 @@ TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_SetTimeZone) MockSetTimeZone(); MainThread::GetInstance()->Runing(); } -// ../output_files/test/bin/HunttingCameraTest -// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_MockUploadFiles -TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_MockUploadFiles) +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_MockUploadFiles +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_MockUploadFiles) { MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); @@ -104,9 +104,9 @@ TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_MockUploadFiles) MockUploadFiles(); MainThread::GetInstance()->Runing(); } -// ../output_files/test/bin/HunttingCameraTest -// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_McuOpenFailed -TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_McuOpenFailed) +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_McuOpenFailed +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_McuOpenFailed) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); @@ -115,9 +115,9 @@ TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_McuOpenFailed) // MockUploadFiles(); MainThread::GetInstance()->Runing(); } -// ../output_files/test/bin/HunttingCameraTest -// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetParamValue -TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetParamValue) +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetParamValue +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetParamValue) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); @@ -126,9 +126,9 @@ TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetParamValue) MockGetParamValue(); MainThread::GetInstance()->Runing(); } -// ../output_files/test/bin/HunttingCameraTest -// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetCapability -TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetCapability) +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetCapability +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetCapability) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); @@ -137,9 +137,9 @@ TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetCapability) MockGetCapability(); MainThread::GetInstance()->Runing(); } -// ../output_files/test/bin/HunttingCameraTest -// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetLockVideoStatus -TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetLockVideoStatus) +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetLockVideoStatus +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetLockVideoStatus) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); @@ -148,9 +148,9 @@ TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetLockVideoStatus) MockGetLockVideoStatus(); MainThread::GetInstance()->Runing(); } -// ../output_files/test/bin/HunttingCameraTest -// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetStorageInfo -TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetStorageInfo) +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetStorageInfo +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetStorageInfo) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); @@ -159,9 +159,9 @@ TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetStorageInfo) MockGetStorageInfo(); MainThread::GetInstance()->Runing(); } -// ../output_files/test/bin/HunttingCameraTest -// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetStorageFileList -TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetStorageFileList) +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetStorageFileList +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetStorageFileList) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); @@ -170,9 +170,9 @@ TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetStorageFileList) MockGetStorageFileList(); MainThread::GetInstance()->Runing(); } -// ../output_files/test/bin/HunttingCameraTest -// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_SetParamValue -TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_SetParamValue) +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_SetParamValue +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_SetParamValue) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); @@ -181,9 +181,9 @@ TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_SetParamValue) MockSetParamValue(); MainThread::GetInstance()->Runing(); } -// ../output_files/test/bin/HunttingCameraTest -// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_EnterRecorder -TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_EnterRecorder) +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_EnterRecorder +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_EnterRecorder) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); @@ -192,9 +192,9 @@ TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_EnterRecorder) MockEnterRecorder(); MainThread::GetInstance()->Runing(); } -// ../output_files/test/bin/HunttingCameraTest -// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_AppPlayback -TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_AppPlayback) +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_AppPlayback +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_AppPlayback) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); diff --git a/test/application/HunttingCamera/src_mock/HunttingCameraTest.cpp b/test/application/HuntingCamera/src_mock/HuntingCameraTest.cpp similarity index 85% rename from test/application/HunttingCamera/src_mock/HunttingCameraTest.cpp rename to test/application/HuntingCamera/src_mock/HuntingCameraTest.cpp index 395eb08..45833a8 100644 --- a/test/application/HunttingCamera/src_mock/HunttingCameraTest.cpp +++ b/test/application/HuntingCamera/src_mock/HuntingCameraTest.cpp @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "HunttingCameraTest.h" +#include "HuntingCameraTest.h" #include "GtestUsing.h" #include "ILog.h" #include "MainThread.h" @@ -21,22 +21,22 @@ void MainThreadTest::CustomizationInit(void) { // Do nothing here to make sure test tool work. } -HunttingCameraTest::HunttingCameraTest() +HuntingCameraTest::HuntingCameraTest() { } -HunttingCameraTest::~HunttingCameraTest() +HuntingCameraTest::~HuntingCameraTest() { } -void HunttingCameraTest::SetUpTestCase() +void HuntingCameraTest::SetUpTestCase() { CreateLogModule(); ILogInit(LOG_INSTANCE_TYPE_END); } -void HunttingCameraTest::TearDownTestCase() +void HuntingCameraTest::TearDownTestCase() { ILogUnInit(); } -void HunttingCameraTest::SetUp() +void HuntingCameraTest::SetUp() { CreateAllCamerasMcok(); std::shared_ptr mainThread = std::make_shared(); @@ -52,7 +52,7 @@ void HunttingCameraTest::SetUp() HalTestTool::InitSdCardHal(mLinuxTest); TestManager::Init(); } -void HunttingCameraTest::TearDown() +void HuntingCameraTest::TearDown() { TestManager::UnInit(); MissionManagerTestTool::UnInit(); @@ -68,12 +68,12 @@ void HunttingCameraTest::TearDown() MainThread::GetInstance(&mainThread); DestroyAllCamerasMock(); } -void HunttingCameraTest::CreateAllCamerasMcok(void) +void HuntingCameraTest::CreateAllCamerasMcok(void) { std::shared_ptr camera = HalTestTool::MakeCameraHalTest(CameraType::MAIN_CAMERA); mAllCamerasMock[CameraType::MAIN_CAMERA] = camera; } -void HunttingCameraTest::DestroyAllCamerasMock(void) +void HuntingCameraTest::DestroyAllCamerasMock(void) { mAllCamerasMock.clear(); } \ No newline at end of file diff --git a/test/application/HunttingCamera/src_mock/HunttingCameraTest.h b/test/application/HuntingCamera/src_mock/HuntingCameraTest.h similarity index 90% rename from test/application/HunttingCamera/src_mock/HunttingCameraTest.h rename to test/application/HuntingCamera/src_mock/HuntingCameraTest.h index f63d0c4..cfb656c 100644 --- a/test/application/HunttingCamera/src_mock/HunttingCameraTest.h +++ b/test/application/HuntingCamera/src_mock/HuntingCameraTest.h @@ -12,8 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef HUNTTING_CAMERA_TEST_H -#define HUNTTING_CAMERA_TEST_H +#ifndef HUNTING_CAMERA_TEST_H +#define HUNTING_CAMERA_TEST_H #include "AppManagerTestTool.h" #include "GtestUsing.h" #include "HalTestTool.h" @@ -30,7 +30,7 @@ public: virtual ~MainThreadTest() = default; void CustomizationInit(void) override; }; -class HunttingCameraTest : public testing::Test, +class HuntingCameraTest : public testing::Test, public TestManager, public MissionManagerTestTool, public McuManagerTestTool, @@ -38,8 +38,8 @@ class HunttingCameraTest : public testing::Test, public HalTestTool { public: - HunttingCameraTest(); - virtual ~HunttingCameraTest(); + HuntingCameraTest(); + virtual ~HuntingCameraTest(); static void SetUpTestCase(); static void TearDownTestCase(); void SetUp() override; diff --git a/test/application/HunttingCamera/src_mock/MediaManager_Mock_Test.cpp b/test/application/HuntingCamera/src_mock/MediaManager_Mock_Test.cpp similarity index 83% rename from test/application/HunttingCamera/src_mock/MediaManager_Mock_Test.cpp rename to test/application/HuntingCamera/src_mock/MediaManager_Mock_Test.cpp index 644f9e8..26b55d9 100644 --- a/test/application/HunttingCamera/src_mock/MediaManager_Mock_Test.cpp +++ b/test/application/HuntingCamera/src_mock/MediaManager_Mock_Test.cpp @@ -15,7 +15,7 @@ #include "AppManagerTestTool.h" #include "GtestUsing.h" #include "HalTestTool.h" -#include "HunttingCameraTest.h" +#include "HuntingCameraTest.h" #include "ILog.h" #include "MainThread.h" #include "McuManagerTestTool.h" @@ -24,9 +24,9 @@ #include namespace MediaManager_Mock_Test { -// ../output_files/test/bin/HunttingCameraTest -// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_EXAMPLE_MediaReprot -TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_EXAMPLE_MediaReprot) +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_EXAMPLE_MediaReprot +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_EXAMPLE_MediaReprot) { SetAllCamerasResult(mAllCamerasMock); MockReportCameraEvent("/tmp/test.MP4", CameraType::MAIN_CAMERA); diff --git a/test/utils/TestManager/CMakeLists.txt b/test/utils/TestManager/CMakeLists.txt index a61d98a..7b2b91b 100644 --- a/test/utils/TestManager/CMakeLists.txt +++ b/test/utils/TestManager/CMakeLists.txt @@ -5,7 +5,7 @@ set(LIBRARY_OUTPUT_PATH ${LIBS_OUTPUT_PATH}) include_directories( ./src ./include - ${APPLICATION_SOURCE_PATH}/HunttingCamera/src + ${APPLICATION_SOURCE_PATH}/HuntingCamera/src ${UTILS_SOURCE_PATH}/Log/include ${UTILS_SOURCE_PATH}/StatusCode/include ${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index bd0ba16..5240e45 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -15,4 +15,5 @@ add_subdirectory(KeyControl) add_subdirectory(MediaAdapter) add_subdirectory(FxHttpServer) add_subdirectory(Servers) -add_subdirectory(TcpModule) \ No newline at end of file +add_subdirectory(TcpModule) +add_subdirectory(UpgradeBase) \ No newline at end of file diff --git a/utils/UpgradeBase/CMakeLists.txt b/utils/UpgradeBase/CMakeLists.txt new file mode 100644 index 0000000..e34986c --- /dev/null +++ b/utils/UpgradeBase/CMakeLists.txt @@ -0,0 +1,54 @@ +include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake) +set(EXECUTABLE_OUTPUT_PATH ${EXEC_OUTPUT_PATH}) +set(LIBRARY_OUTPUT_PATH ${LIBS_OUTPUT_PATH}) + +include_directories( + ./src + ./include + ${UTILS_SOURCE_PATH}/LinuxApi/include + ${UTILS_SOURCE_PATH}/StatusCode/include + ${UTILS_SOURCE_PATH}/Log/include +) +# link_directories( +# ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs +# ) + +aux_source_directory(./src SRC_FILES) + +set(TARGET_NAME UpgradeBase) +add_library(${TARGET_NAME} STATIC ${SRC_FILES}) +target_link_libraries(${TARGET_NAME} StatusCode Log) + +if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true") +add_custom_target( + UpgradeBase_code_check + COMMAND ${CLANG_TIDY_EXE} + -checks='${CLANG_TIDY_CHECKS}' + --header-filter=.* + --system-headers=false + ${SRC_FILES} + ${CLANG_TIDY_CONFIG} + -p ${PLATFORM_PATH}/cmake-shell + WORKING_DIRECTORY ${UTILS_SOURCE_PATH}/UpgradeBase +) +file(GLOB_RECURSE HEADER_FILES *.h) +add_custom_target( + UpgradeBase_code_format + COMMAND ${CLANG_FORMAT_EXE} + -style=file + -i ${SRC_FILES} ${HEADER_FILES} + WORKING_DIRECTORY ${UTILS_SOURCE_PATH}/UpgradeBase +) +add_custom_command( + TARGET ${TARGET_NAME} + PRE_BUILD + COMMAND make UpgradeBase_code_check + COMMAND make UpgradeBase_code_format + WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ +) +endif() + +define_file_name(${TARGET_NAME}) + +file(GLOB_RECURSE INSTALL_HEADER_FILES include/*.h) +install(FILES ${INSTALL_HEADER_FILES} DESTINATION include) \ No newline at end of file diff --git a/utils/UpgradeBase/README.md b/utils/UpgradeBase/README.md new file mode 100644 index 0000000..1fb1714 --- /dev/null +++ b/utils/UpgradeBase/README.md @@ -0,0 +1,23 @@ +# 1. 升级功能基类 + +## 1.1. 概述 + +  升级功能基类,用于升级功能模块,提供升级功能模块的通用方法。 + +## 1.2. 文件头定义 + +**32字节头定义** + +| 打包时间(6) | 版本号(4) | 型号代码(2) | 项目代码(2) | 升级类型(1) | 预留(17) | +|----|----|----|----|----|----| +|----|----|----|----|----|----| + +**升级类型说明** + +0x00:仅仅应用程序; +0x01:烧录flash; + +## 1.3. 仅升级应用程序 + +1. 插卡后检查sd卡是否存在升级文件; +2. 校验升级文件并拷贝到升级目录; \ No newline at end of file diff --git a/utils/UpgradeBase/include/UpgradeBase.h b/utils/UpgradeBase/include/UpgradeBase.h new file mode 100644 index 0000000..d0ccfce --- /dev/null +++ b/utils/UpgradeBase/include/UpgradeBase.h @@ -0,0 +1,44 @@ +/* + * 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. + */ +#ifndef UPGRADE_BASE_H +#define UPGRADE_BASE_H +#include "StatusCode.h" +typedef struct __attribute__((packed)) upgrade_file_header +{ + unsigned char packTime[6]; + unsigned char version[4]; + unsigned char product[2]; + unsigned char project[2]; + unsigned char upgradeType[1]; + unsigned char reserved[17]; +} UpgradeFileHeader; +class UpgradeBase +{ +public: + UpgradeBase() = default; + virtual ~UpgradeBase() = default; + virtual StatusCode CheckFileHeader(const UpgradeFileHeader &head) = 0; + /** + * @brief Verify if the file belongs to the upgrade file. + * + * @param fileName The file name being verified. Enter the parameter using an absolute path. + * @return StatusCode + */ + StatusCode CheckUpgradeFile(const char *fileName); + StatusCode MoveUpgradeFile(const char *sourceFile, const char *targetFile); + +private: +}; +#endif \ No newline at end of file diff --git a/utils/UpgradeBase/src/UpgradeBase.cpp b/utils/UpgradeBase/src/UpgradeBase.cpp new file mode 100644 index 0000000..964f8c8 --- /dev/null +++ b/utils/UpgradeBase/src/UpgradeBase.cpp @@ -0,0 +1,87 @@ +/* + * 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 "UpgradeBase.h" +#include "ILog.h" +#include "LinuxApi.h" +#include +#include +#include +StatusCode UpgradeBase::CheckUpgradeFile(const char *fileName) +{ + FILE *file = nullptr; + UpgradeFileHeader fileHead; + + file = fopen(fileName, "rb"); + if (file == NULL) { + perror("Error opening file"); + return CreateStatusCode(STATUS_CODE_NOT_OK); + } + + size_t bytesRead = fread(&fileHead, sizeof(UpgradeFileHeader), 1, file); + if (bytesRead != 1) { + perror("Error reading file header"); + fclose(file); + return CreateStatusCode(STATUS_CODE_NOT_OK); + } + return CheckFileHeader(fileHead); +} +StatusCode UpgradeBase::MoveUpgradeFile(const char *sourceFile, const char *targetFile) +{ + FILE *inputFile = nullptr; + FILE *outputFile = nullptr; + constexpr int BUFF_SIZE = 1024 * 200; + UpgradeFileHeader fileHeader; + const size_t headerSize = sizeof(UpgradeFileHeader); + unsigned char buffer[BUFF_SIZE]; + size_t bytesRead; + + inputFile = fopen(sourceFile, "rb"); + if (inputFile == NULL) { + perror("Error opening input file"); + return CreateStatusCode(STATUS_CODE_NOT_OK); + } + + outputFile = fopen(targetFile, "wb"); + if (outputFile == NULL) { + perror("Error opening output file"); + fclose(inputFile); + return CreateStatusCode(STATUS_CODE_NOT_OK); + } + + bytesRead = fread(&fileHeader, 1, headerSize, inputFile); + if (bytesRead != headerSize) { + perror("Error reading file header"); + fclose(inputFile); + fclose(outputFile); + return CreateStatusCode(STATUS_CODE_NOT_OK); + } + + while ((bytesRead = fread(buffer, 1, sizeof(buffer), inputFile)) > 0) { + fwrite(buffer, 1, bytesRead, outputFile); + if (ferror(inputFile) || ferror(outputFile)) { + perror("Error reading or writing file"); + fclose(inputFile); + fclose(outputFile); + return CreateStatusCode(STATUS_CODE_NOT_OK); + } + } + + fclose(inputFile); + fclose(outputFile); + + LogInfo("File processed successfully.\n"); + + return CreateStatusCode(STATUS_CODE_OK); +} \ No newline at end of file