提交 d69b1215 编写于 作者: C cheng_jinsong

reboot loader

Signed-off-by: Ncheng_jinsong <chengjinsong2@huawei.com>
上级 74309074
......@@ -224,7 +224,9 @@ static void ScanModules(MODULE_MGR *moduleMgr, const char *path)
ModuleMgrInstall(moduleMgr, moduleName, 0, NULL);
}
}
free(moduleName);
if (moduleName != NULL) {
free(moduleName);
}
closedir(dir);
}
......
......@@ -68,7 +68,7 @@ static int CheckParamCmdExist(const char *cmd)
char *cmdName = Dup2String(REBOOT_CMD_PREFIX, cmd);
PLUGIN_CHECK(cmdName != NULL, return 0, "Failed to copy %s", cmd);
for (int i = 0; i < g_rebootParamCmdValidNumber; i++) {
if (strcmp(g_rebootParamCmdInfos[i].cmd, cmdName) == 0){
if (strcmp(g_rebootParamCmdInfos[i].cmd, cmdName) == 0) {
free(cmdName);
return 1;
}
......@@ -160,4 +160,4 @@ MODULE_CONSTRUCTOR(void)
{
// 执行reboot时调用,安装reboot模块
InitAddRebootHook(InitRebootHook_);
}
\ No newline at end of file
}
......@@ -39,17 +39,14 @@ public:
static int g_result = 0;
HWTEST_F(InitRebootUnitTest, TestAddRebootCmd, TestSize.Level1)
{
int ret = AddRebootCmdExecutor("reboot_cmd1", [](int id, const char *name, int argc, const char **argv)-> int {
auto rebootCallback = [](int id, const char *name, int argc, const char **argv) -> int {
return 0;
});
}
int ret = AddRebootCmdExecutor("reboot_cmd1", rebootCallback);
EXPECT_EQ(ret, 0);
ret = AddRebootCmdExecutor("reboot_cmd2", [](int id, const char *name, int argc, const char **argv)-> int {
return 0;
});
ret = AddRebootCmdExecutor("reboot_cmd2", rebootCallback);
EXPECT_EQ(ret, 0);
ret = AddRebootCmdExecutor("reboot_cmd3", [](int id, const char *name, int argc, const char **argv)-> int {
return 0;
});
ret = AddRebootCmdExecutor("reboot_cmd3", rebootCallback);
EXPECT_EQ(ret, 0);
ret = AddRebootCmdExecutor("reboot_cmd4", [](int id, const char *name, int argc, const char **argv)-> int {
g_result = 4; // 4 test index
......@@ -66,13 +63,9 @@ HWTEST_F(InitRebootUnitTest, TestAddRebootCmd, TestSize.Level1)
return 0;
});
EXPECT_EQ(ret, 0);
ret = AddRebootCmdExecutor("reboot_cmd7", [](int id, const char *name, int argc, const char **argv)-> int {
return 0;
});
ret = AddRebootCmdExecutor("reboot_cmd7", rebootCallback);
EXPECT_EQ(ret, 0);
ret = AddRebootCmdExecutor("reboot_cmd7", [](int id, const char *name, int argc, const char **argv)-> int {
return 0;
});
ret = AddRebootCmdExecutor("reboot_cmd7", rebootCallback);
EXPECT_NE(ret, 0);
TestSetParamCheckResult("ohos.servicectrl.reboot", 0777, 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册