From 5c00f7fac8a679350200e5b65404aac80390b2c6 Mon Sep 17 00:00:00 2001 From: Federer-JC Date: Fri, 8 Nov 2024 11:16:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E8=BF=9B=E7=A8=8B=E6=8A=93trace?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E7=94=A8=E4=BE=8B=E8=A1=A5=E5=85=85=20Signed?= =?UTF-8?q?-off-by:Federer-JC=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Federer-JC --- .../hitrace_dump/hitrace_dump_test.cpp | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/test/unittest/hitrace_dump/hitrace_dump_test.cpp b/test/unittest/hitrace_dump/hitrace_dump_test.cpp index ded2f15..00bae37 100644 --- a/test/unittest/hitrace_dump/hitrace_dump_test.cpp +++ b/test/unittest/hitrace_dump/hitrace_dump_test.cpp @@ -683,6 +683,61 @@ HWTEST_F(HitraceDumpTest, DumpForCmdMode_009, TestSize.Level0) ASSERT_TRUE(CloseTrace() == TraceErrorCode::SUCCESS); } +/** + * @tc.name: DumpForCmdMode_010 + * @tc.desc: Test the multi-process task CMD_MODE when set fileLimit in args. + * @tc.type: FUNC + */ +HWTEST_F(HitraceDumpTest, DumpForCmdMode_010, TestSize.Level0) +{ + std::string args = "tags:sched,ace,app,disk,distributeddatamgr,freq,graphic,idle,irq,load,mdfs,mmc,"; + args += "notification,ohos,pagecache,regulators,sync,ufs,workq,zaudio,zcamera,zimage,zmedia "; + args += "clockType: boot bufferSize:1024 overwrite: 1 fileLimit: 2"; + ASSERT_TRUE(OpenTrace(args) == TraceErrorCode::SUCCESS); + + pid_t pid = fork(); + if (pid < 0) { + HILOG_ERROR(LOG_CORE, "fork error."); + } else if (pid == 0) { + ASSERT_TRUE(OpenTrace(args) == TraceErrorCode::WRONG_TRACE_MODE); + _exit(EXIT_SUCCESS); + } + + ASSERT_TRUE(DumpTraceOn() == TraceErrorCode::SUCCESS); + sleep(1); + + TraceRetInfo ret = DumpTraceOff(); + ASSERT_TRUE(ret.errorCode == TraceErrorCode::SUCCESS); + ASSERT_TRUE(ret.outputFiles.size() > 0); + + ASSERT_TRUE(CloseTrace() == TraceErrorCode::SUCCESS); +} + +/** + * @tc.name: DumpForCmdMode_011 + * @tc.desc: Test the multi-process task SERVICE_MODE and Enable the cmd mode in non-close mode. + * @tc.type: FUNC + */ +HWTEST_F(HitraceDumpTest, DumpForCmdMode_011, TestSize.Level0) +{ + const std::vector tagGroups = {"scene_performance"}; + ASSERT_TRUE(OpenTrace(tagGroups) == TraceErrorCode::SUCCESS); + + pid_t pid = fork(); + if (pid < 0) { + HILOG_ERROR(LOG_CORE, "fork error."); + } else if (pid == 0) { + ASSERT_TRUE(OpenTrace(tagGroups) == TraceErrorCode::WRONG_TRACE_MODE); + _exit(EXIT_SUCCESS); + } + + std::string args = "tags:sched clockType:boot bufferSize:1024 overwrite:1"; + ASSERT_TRUE(OpenTrace(args) == TraceErrorCode::WRONG_TRACE_MODE); + ASSERT_TRUE(DumpTraceOn() == TraceErrorCode::WRONG_TRACE_MODE); + + ASSERT_TRUE(CloseTrace() == TraceErrorCode::SUCCESS); +} + /** * @tc.name: ParammeterCheck_001 * @tc.desc: Check parameter after interface call.