Improve:cross compile.
This commit is contained in:
parent
f1f1c7bfa3
commit
2a8655a76a
|
@ -55,10 +55,10 @@ StatusCode WifiHal::OpenApMode(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LogInfo("wlan0 ok. \n");
|
LogInfo("wlan0 ok. \n");
|
||||||
fx_system("ifconfig wlan0 192.168.169.1 netmask 255.255.255.0");
|
fx_system_v2("ifconfig wlan0 192.168.169.1 netmask 255.255.255.0");
|
||||||
fx_system("hostapd -d /etc/hostapd.conf &");
|
fx_system_v2("hostapd -d /etc/hostapd.conf &");
|
||||||
fx_system("touch /var/lib/misc/udhcpd.leases");
|
fx_system_v2("touch /var/lib/misc/udhcpd.leases");
|
||||||
fx_system("udhcpd -f /etc/udhcpd.conf &");
|
fx_system_v2("udhcpd -f /etc/udhcpd.conf &");
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
}
|
}
|
||||||
StatusCode WifiHal::CloseApMode(void)
|
StatusCode WifiHal::CloseApMode(void)
|
||||||
|
|
|
@ -73,8 +73,8 @@ StatusCode SdCardHandle::SdSaveFile(const std::string &sourceFile, const std::st
|
||||||
return CreateStatusCode(STATUS_CODE_NOT_OK);
|
return CreateStatusCode(STATUS_CODE_NOT_OK);
|
||||||
}
|
}
|
||||||
snprintf(cmd, CMD_BUF_SIZE, "cp %s %s", sourceFile.c_str(), realSavePah.c_str());
|
snprintf(cmd, CMD_BUF_SIZE, "cp %s %s", sourceFile.c_str(), realSavePah.c_str());
|
||||||
fx_system(cmd);
|
fx_system_v2(cmd);
|
||||||
fx_system("sync");
|
fx_system_v2("sync");
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
}
|
}
|
||||||
StorageEvent SdCardHandle::StorageEventConvert(const SdCardHalStatus &status)
|
StorageEvent SdCardHandle::StorageEventConvert(const SdCardHalStatus &status)
|
||||||
|
|
|
@ -31,7 +31,7 @@ void MissionManagerTestTool::UnInit(void)
|
||||||
}
|
}
|
||||||
void MissionManagerTestTool::CreateUpgradeFile(void)
|
void MissionManagerTestTool::CreateUpgradeFile(void)
|
||||||
{
|
{
|
||||||
fx_system("touch " SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH "-test");
|
fx_system_v2("touch " SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH "-test");
|
||||||
UpgradeTool::GetInstance()->PackFile(SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH "-test",
|
UpgradeTool::GetInstance()->PackFile(SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH "-test",
|
||||||
SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH,
|
SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH,
|
||||||
"1.0.0.0",
|
"1.0.0.0",
|
||||||
|
@ -41,5 +41,5 @@ void MissionManagerTestTool::CreateUpgradeFile(void)
|
||||||
}
|
}
|
||||||
void MissionManagerTestTool::RemoveUpgradeFile(void)
|
void MissionManagerTestTool::RemoveUpgradeFile(void)
|
||||||
{
|
{
|
||||||
fx_system("rm " SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH);
|
fx_system_v2("rm " SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH);
|
||||||
}
|
}
|
|
@ -24,6 +24,10 @@ set(TEST_TOOL_TARGET HalTestTool)
|
||||||
add_library(${TEST_TOOL_TARGET} STATIC ${TEST_TOOL_SRC_FILES})
|
add_library(${TEST_TOOL_TARGET} STATIC ${TEST_TOOL_SRC_FILES})
|
||||||
target_link_libraries(${TEST_TOOL_TARGET} MediaBase Hal KeyControl LedControl LinuxApiMock Log)
|
target_link_libraries(${TEST_TOOL_TARGET} MediaBase Hal KeyControl LedControl LinuxApiMock Log)
|
||||||
|
|
||||||
|
# if(${TARGET_PLATFORM} MATCHES ${DEFINE_LINUX})
|
||||||
|
# target_link_libraries(${TEST_TOOL_TARGET} LinuxApiMock)
|
||||||
|
# endif()
|
||||||
|
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
HalTestTool_code_check
|
HalTestTool_code_check
|
||||||
COMMAND ${CLANG_TIDY_EXE}
|
COMMAND ${CLANG_TIDY_EXE}
|
||||||
|
|
|
@ -50,6 +50,7 @@ void SdCardHalMock::MockSdCardInsert(std::shared_ptr<LinuxTest> &mock)
|
||||||
}
|
}
|
||||||
void SdCardHalMock::MockSdCardFormatResult(std::shared_ptr<LinuxTest> &mock, const int &result)
|
void SdCardHalMock::MockSdCardFormatResult(std::shared_ptr<LinuxTest> &mock, const int &result)
|
||||||
{
|
{
|
||||||
LinuxTest::SetSystemCommandResult(mock, "mkfs.vfat", result);
|
// TODO: improve
|
||||||
LinuxTest::SetSystemCommandResult(mock, "umount", result);
|
// LinuxTest::SetSystemCommandResult(mock, "mkfs.vfat", result);
|
||||||
|
// LinuxTest::SetSystemCommandResult(mock, "umount", result);
|
||||||
}
|
}
|
|
@ -32,7 +32,7 @@ endif()
|
||||||
|
|
||||||
set(TARGET_NAME HuntingUpgradeTest)
|
set(TARGET_NAME HuntingUpgradeTest)
|
||||||
add_executable(${TARGET_NAME} ${SRC_FILES_MAIN} ${SRC_FILES})
|
add_executable(${TARGET_NAME} ${SRC_FILES_MAIN} ${SRC_FILES})
|
||||||
target_link_libraries(${TARGET_NAME} HuntingUpgradeTestTool LinuxApiMock gtest gmock pthread)
|
target_link_libraries(${TARGET_NAME} HuntingUpgradeTestTool gtest gmock pthread)
|
||||||
if(${TEST_COVERAGE} MATCHES "true")
|
if(${TEST_COVERAGE} MATCHES "true")
|
||||||
target_link_libraries(${TARGET_NAME} gcov)
|
target_link_libraries(${TARGET_NAME} gcov)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -27,13 +27,13 @@ void HuntingUpgradeTestTool::Init(void)
|
||||||
void HuntingUpgradeTestTool::UnInit(void)
|
void HuntingUpgradeTestTool::UnInit(void)
|
||||||
{
|
{
|
||||||
if (access(SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH "-test", F_OK) == 0) {
|
if (access(SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH "-test", F_OK) == 0) {
|
||||||
fx_system("rm -rf " SD_CARD_MOUNT_PATH);
|
fx_system_v2("rm -rf " SD_CARD_MOUNT_PATH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void HuntingUpgradeTestTool::CreateUpgradeFile(void)
|
void HuntingUpgradeTestTool::CreateUpgradeFile(void)
|
||||||
{
|
{
|
||||||
CheckDirectory(SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH "-test");
|
CheckDirectory(SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH "-test");
|
||||||
fx_system("touch " SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH "-test");
|
fx_system_v2("touch " SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH "-test");
|
||||||
UpgradeTool::GetInstance()->PackFile(SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH "-test",
|
UpgradeTool::GetInstance()->PackFile(SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH "-test",
|
||||||
SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH,
|
SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH,
|
||||||
"6.4.5.6",
|
"6.4.5.6",
|
||||||
|
|
|
@ -60,6 +60,6 @@ void IpcConfigTest::RemoveConfigFile(void)
|
||||||
constexpr int BUFF_SIZE = 128;
|
constexpr int BUFF_SIZE = 128;
|
||||||
char cmd[BUFF_SIZE] = {0};
|
char cmd[BUFF_SIZE] = {0};
|
||||||
snprintf(cmd, BUFF_SIZE, "rm -f %s", IPC_CONFIG_FILE_PATH);
|
snprintf(cmd, BUFF_SIZE, "rm -f %s", IPC_CONFIG_FILE_PATH);
|
||||||
fx_system(cmd);
|
fx_system_v2(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,7 +20,7 @@ include_directories(
|
||||||
aux_source_directory(./src TEST_TOOL_SRC_FILES)
|
aux_source_directory(./src TEST_TOOL_SRC_FILES)
|
||||||
set(TEST_TOOL_TARGET IpcConfigTestTool)
|
set(TEST_TOOL_TARGET IpcConfigTestTool)
|
||||||
add_library(${TEST_TOOL_TARGET} STATIC ${TEST_TOOL_SRC_FILES})
|
add_library(${TEST_TOOL_TARGET} STATIC ${TEST_TOOL_SRC_FILES})
|
||||||
target_link_libraries(${TEST_TOOL_TARGET} IpcConfig LinuxApiMock Log)
|
target_link_libraries(${TEST_TOOL_TARGET} IpcConfig Log)
|
||||||
|
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
IpcConfigTestTool_code_check
|
IpcConfigTestTool_code_check
|
||||||
|
|
|
@ -34,7 +34,7 @@ void IpcConfigTestTool::UnInit(void)
|
||||||
constexpr int BUF_LENGTH = 256;
|
constexpr int BUF_LENGTH = 256;
|
||||||
char cmd[BUF_LENGTH] = {0};
|
char cmd[BUF_LENGTH] = {0};
|
||||||
sprintf(cmd, "rm -rf %s", MOUNTED_FILE);
|
sprintf(cmd, "rm -rf %s", MOUNTED_FILE);
|
||||||
fx_system(cmd);
|
fx_system_v2(cmd);
|
||||||
}
|
}
|
||||||
void IpcConfigTestTool::MockMountedFile(void)
|
void IpcConfigTestTool::MockMountedFile(void)
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,7 @@ void IpcConfigTestTool::MockMountedFile(void)
|
||||||
"rw,relatime,fmask=0022,dmask=0022,codepage=936,iocharset=cp936,shortname=mixed,utf8,errors=remount-ro 0 0\n");
|
"rw,relatime,fmask=0022,dmask=0022,codepage=936,iocharset=cp936,shortname=mixed,utf8,errors=remount-ro 0 0\n");
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
fx_system("sync");
|
fx_system_v2("sync");
|
||||||
LogInfo("File written successfully.\n");
|
LogInfo("File written successfully.\n");
|
||||||
}
|
}
|
||||||
FILE *IpcConfigTestTool::OpenMockMountedFile(const char *mode)
|
FILE *IpcConfigTestTool::OpenMockMountedFile(const char *mode)
|
||||||
|
|
|
@ -68,6 +68,10 @@ public:
|
||||||
virtual int GetHandleForMock(void);
|
virtual int GetHandleForMock(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief The functions from here on are all used in the simulator under the Ubuntu system. When cross-compiling, it
|
||||||
|
* is forbidden to use the following functions directly.
|
||||||
|
*/
|
||||||
static std::shared_ptr<LinuxTest> CreateLinuxTest(void);
|
static std::shared_ptr<LinuxTest> CreateLinuxTest(void);
|
||||||
static void SetSystemCommandResult(std::shared_ptr<LinuxTest> &mock, const std::string &command, const int &result);
|
static void SetSystemCommandResult(std::shared_ptr<LinuxTest> &mock, const std::string &command, const int &result);
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,7 +20,7 @@ aux_source_directory(./src SRC_FILES)
|
||||||
|
|
||||||
set(TARGET_NAME SharedDataTest)
|
set(TARGET_NAME SharedDataTest)
|
||||||
add_executable(${TARGET_NAME} ${SRC_FILES})
|
add_executable(${TARGET_NAME} ${SRC_FILES})
|
||||||
target_link_libraries(${TARGET_NAME} SharedData LinuxApiMock gtest gmock pthread Log)
|
target_link_libraries(${TARGET_NAME} SharedData gtest gmock pthread Log)
|
||||||
if(${TEST_COVERAGE} MATCHES "true")
|
if(${TEST_COVERAGE} MATCHES "true")
|
||||||
target_link_libraries(${TARGET_NAME} gcov)
|
target_link_libraries(${TARGET_NAME} gcov)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -24,7 +24,20 @@
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
/**
|
||||||
|
* @brief This function can be used to test the function, and the system function can be used as an imperative return
|
||||||
|
* result.
|
||||||
|
* @param command
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
int fx_system(const char *command);
|
int fx_system(const char *command);
|
||||||
|
/**
|
||||||
|
* @brief Under the circumstances of the return of the system, there is a "warning" written by the organization, and the
|
||||||
|
* use of the function does not exist.
|
||||||
|
* @param command
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
int fx_system_v2(const char *command);
|
||||||
int fx_open(const char *pathname, int flags);
|
int fx_open(const char *pathname, int flags);
|
||||||
int fx_tcgetattr(int fd, struct termios *termios_p);
|
int fx_tcgetattr(int fd, struct termios *termios_p);
|
||||||
int fx_tcsetattr(int fd, int optional_actions, const struct termios *termios_p);
|
int fx_tcsetattr(int fd, int optional_actions, const struct termios *termios_p);
|
||||||
|
|
|
@ -28,6 +28,10 @@ int fx_system(const char *command)
|
||||||
{
|
{
|
||||||
return system(command);
|
return system(command);
|
||||||
}
|
}
|
||||||
|
int fx_system_v2(const char *command)
|
||||||
|
{
|
||||||
|
return system(command);
|
||||||
|
}
|
||||||
int fx_open(const char *pathname, int flags)
|
int fx_open(const char *pathname, int flags)
|
||||||
{
|
{
|
||||||
return open(pathname, flags);
|
return open(pathname, flags);
|
||||||
|
|
|
@ -66,7 +66,7 @@ StatusCode FfmpegMuxStreamV2::CloseOutputFile(void)
|
||||||
avio_closep(&mOutputFormat->pb);
|
avio_closep(&mOutputFormat->pb);
|
||||||
}
|
}
|
||||||
avformat_free_context(mOutputFormat);
|
avformat_free_context(mOutputFormat);
|
||||||
fx_system("sync");
|
fx_system_v2("sync");
|
||||||
mOutputFileInfo.reset();
|
mOutputFileInfo.reset();
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ StatusCode SharedMemory::MakeSharedMemory(const int &size)
|
||||||
char touchPath[128] = {0};
|
char touchPath[128] = {0};
|
||||||
if (access(mPath, F_OK) != 0) {
|
if (access(mPath, F_OK) != 0) {
|
||||||
sprintf(touchPath, "%s %s", "touch", mPath);
|
sprintf(touchPath, "%s %s", "touch", mPath);
|
||||||
fx_system(touchPath);
|
fx_system_v2(touchPath);
|
||||||
}
|
}
|
||||||
key_t key = ftok(mPath, mProjectId);
|
key_t key = ftok(mPath, mProjectId);
|
||||||
if (key < 0) {
|
if (key < 0) {
|
||||||
|
|
|
@ -124,12 +124,12 @@ void UpgradeTool::PackFile(const std::string &fileName, const std::string &outpu
|
||||||
LogError("write file failed, remove output file.\n");
|
LogError("write file failed, remove output file.\n");
|
||||||
char cmd[1024];
|
char cmd[1024];
|
||||||
snprintf(cmd, sizeof(cmd), "rm -f %s", outputFile.c_str());
|
snprintf(cmd, sizeof(cmd), "rm -f %s", outputFile.c_str());
|
||||||
fx_system(cmd);
|
fx_system_v2(cmd);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogInfo("write file success.\n");
|
LogInfo("write file success.\n");
|
||||||
}
|
}
|
||||||
fclose(input_file);
|
fclose(input_file);
|
||||||
fclose(output_file);
|
fclose(output_file);
|
||||||
fx_system("sync");
|
fx_system_v2("sync");
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user