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: IsDebuggerConnectedTest 42 * @tc.desc: test IsDebuggerConnectedTest. 43 * @tc.type: FUNC 44 */ 45 HWTEST_F(HidebugNativeInterfaceTest, IsDebuggerConnectedTest, TestSize.Level0) 46 { 47 auto& interface = HidebugNativeInterface::GetInstance(); 48 ASSERT_FALSE(interface.IsDebuggerConnected()); 49 } 50 51 /** 52 * @tc.name: GetVssTest 53 * @tc.desc: test GetVssTest. get vss memory. 54 * @tc.type: FUNC 55 */ 56 HWTEST_F(HidebugNativeInterfaceTest, GetVssTest, TestSize.Level0) 57 { 58 auto& interface = HidebugNativeInterface::GetInstance(); 59 auto vssInfo = interface.GetVss(); 60 ASSERT_TRUE(vssInfo); 61 ASSERT_GE(vssInfo.value(), 0); 62 } 63 64 #ifdef __aarch64__ 65 /** 66 * @tc.name: OH_HiDebug_GetGraphicsMemory 67 * @tc.desc: test OH_HiDebug_GetRealNanoSecondsTimestamp. get graphics memory. 68 * @tc.type: FUNC 69 */ 70 HWTEST_F(HidebugNativeInterfaceTest, GetMemoryLeakResourceTest, TestSize.Level1) 71 { 72 auto& interface = HidebugNativeInterface::GetInstance(); 73 ASSERT_EQ(interface.GetMemoryLeakResource("test", 10, false), NATIVE_SUCCESS); 74 } 75 #endif 76 } 77 }