1 /* 2 * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include <cstdlib> 17 #include <filesystem> 18 19 #include <gtest/hwext/gtest-ext.h> 20 #include <gtest/hwext/gtest-tag.h> 21 22 #include "hidebug/hidebug.h" 23 #include "hidebug/hidebug_type.h" 24 #include "hidebug_native_interface.h" 25 26 using namespace testing::ext; 27 28 namespace OHOS { 29 namespace HiviewDFX { 30 class HidebugNativeInterfaceTest : public ::testing::Test { 31 protected: SetUp()32 void SetUp() override {} TearDown()33 void TearDown() override 34 { 35 system("param set hiviewdfx.debugenv.hidebug_test 0"); 36 system("param set libc.hook_mode 0"); 37 } 38 }; 39 40 /** 41 * @tc.name: OH_HiDebug_GetGraphicsMemory 42 * @tc.desc: test OH_HiDebug_GetRealNanoSecondsTimestamp. get graphics memory. 43 * @tc.type: FUNC 44 */ 45 HWTEST_F(HidebugNativeInterfaceTest, IsDebuggerConnectedTest, TestSize.Level1) 46 { 47 auto& interface = HidebugNativeInterface::GetInstance(); 48 ASSERT_FALSE(interface.IsDebuggerConnected()); 49 } 50 51 #ifdef __aarch64__ 52 /** 53 * @tc.name: OH_HiDebug_GetGraphicsMemory 54 * @tc.desc: test OH_HiDebug_GetRealNanoSecondsTimestamp. get graphics memory. 55 * @tc.type: FUNC 56 */ 57 HWTEST_F(HidebugNativeInterfaceTest, GetMemoryLeakResourceTest, TestSize.Level1) 58 { 59 auto& interface = HidebugNativeInterface::GetInstance(); 60 ASSERT_EQ(interface.GetMemoryLeakResource("test", 10, false), MemoryState::MEMORY_SUCCESS); 61 } 62 #endif 63 } 64 }