1 /*
2  * Copyright (c) 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 #include "dfx_define.h"
18 #include "dfx_param.h"
19 #include "dfx_trace.h"
20 #include "dfx_util.h"
21 
22 using namespace OHOS::HiviewDFX;
23 using namespace testing::ext;
24 using namespace std;
25 
26 namespace OHOS {
27 namespace HiviewDFX {
28 class ParamTest : public testing::Test {
29 public:
SetUpTestCase(void)30     static void SetUpTestCase(void) {}
TearDownTestCase(void)31     static void TearDownTestCase(void) {}
SetUp()32     void SetUp() {}
TearDown()33     void TearDown() {}
34 };
35 
36 /**
37  * @tc.name: DfxParamTest001
38  * @tc.desc: test DfxParam class functions
39  * @tc.type: FUNC
40  */
41 HWTEST_F(ParamTest, DfxParamTest001, TestSize.Level2)
42 {
43     GTEST_LOG_(INFO) << "DfxParamTest001: start.";
44     ASSERT_EQ(DfxParam::EnableMixstack(), true);
45     GTEST_LOG_(INFO) << "DfxParamTest001: end.";
46 }
47 
48 /**
49  * @tc.name: TraceTest001
50  * @tc.desc: test FormatTraceName functions
51  * @tc.type: FUNC
52  */
53 HWTEST_F(ParamTest, TraceTest001, TestSize.Level2)
54 {
55     GTEST_LOG_(INFO) << "TraceTest001: start.";
56     char *name = nullptr;
57     FormatTraceName(name, 0, nullptr);
58     ASSERT_EQ(name, nullptr);
59     const size_t size = 2;
60     FormatTraceName(name, size, nullptr);
61     ASSERT_EQ(name, nullptr);
62     GTEST_LOG_(INFO) << "TraceTest001: end.";
63 }
64 
65 /**
66  * @tc.name: DfxutilTest001
67  * @tc.desc: test TrimAndDupStr functions
68  * @tc.type: FUNC
69  */
70 HWTEST_F(ParamTest, DfxutilTest001, TestSize.Level2)
71 {
72     GTEST_LOG_(INFO) << "DfxutilTest001: start.";
73     std::string filePath = "";
74     std::vector<const std::string> validPaths;
75     bool ret = VerifyFilePath(filePath, validPaths);
76     ASSERT_EQ(ret, true);
77     GTEST_LOG_(INFO) << "DfxutilTest001: end.";
78 }
79 } // namespace HiviewDFX
80 } // namespace OHOS