提交 f5460ef9 编写于 作者: C cheng_jinsong 提交者: Mupceet

fixed 38faede1 from https://gitee.com/mupceet/startup_init_lite/pulls/1457

add new interface ut
Signed-off-by: Ncheng_jinsong <chengjinsong2@huawei.com>
Change-Id: I8cac39850770499d00dfc3bd2cc31cffefed8da7
上级 4f78bbf7
......@@ -34,8 +34,6 @@ int SystemWriteParam(const char *name, const char *value);
int SystemReadParam(const char *name, char *value, unsigned int *len);
int LoadParamsFile(const char *fileName, bool onlyAdd);
typedef int (*CmdExecutor)(int id, const char *name, int argc, const char **argv);
int AddCmdExecutor(const char *cmdName, CmdExecutor execCmd);
......
[
{ "name": "SystemWriteParam" },
{ "name": "SystemReadParam" },
{ "name": "LoadParamsFile" },
{ "name": "SplitString" },
{ "name": "AddCmdExecutor" },
{ "name": "RemoveCmdExecutor" },
......
......@@ -193,11 +193,6 @@ static int ProcessParamFile(const char *fileName, void *context)
return LoadDefaultParam_(fileName, mode, exclude, ARRAY_LENGTH(exclude), LoadOneParam_);
}
int LoadParamsFile(const char *fileName, bool onlyAdd)
{
return LoadDefaultParams(fileName, onlyAdd ? LOAD_PARAM_ONLY_ADD : LOAD_PARAM_NORMAL);
}
int LoadDefaultParams(const char *fileName, uint32_t mode)
{
PARAM_CHECK(fileName != NULL, return -1, "Invalid filename for load");
......
......@@ -225,4 +225,29 @@ HWTEST_F(InnerkitsUnitTest, TestSysCap, TestSize.Level1)
ret = HasSystemCapability("SystemCapability.ArkUI.ArkUI.Napi");
EXPECT_EQ(ret, true);
}
// TestControlService
HWTEST_F(InnerkitsUnitTest, TestControlService, TestSize.Level1)
{
ServiceControl("deviceinfoservice", START);
ServiceControl("deviceinfoservice", STOP);
ServiceControl("deviceinfoservice", RESTART);
ServiceControl("param_watcher", RESTART);
EXPECT_EQ(ServiceControl(nullptr, RESTART), -1);
const char *argv[] = {"testArg"};
ServiceControlWithExtra("deviceinfoservice", RESTART, argv, 1);
ServiceControlWithExtra(nullptr, RESTART, argv, 1);
ServiceControlWithExtra(nullptr, 3, argv, 1); // 3 is action
ServiceControlWithExtra("notservie", RESTART, argv, 1);
ServiceSetReady("deviceinfoservice");
ServiceSetReady(nullptr);
ServiceWaitForStatus("deviceinfoservice", SERVICE_READY, 1);
ServiceWaitForStatus("deviceinfoservice", SERVICE_READY, -1);
ServiceWaitForStatus(nullptr, SERVICE_READY, 1);
StartServiceByTimer("deviceinfoservice", 1);
StartServiceByTimer("deviceinfoservice", 0);
StartServiceByTimer(nullptr, 0);
StopServiceTimer("deviceinfoservice");
}
} // namespace init_ut
......@@ -21,6 +21,7 @@
#include "param_security.h"
#include "param_utils.h"
#include "init_group_manager.h"
#include "beget_ext.h"
#ifdef PARAM_LOAD_CFG_FROM_CODE
#include "param_cfg.h"
#endif
......@@ -443,6 +444,7 @@ int TestFreeLocalSecurityLabel(ParamSecurityLabel *srcLabel)
static __attribute__((constructor(101))) void ParamTestStubInit(void)
{
EnableInitLog(INIT_DEBUG);
SetInitLogLevel(INIT_DEBUG);
PARAM_LOGI("ParamTestStubInit");
PrepareInitUnitTestEnv();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册