From f5460ef9dc6cae555e34ab705783da6e859d30c8 Mon Sep 17 00:00:00 2001 From: cheng_jinsong Date: Mon, 31 Oct 2022 06:06:28 -0700 Subject: [PATCH] fixed 38faede from https://gitee.com/mupceet/startup_init_lite/pulls/1457 add new interface ut Signed-off-by: cheng_jinsong Change-Id: I8cac39850770499d00dfc3bd2cc31cffefed8da7 --- .../include/init_module_engine.h | 2 -- .../init_module_engine/stub/libinit.stub.json | 1 - services/param/manager/param_server.c | 5 ---- .../unittest/innerkits/innerkits_unittest.cpp | 25 +++++++++++++++++++ test/unittest/param/param_stub.cpp | 2 ++ 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/interfaces/innerkits/init_module_engine/include/init_module_engine.h b/interfaces/innerkits/init_module_engine/include/init_module_engine.h index 005a1a29..c9de0110 100755 --- a/interfaces/innerkits/init_module_engine/include/init_module_engine.h +++ b/interfaces/innerkits/init_module_engine/include/init_module_engine.h @@ -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); diff --git a/interfaces/innerkits/init_module_engine/stub/libinit.stub.json b/interfaces/innerkits/init_module_engine/stub/libinit.stub.json index bf210c7a..09fae666 100755 --- a/interfaces/innerkits/init_module_engine/stub/libinit.stub.json +++ b/interfaces/innerkits/init_module_engine/stub/libinit.stub.json @@ -1,7 +1,6 @@ [ { "name": "SystemWriteParam" }, { "name": "SystemReadParam" }, - { "name": "LoadParamsFile" }, { "name": "SplitString" }, { "name": "AddCmdExecutor" }, { "name": "RemoveCmdExecutor" }, diff --git a/services/param/manager/param_server.c b/services/param/manager/param_server.c index d1e83952..26af8fe2 100755 --- a/services/param/manager/param_server.c +++ b/services/param/manager/param_server.c @@ -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"); diff --git a/test/unittest/innerkits/innerkits_unittest.cpp b/test/unittest/innerkits/innerkits_unittest.cpp index dbf68df2..718e5c12 100644 --- a/test/unittest/innerkits/innerkits_unittest.cpp +++ b/test/unittest/innerkits/innerkits_unittest.cpp @@ -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 diff --git a/test/unittest/param/param_stub.cpp b/test/unittest/param/param_stub.cpp index 55e8a87a..afe4eae6 100644 --- a/test/unittest/param/param_stub.cpp +++ b/test/unittest/param/param_stub.cpp @@ -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(); } -- GitLab