From e35ee4b6046b85c4d60f31ea79bde400c89d7a90 Mon Sep 17 00:00:00 2001 From: limingkang Date: Fri, 3 Feb 2023 15:49:31 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: limingkang Change-Id: I14f2b6edc141eea520051856211b873463271167 --- services/modules/reboot/reboot.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services/modules/reboot/reboot.c b/services/modules/reboot/reboot.c index fac1d6505..d4610caf9 100644 --- a/services/modules/reboot/reboot.c +++ b/services/modules/reboot/reboot.c @@ -62,8 +62,11 @@ static int DoRebootPanic(int id, const char *name, int argc, const char **argv) if (panic == NULL) { return reboot(RB_AUTOBOOT); } - fwrite((void *)"c", 1, 1, panic); - fclose(panic); + if (fwrite((void *)"c", 1, 1, panic) != 1) { + (void)fclose(panic); + PLUGIN_LOGI("fwrite to panic failed"); + } + (void)fclose(panic); #endif return 0; } From 6299002dae5048496485aad0f7af7ae36992c831 Mon Sep 17 00:00:00 2001 From: zhanghaodong <443802242@qq.com> Date: Tue, 7 Feb 2023 14:03:13 +0800 Subject: [PATCH 2/7] fix:add the gid of the resources related to the codec driver Signed-off-by: zhanghaodong <443802242@qq.com> --- services/etc/group | 1 + services/etc/passwd | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/services/etc/group b/services/etc/group index 500695263..aeeaed1db 100644 --- a/services/etc/group +++ b/services/etc/group @@ -128,3 +128,4 @@ dev_dma_heap:x:3070: dev_memory:x:3071: dev_lcd_backlight:x:3072: dev_vibrator:x:3080: +vcodec:x:3073: diff --git a/services/etc/passwd b/services/etc/passwd index 6afe14fec..325f0eee0 100644 --- a/services/etc/passwd +++ b/services/etc/passwd @@ -124,4 +124,5 @@ device_attest:x:3049:3049:::/bin/false dev_dma_heap:x:3070:3070:::/bin/false dev_memory:x:3071:3071:::/bin/false dev_lcd_backlight:x:3072:3072:::/bin/false -dev_vibrator:x:3080:3080:::/bin/false \ No newline at end of file +dev_vibrator:x:3080:3080:::/bin/false +vcodec:x:3073:3073:::/bin/false \ No newline at end of file From 64d500834d9e5e7b1235472ae9673d5cc1cf8476 Mon Sep 17 00:00:00 2001 From: limingkang Date: Wed, 8 Feb 2023 16:20:46 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: limingkang Change-Id: I9b5ffda7df62edc283ed0eb4e3a27c8a04a16789 --- interfaces/innerkits/fs_manager/fstab.c | 2 +- services/param/base/param_base.c | 2 +- test/unittest/syspara/syspara_unittest.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/interfaces/innerkits/fs_manager/fstab.c b/interfaces/innerkits/fs_manager/fstab.c index cafb40f14..91dc1737c 100644 --- a/interfaces/innerkits/fs_manager/fstab.c +++ b/interfaces/innerkits/fs_manager/fstab.c @@ -270,7 +270,7 @@ FstabItem *FindFstabItemForPath(Fstab fstab, const char *path) { FstabItem *item = NULL; - if (path == NULL || *path == '\0' || *path != '/') { + if (path == NULL || *path != '/') { return NULL; } diff --git a/services/param/base/param_base.c b/services/param/base/param_base.c index 91a1ed23b..a88447ac6 100644 --- a/services/param/base/param_base.c +++ b/services/param/base/param_base.c @@ -743,7 +743,7 @@ STATIC_INLINE const char *CachedParameterCheck(CachedParameter *param) const char *CachedParameterGet(CachedHandle handle) { CachedParameter *param = (CachedParameter *)handle; - PARAM_CHECK(param != NULL, return NULL, "Invalid handle %x", handle); + PARAM_CHECK(param != NULL, return NULL, "Invalid handle"); return CachedParameterCheck(param); } diff --git a/test/unittest/syspara/syspara_unittest.cpp b/test/unittest/syspara/syspara_unittest.cpp index 38908093e..949eca663 100644 --- a/test/unittest/syspara/syspara_unittest.cpp +++ b/test/unittest/syspara/syspara_unittest.cpp @@ -282,8 +282,8 @@ HWTEST_F(SysparaUnitTest, parameterTest0013, TestSize.Level0) EXPECT_EQ(GetUintParameter("test.int.get", 0), 0); EXPECT_EQ(GetIntParameter("test.uint.get", 0), TEST_VALUE); EXPECT_EQ(GetUintParameter("test.uint.get", 0), TEST_VALUE); - EXPECT_EQ(GetIntParameter("test.int.default", 10), 10); //key not find,value = default - EXPECT_EQ(GetUintParameter("test.uint.default", 10), 10); //key not find,value = default + EXPECT_EQ(GetIntParameter("test.int.default", 10), 10); // key not find,value = default + EXPECT_EQ(GetUintParameter("test.uint.default", 10), 10); // key not find,value = default EXPECT_EQ(IsValidParamValue(nullptr, 0), 0); EXPECT_EQ(IsValidParamValue("testvalue", strlen("testvalue") + 1), 1); EXPECT_EQ(StringToLL("0x11", &out), 0); From 78c2feda81238a0c8a33119c244363e39c59cb4b Mon Sep 17 00:00:00 2001 From: chengjinsong2 Date: Wed, 8 Feb 2023 17:25:07 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E8=A7=A3=E5=86=B3watcher=E5=8D=A1=E6=AD=BB?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chengjinsong2 --- services/param/watcher/proxy/watcher_manager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/param/watcher/proxy/watcher_manager.cpp b/services/param/watcher/proxy/watcher_manager.cpp index 8a5ba0150..32349f344 100644 --- a/services/param/watcher/proxy/watcher_manager.cpp +++ b/services/param/watcher/proxy/watcher_manager.cpp @@ -38,6 +38,10 @@ WatcherManager::~WatcherManager() uint32_t WatcherManager::AddRemoteWatcher(uint32_t id, const sptr &watcher) { + if (id == getpid()) { + WATCHER_LOGE("Failed to add remote watcher %d", id); + return 0; + } WATCHER_CHECK(watcher != nullptr, return 0, "Invalid remote watcher"); WATCHER_CHECK(deathRecipient_ != nullptr, return 0, "Invalid deathRecipient_"); sptr object = watcher->AsObject(); From dfdad30e478ef15fec57375fa6442d6ad65053af Mon Sep 17 00:00:00 2001 From: limingkang Date: Thu, 9 Feb 2023 12:04:08 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: limingkang Change-Id: I7ccf46683dcbb4c06dcf0195163208778c2d1c6e --- services/modules/reboot/reboot.c | 1 - 1 file changed, 1 deletion(-) diff --git a/services/modules/reboot/reboot.c b/services/modules/reboot/reboot.c index d4610caf9..ffbd4c9c2 100644 --- a/services/modules/reboot/reboot.c +++ b/services/modules/reboot/reboot.c @@ -144,7 +144,6 @@ static int DoRebootOther(int id, const char *name, int argc, const char **argv) static void RebootAdpInit(void) { - // sample {"reboot,shutdown", "reboot.shutdown", "reboot.shutdown"}, // add default reboot cmd (void)AddCmdExecutor("reboot", DoReboot); (void)AddCmdExecutor("reboot.other", DoRebootOther); From 8ba2ed792692591ed06c7f871cb9ad309394fb7f Mon Sep 17 00:00:00 2001 From: limingkang Date: Thu, 9 Feb 2023 15:46:09 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: limingkang Change-Id: I02ca887debe3627619fb0d350959f776754a6cb7 --- services/modules/reboot/reboot.c | 1 + 1 file changed, 1 insertion(+) diff --git a/services/modules/reboot/reboot.c b/services/modules/reboot/reboot.c index d4610caf9..c1a3bd056 100644 --- a/services/modules/reboot/reboot.c +++ b/services/modules/reboot/reboot.c @@ -65,6 +65,7 @@ static int DoRebootPanic(int id, const char *name, int argc, const char **argv) if (fwrite((void *)"c", 1, 1, panic) != 1) { (void)fclose(panic); PLUGIN_LOGI("fwrite to panic failed"); + return -1; } (void)fclose(panic); #endif From b70ec053e1b0a61e4b8a8a806b7d55b47c67d5a8 Mon Sep 17 00:00:00 2001 From: cheng_jinsong Date: Thu, 9 Feb 2023 01:38:40 -0800 Subject: [PATCH 7/7] fix ut Signed-off-by: cheng_jinsong Change-Id: I01b30b0979c296df3ac44d0db0ea7b77d37d10ae --- test/unittest/BUILD.gn | 1 - test/unittest/init/cmds_unittest.cpp | 38 --------- test/unittest/init/group_unittest.cpp | 2 +- test/unittest/init/service_unittest.cpp | 11 +-- .../unittest/innerkits/innerkits_unittest.cpp | 10 ++- .../unittest/innerkits/modulemgr_unittest.cpp | 84 ------------------- .../unittest/loopevent/loopevent_unittest.cpp | 14 ---- test/unittest/modules/modules_unittest.cpp | 10 +-- test/unittest/param/param_shell_unittest.cpp | 2 +- test/unittest/param/trigger_unittest.cpp | 2 +- 10 files changed, 17 insertions(+), 157 deletions(-) diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index a20672a62..97ba3bfbf 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -177,7 +177,6 @@ ohos_unittest("init_unittest") { "init/utils_unittest.cpp", "innerkits/innerkits_unittest.cpp", "loopevent/loopevent_unittest.cpp", - "loopevent/loopserver_unittest.cpp", "loopevent/loopsignal_unittest.cpp", "modules/modules_unittest.cpp", "param/client_unittest.cpp", diff --git a/test/unittest/init/cmds_unittest.cpp b/test/unittest/init/cmds_unittest.cpp index acd7a1fdf..beb11b27a 100644 --- a/test/unittest/init/cmds_unittest.cpp +++ b/test/unittest/init/cmds_unittest.cpp @@ -36,44 +36,6 @@ public: void TearDown() {}; }; -HWTEST_F(CmdsUnitTest, TestCmdExecByName, TestSize.Level1) -{ - DoCmdByName("load_param ", " /system/etc/param onlyadd"); - DoCmdByName("symlink ", "/proc/self/fd/0 /dev/stdin"); - DoCmdByName("symlink ", "/notfile "); - DoCmdByName("insmod ", - "libdemo.z.so anony=1 mmz_allocator=hisi mmz=anonymous,0,0xA8000000,384M || report_error"); - DoCmdByName("insmod ", "/vendor/modules/hi_irq.ko"); - DoCmdByName("insmod ", STARTUP_INIT_UT_PATH"/test_insmod"); - - DoCmdByName("setparam ", "sys.usb.config ${persist.sys.usb.config}"); - - DoCmdByName("load_persist_params ", ""); - DoCmdByName("trigger ", ""); - DoCmdByName("domainname ", "localdomain"); - DoCmdByName("hostname ", "localhost"); - DoCmdByName("sleep ", "1"); - DoCmdByName("setrlimit ", "RLIMIT_NICE 40 40"); - DoCmdByName("setrlimit ", "RLIMIT_NICE unlimited unlimited"); - DoCmdByName("setrlimit ", "RLIMIT_NICE2 40 40"); - DoCmdByName("start ", "init_ut"); - DoCmdByName("stop ", "init_ut"); - DoCmdByName("reset ", "init_ut"); - DoCmdByName("reboot ", ""); - DoCmdByName("ifup ", "lo"); - DoCmdByName("mknode ", "/dev/null b 0666 1 3"); - DoCmdByName("mknode ", "/dev/null C 0666 1 3"); - DoCmdByName("mknode ", "/dev/null F 0666 1 3"); - DoCmdByName("mknode ", "/dev/null A 0666 1 3"); - DoCmdByName("makedev ", "999 999"); - DoCmdByName("mount_fstab ", "/wwwwwww"); - DoCmdByName("umount_fstab ", "/wwwwwww"); - DoCmdByName("mksandbox ", "system chipset"); - DoCmdByName("mksandbox ", "system"); - DoCmdByName("mksandbox ", "notsupport"); - DoCmdByName("mksandbox ", ""); - DoCmdByName("mksandbox ", nullptr); -} HWTEST_F(CmdsUnitTest, TestCmdExecByName1, TestSize.Level1) { DoCmdByName("timer_start ", "media_service|5000"); diff --git a/test/unittest/init/group_unittest.cpp b/test/unittest/init/group_unittest.cpp index 493d0b7b3..467353fc5 100644 --- a/test/unittest/init/group_unittest.cpp +++ b/test/unittest/init/group_unittest.cpp @@ -343,7 +343,7 @@ HWTEST_F(InitGroupManagerUnitTest, TestUpdaterServiceFds, TestSize.Level1) { Service *service = AddService("test_service8"); ASSERT_NE(nullptr, service); - int *fds = (int *)malloc(sizeof(int) * 1); // ServiceStop will release fds + int fds[1] = { -1 }; // ServiceStop will release fds UpdaterServiceFds(nullptr, nullptr, 0); UpdaterServiceFds(service, fds, 1); UpdaterServiceFds(service, fds, 0); diff --git a/test/unittest/init/service_unittest.cpp b/test/unittest/init/service_unittest.cpp index d58ad4e62..e2d43fa96 100644 --- a/test/unittest/init/service_unittest.cpp +++ b/test/unittest/init/service_unittest.cpp @@ -87,8 +87,7 @@ HWTEST_F(ServiceUnitTest, case02, TestSize.Level1) int ret = ParseOneService(serviceItem, service); EXPECT_EQ(ret, 0); - int *fds = (int *)malloc(sizeof(int) * 1); // ServiceStop will release fds - ASSERT_NE(nullptr, fds); + int fds[1] = {-1}; // ServiceStop will release fds UpdaterServiceFds(service, fds, 1); service->attribute = SERVICE_ATTR_ONDEMAND; ret = ServiceStart(service); @@ -130,16 +129,12 @@ HWTEST_F(ServiceUnitTest, TestServiceStartAbnormal, TestSize.Level1) int ret = ParseOneService(serviceItem, service); EXPECT_EQ(ret, 0); - const char *path = "/data/init_ut/test_service_unused"; - ret = strncpy_s(service->pathArgs.argv[0], strlen(path) + 1, path, strlen(path)); - EXPECT_EQ(ret, 0); - ret = ServiceStart(service); - EXPECT_EQ(ret, -1); + EXPECT_EQ(ret, 0); service->attribute &= SERVICE_ATTR_INVALID; ret = ServiceStart(service); - EXPECT_EQ(ret, -1); + EXPECT_EQ(ret, 0); service->pid = -1; ret = ServiceStop(service); diff --git a/test/unittest/innerkits/innerkits_unittest.cpp b/test/unittest/innerkits/innerkits_unittest.cpp index fed07c020..7999b9a24 100644 --- a/test/unittest/innerkits/innerkits_unittest.cpp +++ b/test/unittest/innerkits/innerkits_unittest.cpp @@ -246,7 +246,7 @@ HWTEST_F(InnerkitsUnitTest, MountAllWithFstabFile_unittest, TestSize.Level1) EXPECT_EQ(MountAllWithFstabFile("/testErrorFile", 0), -1); EXPECT_EQ(MountAllWithFstabFile(nullptr, 0), -1); EXPECT_EQ(GetMountStatusForMountPoint(nullptr), -1); - FstabItem fstabItem; + FstabItem fstabItem = {}; fstabItem.fsType = strdup("notSupport"); EXPECT_EQ(MountOneItem(nullptr), -1); EXPECT_EQ(MountOneItem(&fstabItem), 0); @@ -349,7 +349,9 @@ HWTEST_F(InnerkitsUnitTest, TestControlFd, TestSize.Level1) ProcessPtyWrite(nullptr, STDERR_FILENO, &events, nullptr); close(fd); - CmdOnClose(agent->task); + if (agent) { + CmdOnClose(agent->task); + } } HWTEST_F(InnerkitsUnitTest, TestControlFdServer, TestSize.Level1) @@ -361,7 +363,7 @@ HWTEST_F(InnerkitsUnitTest, TestControlFdServer, TestSize.Level1) UNUSED(context); }, LE_GetDefaultLoop()); - TaskHandle testServer; + TaskHandle testServer = NULL; LE_StreamServerInfo info = {}; info.baseInfo.flags = TASK_STREAM | TASK_SERVER | TASK_PIPE | TASK_TEST; info.server = (char *)"/data/testSock1"; @@ -432,7 +434,7 @@ HWTEST_F(InnerkitsUnitTest, TestHoldFd2, TestSize.Level1) int *fds = nullptr; char buffer[MAX_FD_HOLDER_BUFFER + 1] = {}; pid_t requestPid = -1; - struct msghdr msghdr; + struct msghdr msghdr = {}; GetFdsFromMsg(&fdCount, &requestPid, msghdr); msghdr.msg_flags = MSG_TRUNC; GetFdsFromMsg(&fdCount, &requestPid, msghdr); diff --git a/test/unittest/innerkits/modulemgr_unittest.cpp b/test/unittest/innerkits/modulemgr_unittest.cpp index 50b662941..bf88ea545 100644 --- a/test/unittest/innerkits/modulemgr_unittest.cpp +++ b/test/unittest/innerkits/modulemgr_unittest.cpp @@ -83,63 +83,6 @@ HWTEST_F(ModuleMgrUnitTest, PluginAddCmd, TestSize.Level1) RemoveCmdExecutor("testCmd4", cmdExecId4); } -HWTEST_F(ModuleMgrUnitTest, ModuleInstallTest, TestSize.Level1) -{ - int ret; - int cnt; - - // Create module manager - ASSERT_EQ(ModuleMgrCreate(nullptr), nullptr); - ModuleMgrDestroy(nullptr); - MODULE_MGR *moduleMgr = ModuleMgrCreate("init"); - ASSERT_NE(moduleMgr, nullptr); - cnt = ModuleMgrGetCnt(moduleMgr); - ASSERT_EQ(cnt, 0); - - // Install one module -#ifdef SUPPORT_64BIT - ret = ModuleMgrInstall(moduleMgr, "/system/lib64/init/libbootchart", 0, NULL); -#else - ret = ModuleMgrInstall(moduleMgr, "/system/lib/init/libbootchart", 0, NULL); -#endif - ASSERT_EQ(ret, 0); - cnt = ModuleMgrGetCnt(moduleMgr); - ASSERT_EQ(cnt, 1); - - // Uninstall the module - ModuleMgrUninstall(moduleMgr, "bootchart"); - InitModuleMgrUnInstall("bootchart"); - cnt = ModuleMgrGetCnt(moduleMgr); - ASSERT_EQ(cnt, 0); - - // Install two module - ret = ModuleMgrInstall(moduleMgr, "bootchart", 0, NULL); - ASSERT_EQ(ret, 0); - cnt = ModuleMgrGetCnt(moduleMgr); - ASSERT_EQ(cnt, 1); - ret = ModuleMgrInstall(moduleMgr, "notexist", 0, NULL); - ASSERT_NE(ret, 0); - cnt = ModuleMgrGetCnt(moduleMgr); - ASSERT_EQ(cnt, 1); - - // Uninstall the module - ModuleMgrUninstall(moduleMgr, "bootchart"); - cnt = ModuleMgrGetCnt(moduleMgr); - ASSERT_EQ(cnt, 0); - ModuleMgrUninstall(moduleMgr, "notexist"); - cnt = ModuleMgrGetCnt(moduleMgr); - ASSERT_EQ(cnt, 0); - - ModuleMgrDestroy(moduleMgr); - - // test updater mode - int fd = open("/bin/updater", O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, S_IRWXU); - ASSERT_NE(fd, 0); - ModuleMgrScan("init/autorun"); - unlink("/bin/updater"); - close(fd); -} - static void TestModuleDump(const MODULE_INFO *moduleInfo) { printf("%s\n", moduleInfo->name); @@ -176,31 +119,4 @@ HWTEST_F(ModuleMgrUnitTest, ModuleTraversalTest, TestSize.Level1) ModuleMgrGetArgs(); ModuleMgrDestroy(moduleMgr); } - -HWTEST_F(ModuleMgrUnitTest, ModuleScanTest, TestSize.Level1) -{ - // Scan all modules test init - MODULE_MGR *moduleMgr = ModuleMgrScan("init"); - ASSERT_NE(moduleMgr, nullptr); - int cnt = ModuleMgrGetCnt(moduleMgr); - ASSERT_GE(cnt, 1); - - ModuleMgrUninstall(nullptr, nullptr); - ModuleMgrUninstall(moduleMgr, NULL); - cnt = ModuleMgrGetCnt(moduleMgr); - ASSERT_EQ(cnt, 0); - ModuleMgrDestroy(moduleMgr); - - // scan /lib/init/ -#ifdef SUPPORT_64BIT - moduleMgr = ModuleMgrScan("/lib64/init"); -#else - moduleMgr = ModuleMgrScan("/lib/init"); -#endif - ASSERT_NE(moduleMgr, nullptr); - ModuleMgrGetCnt(nullptr); - cnt = ModuleMgrGetCnt(moduleMgr); - ModuleMgrDestroy(moduleMgr); - EXPECT_EQ(InitModuleMgrInstall(nullptr), -1); -} } // namespace init_ut diff --git a/test/unittest/loopevent/loopevent_unittest.cpp b/test/unittest/loopevent/loopevent_unittest.cpp index 8c111610c..678c26060 100644 --- a/test/unittest/loopevent/loopevent_unittest.cpp +++ b/test/unittest/loopevent/loopevent_unittest.cpp @@ -244,20 +244,6 @@ private: ParamTaskPtr serverTask_ = NULL; }; -HWTEST_F(LoopEventUnittest, StreamTaskTest, TestSize.Level1) -{ - LoopEventUnittest loopevtest = LoopEventUnittest(); - loopevtest.CreateServerTask(); - loopevtest.StreamTaskTest(); - LE_StreamInfo streamInfo = {}; - streamInfo.recvMessage = OnReceiveRequest; - streamInfo.baseInfo.flags = TASK_PIPE | TASK_CONNECT; - streamInfo.server = (char *)PIPE_NAME; - TaskHandle clientTaskHandlec = nullptr; - LE_CreateStreamClient(LE_GetDefaultLoop(), &clientTaskHandlec, &streamInfo); - EXPECT_NE(clientTaskHandlec, nullptr); -} - HWTEST_F(LoopEventUnittest, LeTaskTest, TestSize.Level1) { LoopEventUnittest loopevtest = LoopEventUnittest(); diff --git a/test/unittest/modules/modules_unittest.cpp b/test/unittest/modules/modules_unittest.cpp index 7f74494c0..21b3ff230 100644 --- a/test/unittest/modules/modules_unittest.cpp +++ b/test/unittest/modules/modules_unittest.cpp @@ -67,8 +67,8 @@ HWTEST_F(ModulesUnitTest, TestBootchartLogFile, TestSize.Level1) { DoBootchartStart(); FILE *log = fopen("/data/init_ut/ModulesTest.log", "w"); - BootchartLogFile(log, "/proc/stat"); - if (log != NULL) { + if (log) { + BootchartLogFile(log, "/proc/stat"); (void)fflush(log); (void)fclose(log); } @@ -78,8 +78,8 @@ HWTEST_F(ModulesUnitTest, TestBootchartLogProcessStat, TestSize.Level1) { FILE *log = fopen("/data/init_ut/ModulesTest.log", "w"); pid_t selfPid = getpid(); - BootchartLogProcessStat(log, selfPid); if (log != NULL) { + BootchartLogProcessStat(log, selfPid); (void)fflush(log); (void)fclose(log); } @@ -88,8 +88,8 @@ HWTEST_F(ModulesUnitTest, TestBootchartLogProcessStat, TestSize.Level1) HWTEST_F(ModulesUnitTest, TestbootchartLogProcess, TestSize.Level1) { FILE *log = fopen("/data/init_ut/ModulesTest.log", "w"); - bootchartLogProcess(log); - if (log != NULL) { + if (log) { + bootchartLogProcess(log); (void)fflush(log); (void)fclose(log); } diff --git a/test/unittest/param/param_shell_unittest.cpp b/test/unittest/param/param_shell_unittest.cpp index 34c469ad2..bf0af31ca 100644 --- a/test/unittest/param/param_shell_unittest.cpp +++ b/test/unittest/param/param_shell_unittest.cpp @@ -213,6 +213,6 @@ HWTEST_F(ParamShellUnitTest, TestParamShellcmd2, TestSize.Level1) BShellEnvLoop(nullptr); BShellEnvErrString(GetShellHandle(), 1); BShellEnvOutputResult(GetShellHandle(), 1); - demoExit(); + } } // namespace init_ut diff --git a/test/unittest/param/trigger_unittest.cpp b/test/unittest/param/trigger_unittest.cpp index 86ced24a5..2b8005c6b 100644 --- a/test/unittest/param/trigger_unittest.cpp +++ b/test/unittest/param/trigger_unittest.cpp @@ -601,5 +601,5 @@ HWTEST_F(TriggerUnitTest, TestExecuteParamTrigger6, TestSize.Level0) { TriggerUnitTest test; test.TestDumpTrigger(); - CloseTriggerWorkSpace(); + }