Add:AppManager test code.

This commit is contained in:
Fancy code 2024-03-03 09:58:06 -08:00
parent 3fef82c7d4
commit a73b84039a
24 changed files with 394 additions and 70 deletions

View File

@ -20,11 +20,42 @@
#include <vector>
bool CreateAppManagerModule(void);
bool DestroyAppManagerModule(void);
enum class ResposeResult
{
SUCCESSFUL = 0,
FAILED,
END
};
enum class UploadCommand
{
UPGRADE_CPU = 0,
END
};
typedef struct app_get_product_info
{
app_get_product_info() {}
std::string mModel;
std::string mCompany;
std::string mSoc;
std::string mSp;
} AppGetProductInfo;
typedef struct app_upload_file
{
app_upload_file(const std::string filePath, const UploadCommand command) : mFilePath(filePath), mCommand(command)
{
mResult = ResposeResult::END;
}
const std::string mFilePath;
const UploadCommand mCommand;
ResposeResult mResult;
} AppUploadFile;
class VAppMonitor
{
public:
VAppMonitor() = default;
virtual ~VAppMonitor() = default;
virtual StatusCode GetProductInfo(AppGetProductInfo &param);
virtual StatusCode UploadFile(AppUploadFile &param);
};
typedef struct app_param
{
@ -40,5 +71,6 @@ public:
static std::shared_ptr<IAppManager> &GetInstance(std::shared_ptr<IAppManager> *impl = nullptr);
virtual const StatusCode Init(const AppParam &param);
virtual const StatusCode UnInit(void);
virtual const StatusCode SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor);
};
#endif

View File

@ -34,6 +34,11 @@ const StatusCode AppManager::UnInit(void)
mProtocolHandle.reset();
return CreateStatusCode(STATUS_CODE_OK);
}
const StatusCode AppManager::SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor)
{
mProtocolHandle->SetAppMonitor(monitor);
return CreateStatusCode(STATUS_CODE_OK);
}
void AppManager::AppRequestHandle(const char *url, const unsigned int urlLength, ResponseHandle responseHandle,
void *context)
{

View File

@ -24,6 +24,7 @@ public:
virtual ~AppManager() = default;
const StatusCode Init(const AppParam &param) override;
const StatusCode UnInit(void) override;
const StatusCode SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor) override;
void AppRequestHandle(const char *url, const unsigned int urlLength, ResponseHandle responseHandle, void *context);
private:

View File

@ -14,6 +14,12 @@
*/
#include "IAppManager.h"
#include "ILog.h"
StatusCode VAppMonitor::GetProductInfo(AppGetProductInfo &param)
{
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
}
StatusCode VAppMonitor::UploadFile(AppUploadFile &param) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
std::shared_ptr<IAppManager> &IAppManager::GetInstance(std::shared_ptr<IAppManager> *impl)
{
static auto instance = std::make_shared<IAppManager>();
@ -29,4 +35,8 @@ std::shared_ptr<IAppManager> &IAppManager::GetInstance(std::shared_ptr<IAppManag
return instance;
}
const StatusCode IAppManager::Init(const AppParam &param) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
const StatusCode IAppManager::UnInit(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
const StatusCode IAppManager::UnInit(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
const StatusCode IAppManager::SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor)
{
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
}

View File

@ -14,8 +14,8 @@
*/
#ifndef I_APP_PROTOCOL_HANDLE_H
#define I_APP_PROTOCOL_HANDLE_H
#include "FxHttpServer.h"
#include "StatusCode.h"
#include "WebServer.h"
#include <iostream>
#include <memory>
#include <vector>
@ -36,5 +36,6 @@ public:
void *context)
{
}
virtual void SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor) {}
};
#endif

View File

@ -21,9 +21,12 @@ using std::placeholders::_2;
using std::placeholders::_3;
// using std::placeholders::_4;
const char *APP_GET_PRODUCT_INFO = "/app/getproductinfo";
const char *APP_UPLOAD_FILE = "/upload";
SixFrameHandle::SixFrameHandle()
{
mAppMonitor = std::make_shared<VAppMonitor>();
mResquesHandleFunc[APP_GET_PRODUCT_INFO] = std::bind(&SixFrameHandle::RequestGetProductInfo, this, _1, _2, _3);
mResquesHandleFunc[APP_UPLOAD_FILE] = std::bind(&SixFrameHandle::RequestUpload, this, _1, _2, _3);
// mResquesHandleFunc["favicon.ico"] = std::bind(&SixFrameHandle::DoNothing, this, _1, _2, _3);
}
void SixFrameHandle::RequestHandle(const char *url, const unsigned int urlLength, ResponseHandle responseHandle,
@ -88,6 +91,21 @@ void SixFrameHandle::RequestGetProductInfo(std::multimap<std::string, std::strin
char *resultStr = nullptr;
cJSON *result = MakeResponseResult(ResposeResult::SUCCESSFUL);
resultStr = cJSON_Print(result);
AppGetProductInfo info;
mAppMonitor->GetProductInfo(info);
responseHandle(resultStr, context);
free(resultStr);
cJSON_Delete(result);
}
void SixFrameHandle::RequestUpload(std::multimap<std::string, std::string> &paramsMap, ResponseHandle responseHandle,
void *context)
{
LogInfo("RequestUpload.\n");
char *resultStr = nullptr;
AppUploadFile info("path", UploadCommand::UPGRADE_CPU);
mAppMonitor->UploadFile(info);
cJSON *result = MakeResponseResult(info.mResult);
resultStr = cJSON_Print(result);
responseHandle(resultStr, context);
free(resultStr);
cJSON_Delete(result);
@ -98,4 +116,13 @@ cJSON *SixFrameHandle::MakeResponseResult(const ResposeResult result)
cJSON *resultCJSON = cJSON_CreateObject();
cJSON_AddNumberToObject(resultCJSON, RESPONSE_RESULT, static_cast<int>(result));
return resultCJSON;
}
void SixFrameHandle::SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor)
{
if (monitor) {
mAppMonitor = monitor;
}
else {
LogError("SetAppMonitor failed.\n");
}
}

View File

@ -14,6 +14,7 @@
*/
#ifndef SIX_FRAME_HANDLE_H
#define SIX_FRAME_HANDLE_H
#include "IAppManager.h"
#include "IAppProtocolHandle.h"
#include "StatusCode.h"
#include <cJSON.h>
@ -23,12 +24,6 @@
#include <memory>
#include <vector>
using ResquesHandleFunc = std::function<void(std::multimap<std::string, std::string> &, ResponseHandle, void *)>;
enum class ResposeResult
{
SUCCESSFUL = 0,
FAILED,
END
};
class SixFrameHandle : public IAppProtocolHandle
{
public:
@ -46,11 +41,17 @@ private:
void DoNothing(std::multimap<std::string, std::string> &paramsMap, ResponseHandle responseHandle, void *context);
void RequestGetProductInfo(std::multimap<std::string, std::string> &paramsMap, ResponseHandle responseHandle,
void *context);
void RequestUpload(std::multimap<std::string, std::string> &paramsMap, ResponseHandle responseHandle,
void *context);
private:
cJSON *MakeResponseResult(const ResposeResult result);
protected:
void SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor) override;
private:
std::map<std::string, ResquesHandleFunc> mResquesHandleFunc;
std::shared_ptr<VAppMonitor> mAppMonitor;
};
#endif

View File

@ -45,4 +45,5 @@ using ::testing::SetArgumentPointee;
using ::testing::Unused;
using ::testing::WithArgs;
using ::testing::internal::BuiltInDefaultValue;
using ::testing::SetArgReferee;
#endif

View File

@ -9,11 +9,8 @@ include_directories(
${UTILS_SOURCE_PATH}/Log/include
${UTILS_SOURCE_PATH}/KeyControl/include
${UTILS_SOURCE_PATH}/LedControl/include
# ${UTILS_SOURCE_PATH}/McuProtocol/include
${HAL_SOURCE_PATH}/src
# /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/hal/src/HalCpp.h
# ${TEST_SOURCE_PATH}/utils/LinuxApiMock/include
# ${TEST_SOURCE_PATH}/utils/McuProtocol/tool/include
${TEST_SOURCE_PATH}
)
# link_directories(
# ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs

View File

@ -14,40 +14,9 @@
*/
#ifndef HAL_TEST_TOOL_H
#define HAL_TEST_TOOL_H
#include "GtestUsing.h"
#include "IHalCpp.h"
#include "LedControl.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
using ::testing::_;
using ::testing::Action;
using ::testing::ActionInterface;
using ::testing::AnyNumber;
using ::testing::Assign;
using ::testing::AtLeast;
using ::testing::ByMove;
using ::testing::ByRef;
using ::testing::DefaultValue;
using ::testing::DoAll;
using ::testing::DoDefault;
using ::testing::IgnoreResult;
using ::testing::Invoke;
using ::testing::InvokeWithoutArgs;
using ::testing::MakePolymorphicAction;
using ::testing::PolymorphicAction;
using ::testing::Return;
using ::testing::ReturnNew;
using ::testing::ReturnNull;
using ::testing::ReturnPointee;
using ::testing::ReturnRef;
using ::testing::ReturnRefOfCopy;
using ::testing::ReturnRoundRobin;
using ::testing::SaveArg;
using ::testing::SetArgPointee;
using ::testing::SetArgReferee;
using ::testing::SetArgumentPointee;
using ::testing::Unused;
using ::testing::WithArgs;
using ::testing::internal::BuiltInDefaultValue;
class HalTestTool
{
public:

View File

@ -10,6 +10,7 @@ include_directories(
${UTILS_SOURCE_PATH}/StatusCode/include
${UTILS_SOURCE_PATH}/KeyControl/include
${UTILS_SOURCE_PATH}/LedControl/include
${UTILS_SOURCE_PATH}/WebServer/include
${HAL_SOURCE_PATH}/include
${MIDDLEWARE_SOURCE_PATH}/AppManager/include
${MIDDLEWARE_SOURCE_PATH}/AppManager/src

View File

@ -55,7 +55,7 @@ TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_Demo0)
{
IAppManager::GetInstance()->Init(mAppParam);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
std::this_thread::sleep_for(std::chrono::milliseconds(200000));
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
IAppManager::GetInstance()->UnInit();
}
// ../output_files/test/bin/AppManagerTest --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_Demo
@ -67,8 +67,8 @@ TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_Demo)
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
IAppManager::GetInstance()->UnInit();
}
// ../output_files/test/bin/AppManagerTest --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_Demo2
TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_Demo2)
// ../output_files/test/bin/AppManagerTest --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_Upload
TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_Upload)
{
IAppManager::GetInstance()->Init(mAppParam);
std::this_thread::sleep_for(std::chrono::milliseconds(100));

View File

@ -15,6 +15,8 @@
#ifndef APP_MANAGER_TEST_TOOL_H
#define APP_MANAGER_TEST_TOOL_H
#include "GtestUsing.h"
#include "IAppManager.h"
#include <memory>
class AppManagerTestTool
{
public:
@ -26,5 +28,12 @@ public:
protected:
void MockGetProductInfo(void);
void MockUploadFiles(void);
private:
void AppManagerMockInit(std::shared_ptr<IAppManager> &vMock);
private:
std::shared_ptr<IAppManager> mAppManagerMock;
std::shared_ptr<VAppMonitor> mAppMonitorMock;
};
#endif

View File

@ -0,0 +1,55 @@
/*
* 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 "AppManagerMakePtrTest.h"
#include "ILog.h"
void OverrideAppManagerMakePtrObject(std::shared_ptr<AppManagerMock> &appManagerMock)
{
std::shared_ptr<AppManagerMakePtr> impl = std::make_shared<AppManagerMakePtrTest>();
std::shared_ptr<AppManagerMakePtrTest> test = std::dynamic_pointer_cast<AppManagerMakePtrTest>(impl);
if (test) {
test->mAppManagerMock = appManagerMock;
}
AppManagerMakePtr::GetInstance(&impl);
}
void CancelOverrideAppManagerMakePtrObject(void)
{
std::shared_ptr<AppManagerMakePtr> tmp = AppManagerMakePtr::GetInstance();
std::shared_ptr<AppManagerMakePtrTest> test = std::dynamic_pointer_cast<AppManagerMakePtrTest>(tmp);
if (test) {
test->mAppManagerMock.reset();
}
std::shared_ptr<AppManagerMakePtr> impl = std::make_shared<AppManagerMakePtrTest>();
AppManagerMakePtr::GetInstance(&impl);
}
AppManagerMakePtrTest::AppManagerMakePtrTest()
{
//
}
AppManagerMakePtrTest::~AppManagerMakePtrTest()
{
//
mAppManagerMock.reset();
}
const StatusCode AppManagerMakePtrTest::CreateAppManager(std::shared_ptr<IAppManager> &impl)
{
if (mAppManagerMock) {
LogInfo("CreateAppManager mAppManagerMock\n");
impl = mAppManagerMock;
}
else {
LogWarning("CreateMcuManager failed:mAppManagerMock is nullptr.\n");
}
return CreateStatusCode(STATUS_CODE_OK);
}

View File

@ -0,0 +1,32 @@
/*
* 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 APP_MANAGER_MAKE_PTR_TEST_H
#define APP_MANAGER_MAKE_PTR_TEST_H
#include "AppManagerMakePtr.h"
#include "AppManagerMock.h"
#include "AppManagerTestTool.h"
void OverrideAppManagerMakePtrObject(std::shared_ptr<AppManagerMock> &appManagerMock);
void CancelOverrideAppManagerMakePtrObject(void);
class AppManagerMakePtrTest : public AppManagerMakePtr
{
public:
AppManagerMakePtrTest();
virtual ~AppManagerMakePtrTest();
const StatusCode CreateAppManager(std::shared_ptr<IAppManager> &impl) override;
public:
std::shared_ptr<AppManagerMock> mAppManagerMock;
};
#endif

View File

@ -0,0 +1,40 @@
/*
* 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 "AppManagerMock.h"
#include "ILog.h"
const StatusCode AppManagerTest::SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor)
{
LogInfo("AppManagerTest::GetAllLeds\n");
StatusCode code = SetAppMonitorTrace(monitor);
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
return AppManager::SetAppMonitor(monitor);
}
return code;
}
const StatusCode AppManagerTest::SetAppMonitorTrace(std::shared_ptr<VAppMonitor> &monitor)
{
LogInfo("AppManagerTest::SetAppMonitorTrace\n");
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
}
// StatusCode AppManagerTest::GetAllLedsTrace(std::map<std::string, std::shared_ptr<VLedHal>> &allLeds)
// {
// LogInfo("AppManagerTest::GetAllLedsTrace\n");
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
// }
// StatusCode AppManagerTest::GetAllKeysTrace(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys)
// {
// LogInfo("AppManagerTest::GetAllKeysTrace\n");
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
// }

View File

@ -0,0 +1,36 @@
/*
* 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 APP_MANAGER_MOCK_H
#define APP_MANAGER_MOCK_H
#include "AppManager.h"
#include "AppManagerTestTool.h"
class AppManagerTest : public AppManager
{
public:
AppManagerTest() = default;
virtual ~AppManagerTest() = default;
const StatusCode SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor) override;
protected:
virtual const StatusCode SetAppMonitorTrace(std::shared_ptr<VAppMonitor> &monitor);
};
class AppManagerMock : public AppManagerTest
{
public:
AppManagerMock() = default;
virtual ~AppManagerMock() = default;
MOCK_METHOD1(SetAppMonitorTrace, const StatusCode(std::shared_ptr<VAppMonitor> &));
};
#endif

View File

@ -13,14 +13,23 @@
* limitations under the License.
*/
#include "AppManagerTestTool.h"
#include "AppManagerMakePtrTest.h"
#include "AppManagerMock.h"
#include "AppMonitorMock.h"
#include "ILog.h"
#include "ServersMock.h"
void AppManagerTestTool::Init(void)
{
//
mAppManagerMock = std::make_shared<AppManagerMock>();
AppManagerMockInit(mAppManagerMock);
std::shared_ptr<AppManagerMock> mock = std::dynamic_pointer_cast<AppManagerMock>(mAppManagerMock);
OverrideAppManagerMakePtrObject(mock);
}
void AppManagerTestTool::UnInit(void)
{
//
mAppManagerMock.reset();
mAppMonitorMock.reset();
CancelOverrideAppManagerMakePtrObject();
}
void AppManagerTestTool::MockGetProductInfo(void)
{
@ -31,4 +40,20 @@ void AppManagerTestTool::MockUploadFiles(void)
{
//
ServersMock::GetInstance()->MockUploadFiles();
}
void AppManagerTestTool::AppManagerMockInit(std::shared_ptr<IAppManager> &vMock)
{
std::shared_ptr<AppManagerMock> mock = std::dynamic_pointer_cast<AppManagerMock>(vMock);
if (!mock) {
LogError("vMock error.\n");
return;
}
auto getAppMonitor = [=](std::shared_ptr<VAppMonitor> &monitor) {
LogInfo("mAppMonitorMock get.\n");
mAppMonitorMock = std::dynamic_pointer_cast<AppMonitorMock>(monitor);
};
constexpr int ONLY_BE_CALLED_ONCE = 1;
EXPECT_CALL(*mock.get(), SetAppMonitorTrace(_))
.Times(ONLY_BE_CALLED_ONCE)
.WillOnce(DoAll(WithArgs<0>(Invoke(getAppMonitor)), Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
}

View File

@ -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.
*/
#include "AppMonitorMock.h"
#include "ILog.h"
StatusCode AppMonitorTest::GetProductInfo(AppGetProductInfo &param)
{
LogInfo("AppMonitorTest::GetProductInfo\n");
StatusCode code = GetProductInfoTrace(param);
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
return VAppMonitor::GetProductInfo(param);
}
return code;
}
StatusCode AppMonitorTest::UploadFile(AppUploadFile &param)
{
LogInfo("AppMonitorTest::UploadFile\n");
StatusCode code = UploadFileTrace(param);
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
return VAppMonitor::UploadFile(param);
}
return code;
}
StatusCode AppMonitorTest::GetProductInfoTrace(AppGetProductInfo &param)
{
LogInfo("AppMonitorTest::GetProductInfoTrace\n");
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
}
StatusCode AppMonitorTest::UploadFileTrace(AppUploadFile &param)
{
LogInfo("AppMonitorTest::UploadFileTrace\n");
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
}

View File

@ -0,0 +1,39 @@
/*
* 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 APP_MONITOR_MOCK_H
#define APP_MONITOR_MOCK_H
#include "GtestUsing.h"
#include "IAppManager.h"
class AppMonitorTest : public VAppMonitor
{
public:
AppMonitorTest() = default;
virtual ~AppMonitorTest() = default;
StatusCode GetProductInfo(AppGetProductInfo &param) override;
StatusCode UploadFile(AppUploadFile &param) override;
protected:
virtual StatusCode GetProductInfoTrace(AppGetProductInfo &param);
virtual StatusCode UploadFileTrace(AppUploadFile &param);
};
class AppMonitorMock : public AppMonitorTest
{
public:
AppMonitorMock() = default;
virtual ~AppMonitorMock() = default;
MOCK_METHOD1(GetProductInfoTrace, StatusCode(AppGetProductInfo &));
MOCK_METHOD1(UploadFileTrace, StatusCode(AppUploadFile &));
};
#endif

View File

@ -59,7 +59,7 @@ void ServersMock::MockGetProductInfo(void)
}
}
#ifndef PLATFORM_PATH
#error Add the code in your linux.toolchain.cmake : add_definitions(-DPLATFORM_PATH="${PLATFORM_PATH}")
#error Add the code in your linux.toolchain.cmake : add_definitions(-DPLATFORM_PATH="${PLATFORM_PATH}")
#endif
void ServersMock::MockUploadFiles(void)
{

View File

@ -8,20 +8,13 @@ include_directories(
./tool/include
${UTILS_SOURCE_PATH}/Log/include
${UTILS_SOURCE_PATH}/StatusCode/include
# ${UTILS_SOURCE_PATH}/UartDevice/include
# ${UTILS_SOURCE_PATH}/McuProtocol/include
${UTILS_SOURCE_PATH}/KeyControl/include
${UTILS_SOURCE_PATH}/LedControl/include
${HAL_SOURCE_PATH}/include
# ${HAL_SOURCE_PATH}/src
${MIDDLEWARE_SOURCE_PATH}/DeviceManager/include
${MIDDLEWARE_SOURCE_PATH}/DeviceManager/src
# ${MIDDLEWARE_SOURCE_PATH}/McuAskBase/include
# ${TEST_SOURCE_PATH}/utils/LinuxApiMock/include
${TEST_SOURCE_PATH}
${TEST_SOURCE_PATH}/hal/tool/include
# ${TEST_SOURCE_PATH}/utils/UartDevice/tool/include
# ${TEST_SOURCE_PATH}/utils/McuProtocol/tool/include
# ${TEST_SOURCE_PATH}/middleware/McuAskBase/tool/include
${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include
${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googlemock/include
)

View File

@ -13,6 +13,7 @@ include_directories(
${MIDDLEWARE_SOURCE_PATH}/McuManager/include
${MIDDLEWARE_SOURCE_PATH}/McuManager/src
${MIDDLEWARE_SOURCE_PATH}/McuAskBase/include
${TEST_SOURCE_PATH}
${TEST_SOURCE_PATH}/utils/LinuxApiMock/include
${TEST_SOURCE_PATH}/utils/UartDevice/tool/include
${TEST_SOURCE_PATH}/utils/McuProtocol/tool/include

View File

@ -27,22 +27,27 @@ static void sigHandler(int signo)
static void CheckUploadDir(void)
{
const char *directory = GOAHEAD_UPLOAD_TMP_PATH;
int result = mkdir(directory, 0777);
if (access(directory, F_OK) != 0) {
int result = mkdir(directory, 0777);
if (result == 0) {
LogInfo("mkdir upload tmp path successfuly.\n");
}
else {
LogError("mkdir upload tmp path failed.\n");
if (result == 0) {
LogInfo("mkdir upload tmp path successfuly.\n");
}
else {
LogError("mkdir upload tmp path failed.\n");
}
}
const char *directory2 = GOAHEAD_UPLOAD_PATH;
result = mkdir(directory2, 0777);
if (access(directory2, F_OK) != 0) {
int result = mkdir(directory2, 0777);
if (result == 0) {
LogInfo("mkdir upload path successfuly.\n");
}
else {
LogError("mkdir upload path failed.\n");
if (result == 0) {
LogInfo("mkdir upload path successfuly.\n");
}
else {
LogError("mkdir upload path failed.\n");
}
}
}
static void logHeader(void)