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