1 /* 2 * Copyright (c) 2023-2024 Huawei Device Co., Ltd. 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 <gtest/gtest.h> 17 18 #include <cstdio> 19 #include <future> 20 #include <malloc.h> 21 #include <map> 22 #include <securec.h> 23 #include <thread> 24 #include <unistd.h> 25 26 #include "dfx_ptrace.h" 27 #include "dfx_regs_get.h" 28 #include "elapsed_time.h" 29 #include "unwinder.h" 30 31 using namespace testing; 32 using namespace testing::ext; 33 34 namespace OHOS { 35 namespace HiviewDFX { 36 class AccessorsTest : public testing::Test { 37 public: SetUpTestCase()38 static void SetUpTestCase() {} TearDownTestCase()39 static void TearDownTestCase() {} SetUp()40 void SetUp() {} TearDown()41 void TearDown() {} 42 }; 43 44 /** 45 * @tc.name: IsValidFrameTest001 46 * @tc.desc: test DfxAccessorsLocal IsValidFrame interface 47 * @tc.type: FUNC 48 */ 49 HWTEST_F(AccessorsTest, IsValidFrameTest001, TestSize.Level2) 50 { 51 GTEST_LOG_(INFO) << "IsValidFrameTest001: start."; 52 auto accessors = std::make_shared<DfxAccessorsLocal>(); 53 uintptr_t stackBottom = 999; 54 uintptr_t addr = 10; 55 uintptr_t stackTop = static_cast<uintptr_t>(1); 56 ASSERT_FALSE(accessors->IsValidFrame(addr, stackBottom, stackTop)); 57 stackBottom = 1; 58 stackTop = static_cast<uintptr_t>(-1); 59 ASSERT_TRUE(accessors->IsValidFrame(addr, stackBottom, stackTop)); 60 GTEST_LOG_(INFO) << "IsValidFrameTest001: end."; 61 } 62 } // namespace HiviewDFX 63 } // namepsace OHOS