diff --git a/hiviewdfx_lite/hilog_hal/BUILD.gn b/hiviewdfx_lite/hilog_hal/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..5628d6c74359864d188b106c009582f42acad2ee --- /dev/null +++ b/hiviewdfx_lite/hilog_hal/BUILD.gn @@ -0,0 +1,34 @@ + # Copyright (c) 2020 Huawei Device Co., Ltd. + # Licensed under the Apache License, Version 2.0 (the "License"); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + +import("//test/xts/tools/build/suite_lite.gni") +hctest_suite("ActsDfxFuncTest") { + suite_name = "acts" + sources = [ + "src/dfx_hilog.c", + ] + + include_dirs = [ + "src", + "//base/hiviewdfx/interfaces/kits/hilog_lite", + "//base/hiviewdfx/interfaces/innerkits/hievent_lite", + "//base/hiviewdfx/utils/lite", + "//base/hiviewdfx/frameworks/hievent_lite", + "//base/hiviewdfx/frameworks/hilog_lite/mini", + "//base/hiviewdfx/services/hilogcat_lite/commond", + "//vendor/hisi/hi3861/hi3861/include", + "//vendor/hisi/hi3861/hi3861/components/lwip_sack/include" + ] + + cflags = [ "-Wno-error" ] +} diff --git a/hiviewdfx_lite/hilog_hal/Test.tmpl b/hiviewdfx_lite/hilog_hal/Test.tmpl new file mode 100755 index 0000000000000000000000000000000000000000..be8407e1286041a5af2bdc75a15633337376eb9d --- /dev/null +++ b/hiviewdfx_lite/hilog_hal/Test.tmpl @@ -0,0 +1,19 @@ +{ + "description": "Config for $module test cases", + "environment": [ + { + "type": "device", + "label": "wifiiot" + } + ], + "kits": [ + { + "type": "DeployKit", + "timeout": "20000", + "burn_file": "$subsystem/$module.bin" + } + ], + "driver": { + "type": "CTestLite" + } +} \ No newline at end of file diff --git a/hiviewdfx_lite/hilog_hal/src/dfx_hilog.c b/hiviewdfx_lite/hilog_hal/src/dfx_hilog.c new file mode 100755 index 0000000000000000000000000000000000000000..e83686365148798033d1fb9aa95aaeb12195ee35 --- /dev/null +++ b/hiviewdfx_lite/hilog_hal/src/dfx_hilog.c @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include +#include +#include "hos_init.h" +#include "hiview_output_log.h" +#include "log.h" +#include "hctest.h" + +/** + * @tc.desc : register a test suite, this suite is used to test basic flow and interface dependency + * @param : subsystem name is dfx + * @param : module name is dfxlite + * @param : test suit name is DfxFuncTestSuite + */ +LITE_TEST_SUIT(dfx, dfxlite, DfxFuncTestSuite); + +/** + * @tc.setup : setup for all testcases + * @return : setup result, TRUE is success, FALSE is fail + */ +static BOOL DfxFuncTestSuiteSetUp(void) +{ + return TRUE; +} + +/** + * @tc.teardown : teardown for all testcases + * @return : teardown result, TRUE is success, FALSE is fail + */ +static BOOL DfxFuncTestSuiteTearDown(void) +{ + printf("+-------------------------------------------+\n"); + return TRUE; +} + +/** + * @tc.number : SUB_DFX_DFT_Hilog_0100 + * @tc.name : DebugLog print test + * @tc.desc : [C- SOFTWARE -0200] + * @tc.size : MEDIUM + * @tc.type : RELI + * @tc.level : Level 0 + */ +LITE_TEST_CASE(DfxFuncTestSuite, subDfxDftHilog0100, LEVEL0) +{ + HILOG_DEBUG(HILOG_MODULE_HIVIEW, "debuglog test pass"); +}; + + +/** + * @tc.number : SUB_DFX_DFT_Hilog_0200 + * @tc.name : InfoLog print test + * @tc.desc : [C- SOFTWARE -0200] + * @tc.size : MEDIUM + * @tc.type : RELI + * @tc.level : Level 1 + */ +LITE_TEST_CASE(DfxFuncTestSuite, subDfxDftHilog0200, LEVEL1) +{ + HILOG_INFO(HILOG_MODULE_HIVIEW, "infolog test pass"); +}; + +/** + * @tc.number : SUB_DFX_DFT_Hilog_0300 + * @tc.name : DebugLog print test + * @tc.desc : [C- SOFTWARE -0200] + * @tc.size : MEDIUM + * @tc.type : RELI + * @tc.level : Level 1 + */ +LITE_TEST_CASE(DfxFuncTestSuite, subDfxDftHilog0300, LEVEL1) +{ + HILOG_WARN(HILOG_MODULE_HIVIEW, "warnlog test pass"); +}; + +/** + * @tc.number : SUB_DFX_DFT_Hilog_0400 + * @tc.name : ErrorLog print test + * @tc.desc : [C- SOFTWARE -0200] + * @tc.size : MEDIUM + * @tc.type : RELI + * @tc.level : Level 1 + */ +LITE_TEST_CASE(DfxFuncTestSuite, subDfxDftHilog0400, LEVEL1) +{ + HILOG_ERROR(HILOG_MODULE_HIVIEW, "errorlog test pass"); +}; + +/** + * @tc.number : SUB_DFX_DFT_Hilog_0500 + * @tc.name : FatalLog print test + * @tc.desc : [C- SOFTWARE -0200] + * @tc.size : MEDIUM + * @tc.type : RELI + * @tc.level : Level 1 + */ +LITE_TEST_CASE(DfxFuncTestSuite, subDfxDftHilog0500, LEVEL1) +{ + HILOG_FATAL(HILOG_MODULE_HIVIEW, "fatallog test pass"); +}; + +/** + * @tc.number : SUB_DFX_DFT_Hilog_0600 + * @tc.name : HiLogRegisterModule test + * @tc.desc : [C- SOFTWARE -0200] + * @tc.size : MEDIUM + * @tc.type : RELI + * @tc.level : Level 0 + */ +LITE_TEST_CASE(DfxFuncTestSuite, subDfxDftHilog0600, LEVEL0) +{ + bool ret = TRUE; + ret = HiLogRegisterModule(HILOG_MODULE_HIVIEW, "HIVIEW"); + TEST_ASSERT_FALSE(ret); +}; + +/** + * @tc.number : SUB_DFX_DFT_Hilog_0700 + * @tc.name : HiLogGetModuleName test + * @tc.desc : [C- SOFTWARE -0200] + * @tc.size : MEDIUM + * @tc.type : RELI + * @tc.level : Level 0 + */ +LITE_TEST_CASE(DfxFuncTestSuite, subDfxDftHilog0700, LEVEL0) +{ + const char * ret = HiLogGetModuleName(HILOG_MODULE_HIVIEW); + TEST_ASSERT_EQUAL_STRING(ret, "HIVIEW"); +}; + +RUN_TEST_SUITE(DfxFuncTestSuite); diff --git a/hiviewdfx_lite/hilog_posix/BUILD.gn b/hiviewdfx_lite/hilog_posix/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..d6d863a75230270e15a3d906b385256b24dfe54b --- /dev/null +++ b/hiviewdfx_lite/hilog_posix/BUILD.gn @@ -0,0 +1,35 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/lite/build/suite_lite.gni") + +hcpptest_suite("ActsHilogTest") { + suite_name = "acts" + sources = [ "src/HilogTest.cpp" ] + + include_dirs = [ + "src", + "//test/xts/tools/hctest/include", + "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/", + "//kernel/liteos_a/include/config/base/core", + ] + deps = [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared" ] + + cflags = [ "-Wno-error" ] + defines = [ "OHOS_APPEXECFWK_BMS_BUNDLEMANAGER" ] + ldflags = [ + "-lstdc++", + "-lm", + "-lpthread", + ] +} diff --git a/hiviewdfx_lite/hilog_posix/Test.json b/hiviewdfx_lite/hilog_posix/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..dee2c081df3311ec8bc20a14a80c5ca6154baafb --- /dev/null +++ b/hiviewdfx_lite/hilog_posix/Test.json @@ -0,0 +1,26 @@ + +{ + "description": "Config for kernel_lite test cases", + "environment": [ + { + "type": "device", + "label": "ipcamera" + } + ], + "kits": [ + { + "type": "MountKit", + "server": "NfsServer", + "mount": [ + { + "source": "testcases/hiviewdfx", + "target": "/test_root/hiviewdfx" + } + ] + } + ], + "driver": { + "type": "CppTestLite", + "execute": "/test_root/hiviewdfx/ActsHilogTest.bin" + } +} \ No newline at end of file diff --git a/hiviewdfx_lite/hilog_posix/src/HilogTest.cpp b/hiviewdfx_lite/hilog_posix/src/HilogTest.cpp new file mode 100755 index 0000000000000000000000000000000000000000..790a403f2a5c7716849b3b105a158ceb28871ffe --- /dev/null +++ b/hiviewdfx_lite/hilog_posix/src/HilogTest.cpp @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include "gtest/gtest.h" +#include "log.h" + +#undef LOG_TAG +#undef LOG_DOMAIN +#define LOG_TAG "Test_TAG" +#define LOG_DOMAIN 0xD002D00 + +using namespace OHOS::HiviewDFX; +static constexpr HilogLabel LABEL = {LOG_CORE, 0xD002D00, "Test_TAG"}; +using namespace std; +using namespace testing::ext; + +class HilogTest : public testing::Test { +protected: + static void SetUpTestCase(void) {} + static void TearDownTestCase(void) {} + virtual void SetUp() {} + virtual void TearDown() {} +}; + +/** + * @tc.number : Sub_Dfx_Dft_Hilog_Cortexaapi_0100 + * @tc.name : Hilog_DEBUG parameter legal test (Cortex-A, C) + * @tc.desc : [C- SOFTWARE -0200] + */ +HWTEST_F(HilogTest, subDfxDftHilogCortexaapi0100, Function | MediumTest | Level0) +{ + HILOG_DEBUG(LOG_CORE, "Debug log of Hilog API test"); +} + + +/** + * @tc.number : Sub_Dfx_Dft_Hilog_Cortexaapi_0200 + * @tc.name : HILOG_INFO parameter legal test (Cortex-A, C) + * @tc.desc : [C- SOFTWARE -0200] + */ +HWTEST_F(HilogTest, subDfxDftHilogCortexaapi0200, Function | MediumTest | Level1) +{ + HILOG_INFO(LOG_CORE, "Info log of Hilog API test"); +} + +/** + * @tc.number : Sub_Dfx_Dft_Hilog_Cortexaapi_0300 + * @tc.name : HILOG_WARN parameter legal test (Cortex-A, C) + * @tc.desc : [C- SOFTWARE -0200] + */ +HWTEST_F(HilogTest, subDfxDftHilogCortexaapi0300, Function | MediumTest | Level1) +{ + HILOG_WARN(LOG_CORE, "Warn log of Hilog API test"); +} + +/** + * @tc.number : Sub_Dfx_Dft_Hilog_Cortexaapi_0400 + * @tc.name : HILOG_ERROR parameter legal test (Cortex-A, C) + * @tc.desc : [C- SOFTWARE -0200] + */ +HWTEST_F(HilogTest, subDfxDftHilogCortexaapi0400, Function | MediumTest | Level1) +{ + HILOG_ERROR(LOG_CORE, "Error log of Hilog API test"); +} + +/** + * @tc.number : Sub_Dfx_Dft_Hilog_Cortexaapi_0500 + * @tc.name : HILOG_FATAL parameter legal test (Cortex-A, C) + * @tc.desc : [C- SOFTWARE -0200] + */ +HWTEST_F(HilogTest, subDfxDftHilogCortexaapi0500, Function | MediumTest | Level1) +{ + HILOG_FATAL(LOG_CORE, "Fatal log of Hilog API test"); +} + +/** + * @tc.number : Sub_Dfx_Dft_Hilog_Cortexaapi_0600 + * @tc.name : Hilog::Debug parameter legal test (Cortex-A, C) + * @tc.desc : [C- SOFTWARE -0200] + */ +HWTEST_F(HilogTest, subDfxDftHilogCortexaapi0600, Function | MediumTest | Level1) +{ + bool ret = True; + ret = Hilog::Debug(LABEL, "Debug log of Hilog API test"); + EXPECT_TRUE(ret); +} + +/** + * @tc.number : Sub_Dfx_Dft_Hilog_Cortexaapi_0700 + * @tc.name : Hilog::Error parameter legal test (Cortex-A, C) + * @tc.desc : [C- SOFTWARE -0200] + */ +HWTEST_F(HilogTest, subDfxDftHilogCortexaapi0700, Function | MediumTest | Level1) +{ + bool ret = True; + ret = Hilog::Error(LABEL, "Error log of Hilog API test"); + EXPECT_TRUE(ret); +} + +/** + * @tc.number : Sub_Dfx_Dft_Hilog_Cortexaapi_0800 + * @tc.name : Hilog::Fatal parameter legal test (Cortex-A, C) + * @tc.desc : [C- SOFTWARE -0200] + */ +HWTEST_F(HilogTest, subDfxDftHilogCortexaapi0800, Function | MediumTest | Level1) +{ + bool ret = True; + ret = Hilog::Fatal(LABEL, "Fatal log of Hilog API test"); + EXPECT_TRUE(ret); +} + +/** + * @tc.number : Sub_Dfx_Dft_Hilog_Cortexaapi_0900 + * @tc.name : Hilog::Info parameter legal test (Cortex-A, C) + * @tc.desc : [C- SOFTWARE -0200] + */ +HWTEST_F(HilogTest, subDfxDftHilogCortexaapi0900, Function | MediumTest | Level1) +{ + bool ret = True; + ret = Hilog::Info(LABEL, "Info log of Hilog API test"); + EXPECT_TRUE(ret); +} + +/** + * @tc.number : Sub_Dfx_Dft_Hilog_Cortexaapi_1000 + * @tc.name : Hilog::Warn parameter legal test (Cortex-A, C) + * @tc.desc : [C- SOFTWARE -0200] + */ +HWTEST_F(HilogTest, subDfxDftHilogCortexaapi1000, Function | MediumTest | Level1) +{ + bool ret = True; + ret = Hilog::Warn(LABEL, "Warn log of Hilog API test"); + EXPECT_TRUE(ret); +}