diff --git a/interfaces/native/innerkits/src/hitrace_dump.cpp b/interfaces/native/innerkits/src/hitrace_dump.cpp index affe8e7..88a72b7 100644 --- a/interfaces/native/innerkits/src/hitrace_dump.cpp +++ b/interfaces/native/innerkits/src/hitrace_dump.cpp @@ -589,7 +589,8 @@ bool WriteFile(uint8_t contentType, const std::string &src, int outFd, const std if (traceEndTime < pageTraceTime) { endFlag = true; readBytes = 0; - HILOG_ERROR(LOG_CORE, "Current pageTraceTime:(%{public}" PRId64 ") is larger than traceEndTime:(%{public}" PRId64 "), stop to read trace info.", + HILOG_INFO(LOG_CORE, + "Current pageTraceTime:(%{public}" PRId64 ") is larger than traceEndTime:(%{public}" PRId64 ")", pageTraceTime, traceEndTime); break; } @@ -1105,7 +1106,11 @@ TraceErrorCode DumpTraceInner(std::vector &outputFiles) } if (g_dumpStatus) { - remove(reOutPath.c_str()); + if (remove(reOutPath.c_str()) == 0) { + HILOG_INFO(LOG_CORE, "Delete outpath:%{public}s success.", reOutPath.c_str()); + } else { + HILOG_INFO(LOG_CORE, "Delete outpath:%{public}s failed.", reOutPath.c_str()); + } return static_cast(g_dumpStatus.load()); } @@ -1492,7 +1497,8 @@ TraceRetInfo DumpTrace(int maxDuration, uint64_t traceEndTime) // beware of input precision of seconds: add an extra second of tolerance g_inputTraceEndTime = (traceEndTime - static_cast(boot_time) + 1) * S_TO_NS; } else { - HILOG_ERROR(LOG_CORE, "DumpTrace: traceEndTime:(%{public}" PRId64 ") is earlier than boot_time:(%{public}" PRId64 ").", + HILOG_ERROR(LOG_CORE, + "DumpTrace: traceEndTime:(%{public}" PRId64 ") is earlier than boot_time:(%{public}" PRId64 ").", traceEndTime, static_cast(boot_time)); ret.errorCode = OUT_OF_TIME; return ret; diff --git a/test/unittest/hitrace_dump/hitrace_dump_test.cpp b/test/unittest/hitrace_dump/hitrace_dump_test.cpp index ecc1e0d..4afc3b8 100644 --- a/test/unittest/hitrace_dump/hitrace_dump_test.cpp +++ b/test/unittest/hitrace_dump/hitrace_dump_test.cpp @@ -245,6 +245,7 @@ HWTEST_F(HitraceDumpTest, DumpTraceTest_004, TestSize.Level0) uint64_t traceEndTime = 1; TraceRetInfo ret = DumpTrace(0, traceEndTime); ASSERT_TRUE(ret.errorCode == TraceErrorCode::OUT_OF_TIME); + ASSERT_TRUE(ret.outputFiles.empty()); ASSERT_TRUE(CloseTrace() == TraceErrorCode::SUCCESS); ASSERT_TRUE(OpenTrace(tagGroups) == TraceErrorCode::SUCCESS); @@ -272,6 +273,7 @@ HWTEST_F(HitraceDumpTest, DumpTraceTest_004, TestSize.Level0) maxDuration = 10; ret = DumpTrace(maxDuration, traceEndTime); ASSERT_TRUE(ret.errorCode == TraceErrorCode::OUT_OF_TIME); + ASSERT_TRUE(ret.outputFiles.empty()); ASSERT_TRUE(CloseTrace() == TraceErrorCode::SUCCESS); ASSERT_TRUE(OpenTrace(tagGroups) == TraceErrorCode::SUCCESS); @@ -279,6 +281,7 @@ HWTEST_F(HitraceDumpTest, DumpTraceTest_004, TestSize.Level0) maxDuration = 10; ret = DumpTrace(maxDuration, traceEndTime); ASSERT_TRUE(ret.errorCode == TraceErrorCode::OUT_OF_TIME); + ASSERT_TRUE(ret.outputFiles.empty()); ASSERT_TRUE(CloseTrace() == TraceErrorCode::SUCCESS); ASSERT_TRUE(OpenTrace(tagGroups) == TraceErrorCode::SUCCESS); @@ -302,6 +305,7 @@ HWTEST_F(HitraceDumpTest, DumpTraceTest_005, TestSize.Level0) uint64_t traceEndTime = static_cast(std::time(nullptr)) - 20; // current time - 20 seconds TraceRetInfo ret = DumpTrace(0, traceEndTime); ASSERT_TRUE(ret.errorCode == TraceErrorCode::OUT_OF_TIME); + ASSERT_TRUE(ret.outputFiles.empty()); ASSERT_TRUE(CloseTrace() == TraceErrorCode::SUCCESS); ASSERT_TRUE(OpenTrace(tagGroups) == TraceErrorCode::SUCCESS); @@ -310,6 +314,7 @@ HWTEST_F(HitraceDumpTest, DumpTraceTest_005, TestSize.Level0) int maxDuration = 10; ret = DumpTrace(maxDuration, traceEndTime); ASSERT_TRUE(ret.errorCode == TraceErrorCode::OUT_OF_TIME); + ASSERT_TRUE(ret.outputFiles.empty()); ASSERT_TRUE(CloseTrace() == TraceErrorCode::SUCCESS); }