trace collect error code modify

Signed-off-by: negegne <zhengshunxin@huawei.com>
This commit is contained in:
negegne 2024-11-05 21:05:09 +08:00
parent 9f889dfcb5
commit c9351bceb6
4 changed files with 28 additions and 3 deletions

View File

@ -37,8 +37,12 @@ const std::map<TraceErrorCode, UcError> CODE_MAP = {
{TraceErrorCode::TAG_ERROR, UcError::TRACE_TAG_ERROR},
{TraceErrorCode::FILE_ERROR, UcError::TRACE_FILE_ERROR},
{TraceErrorCode::WRITE_TRACE_INFO_ERROR, UcError::TRACE_WRITE_ERROR},
{TraceErrorCode::CALL_ERROR, UcError::TRACE_CALL_ERROR},
{TraceErrorCode::WRONG_TRACE_MODE, UcError::TRACE_WRONG_MODE},
{TraceErrorCode::OUT_OF_TIME, UcError::TRACE_OUT_OF_TIME},
{TraceErrorCode::FORK_ERROR, UcError::TRACE_FORK_ERROR},
{TraceErrorCode::EPOLL_WAIT_ERROR, UcError::TRACE_EPOLL_WAIT_ERROR},
{TraceErrorCode::PIPE_CREATE_ERROR, UcError::TRACE_PIPE_CREATE_ERROR},
{TraceErrorCode::SYSINFO_READ_FAILURE, UcError::TRACE_SYSINFO_READ_FAILURE},
};
}

View File

@ -52,7 +52,7 @@ int32_t TraceManager::OpenSnapshotTrace(const std::vector<std::string> &tagGroup
if (OHOS::HiviewDFX::Hitrace::GetTraceMode() ==
OHOS::HiviewDFX::Hitrace::TraceMode::SERVICE_MODE) {
HIVIEW_LOGE("now is snapshot status, open snapshot failed.");
return UcError::TRACE_CALL_ERROR;
return UcError::TRACE_WRONG_MODE;
}
// recording mode

View File

@ -31,8 +31,12 @@ enum UcError {
TRACE_TAG_ERROR = 1003,
TRACE_FILE_ERROR = 1004,
TRACE_WRITE_ERROR = 1005,
TRACE_CALL_ERROR = 1006,
TRACE_WRONG_MODE = 1006,
TRACE_OUT_OF_TIME = 1007,
TRACE_FORK_ERROR = 1008,
TRACE_EPOLL_WAIT_ERROR = 1009,
TRACE_PIPE_CREATE_ERROR = 1010,
TRACE_SYSINFO_READ_FAILURE = 1011,
// control policy
TRACE_OVER_FLOW = 1100,

View File

@ -397,3 +397,20 @@ HWTEST_F(TraceCollectorTest, TraceCollectorTest017, TestSize.Level1)
ASSERT_TRUE(resultDumpTrace.data.size() >= 0);
ASSERT_TRUE(g_traceManager.CloseTrace() == 0);
}
/**
* @tc.name: TraceCollectorTest018
* @tc.desc: used to test abnormal scene about trace operations
* @tc.type: FUNC
*/
HWTEST_F(TraceCollectorTest, TraceCollectorTest018, TestSize.Level1)
{
const std::vector<std::string> tagGroups = {"scene_performance"};
ASSERT_EQ(g_traceManager.OpenSnapshotTrace(tagGroups), UcError::SUCCESS);
ASSERT_EQ(g_traceManager.OpenSnapshotTrace(tagGroups), UcError::TRACE_WRONG_MODE);
const std::string args = "tags:sched clockType:boot bufferSize:1024 overwrite:1";
ASSERT_EQ(g_traceManager.OpenRecordingTrace(args), UcError::SUCCESS);
ASSERT_EQ(g_traceManager.OpenRecordingTrace(args), UcError::TRACE_IS_OCCUPIED);
ASSERT_EQ(g_traceManager.OpenSnapshotTrace(tagGroups), UcError::TRACE_IS_OCCUPIED);
ASSERT_EQ(g_traceManager.CloseTrace(), UcError::SUCCESS);
}