106f6ba60Sopenharmony_ci/*
206f6ba60Sopenharmony_ci * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved.
306f6ba60Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
406f6ba60Sopenharmony_ci * you may not use this file except in compliance with the License.
506f6ba60Sopenharmony_ci * You may obtain a copy of the License at
606f6ba60Sopenharmony_ci *
706f6ba60Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
806f6ba60Sopenharmony_ci *
906f6ba60Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1006f6ba60Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1106f6ba60Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1206f6ba60Sopenharmony_ci * See the License for the specific language governing permissions and
1306f6ba60Sopenharmony_ci * limitations under the License.
1406f6ba60Sopenharmony_ci */
1506f6ba60Sopenharmony_ci
1606f6ba60Sopenharmony_ci#include "hidebug_base.h"
1706f6ba60Sopenharmony_ci#include "hidebug/hidebug.h"
1806f6ba60Sopenharmony_ci#include "hidebug/hidebug_type.h"
1906f6ba60Sopenharmony_ci
2006f6ba60Sopenharmony_ci#include <filesystem>
2106f6ba60Sopenharmony_ci#include <hwext/gtest-ext.h>
2206f6ba60Sopenharmony_ci#include <hwext/gtest-tag.h>
2306f6ba60Sopenharmony_ci
2406f6ba60Sopenharmony_ci#include <cstdlib>
2506f6ba60Sopenharmony_ci
2606f6ba60Sopenharmony_ciusing namespace testing::ext;
2706f6ba60Sopenharmony_ci
2806f6ba60Sopenharmony_cinamespace {
2906f6ba60Sopenharmony_ciclass HidebugTest : public ::testing::Test {
3006f6ba60Sopenharmony_ciprotected:
3106f6ba60Sopenharmony_ci    void SetUp() override {}
3206f6ba60Sopenharmony_ci    void TearDown() override
3306f6ba60Sopenharmony_ci    {
3406f6ba60Sopenharmony_ci        system("param set hiviewdfx.debugenv.hidebug_test 0");
3506f6ba60Sopenharmony_ci        system("param set libc.hook_mode 0");
3606f6ba60Sopenharmony_ci    }
3706f6ba60Sopenharmony_ci};
3806f6ba60Sopenharmony_ci
3906f6ba60Sopenharmony_ci/**
4006f6ba60Sopenharmony_ci * @tc.name: InitEnvironmentParam
4106f6ba60Sopenharmony_ci * @tc.desc: test InitEnvironmentParam
4206f6ba60Sopenharmony_ci * @tc.type: FUNC
4306f6ba60Sopenharmony_ci */
4406f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, InitEnvironmentParam1, TestSize.Level1)
4506f6ba60Sopenharmony_ci{
4606f6ba60Sopenharmony_ci    system("param set hiviewdfx.debugenv.hidebug_test aaa:bbb");
4706f6ba60Sopenharmony_ci    const char* inputName = "hidebug_test";
4806f6ba60Sopenharmony_ci    EXPECT_TRUE(InitEnvironmentParam(inputName));
4906f6ba60Sopenharmony_ci}
5006f6ba60Sopenharmony_ci
5106f6ba60Sopenharmony_ci/**
5206f6ba60Sopenharmony_ci * @tc.name: InitEnvironmentParam
5306f6ba60Sopenharmony_ci * @tc.desc: test InitEnvironmentParam for input is nullptr
5406f6ba60Sopenharmony_ci * @tc.type: FUNC
5506f6ba60Sopenharmony_ci */
5606f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, InitEnvironmentParam2, TestSize.Level1)
5706f6ba60Sopenharmony_ci{
5806f6ba60Sopenharmony_ci    system("param set hiviewdfx.debugenv.hidebug_test aaa:bbb");
5906f6ba60Sopenharmony_ci    const char* inputName = nullptr;
6006f6ba60Sopenharmony_ci    EXPECT_FALSE(InitEnvironmentParam(inputName));
6106f6ba60Sopenharmony_ci}
6206f6ba60Sopenharmony_ci
6306f6ba60Sopenharmony_ci/**
6406f6ba60Sopenharmony_ci * @tc.name: InitEnvironmentParam
6506f6ba60Sopenharmony_ci * @tc.desc: test InitEnvironmentParam for input is wrong
6606f6ba60Sopenharmony_ci * @tc.type: FUNC
6706f6ba60Sopenharmony_ci */
6806f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, InitEnvironmentParam3, TestSize.Level1)
6906f6ba60Sopenharmony_ci{
7006f6ba60Sopenharmony_ci    system("param set hiviewdfx.debugenv.hidebug_test aaa:bbb");
7106f6ba60Sopenharmony_ci    const char* inputName = "hidebug_test/";
7206f6ba60Sopenharmony_ci    EXPECT_FALSE(InitEnvironmentParam(inputName));
7306f6ba60Sopenharmony_ci}
7406f6ba60Sopenharmony_ci
7506f6ba60Sopenharmony_ci/**
7606f6ba60Sopenharmony_ci * @tc.name: InitEnvironmentParam
7706f6ba60Sopenharmony_ci * @tc.desc: test InitEnvironmentParam for param set wrong
7806f6ba60Sopenharmony_ci * @tc.type: FUNC
7906f6ba60Sopenharmony_ci */
8006f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, InitEnvironmentParam4, TestSize.Level1)
8106f6ba60Sopenharmony_ci{
8206f6ba60Sopenharmony_ci    system("param set hiviewdfx.debugenv.hidebug_test error_input");
8306f6ba60Sopenharmony_ci    const char* inputName = "hidebug_test";
8406f6ba60Sopenharmony_ci    EXPECT_FALSE(InitEnvironmentParam(inputName));
8506f6ba60Sopenharmony_ci}
8606f6ba60Sopenharmony_ci
8706f6ba60Sopenharmony_ci/**
8806f6ba60Sopenharmony_ci * @tc.name: InitEnvironmentParam
8906f6ba60Sopenharmony_ci * @tc.desc: test InitEnvironmentParam for libc.hook_mode
9006f6ba60Sopenharmony_ci * @tc.type: FUNC
9106f6ba60Sopenharmony_ci */
9206f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, InitEnvironmentParam5, TestSize.Level1)
9306f6ba60Sopenharmony_ci{
9406f6ba60Sopenharmony_ci    system("param set hiviewdfx.debugenv.hidebug_test aaa:bbb");
9506f6ba60Sopenharmony_ci    system("param set libc.hook_mode startup:hidebug_test");
9606f6ba60Sopenharmony_ci    const char* inputName = "hidebug_test";
9706f6ba60Sopenharmony_ci    EXPECT_TRUE(InitEnvironmentParam(inputName));
9806f6ba60Sopenharmony_ci}
9906f6ba60Sopenharmony_ci
10006f6ba60Sopenharmony_ci/**
10106f6ba60Sopenharmony_ci * @tc.name: InitEnvironmentParam
10206f6ba60Sopenharmony_ci * @tc.desc: test InitEnvironmentParam for libc.hook_mode param set fail
10306f6ba60Sopenharmony_ci * @tc.type: FUNC
10406f6ba60Sopenharmony_ci */
10506f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, InitEnvironmentParam6, TestSize.Level1)
10606f6ba60Sopenharmony_ci{
10706f6ba60Sopenharmony_ci    system("param set hiviewdfx.debugenv.hidebug_test error_input");
10806f6ba60Sopenharmony_ci    system("param set libc.hook_mode error_set:hidebug_test");
10906f6ba60Sopenharmony_ci    const char* inputName = "hidebug_test";
11006f6ba60Sopenharmony_ci    EXPECT_FALSE(InitEnvironmentParam(inputName));
11106f6ba60Sopenharmony_ci}
11206f6ba60Sopenharmony_ci
11306f6ba60Sopenharmony_ci/**
11406f6ba60Sopenharmony_ci * @tc.name: InitEnvironmentParam
11506f6ba60Sopenharmony_ci * @tc.desc: test InitEnvironmentParam for libc.hook_mode fail
11606f6ba60Sopenharmony_ci * @tc.type: FUNC
11706f6ba60Sopenharmony_ci */
11806f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, InitEnvironmentParam7, TestSize.Level1)
11906f6ba60Sopenharmony_ci{
12006f6ba60Sopenharmony_ci    system("param set hiviewdfx.debugenv.hidebug_test error_input");
12106f6ba60Sopenharmony_ci    system("param set libc.hook_mode error_set:hidebug_test");
12206f6ba60Sopenharmony_ci    const char* inputName = "hidebug_test";
12306f6ba60Sopenharmony_ci    EXPECT_FALSE(InitEnvironmentParam(inputName));
12406f6ba60Sopenharmony_ci}
12506f6ba60Sopenharmony_ci
12606f6ba60Sopenharmony_ci/**
12706f6ba60Sopenharmony_ci * @tc.name: InitEnvironmentParam
12806f6ba60Sopenharmony_ci * @tc.desc: test InitEnvironmentParam for libc.hook_mode input error
12906f6ba60Sopenharmony_ci * @tc.type: FUNC
13006f6ba60Sopenharmony_ci */
13106f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, InitEnvironmentParam8, TestSize.Level1)
13206f6ba60Sopenharmony_ci{
13306f6ba60Sopenharmony_ci    system("param set hiviewdfx.debugenv.hidebug_test aaa:bbb");
13406f6ba60Sopenharmony_ci    system("param set libc.hook_mode error_set:hidebug_test");
13506f6ba60Sopenharmony_ci    const char* inputName = "error_input";
13606f6ba60Sopenharmony_ci    EXPECT_FALSE(InitEnvironmentParam(inputName));
13706f6ba60Sopenharmony_ci}
13806f6ba60Sopenharmony_ci
13906f6ba60Sopenharmony_ci/**
14006f6ba60Sopenharmony_ci * @tc.name: InitEnvironmentParam
14106f6ba60Sopenharmony_ci * @tc.desc: test InitEnvironmentParam for libc.hook_mode param set wrong_proc
14206f6ba60Sopenharmony_ci * @tc.type: FUNC
14306f6ba60Sopenharmony_ci */
14406f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, InitEnvironmentParam9, TestSize.Level1)
14506f6ba60Sopenharmony_ci{
14606f6ba60Sopenharmony_ci    system("param set hiviewdfx.debugenv.hidebug_test error_input");
14706f6ba60Sopenharmony_ci    system("param set libc.hook_mode start_up:wrong_proc");
14806f6ba60Sopenharmony_ci    const char* inputName = "hidebug";
14906f6ba60Sopenharmony_ci    EXPECT_FALSE(InitEnvironmentParam(inputName));
15006f6ba60Sopenharmony_ci}
15106f6ba60Sopenharmony_ci
15206f6ba60Sopenharmony_ci/**
15306f6ba60Sopenharmony_ci * @tc.name: OH_HiDebug_GetAppCpuUsage1
15406f6ba60Sopenharmony_ci * @tc.desc: test OH_HiDebug_GetAppCpuUsage.get app cpu usage
15506f6ba60Sopenharmony_ci * @tc.type: FUNC
15606f6ba60Sopenharmony_ci */
15706f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, OH_HiDebug_GetAppCpuUsage1, TestSize.Level1)
15806f6ba60Sopenharmony_ci{
15906f6ba60Sopenharmony_ci    EXPECT_TRUE(OH_HiDebug_GetAppCpuUsage() >= 0);
16006f6ba60Sopenharmony_ci}
16106f6ba60Sopenharmony_ci
16206f6ba60Sopenharmony_ci/**
16306f6ba60Sopenharmony_ci * @tc.name: OH_HiDebug_GetAppThreadCpuUsage1
16406f6ba60Sopenharmony_ci * @tc.desc: test OH_HiDebug_GetAppThreadCpuUsage.get thread cpu usage of app
16506f6ba60Sopenharmony_ci * @tc.type: FUNC
16606f6ba60Sopenharmony_ci */
16706f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, OH_HiDebug_GetAppThreadCpuUsage1, TestSize.Level1)
16806f6ba60Sopenharmony_ci{
16906f6ba60Sopenharmony_ci    HiDebug_ThreadCpuUsagePtr threadCpuUsage = OH_HiDebug_GetAppThreadCpuUsage();
17006f6ba60Sopenharmony_ci    HiDebug_ThreadCpuUsagePtr curThreadCpuUsage = threadCpuUsage;
17106f6ba60Sopenharmony_ci    while (curThreadCpuUsage != nullptr) {
17206f6ba60Sopenharmony_ci        curThreadCpuUsage = curThreadCpuUsage->next;
17306f6ba60Sopenharmony_ci    }
17406f6ba60Sopenharmony_ci    OH_HiDebug_FreeThreadCpuUsage(&threadCpuUsage);
17506f6ba60Sopenharmony_ci    EXPECT_TRUE(true);
17606f6ba60Sopenharmony_ci}
17706f6ba60Sopenharmony_ci
17806f6ba60Sopenharmony_ci/**
17906f6ba60Sopenharmony_ci * @tc.name: GetSystemCpuUsage
18006f6ba60Sopenharmony_ci * @tc.desc: test InitEnvironmentParam for libc.hook_mode param set wrong_proc
18106f6ba60Sopenharmony_ci * @tc.type: FUNC
18206f6ba60Sopenharmony_ci */
18306f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, GetSystemCpuUsage, TestSize.Level1)
18406f6ba60Sopenharmony_ci{
18506f6ba60Sopenharmony_ci    double systemCpuUsage = OH_HiDebug_GetSystemCpuUsage();
18606f6ba60Sopenharmony_ci    EXPECT_TRUE(systemCpuUsage >= 0 && systemCpuUsage <= 1);
18706f6ba60Sopenharmony_ci}
18806f6ba60Sopenharmony_ci
18906f6ba60Sopenharmony_ci/**
19006f6ba60Sopenharmony_ci * @tc.name: GetAppMemoryLimit1
19106f6ba60Sopenharmony_ci * @tc.desc: test GetAppMemoryLimit1
19206f6ba60Sopenharmony_ci * @tc.type: FUNC
19306f6ba60Sopenharmony_ci */
19406f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, GetAppMemoryLimit1, TestSize.Level1)
19506f6ba60Sopenharmony_ci{
19606f6ba60Sopenharmony_ci    HiDebug_MemoryLimit memoryLimit;
19706f6ba60Sopenharmony_ci    OH_HiDebug_GetAppMemoryLimit(&memoryLimit);
19806f6ba60Sopenharmony_ci    ASSERT_TRUE(memoryLimit.rssLimit >= 0);
19906f6ba60Sopenharmony_ci    ASSERT_TRUE(memoryLimit.vssLimit >= 0);
20006f6ba60Sopenharmony_ci}
20106f6ba60Sopenharmony_ci
20206f6ba60Sopenharmony_ci/**
20306f6ba60Sopenharmony_ci * @tc.name: OH_HiDebug_GetAppNativeMemInfo1
20406f6ba60Sopenharmony_ci * @tc.desc: test OH_HiDebug_GetAppNativeMemInfo. get application process memory info
20506f6ba60Sopenharmony_ci * @tc.type: FUNC
20606f6ba60Sopenharmony_ci */
20706f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, OH_HiDebug_GetAppNativeMemInfo1, TestSize.Level1)
20806f6ba60Sopenharmony_ci{
20906f6ba60Sopenharmony_ci    HiDebug_NativeMemInfo nativeMemInfo;
21006f6ba60Sopenharmony_ci    OH_HiDebug_GetAppNativeMemInfo(&nativeMemInfo);
21106f6ba60Sopenharmony_ci    ASSERT_TRUE(nativeMemInfo.pss >= 0);
21206f6ba60Sopenharmony_ci    ASSERT_TRUE(nativeMemInfo.vss >= 0);
21306f6ba60Sopenharmony_ci    ASSERT_TRUE(nativeMemInfo.rss >= 0);
21406f6ba60Sopenharmony_ci    ASSERT_TRUE(nativeMemInfo.sharedDirty >= 0);
21506f6ba60Sopenharmony_ci    ASSERT_TRUE(nativeMemInfo.privateDirty >= 0);
21606f6ba60Sopenharmony_ci    ASSERT_TRUE(nativeMemInfo.sharedClean >= 0);
21706f6ba60Sopenharmony_ci    ASSERT_TRUE(nativeMemInfo.privateClean >= 0);
21806f6ba60Sopenharmony_ci}
21906f6ba60Sopenharmony_ci
22006f6ba60Sopenharmony_ci/**
22106f6ba60Sopenharmony_ci * @tc.name: OH_HiDebug_GetSystemMemInfo1
22206f6ba60Sopenharmony_ci * @tc.desc: test OH_HiDebug_GetSystemMemInfo. get system memory info
22306f6ba60Sopenharmony_ci * @tc.type: FUNC
22406f6ba60Sopenharmony_ci */
22506f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, OH_HiDebug_GetSystemMemInfo1, TestSize.Level1)
22606f6ba60Sopenharmony_ci{
22706f6ba60Sopenharmony_ci    HiDebug_SystemMemInfo systemMemInfo;
22806f6ba60Sopenharmony_ci    OH_HiDebug_GetSystemMemInfo(&systemMemInfo);
22906f6ba60Sopenharmony_ci    ASSERT_TRUE(systemMemInfo.totalMem >= 0);
23006f6ba60Sopenharmony_ci    ASSERT_TRUE(systemMemInfo.freeMem >= 0);
23106f6ba60Sopenharmony_ci    ASSERT_TRUE(systemMemInfo.availableMem >= 0);
23206f6ba60Sopenharmony_ci}
23306f6ba60Sopenharmony_ci
23406f6ba60Sopenharmony_ci/**
23506f6ba60Sopenharmony_ci * @tc.name: OH_HiDebug_StartAppTraceCapture1
23606f6ba60Sopenharmony_ci * @tc.desc: test OH_HiDebug_StartAppTraceCapture. start app capture trace
23706f6ba60Sopenharmony_ci * @tc.type: FUNC
23806f6ba60Sopenharmony_ci */
23906f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, OH_HiDebug_StartAppTraceCapture1, TestSize.Level1)
24006f6ba60Sopenharmony_ci{
24106f6ba60Sopenharmony_ci    uint32_t fileLength = 256;
24206f6ba60Sopenharmony_ci    char fileName[256] = {0};
24306f6ba60Sopenharmony_ci    HiDebug_TraceFlag flag = HIDEBUG_TRACE_FLAG_MAIN_THREAD;
24406f6ba60Sopenharmony_ci    uint64_t tags = HIDEBUG_TRACE_TAG_COMMON_LIBRARY;
24506f6ba60Sopenharmony_ci    uint32_t limitSize = 1024 * 1024;
24606f6ba60Sopenharmony_ci    const char* targetPath = "/data/storage/el2/log";
24706f6ba60Sopenharmony_ci    auto captureResult = OH_HiDebug_StartAppTraceCapture(flag, tags, limitSize, fileName, fileLength);
24806f6ba60Sopenharmony_ci    if (std::filesystem::exists(targetPath)) {
24906f6ba60Sopenharmony_ci        EXPECT_EQ(captureResult, HIDEBUG_SUCCESS);
25006f6ba60Sopenharmony_ci        EXPECT_GT(sizeof(fileName) / sizeof(fileName[0]), 1);
25106f6ba60Sopenharmony_ci        EXPECT_EQ(OH_HiDebug_StopAppTraceCapture(), HIDEBUG_SUCCESS);
25206f6ba60Sopenharmony_ci    } else {
25306f6ba60Sopenharmony_ci        EXPECT_EQ(captureResult, HIDEBUG_NO_PERMISSION);
25406f6ba60Sopenharmony_ci        EXPECT_EQ(OH_HiDebug_StopAppTraceCapture(), HIDEBUG_NO_TRACE_RUNNING);
25506f6ba60Sopenharmony_ci    }
25606f6ba60Sopenharmony_ci}
25706f6ba60Sopenharmony_ci
25806f6ba60Sopenharmony_ci/**
25906f6ba60Sopenharmony_ci * @tc.name: OH_HiDebug_StartAppTraceCapture2
26006f6ba60Sopenharmony_ci * @tc.desc: test OH_HiDebug_StartAppTraceCapture. repeat start app capture trace
26106f6ba60Sopenharmony_ci * @tc.type: FUNC
26206f6ba60Sopenharmony_ci */
26306f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, OH_HiDebug_StartAppTraceCapture2, TestSize.Level1)
26406f6ba60Sopenharmony_ci{
26506f6ba60Sopenharmony_ci    uint32_t fileLength = 256;
26606f6ba60Sopenharmony_ci    char fileName[256] = {0};
26706f6ba60Sopenharmony_ci    HiDebug_TraceFlag flag = HIDEBUG_TRACE_FLAG_MAIN_THREAD;
26806f6ba60Sopenharmony_ci    uint64_t tags = HIDEBUG_TRACE_TAG_COMMON_LIBRARY;
26906f6ba60Sopenharmony_ci    uint32_t limitSize = 1024 * 1024;
27006f6ba60Sopenharmony_ci    const char* targetPath = "/data/storage/el2/log";
27106f6ba60Sopenharmony_ci    auto captureResult = OH_HiDebug_StartAppTraceCapture(flag, tags, limitSize, fileName, fileLength);
27206f6ba60Sopenharmony_ci    if (std::filesystem::exists(targetPath)) {
27306f6ba60Sopenharmony_ci        EXPECT_EQ(captureResult, HIDEBUG_SUCCESS);
27406f6ba60Sopenharmony_ci        auto captureResult2 = OH_HiDebug_StartAppTraceCapture(flag, tags, limitSize, fileName, fileLength);
27506f6ba60Sopenharmony_ci        EXPECT_EQ(captureResult2, HIDEBUG_TRACE_CAPTURED_ALREADY);
27606f6ba60Sopenharmony_ci        EXPECT_GT(sizeof(fileName) / sizeof(fileName[0]), 1);
27706f6ba60Sopenharmony_ci        EXPECT_EQ(OH_HiDebug_StopAppTraceCapture(), HIDEBUG_SUCCESS);
27806f6ba60Sopenharmony_ci    } else {
27906f6ba60Sopenharmony_ci        EXPECT_EQ(captureResult, HIDEBUG_NO_PERMISSION);
28006f6ba60Sopenharmony_ci        EXPECT_EQ(OH_HiDebug_StopAppTraceCapture(), HIDEBUG_NO_TRACE_RUNNING);
28106f6ba60Sopenharmony_ci    }
28206f6ba60Sopenharmony_ci}
28306f6ba60Sopenharmony_ci
28406f6ba60Sopenharmony_ci/**
28506f6ba60Sopenharmony_ci * @tc.name: OH_HiDebug_StartAppTraceCapture3
28606f6ba60Sopenharmony_ci * @tc.desc: test OH_HiDebug_StartAppTraceCapture. repeat stop app capture trace
28706f6ba60Sopenharmony_ci * @tc.type: FUNC
28806f6ba60Sopenharmony_ci */
28906f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, OH_HiDebug_StartAppTraceCapture3, TestSize.Level1)
29006f6ba60Sopenharmony_ci{
29106f6ba60Sopenharmony_ci    uint32_t fileLength = 256;
29206f6ba60Sopenharmony_ci    char fileName[256] = {0};
29306f6ba60Sopenharmony_ci    HiDebug_TraceFlag flag = HIDEBUG_TRACE_FLAG_MAIN_THREAD;
29406f6ba60Sopenharmony_ci    uint64_t tags = HIDEBUG_TRACE_TAG_COMMON_LIBRARY;
29506f6ba60Sopenharmony_ci    uint32_t limitSize = 1024 * 1024;
29606f6ba60Sopenharmony_ci    const char* targetPath = "/data/storage/el2/log";
29706f6ba60Sopenharmony_ci    auto captureResult = OH_HiDebug_StartAppTraceCapture(flag, tags, limitSize, fileName, fileLength);
29806f6ba60Sopenharmony_ci    if (std::filesystem::exists(targetPath)) {
29906f6ba60Sopenharmony_ci        EXPECT_EQ(captureResult, HIDEBUG_SUCCESS);
30006f6ba60Sopenharmony_ci        EXPECT_GT(sizeof(fileName) / sizeof(fileName[0]), 1);
30106f6ba60Sopenharmony_ci        EXPECT_EQ(OH_HiDebug_StopAppTraceCapture(), HIDEBUG_SUCCESS);
30206f6ba60Sopenharmony_ci        EXPECT_EQ(OH_HiDebug_StopAppTraceCapture(), HIDEBUG_NO_TRACE_RUNNING);
30306f6ba60Sopenharmony_ci    } else {
30406f6ba60Sopenharmony_ci        EXPECT_EQ(captureResult, HIDEBUG_NO_PERMISSION);
30506f6ba60Sopenharmony_ci        EXPECT_EQ(OH_HiDebug_StopAppTraceCapture(), HIDEBUG_NO_TRACE_RUNNING);
30606f6ba60Sopenharmony_ci    }
30706f6ba60Sopenharmony_ci}
30806f6ba60Sopenharmony_ci
30906f6ba60Sopenharmony_ci/**
31006f6ba60Sopenharmony_ci * @tc.name: OH_HiDebug_GetGraphicsMemory
31106f6ba60Sopenharmony_ci * @tc.desc: test OH_HiDebug_GetGraphicsMemory. get graphics memory.
31206f6ba60Sopenharmony_ci * @tc.type: FUNC
31306f6ba60Sopenharmony_ci */
31406f6ba60Sopenharmony_ciHWTEST_F(HidebugTest, OH_HiDebug_GetGraphicsMemory, TestSize.Level1)
31506f6ba60Sopenharmony_ci{
31606f6ba60Sopenharmony_ci    uint32_t value = 0;
31706f6ba60Sopenharmony_ci    EXPECT_EQ(OH_HiDebug_GetGraphicsMemory(&value), HIDEBUG_SUCCESS);
31806f6ba60Sopenharmony_ci    EXPECT_GE(value, 0);
31906f6ba60Sopenharmony_ci}
32006f6ba60Sopenharmony_ci} // namespace
321