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 <stdio.h> 18 #include "gtest/gtest.h" 19 #include "log.h" 20 21 #undef LOG_TAG 22 #undef LOG_DOMAIN 23 #define LOG_TAG "Test_TAG" 24 #define LOG_DOMAIN 0xD002D00 25 26 using namespace OHOS::HiviewDFX; 27 static constexpr HiLogLabel LABEL = {LOG_CORE, 0xD002D00, "Test_TAG"}; 28 using namespace std; 29 using namespace testing::ext; 30 31 class HiLogTest : public testing::Test { 32 protected: SetUpTestCase(void)33 static void SetUpTestCase(void) {} TearDownTestCase(void)34 static void TearDownTestCase(void) {} SetUp()35 virtual void SetUp() {} TearDown()36 virtual void TearDown() {} 37 }; 38 39 /** 40 * @tc.number : Sub_Dfx_Dft_HiLog_Cortexaapi_0100 41 * @tc.name : HiLog_DEBUG parameter legal test (Cortex-A, C) 42 * @tc.desc : [C- SOFTWARE -0200] 43 */ 44 HWTEST_F(HiLogTest, subDfxDftHiLogCortexaapi0100, Function | MediumTest | Level0) 45 { 46 HILOG_DEBUG(LOG_CORE, "Debug log of HiLog API test"); 47 } 48 49 50 /** 51 * @tc.number : Sub_Dfx_Dft_HiLog_Cortexaapi_0200 52 * @tc.name : HILOG_INFO parameter legal test (Cortex-A, C) 53 * @tc.desc : [C- SOFTWARE -0200] 54 */ 55 HWTEST_F(HiLogTest, subDfxDftHiLogCortexaapi0200, Function | MediumTest | Level1) 56 { 57 HILOG_INFO(LOG_CORE, "Info log of HiLog API test"); 58 } 59 60 /** 61 * @tc.number : Sub_Dfx_Dft_HiLog_Cortexaapi_0300 62 * @tc.name : HILOG_WARN parameter legal test (Cortex-A, C) 63 * @tc.desc : [C- SOFTWARE -0200] 64 */ 65 HWTEST_F(HiLogTest, subDfxDftHiLogCortexaapi0300, Function | MediumTest | Level1) 66 { 67 HILOG_WARN(LOG_CORE, "Warn log of HiLog API test"); 68 } 69 70 /** 71 * @tc.number : Sub_Dfx_Dft_HiLog_Cortexaapi_0400 72 * @tc.name : HILOG_ERROR parameter legal test (Cortex-A, C) 73 * @tc.desc : [C- SOFTWARE -0200] 74 */ 75 HWTEST_F(HiLogTest, subDfxDftHiLogCortexaapi0400, Function | MediumTest | Level1) 76 { 77 HILOG_ERROR(LOG_CORE, "Error log of HiLog API test"); 78 } 79 80 /** 81 * @tc.number : Sub_Dfx_Dft_HiLog_Cortexaapi_0500 82 * @tc.name : HILOG_FATAL parameter legal test (Cortex-A, C) 83 * @tc.desc : [C- SOFTWARE -0200] 84 */ 85 HWTEST_F(HiLogTest, subDfxDftHiLogCortexaapi0500, Function | MediumTest | Level1) 86 { 87 HILOG_FATAL(LOG_CORE, "Fatal log of HiLog API test"); 88 } 89 90 /** 91 * @tc.number : Sub_Dfx_Dft_HiLog_Cortexaapi_0600 92 * @tc.name : HiLog::Debug parameter legal test (Cortex-A, C) 93 * @tc.desc : [C- SOFTWARE -0200] 94 */ 95 HWTEST_F(HiLogTest, subDfxDftHiLogCortexaapi0600, Function | MediumTest | Level1) 96 { 97 bool ret = true; 98 ret = HiLog::Debug(LABEL, "Debug log of HiLog API test"); 99 EXPECT_TRUE(ret); 100 } 101 102 /** 103 * @tc.number : Sub_Dfx_Dft_HiLog_Cortexaapi_0700 104 * @tc.name : HiLog::Error parameter legal test (Cortex-A, C) 105 * @tc.desc : [C- SOFTWARE -0200] 106 */ 107 HWTEST_F(HiLogTest, subDfxDftHiLogCortexaapi0700, Function | MediumTest | Level1) 108 { 109 bool ret = true; 110 ret = HiLog::Error(LABEL, "Error log of HiLog API test"); 111 EXPECT_TRUE(ret); 112 } 113 114 /** 115 * @tc.number : Sub_Dfx_Dft_HiLog_Cortexaapi_0800 116 * @tc.name : HiLog::Fatal parameter legal test (Cortex-A, C) 117 * @tc.desc : [C- SOFTWARE -0200] 118 */ 119 HWTEST_F(HiLogTest, subDfxDftHiLogCortexaapi0800, Function | MediumTest | Level1) 120 { 121 bool ret = true; 122 ret = HiLog::Fatal(LABEL, "Fatal log of HiLog API test"); 123 EXPECT_TRUE(ret); 124 } 125 126 /** 127 * @tc.number : Sub_Dfx_Dft_HiLog_Cortexaapi_0900 128 * @tc.name : HiLog::Info parameter legal test (Cortex-A, C) 129 * @tc.desc : [C- SOFTWARE -0200] 130 */ 131 HWTEST_F(HiLogTest, subDfxDftHiLogCortexaapi0900, Function | MediumTest | Level1) 132 { 133 bool ret = true; 134 ret = HiLog::Info(LABEL, "Info log of HiLog API test"); 135 EXPECT_TRUE(ret); 136 } 137 138 /** 139 * @tc.number : Sub_Dfx_Dft_HiLog_Cortexaapi_1000 140 * @tc.name : HiLog::Warn parameter legal test (Cortex-A, C) 141 * @tc.desc : [C- SOFTWARE -0200] 142 */ 143 HWTEST_F(HiLogTest, subDfxDftHiLogCortexaapi1000, Function | MediumTest | Level1) 144 { 145 bool ret = true; 146 ret = HiLog::Warn(LABEL, "Warn log of HiLog API test"); 147 EXPECT_TRUE(ret); 148 } 149