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
16
17 #include <hiview_util.h>
18 #include <securec.h>
19 #include <hiview_config.h>
20 #include <hiview_def.h>
21 #include "hiview_output_log.h"
22 #include "log.h"
23 #include "hctest.h"
24
25 /**
26 * @tc.desc : register a test suite, this suite is used to test basic flow and interface dependency
27 * @param : subsystem name is dfx
28 * @param : module name is dfxlite
29 * @param : test suit name is DfxFuncTestSuite
30 */
31 LITE_TEST_SUIT(dfx, dfxlite, DfxFuncTestSuite);
32
33 /**
34 * @tc.setup : setup for all testcases
35 * @return : setup result, TRUE is success, FALSE is fail
36 */
DfxFuncTestSuiteSetUp(void)37 static BOOL DfxFuncTestSuiteSetUp(void)
38 {
39 return TRUE;
40 }
41
42 /**
43 * @tc.teardown : teardown for all testcases
44 * @return : teardown result, TRUE is success, FALSE is fail
45 */
DfxFuncTestSuiteTearDown(void)46 static BOOL DfxFuncTestSuiteTearDown(void)
47 {
48 printf("+-------------------------------------------+\n");
49 return TRUE;
50 }
51
52 /**
53 * @tc.number : SUB_DFX_DFT_Hilog_0100
54 * @tc.name : DebugLog print test
55 * @tc.desc : [C- SOFTWARE -0200]
56 * @tc.size : MEDIUM
57 * @tc.type : RELI
58 * @tc.level : Level 0
59 */
LITE_TEST_CASE(DfxFuncTestSuite,subDfxDftHilog0100,LEVEL0)60 LITE_TEST_CASE(DfxFuncTestSuite, subDfxDftHilog0100, LEVEL0)
61 {
62 HILOG_DEBUG(HILOG_MODULE_HIVIEW, "debuglog test pass");
63 };
64
65
66 /**
67 * @tc.number : SUB_DFX_DFT_Hilog_0200
68 * @tc.name : InfoLog print test
69 * @tc.desc : [C- SOFTWARE -0200]
70 * @tc.size : MEDIUM
71 * @tc.type : RELI
72 * @tc.level : Level 1
73 */
LITE_TEST_CASE(DfxFuncTestSuite,subDfxDftHilog0200,LEVEL1)74 LITE_TEST_CASE(DfxFuncTestSuite, subDfxDftHilog0200, LEVEL1)
75 {
76 HILOG_INFO(HILOG_MODULE_HIVIEW, "infolog test pass");
77 };
78
79 /**
80 * @tc.number : SUB_DFX_DFT_Hilog_0300
81 * @tc.name : DebugLog print test
82 * @tc.desc : [C- SOFTWARE -0200]
83 * @tc.size : MEDIUM
84 * @tc.type : RELI
85 * @tc.level : Level 1
86 */
LITE_TEST_CASE(DfxFuncTestSuite,subDfxDftHilog0300,LEVEL1)87 LITE_TEST_CASE(DfxFuncTestSuite, subDfxDftHilog0300, LEVEL1)
88 {
89 HILOG_WARN(HILOG_MODULE_HIVIEW, "warnlog test pass");
90 };
91
92 /**
93 * @tc.number : SUB_DFX_DFT_Hilog_0400
94 * @tc.name : ErrorLog print test
95 * @tc.desc : [C- SOFTWARE -0200]
96 * @tc.size : MEDIUM
97 * @tc.type : RELI
98 * @tc.level : Level 1
99 */
LITE_TEST_CASE(DfxFuncTestSuite,subDfxDftHilog0400,LEVEL1)100 LITE_TEST_CASE(DfxFuncTestSuite, subDfxDftHilog0400, LEVEL1)
101 {
102 HILOG_ERROR(HILOG_MODULE_HIVIEW, "errorlog test pass");
103 };
104
105 /**
106 * @tc.number : SUB_DFX_DFT_Hilog_0500
107 * @tc.name : FatalLog print test
108 * @tc.desc : [C- SOFTWARE -0200]
109 * @tc.size : MEDIUM
110 * @tc.type : RELI
111 * @tc.level : Level 1
112 */
LITE_TEST_CASE(DfxFuncTestSuite,subDfxDftHilog0500,LEVEL1)113 LITE_TEST_CASE(DfxFuncTestSuite, subDfxDftHilog0500, LEVEL1)
114 {
115 HILOG_FATAL(HILOG_MODULE_HIVIEW, "fatallog test pass");
116 };
117
118 /**
119 * @tc.number : SUB_DFX_DFT_Hilog_0600
120 * @tc.name : HiLogRegisterModule test
121 * @tc.desc : [C- SOFTWARE -0200]
122 * @tc.size : MEDIUM
123 * @tc.type : RELI
124 * @tc.level : Level 0
125 */
LITE_TEST_CASE(DfxFuncTestSuite,subDfxDftHilog0600,LEVEL0)126 LITE_TEST_CASE(DfxFuncTestSuite, subDfxDftHilog0600, LEVEL0)
127 {
128 BOOL ret = TRUE;
129 ret = HiLogRegisterModule(HILOG_MODULE_HIVIEW, "HIVIEW");
130 TEST_ASSERT_FALSE(ret);
131 };
132
133 /**
134 * @tc.number : SUB_DFX_DFT_Hilog_0700
135 * @tc.name : HiLogGetModuleName test
136 * @tc.desc : [C- SOFTWARE -0200]
137 * @tc.size : MEDIUM
138 * @tc.type : RELI
139 * @tc.level : Level 0
140 */
LITE_TEST_CASE(DfxFuncTestSuite,subDfxDftHilog0700,LEVEL0)141 LITE_TEST_CASE(DfxFuncTestSuite, subDfxDftHilog0700, LEVEL0)
142 {
143 const char * ret = HiLogGetModuleName(HILOG_MODULE_HIVIEW);
144 TEST_ASSERT_EQUAL_STRING(ret, "HIVIEW");
145 };
146
147 RUN_TEST_SUITE(DfxFuncTestSuite);
148