• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #include "hiview_platform_config_test.h"
16 
17 #include "hiview_platform_config.h"
18 using namespace testing::ext;
19 using namespace OHOS::HiviewDFX;
20 
SetUp()21 void HiviewPlatformConfigTest::SetUp()
22 {
23     /**
24      * @tc.setup: create an event loop and multiple event handlers
25      */
26     printf("SetUp.\n");
27 }
28 
TearDown()29 void HiviewPlatformConfigTest::TearDown()
30 {
31     /**
32      * @tc.teardown: destroy the event loop we have created
33      */
34     printf("TearDown.\n");
35 }
36 
37 /**
38  * @tc.name: PlatformConfigParse001
39  * @tc.desc: parse a correct config file and check result
40  * @tc.type: FUNC
41  * @tc.require: AR000DPTT5
42  */
43 HWTEST_F(HiviewPlatformConfigTest, PlatformConfigParse001, TestSize.Level3)
44 {
45     /**
46      * @tc.steps: step1. create event handler and events
47      */
48     HiviewPlatformConfig platformConfig = HiviewPlatformConfig("/data/test/test_data/hiview_platform_config");
49     HiviewPlatformConfig::PlatformConfigInfo platformConfigInfo;
50     bool state = platformConfig.ParsesConfig(platformConfigInfo);
51     ASSERT_EQ(true, state);
52     ASSERT_EQ(platformConfigInfo.defaultPluginConfigName, "plugin_config");
53     ASSERT_EQ(platformConfigInfo.pluginConfigFileDir, "/data/test/test_data/");
54     ASSERT_EQ(platformConfigInfo.dynamicLibSearchDir, "/system/lib/");
55     ASSERT_EQ(platformConfigInfo.dynamicLib64SearchDir, "/system/lib64/");
56     ASSERT_EQ(platformConfigInfo.workDir, "/data/test/LogService_a/");
57     ASSERT_EQ(platformConfigInfo.commercialWorkDir, "/log/LogService/");
58     ASSERT_EQ(platformConfigInfo.persistDir, "/log/hiview/");
59 }
60 
61 /**
62  * @tc.name: PlatformConfigParse002
63  * @tc.desc: parse a incorrect config file and check result
64  * @tc.type: FUNC
65  * @tc.require: issueI64QXL
66  */
67 HWTEST_F(HiviewPlatformConfigTest, PlatformConfigParse002, TestSize.Level3)
68 {
69     HiviewPlatformConfig platformConfig = HiviewPlatformConfig("//data/test/test_data/just_for_test");
70     HiviewPlatformConfig::PlatformConfigInfo platformConfigInfo;
71     auto ret = platformConfig.ParsesConfig(platformConfigInfo);
72     ASSERT_TRUE(!ret);
73 }