提交 38faede1 编写于 作者: C cheng_jinsong

add new interface ut

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