提交 3a08fb96 编写于 作者: C cheng_jinsong

fix codex

Signed-off-by: Ncheng_jinsong <chengjinsong2@huawei.com>
Change-Id: Ieabc25313064c60e8e1b7d63368da261a37c7844
上级 836ccc39
...@@ -28,7 +28,7 @@ extern "C" { ...@@ -28,7 +28,7 @@ extern "C" {
#define INVALID_PID 0 #define INVALID_PID 0
typedef struct serviceInfo_ { typedef struct {
ServiceStatus status; ServiceStatus status;
pid_t pid; pid_t pid;
} ServiceInfo; } ServiceInfo;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#define DOREBOOT_PARAM "reboot.ut" #define DOREBOOT_PARAM "reboot.ut"
#endif #endif
static int DoReboot_(const char *mode, const char *option) static int DoRebootByInitPlugin(const char *mode, const char *option)
{ {
char value[MAX_REBOOT_OPTION_SIZE]; char value[MAX_REBOOT_OPTION_SIZE];
int ret = 0; int ret = 0;
...@@ -56,7 +56,7 @@ static int DoReboot_(const char *mode, const char *option) ...@@ -56,7 +56,7 @@ static int DoReboot_(const char *mode, const char *option)
return 0; return 0;
} }
static int ExecReboot_(const char *mode, const char *option) static int ExecReboot(const char *mode, const char *option)
{ {
// check if param set ok // check if param set ok
#ifndef STARTUP_INIT_TEST #ifndef STARTUP_INIT_TEST
...@@ -65,7 +65,7 @@ static int ExecReboot_(const char *mode, const char *option) ...@@ -65,7 +65,7 @@ static int ExecReboot_(const char *mode, const char *option)
const int maxCount = 1; const int maxCount = 1;
#endif #endif
int count = 0; int count = 0;
DoReboot_(mode, option); DoRebootByInitPlugin(mode, option);
while (count < maxCount) { while (count < maxCount) {
usleep(100 * 1000); // 100 * 1000 wait 100ms usleep(100 * 1000); // 100 * 1000 wait 100ms
char result[10] = {0}; // 10 stop len char result[10] = {0}; // 10 stop len
...@@ -76,7 +76,7 @@ static int ExecReboot_(const char *mode, const char *option) ...@@ -76,7 +76,7 @@ static int ExecReboot_(const char *mode, const char *option)
return 0; return 0;
} }
count++; count++;
DoReboot_(mode, option); DoRebootByInitPlugin(mode, option);
} }
BEGET_LOGE("Failed to reboot system"); BEGET_LOGE("Failed to reboot system");
return 0; return 0;
...@@ -84,10 +84,10 @@ static int ExecReboot_(const char *mode, const char *option) ...@@ -84,10 +84,10 @@ static int ExecReboot_(const char *mode, const char *option)
int DoReboot(const char *option) int DoReboot(const char *option)
{ {
return ExecReboot_(NULL, option); return ExecReboot(NULL, option);
} }
int DoRebootExt(const char *mode, const char *option) int DoRebootExt(const char *mode, const char *option)
{ {
return ExecReboot_(mode, option); return ExecReboot(mode, option);
} }
\ No newline at end of file
...@@ -57,7 +57,7 @@ static int TraversalEvent(ListNode *node, void *root) ...@@ -57,7 +57,7 @@ static int TraversalEvent(ListNode *node, void *root)
int len = GetServiceName(item->paramName, args->buffer + args->currLen, args->bufferLen - args->currLen); int len = GetServiceName(item->paramName, args->buffer + args->currLen, args->bufferLen - args->currLen);
PLUGIN_CHECK(len > 0 && (((uint32_t)len + args->currLen) < args->bufferLen), return -1, PLUGIN_CHECK(len > 0 && (((uint32_t)len + args->currLen) < args->bufferLen), return -1,
"Failed to format service name %s", item->paramName); "Failed to format service name %s", item->paramName);
args->currLen += len; args->currLen += (uint32_t)len;
len = sprintf_s(args->buffer + args->currLen, args->bufferLen - args->currLen, ",%u:%u,%u:%u;", len = sprintf_s(args->buffer + args->currLen, args->bufferLen - args->currLen, ",%u:%u,%u:%u;",
(uint32_t)item->timestamp[BOOTEVENT_FORK].tv_sec, (uint32_t)item->timestamp[BOOTEVENT_FORK].tv_sec,
......
...@@ -110,7 +110,7 @@ static void CmdlineIterator(const NAME_VALUE_PAIR *nv, void *context) ...@@ -110,7 +110,7 @@ static void CmdlineIterator(const NAME_VALUE_PAIR *nv, void *context)
char fullName[PARAM_NAME_LEN_MAX]; char fullName[PARAM_NAME_LEN_MAX];
cmdLineIteratorCtx *ctx = (cmdLineIteratorCtx *)context; cmdLineIteratorCtx *ctx = (cmdLineIteratorCtx *)context;
char *data = (char *)ctx->cmdline; char *data = (char *)ctx->cmdline;
static const cmdLineInfo cmdLines[] = { static const cmdLineInfo CMDLINES[] = {
{ "hardware", CommonDealFun }, { "hardware", CommonDealFun },
{ "bootgroup", CommonDealFun }, { "bootgroup", CommonDealFun },
{ "reboot_reason", CommonDealFun }, { "reboot_reason", CommonDealFun },
...@@ -131,11 +131,11 @@ static void CmdlineIterator(const NAME_VALUE_PAIR *nv, void *context) ...@@ -131,11 +131,11 @@ static void CmdlineIterator(const NAME_VALUE_PAIR *nv, void *context)
} }
// Matching reserved cmdlines // Matching reserved cmdlines
for (size_t i = 0; i < ARRAY_LENGTH(cmdLines); i++) { for (size_t i = 0; i < ARRAY_LENGTH(CMDLINES); i++) {
// Check exact match // Check exact match
if (strcmp(name, cmdLines[i].name) != 0) { if (strcmp(name, CMDLINES[i].name) != 0) {
// Check if contains ".xxx" for compatibility // Check if contains ".xxx" for compatibility
ret = snprintf_s(fullName, sizeof(fullName), sizeof(fullName) - 1, ".%s", cmdLines[i].name); ret = snprintf_s(fullName, sizeof(fullName), sizeof(fullName) - 1, ".%s", CMDLINES[i].name);
matched = strstr(name, fullName); matched = strstr(name, fullName);
if (matched == NULL) { if (matched == NULL) {
continue; continue;
...@@ -146,13 +146,13 @@ static void CmdlineIterator(const NAME_VALUE_PAIR *nv, void *context) ...@@ -146,13 +146,13 @@ static void CmdlineIterator(const NAME_VALUE_PAIR *nv, void *context)
} }
} }
ret = snprintf_s(fullName, sizeof(fullName), sizeof(fullName) - 1, ret = snprintf_s(fullName, sizeof(fullName), sizeof(fullName) - 1,
OHOS_CMDLINE_PARA_PREFIX "%s", cmdLines[i].name); OHOS_CMDLINE_PARA_PREFIX "%s", CMDLINES[i].name);
if (ret <= 0) { if (ret <= 0) {
continue; continue;
} }
PARAM_LOGV("proc cmdline %s matched.", fullName); PARAM_LOGV("proc cmdline %s matched.", fullName);
ret = cmdLines[i].processor(fullName, nv->value); ret = CMDLINES[i].processor(fullName, nv->value);
if ((ret == 0) && (SnDealFun == cmdLines[i].processor)) { if ((ret == 0) && (SnDealFun == CMDLINES[i].processor)) {
ctx->gotSn = true; ctx->gotSn = true;
} }
return; return;
......
...@@ -39,9 +39,9 @@ void BuildMountCmd(char *buffer, size_t len, const char *mp, const char *dev, co ...@@ -39,9 +39,9 @@ void BuildMountCmd(char *buffer, size_t len, const char *mp, const char *dev, co
bool IsFileExistWithType(const char *file, FileType type); bool IsFileExistWithType(const char *file, FileType type);
} }
static const std::string g_srcFilePath = STARTUP_INIT_UT_PATH"/eng/source/test.txt"; static const std::string SRC_FILE_PATH = STARTUP_INIT_UT_PATH"/eng/source/test.txt";
static const std::string g_targetPath = STARTUP_INIT_UT_PATH"/eng/link_name"; static const std::string TARGET_PATH = STARTUP_INIT_UT_PATH"/eng/link_name";
static const std::string g_engRootPath = STARTUP_INIT_UT_PATH"/eng/"; static const std::string ENG_ROOT_PATH = STARTUP_INIT_UT_PATH"/eng/";
static bool RemoveDir(const std::string &path) static bool RemoveDir(const std::string &path)
{ {
...@@ -111,37 +111,37 @@ public: ...@@ -111,37 +111,37 @@ public:
HWTEST_F(EngUnitTest, TestFilesOverlay, TestSize.Level1) HWTEST_F(EngUnitTest, TestFilesOverlay, TestSize.Level1)
{ {
bool isDel = false; bool isDel = false;
bool isExist = IsDirExist(g_engRootPath.c_str()); bool isExist = IsDirExist(ENG_ROOT_PATH.c_str());
if (isExist) { if (isExist) {
isDel = RemoveDir(g_engRootPath.c_str()); isDel = RemoveDir(ENG_ROOT_PATH.c_str());
EXPECT_EQ(isDel, true); EXPECT_EQ(isDel, true);
} }
isExist = IsDirExist(g_targetPath.c_str()); isExist = IsDirExist(TARGET_PATH.c_str());
if (isExist) { if (isExist) {
isDel = RemoveDir(g_targetPath.c_str()); isDel = RemoveDir(TARGET_PATH.c_str());
EXPECT_EQ(isDel, true); EXPECT_EQ(isDel, true);
} }
DebugFilesOverlay(g_engRootPath.c_str(), g_targetPath.c_str()); DebugFilesOverlay(ENG_ROOT_PATH.c_str(), TARGET_PATH.c_str());
CreateTestFile(g_srcFilePath.c_str(), "test"); CreateTestFile(SRC_FILE_PATH.c_str(), "test");
isExist = IsFileExist(g_srcFilePath.c_str()); isExist = IsFileExist(SRC_FILE_PATH.c_str());
EXPECT_EQ(isExist, true); EXPECT_EQ(isExist, true);
DebugFilesOverlay(g_srcFilePath.c_str(), g_targetPath.c_str()); DebugFilesOverlay(SRC_FILE_PATH.c_str(), TARGET_PATH.c_str());
isExist = IsFileExistWithType(g_srcFilePath.c_str(), TYPE_REG); isExist = IsFileExistWithType(SRC_FILE_PATH.c_str(), TYPE_REG);
EXPECT_EQ(isExist, true); EXPECT_EQ(isExist, true);
if (IsFileExistWithType(g_targetPath.c_str(), TYPE_LINK)) { if (IsFileExistWithType(TARGET_PATH.c_str(), TYPE_LINK)) {
if (unlink(g_targetPath.c_str()) < 0) { if (unlink(TARGET_PATH.c_str()) < 0) {
EXPECT_TRUE(false); EXPECT_TRUE(false);
} }
} }
int ret = symlink(g_engRootPath.c_str(), g_targetPath.c_str()); int ret = symlink(ENG_ROOT_PATH.c_str(), TARGET_PATH.c_str());
EXPECT_EQ(ret, 0); EXPECT_EQ(ret, 0);
isExist = IsFileExistWithType(g_targetPath.c_str(), TYPE_LINK); isExist = IsFileExistWithType(TARGET_PATH.c_str(), TYPE_LINK);
EXPECT_EQ(isExist, true); EXPECT_EQ(isExist, true);
DebugFilesOverlay(g_targetPath.c_str(), g_engRootPath.c_str()); DebugFilesOverlay(TARGET_PATH.c_str(), ENG_ROOT_PATH.c_str());
EXPECT_EQ(ret, 0); EXPECT_EQ(ret, 0);
} }
...@@ -153,38 +153,38 @@ HWTEST_F(EngUnitTest, TestBindMountFile, TestSize.Level1) ...@@ -153,38 +153,38 @@ HWTEST_F(EngUnitTest, TestBindMountFile, TestSize.Level1)
BindMountFile("/data/init_ut", "/"); BindMountFile("/data/init_ut", "/");
bool isExist = false; bool isExist = false;
if (!IsFileExist(g_srcFilePath.c_str())) { if (!IsFileExist(SRC_FILE_PATH.c_str())) {
CreateTestFile(g_srcFilePath.c_str(), "test reg file mount"); CreateTestFile(SRC_FILE_PATH.c_str(), "test reg file mount");
isExist = IsFileExist(g_srcFilePath.c_str()); isExist = IsFileExist(SRC_FILE_PATH.c_str());
EXPECT_EQ(isExist, true); EXPECT_EQ(isExist, true);
BindMountFile(g_srcFilePath.c_str(), "/"); BindMountFile(SRC_FILE_PATH.c_str(), "/");
} }
if (IsFileExist(g_srcFilePath.c_str())) { if (IsFileExist(SRC_FILE_PATH.c_str())) {
RemoveDir(STARTUP_INIT_UT_PATH"/eng/source"); RemoveDir(STARTUP_INIT_UT_PATH"/eng/source");
isExist = IsFileExist(g_srcFilePath.c_str()); isExist = IsFileExist(SRC_FILE_PATH.c_str());
EXPECT_EQ(isExist, false); EXPECT_EQ(isExist, false);
} }
if (IsFileExistWithType(g_targetPath.c_str(), TYPE_LINK)) { if (IsFileExistWithType(TARGET_PATH.c_str(), TYPE_LINK)) {
if (unlink(g_targetPath.c_str()) < 0) { if (unlink(TARGET_PATH.c_str()) < 0) {
EXPECT_TRUE(false); EXPECT_TRUE(false);
} }
} }
bool isLinkFile = IsFileExist(g_targetPath.c_str()); bool isLinkFile = IsFileExist(TARGET_PATH.c_str());
EXPECT_EQ(isLinkFile, false); EXPECT_EQ(isLinkFile, false);
BindMountFile(g_srcFilePath.c_str(), g_targetPath.c_str()); BindMountFile(SRC_FILE_PATH.c_str(), TARGET_PATH.c_str());
int ret = symlink(g_srcFilePath.c_str(), g_targetPath.c_str()); int ret = symlink(SRC_FILE_PATH.c_str(), TARGET_PATH.c_str());
EXPECT_EQ(ret, 0); EXPECT_EQ(ret, 0);
isLinkFile = IsFileExistWithType(g_targetPath.c_str(), TYPE_LINK); isLinkFile = IsFileExistWithType(TARGET_PATH.c_str(), TYPE_LINK);
EXPECT_EQ(isLinkFile, true); EXPECT_EQ(isLinkFile, true);
BindMountFile(g_srcFilePath.c_str(), g_targetPath.c_str()); BindMountFile(SRC_FILE_PATH.c_str(), TARGET_PATH.c_str());
if (!IsDirExist(g_engRootPath.c_str())) { if (!IsDirExist(ENG_ROOT_PATH.c_str())) {
CheckAndCreateDir(STARTUP_INIT_UT_PATH"/eng/"); CheckAndCreateDir(STARTUP_INIT_UT_PATH"/eng/");
} }
BindMountFile(g_engRootPath.c_str(), g_targetPath.c_str()); BindMountFile(ENG_ROOT_PATH.c_str(), TARGET_PATH.c_str());
} }
HWTEST_F(EngUnitTest, TestMountCmd, TestSize.Level1) HWTEST_F(EngUnitTest, TestMountCmd, TestSize.Level1)
...@@ -200,14 +200,14 @@ HWTEST_F(EngUnitTest, TestFileType, TestSize.Level1) ...@@ -200,14 +200,14 @@ HWTEST_F(EngUnitTest, TestFileType, TestSize.Level1)
std::string linkName = "/data/init_ut/eng/link_name_test"; std::string linkName = "/data/init_ut/eng/link_name_test";
bool isExist = false; bool isExist = false;
if (!IsFileExist(g_srcFilePath.c_str())) { if (!IsFileExist(SRC_FILE_PATH.c_str())) {
CreateTestFile(g_srcFilePath.c_str(), "test"); CreateTestFile(SRC_FILE_PATH.c_str(), "test");
isExist = IsFileExist(g_srcFilePath.c_str()); isExist = IsFileExist(SRC_FILE_PATH.c_str());
EXPECT_EQ(isExist, true); EXPECT_EQ(isExist, true);
} }
EXPECT_EQ(IsFileExistWithType(STARTUP_INIT_UT_PATH"/eng", TYPE_DIR), true); EXPECT_EQ(IsFileExistWithType(STARTUP_INIT_UT_PATH"/eng", TYPE_DIR), true);
EXPECT_EQ(IsFileExistWithType(g_srcFilePath.c_str(), TYPE_REG), true); EXPECT_EQ(IsFileExistWithType(SRC_FILE_PATH.c_str(), TYPE_REG), true);
if (IsFileExist(targetFile)) { if (IsFileExist(targetFile)) {
if (unlink(targetFile.c_str()) < 0) { if (unlink(targetFile.c_str()) < 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册