65 lines
1.9 KiB
C++
65 lines
1.9 KiB
C++
/*
|
|
* 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 "IpcConfigTest.h"
|
|
#include "IIpcConfig.h"
|
|
#include "ILog.h"
|
|
#include "LinuxApi.h"
|
|
#include <thread>
|
|
IpcConfigTest::IpcConfigTest()
|
|
{
|
|
}
|
|
IpcConfigTest::~IpcConfigTest()
|
|
{
|
|
}
|
|
void IpcConfigTest::SetUpTestCase()
|
|
{
|
|
CreateLogModule();
|
|
ILogInit(LOG_INSTANCE_TYPE_END);
|
|
}
|
|
void IpcConfigTest::TearDownTestCase()
|
|
{
|
|
ILogUnInit();
|
|
DestroyLogModule();
|
|
}
|
|
void IpcConfigTest::SetUp()
|
|
{
|
|
mLinuxTest = LinuxTest::CreateLinuxTest();
|
|
std::shared_ptr<LinuxApiMock> test = mLinuxTest;
|
|
LinuxApiMock::GetInstance(&test);
|
|
IpcConfigTestTool::Init(mLinuxTest);
|
|
CreateIpcConfigModule();
|
|
IIpcConfig::GetInstance()->Init();
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
}
|
|
void IpcConfigTest::TearDown()
|
|
{
|
|
IIpcConfig::GetInstance()->UnInit();
|
|
DestroyIpcConfigModule();
|
|
RemoveConfigFile();
|
|
IpcConfigTestTool::UnInit();
|
|
mLinuxTest = std::make_shared<LinuxTest>();
|
|
std::shared_ptr<LinuxApiMock> test = std::make_shared<LinuxApiMock>();
|
|
LinuxApiMock::GetInstance(&test);
|
|
}
|
|
void IpcConfigTest::RemoveConfigFile(void)
|
|
{
|
|
constexpr int FIEL_EXIST = 0;
|
|
if (FIEL_EXIST == access(IPC_CONFIG_FILE_PATH, F_OK)) {
|
|
constexpr int BUFF_SIZE = 128;
|
|
char cmd[BUFF_SIZE] = {0};
|
|
snprintf(cmd, BUFF_SIZE, "rm -f %s", IPC_CONFIG_FILE_PATH);
|
|
fx_system(cmd);
|
|
}
|
|
} |