diff --git a/hiviewdfx/BUILD.gn b/hiviewdfx/BUILD.gn index b025a8f5b889ae2187a56cae4b8e8d8320b406a8..cc5382b5397b7faab2930b93d816012d19c564d4 100755 --- a/hiviewdfx/BUILD.gn +++ b/hiviewdfx/BUILD.gn @@ -14,14 +14,6 @@ import("//build/ohos_var.gni") group("hiviewdfxtestacts") { testonly = true if (is_standard_system) { - deps = [ - "faultloggertest/faultloggercpptest:ActsFaultLoggerTest", - "hiappeventtest/hiappeventjstest:ActsHiAppEventJsTest", - "hicollietest/hicolliecpptest:ActsHiCollieCppTest", - "hilogtest/libhilogtest:libhilogtestacts", - "hisyseventtest/hisyseventcpptest:ActsHiSysEventCPPTest", - "hitracetest/hitracecpptest:ActsHitraceCPPTest", - "hitracetest/hitracectest:ActsHitraceCTest", - ] + deps = [ "hiappeventtest/hiappeventjstest:ActsHiAppEventJsTest" ] } } diff --git a/hiviewdfx/faultloggertest/faultloggercpptest/BUILD.gn b/hiviewdfx/faultloggertest/faultloggercpptest/BUILD.gn deleted file mode 100755 index 0eeb66084952e41acba90acc8f74e5b082cf64f6..0000000000000000000000000000000000000000 --- a/hiviewdfx/faultloggertest/faultloggercpptest/BUILD.gn +++ /dev/null @@ -1,41 +0,0 @@ -# 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/build/suite.gni") -module_output_path = "hits/faultloggertest" - -############################################################################### -config("faultloggertest_config") { - visibility = [ ":*" ] - include_dirs = [ - "../../utils/native", - "//utils/native/base/include/", - "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", - "genfault.h", - ] -} -ohos_moduletest_suite("ActsFaultLoggerTest") { - module_out_path = module_output_path - sources = [ - "faultloggertest.cpp", - "genfault.cpp", - ] - deps = [ - "../../utils/native:utilskit", - "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", - "//third_party/googletest:gtest_main", - "//utils/native/base:utils", - ] - - configs = [ ":faultloggertest_config" ] -} diff --git a/hiviewdfx/faultloggertest/faultloggercpptest/Test.json b/hiviewdfx/faultloggertest/faultloggercpptest/Test.json deleted file mode 100755 index 08a3f136b63ad3c7a1803002711070a326abbe52..0000000000000000000000000000000000000000 --- a/hiviewdfx/faultloggertest/faultloggercpptest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "kits": [ - { - "push": [ - "ActsFaultLoggerTest->/data/local/tmp/ActsFaultLoggerTest" - ], - "type": "PushKit" - } - ], - "driver": { - "native-test-timeout": "120000", - "type": "CppTest", - "module-name": "ActsFaultLoggerTest", - "runtime-hint": "1s", - "native-test-device-path": "/data/local/tmp" - }, - "description": "Configuration for ActsFaultLoggerTest Tests" -} \ No newline at end of file diff --git a/hiviewdfx/faultloggertest/faultloggercpptest/faultloggertest.cpp b/hiviewdfx/faultloggertest/faultloggercpptest/faultloggertest.cpp deleted file mode 100755 index 5870de2257c19270d2699a1678846105913375de..0000000000000000000000000000000000000000 --- a/hiviewdfx/faultloggertest/faultloggercpptest/faultloggertest.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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 "genfault.h" -#include "file_utils.h" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" - -#undef LOG_DOMAIN -#undef LOG_TAG -#define LOG_DOMAIN 0xD003200 -#define LOG_TAG "FAULTLOGGERTEST" -using namespace OHOS; -using namespace HiviewDFX; -using namespace testing::ext; -using namespace std; - -class faultloggertest : public testing::Test { -public: - - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp(); - void TearDown(); - pid_t DoTestProcess(int faulttype); - int status; - -private: -}; -void faultloggertest::SetUp() -{ -} -void faultloggertest::TearDown() -{ -} -void faultloggertest::SetUpTestCase() -{ -} -void faultloggertest::TearDownTestCase() -{ -} - -pid_t faultloggertest::DoTestProcess(int faulttype) -{ - printf("DoTestProcess, param is %d\r\n", faulttype); - pid_t pid; - pid = fork(); - printf("pid is %d\r\n", pid); - switch (pid) { - case -1: - std::cout<<"for pid failed"< faultfilelist; - faultfilelist = getfileinpath("/data/log/faultlog/temp/"); - printf("sizeof faultfilelist is %d\r\n", faultfilelist.size()); - bool result = false; - for (std::string filename : faultfilelist) { - printf("file list is %s\r\n", filename.c_str()); - if (filename.find("cppcrash-" + to_string(pid)) != string::npos) { - result = true; - break; - } - } - ASSERT_TRUE(true == result); -} - -/* - * @tc.name faultlogger log file check - * @tc.number DFX_DFR_FaultLogger_0100 - * @tc.desc inject a cppcrash fault and check faultlogger file -*/ -HWTEST_F(faultloggertest, Faultlogger_Faultdetect1, Function|MediumTest|Level1) -{ - pid_t pid = DoTestProcess(3); - printf("pid is %d\r\n", pid); - printf("sub process end with status %d\r\n", faultloggertest::status); - sleep(1); - std::vector faultfilelist; - faultfilelist = getfileinpath("/data/log/faultlog/temp/"); - printf("sizeof faultfilelist is %d\r\n", faultfilelist.size()); - bool result = false; - std::string faultloggerfile = ""; - for (std::string filename : faultfilelist) { - if (filename.find("cppcrash-" + to_string(pid)) != std::string::npos) { - printf("file list is %s\r\n", filename.c_str()); - faultloggerfile = filename; - break; - } - } - string fileinfo; - fileinfo = ReadFile("/data/log/faultlog/temp/" + faultloggerfile); - std::vector para = {"Pid:" + to_string(pid), "Uid:0", - "Process name:", "/data/local/tmp/faultloggertest", - "Reason:Signal:SIGILL", "Fault thread Info:", - "Tid:" + to_string(pid), "Name:faultloggertest"}; - if (!fileinfo.empty()) { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "Faultlogger_Faultdetect1 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "Faultlogger_Faultdetect1 end" << endl; -} \ No newline at end of file diff --git a/hiviewdfx/faultloggertest/faultloggercpptest/genfault.cpp b/hiviewdfx/faultloggertest/faultloggercpptest/genfault.cpp deleted file mode 100755 index 5f48c54278e51f633124927d6a83e22e5434635d..0000000000000000000000000000000000000000 --- a/hiviewdfx/faultloggertest/faultloggercpptest/genfault.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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. - */ -#ifndef TEST_COMMON_H -#define TEST_COMMON_H -#include -#include -#include -#include - -typedef enum { - FAULT_HEAP = 1, - FAULT_STACK = 2, - FAULT_NULLPTR = 3, -}FaultType; - -void FaultHeap(int value) -{ - - int* arraytest = new int[123]; - delete []arraytest; - printf("%d", arraytest[value]); -} - -void FaultStack(int value) -{ - int arraytest[123]; - printf("value of i is %d", arraytest[value]); -} - -void FaultNullPointer() -{ - const int num = 80; - int *i = nullptr; - *i = num; -} - -void GenFault(int faulttype) -{ - printf("genFault, param is %d\r\n", faulttype); - switch (faulttype) { - case FAULT_HEAP: - FaultHeap(125); - case FAULT_STACK: - FaultStack(125); - case FAULT_NULLPTR: - FaultNullPointer(); - break; - } -} -#endif \ No newline at end of file diff --git a/hiviewdfx/faultloggertest/faultloggercpptest/genfault.h b/hiviewdfx/faultloggertest/faultloggercpptest/genfault.h deleted file mode 100755 index 7dc209d33484b0c211c6b84ff3b3a0ad0e9b7e40..0000000000000000000000000000000000000000 --- a/hiviewdfx/faultloggertest/faultloggercpptest/genfault.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 "file_utils.h" -void GenFault(int faulttype); \ No newline at end of file diff --git a/hiviewdfx/hicollietest/hicolliecpptest/BUILD.gn b/hiviewdfx/hicollietest/hicolliecpptest/BUILD.gn deleted file mode 100644 index 3833ab8770cf255299faa204056d359bbf717402..0000000000000000000000000000000000000000 --- a/hiviewdfx/hicollietest/hicolliecpptest/BUILD.gn +++ /dev/null @@ -1,39 +0,0 @@ -# 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/build/suite.gni") -module_output_path = "hits/HiCollieCppTest" - -############################################################################### -config("xcollie_config") { - visibility = [ ":*" ] - include_dirs = [ - "../../utils/native", - "//utils/native/base/include/", - "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", - "//base/hiviewdfx/hicollie/interfaces/native/innerkits/include", - ] -} -ohos_moduletest_suite("ActsHiCollieCppTest") { - module_out_path = module_output_path - sources = [ "HiCollieCppTest.cpp" ] - deps = [ - "../../utils/native:utilskit", - "//base/hiviewdfx/hicollie/interfaces/native/innerkits:libhicollie", - "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", - "//third_party/googletest:gtest_main", - "//utils/native/base:utils", - ] - - configs = [ ":xcollie_config" ] -} diff --git a/hiviewdfx/hicollietest/hicolliecpptest/HiCollieCppTest.cpp b/hiviewdfx/hicollietest/hicolliecpptest/HiCollieCppTest.cpp deleted file mode 100644 index 13ef8e00d7f7daefd15e548fbf6a1db65b208739..0000000000000000000000000000000000000000 --- a/hiviewdfx/hicollietest/hicolliecpptest/HiCollieCppTest.cpp +++ /dev/null @@ -1,317 +0,0 @@ -/* - * 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 -#include - -#include -#include - -#include "xcollie/xcollie.h" -#include "xcollie/xcollie_checker.h" -#include "xcollie/xcollie_define.h" -#include "ctime" -#include "file_utils.h" - -using namespace testing; -using namespace testing::ext; -using namespace std; -using namespace OHOS::HiviewDFX; - -namespace { -int g_type = 1; -int g_blockTime; -int g_waitTime; -int g_setTimeout; -int g_updateTime = -1; -int g_cancelTimeout = -1; -} -class HiCollieCppTest : public testing::Test { -public: - int callbackCnt_; - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp(); - void TearDown(); - string ReadFileList(string basePath, string param); - bool ReadHilogcatredirectFile(string path, string context); - void XcollieTestInstance(string testItem); - void DoXCollieTest(); - void TimeCallback(void *data); - void SetCallbackCnt(int cnt); - HiCollieCppTest(); - ~HiCollieCppTest(); -private: -}; -HiCollieCppTest::HiCollieCppTest():callbackCnt_(0) -{ -} -HiCollieCppTest::~HiCollieCppTest() -{ -} -void HiCollieCppTest::SetUp() -{ - std::cout << "SetUp" << std::endl; -} -void HiCollieCppTest::TearDown() -{ - std::cout << "TearDown" << std::endl; - g_updateTime = -1; - g_cancelTimeout = -1; -} -void HiCollieCppTest::SetUpTestCase() -{ - std::cout << "SetUpTestCase" << std::endl; -} -void HiCollieCppTest::TearDownTestCase() -{ - std::cout << "TearDownTestCase" << std::endl; -} -void HiCollieCppTest::TimeCallback(void *data) -{ - callbackCnt_++; -} -void HiCollieCppTest::SetCallbackCnt(int cnt) -{ - callbackCnt_ = cnt; -} -class XCollieCheckerAssist : public XCollieChecker { - using XCollieChecker::XCollieChecker; - virtual void CheckLock() - { - // sleep 35 seconds - sleep(35); - } -}; -void HiCollieCppTest::DoXCollieTest() -{ - pid_t pid; - int status; - // Fork a child process for leak injection - pid = fork(); - if (pid == -1) { - cout<<"fail to fork!"< checker = new XCollieCheckerAssist("checker"); - XCollie::GetInstance().RegisterXCollieChecker(checker, g_type); - sleep(g_waitTime); - } -} -/** - * @tc.name Verify that when the native layer is blocked by the main thread of - * the monitored service, the service restarts after 60 seconds - * @tc.number DFX_DFR_Xcollie_Watchdog_0001 - * @tc.desc Verify that the native layer is blocked by the main thread of the monitored service -*/ -HWTEST_F(HiCollieCppTest, Xcollie_watchdog_test, Function|MediumTest|Level1) { - GTEST_LOG_(INFO) << "Xcollie_watchdog_test start" << endl; - g_type = XCOLLIE_THREAD; - g_blockTime = 61; - g_waitTime = 20; - DoXCollieTest(); - string cmd = ""; - bool result = false; - sleep(90); - std::vector cmdret; - cmd = "ps -A |grep HiCollieCppTest"; - unsigned long cmdretlen; - cmdretlen = ExecCmdWithRet(cmd, cmdret); - if (cmdretlen == 1) { - result = true; - } else { - GTEST_LOG_(INFO) << "failed to get xcollie log." << endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "Xcollie_watchdog_test end" << endl; -} -/** - * @tc.name Verify that the native layer service deadlock and - * main thread blocking are monitored at the same time - * @tc.number DFX_DFR_Xcollie_Watchdog_0002 - * @tc.desc Verify that the native layer service deadlock and main thread blocking -*/ -HWTEST_F(HiCollieCppTest, Xcollie_watchdog_test1, Function|MediumTest|Level1) { - GTEST_LOG_(INFO) << "Xcollie_watchdog_test1 start" << endl; - string cmd = ""; - bool result = false; - g_type = XCOLLIE_LOCK|XCOLLIE_THREAD; - g_blockTime = 61; - g_waitTime = 20; - DoXCollieTest(); - sleep(90); - std::vector cmdret; - cmd = "ps -A |grep HiCollieCppTest"; - unsigned long cmdretlen; - cmdretlen = ExecCmdWithRet(cmd, cmdret); - if (cmdretlen == 1) { - result = true; - } else { - GTEST_LOG_(INFO) << "failed to get xcollie log." << endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "Xcollie_watchdog_test1 end" << endl; -} -/** - * @tc.name When a deadlock occurs in the monitored service of the native layer, - * the service restarts after 60 seconds - * @tc.number DFX_DFR_Xcollie_Watchdog_0003 - * @tc.desc Verify that deadlock occurs in the monitored service of the native layer -*/ -HWTEST_F(HiCollieCppTest, Xcollie_watchdog_test2, Function|MediumTest|Level1) { - GTEST_LOG_(INFO) << "Xcollie_watchdog_test2 start" << endl; - g_type = XCOLLIE_LOCK; - g_blockTime = 30; - g_waitTime = 75; - DoXCollieTest(); - string cmd = ""; - bool result = false; - sleep(110); - std::vector cmdret; - cmd = "ps -A |grep HiCollieCppTest"; - unsigned long cmdretlen; - cmdretlen = ExecCmdWithRet(cmd, cmdret); - if (cmdretlen == 1) { - result = true; - } else { - GTEST_LOG_(INFO) << "failed to get xcollie log." << endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "Xcollie_watchdog_test2 end" << endl; -} -/** - * @tc.name verification of callback funcitons - * @tc.number DFX_DFR_Xcollie_Timeout_0001 - * @tc.desc callback funcitons - */ -HWTEST_F(HiCollieCppTest, Xcollie_Timeout_test, Function|MediumTest|Level1) { - GTEST_LOG_(INFO) << "Xcollie_Timeout_test start" << endl; - g_type = XCOLLIE_FLAG_NOOP; - SetCallbackCnt(0); - auto func = [this](void *data) { - this->TimeCallback(data); - }; - int last = XCollie::GetInstance().SetTimer("TimeoutTimer", 61, func, nullptr, g_type); - ASSERT_TRUE(last != INVALID_ID); - GTEST_LOG_(INFO) << "Xcollie_Timeout_test end" << endl; -} -/** - * @tc.name UpdateTimer interface test - * @tc.number DFX_DFR_Xcollie_interface_0001 - * @tc.desc interface test - */ -HWTEST_F(HiCollieCppTest, Xcollie_interface_test, Function|MediumTest|Level1) -{ - int id = XCollie::GetInstance().SetTimer("TimeoutTimerTest", 1, nullptr, nullptr, XCOLLIE_FLAG_NOOP); - ASSERT_NE(id, INVALID_ID); - bool result = XCollie::GetInstance().UpdateTimer(id, 1); - ASSERT_TRUE(result); -} -/** - * @tc.name UpdateTimer interface test, id is invalid - * @tc.number DFX_DFR_Xcollie_interface_0002 - * @tc.desc interface test - */ -HWTEST_F(HiCollieCppTest, Xcollie_interface_test1, Function|MediumTest|Level1) -{ - int id = -1; - int timeout = 100; - bool result = XCollie::GetInstance().UpdateTimer(id, timeout); - ASSERT_FALSE(result); -} -/** - * @tc.name UpdateTimer interface test, timeout is 0 - * @tc.number DFX_DFR_Xcollie_interface_0003 - * @tc.desc interface test - */ -HWTEST_F(HiCollieCppTest, Xcollie_interface_test2, Function|MediumTest|Level1) -{ - bool result = XCollie::GetInstance().UpdateTimer(10, 0); - ASSERT_FALSE(result); -} -/** - * @tc.name SetTimer interface test, timeout is 0 - * @tc.number DFX_DFR_Xcollie_interface_0004 - * @tc.desc interface test - */ -HWTEST_F(HiCollieCppTest, Xcollie_interface_test3, Function|MediumTest|Level1) -{ - int id = XCollie::GetInstance().SetTimer("Timer", 0, nullptr, nullptr, XCOLLIE_FLAG_NOOP); - ASSERT_EQ(id, INVALID_ID); -} -/** - * @tc.name SetTimer interface test, timeout is negative. - * @tc.number DFX_DFR_Xcollie_interface_0005 - * @tc.desc interface test - */ -HWTEST_F(HiCollieCppTest, Xcollie_interface_test4, Function|MediumTest|Level1) -{ - int id = XCollie::GetInstance().SetTimer("Timer", -2, nullptr, nullptr, XCOLLIE_FLAG_NOOP); - ASSERT_TRUE(id != INVALID_ID); -} -/** - * @tc.name SetTimer interface test, service name is very long. - * @tc.number DFX_DFR_Xcollie_interface_0006 - * @tc.desc interface test - */ -HWTEST_F(HiCollieCppTest, Xcollie_interface_test5, Function|MediumTest|Level1) -{ - std::string name = "abcd"; - for (int i = 0; i < 1000; i++) { - name += "abcd"; - } - int id = XCollie::GetInstance().SetTimer(name, 5, nullptr, nullptr, XCOLLIE_FLAG_NOOP); - ASSERT_TRUE(id != INVALID_ID); -} -/** - * @tc.name SetTimer interface test, when type is invalid. - * @tc.number DFX_DFR_Xcollie_interface_0007 - * @tc.desc interface test - */ -HWTEST_F(HiCollieCppTest, Xcollie_interface_test6, Function|MediumTest|Level1) -{ - int id = XCollie::GetInstance().SetTimer("Timer", 5, nullptr, nullptr, XCOLLIE_FLAG_NOOP + 100); - ASSERT_TRUE(id != INVALID_ID); -} \ No newline at end of file diff --git a/hiviewdfx/hicollietest/hicolliecpptest/Test.json b/hiviewdfx/hicollietest/hicolliecpptest/Test.json deleted file mode 100644 index 1b4f24550222f84e9aec75fd6dd476d1fc0dfa38..0000000000000000000000000000000000000000 --- a/hiviewdfx/hicollietest/hicolliecpptest/Test.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "kits": [ - { - "push": [ - "ActsHiCollieCppTest->/data/local/tmp/ActsHiCollieCppTest" - ], - "type": "PushKit", - "post-push": [ - "chmod -R 777 /data/local/tmp/*" - ] - } - ], - "driver": { - "native-test-timeout": "120000", - "type": "CppTest", - "module-name": "ActsHiCollieCppTest", - "runtime-hint": "1s", - "native-test-device-path": "/data/local/tmp" - }, - "description": "Configuration for ActsHiCollieCppTest Tests" -} \ No newline at end of file diff --git a/hiviewdfx/hilogtest/libhilogtest/BUILD.gn b/hiviewdfx/hilogtest/libhilogtest/BUILD.gn deleted file mode 100755 index 8346ba122f01e62d649279fa83bc3435cf7db08c..0000000000000000000000000000000000000000 --- a/hiviewdfx/hilogtest/libhilogtest/BUILD.gn +++ /dev/null @@ -1,21 +0,0 @@ -# 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. - -group("libhilogtestacts") { - testonly = true - deps = [ - "hilogtest:ActsHilogTest", - "libhilogCPPtest:ActsLibhilogCPPTest", - "libhilogCtest:ActsLibhilogCTest", - ] -} diff --git a/hiviewdfx/hilogtest/libhilogtest/hilogtest/BUILD.gn b/hiviewdfx/hilogtest/libhilogtest/hilogtest/BUILD.gn deleted file mode 100755 index a8ed71344cc7570622fb71f86581d08f93f84316..0000000000000000000000000000000000000000 --- a/hiviewdfx/hilogtest/libhilogtest/hilogtest/BUILD.gn +++ /dev/null @@ -1,38 +0,0 @@ -# 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/build/suite.gni") -module_output_path = "hits/hilogtest" - -############################################################################### -config("hilogtest_config") { - visibility = [ ":*" ] - include_dirs = [ - "../../../utils/native", - "//utils/native/base/include/", - "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", - ] -} -ohos_moduletest_suite("ActsHilogTest") { - module_out_path = module_output_path - sources = [ "hilogtest.cpp" ] - deps = [ - "../../../utils/native:utilskit", - "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", - "//third_party/googletest:gtest_main", - "//utils/native/base:utils", - ] - - #external_deps = [ "hiviewdfx_hilog_native:libhilog" ] - configs = [ ":hilogtest_config" ] -} diff --git a/hiviewdfx/hilogtest/libhilogtest/hilogtest/Test.json b/hiviewdfx/hilogtest/libhilogtest/hilogtest/Test.json deleted file mode 100755 index 407e33834f2e2c0504f4f4ff9629a47f5e5c87aa..0000000000000000000000000000000000000000 --- a/hiviewdfx/hilogtest/libhilogtest/hilogtest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "kits": [ - { - "push": [ - "ActsHilogTest->/data/local/tmp/ActsHilogTest" - ], - "type": "PushKit" - } - ], - "driver": { - "native-test-timeout": "120000", - "type": "CppTest", - "module-name": "ActsHilogTest", - "runtime-hint": "1s", - "native-test-device-path": "/data/local/tmp" - }, - "description": "Configuration for ActsHilogTest Tests" -} \ No newline at end of file diff --git a/hiviewdfx/hilogtest/libhilogtest/hilogtest/hilogtest.cpp b/hiviewdfx/hilogtest/libhilogtest/hilogtest/hilogtest.cpp deleted file mode 100755 index c9a0870b341004a26e5ea5e7ad491bfd27d01066..0000000000000000000000000000000000000000 --- a/hiviewdfx/hilogtest/libhilogtest/hilogtest/hilogtest.cpp +++ /dev/null @@ -1,1530 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include - -#include "file_utils.h" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" - -#undef LOG_DOMAIN -#undef LOG_TAG -#define LOG_DOMAIN 0xD003200 -#define LOG_TAG "HILOGTOOLTEST" -#define MAX_LINE 1024*10 -using namespace OHOS; -using namespace HiviewDFX; -using namespace testing::ext; -using namespace std; - -class hilogtest : public testing::Test { -public: - string input = ""; - string result = ""; - string expect = ""; - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp(); - void TearDown(); - string gHilogtoolExecutable = "hilog "; - string g_logContent = "123456789_1234567890_public and private log test is:\ - %{public}d, %{private}lf, %{public}.2f, %s, %{private}c\n"; - string g_commonContent = "03200/HILOGTOOLTEST: 123456789_1234567890_public and private log test is:"; -private: -}; -void hilogtest::SetUp() -{ -} -void hilogtest::TearDown() -{ -} -void hilogtest::SetUpTestCase() -{ - ExeCmd("hilog -p on"); - ExeCmd("hilog -Q domainoff"); - ExeCmd("hilog -Q pidoff"); - ExeCmd("hilog -b debug"); - ExeCmd("hilog -b debug -D 218116608"); - ExeCmd("hilog -b debug -T HILOGTOOLTEST"); - ExeCmd("hilog -r -t all"); - ExeCmd("hilog -G 1m -t all"); - ExeCmd("hilog -S -t all"); - ExeCmd("hilog -S -D 218116608"); -} -void hilogtest::TearDownTestCase() -{ - ExeCmd("hilog -p on"); - ExeCmd("hilog -Q domainoff"); - ExeCmd("hilog -Q pidoff"); - ExeCmd("hilog -b debug"); - ExeCmd("hilog -b debug -D 218116608"); - ExeCmd("hilog -b debug -T HILOGTOOLTEST"); - ExeCmd("hilog -r -t all"); - ExeCmd("hilog -G 1m -t all"); - ExeCmd("hilog -S -t all"); - ExeCmd("hilog -S -D 218116608"); - std::cout << "TearDownTestCase" << std::endl; -} - - -/* - * @tc.name one-time read - * @tc.number DFX_DFT_HilogCPP_0840 - * @tc.desc one-time read -*/ -HWTEST_F(hilogtest, Hilogtool_exit, Function|MediumTest|Level3) -{ - CleanCmd(); - std::string saveFile= "/data/local/tmp/test_data_31.txt"; - std::string cmd1 = gHilogtoolExecutable + " -r"; - std::string cmdResult; - CmdRun(cmd1, cmdResult); - LogType type = LOG_APP; - int i = 0; - while (i++ <= 5) { - usleep(1000); - HILOG_DEBUG(type, g_logContent.c_str(), i, 1.00001, 2.333333, "sse", 'a'); - } - std::string cmd2 = gHilogtoolExecutable + "-T HILOGTOOLTEST -x"; - SaveCmdOutput(cmd2, saveFile); - string hilogInfo = ReadFile(saveFile); - bool result = false; - std::vector para = {g_commonContent}; - if (hilogInfo != "") { - result = CheckInfo(para, hilogInfo); - } else { - std::cout << "Hilogtool_exit error" << std::endl; - } - ASSERT_TRUE(true == result); -} - -/* - * @tc.name The log tool can read app log types at a time. - * @tc.number DFX_DFT_HilogCPP_0860 - * @tc.desc The log tool can read app log types at a time. -*/ -HWTEST_F(hilogtest, Hilogtool_type_app, Function|MediumTest|Level3) -{ - CleanCmd(); - std::string saveFile= "/data/local/tmp/test_data_33_1.txt"; - LogType type = LOG_APP; - int i = 0; - while (i++ <= 5) { - usleep(1000); - HILOG_DEBUG(type, g_logContent.c_str(), i, 1.00001, 2.333333, "sse", 'a'); - } - std::string cmd = gHilogtoolExecutable + " -t app -x "; - SaveCmdOutput(cmd, saveFile); - string hilogInfo = ReadFile(saveFile); - bool result = false; - std::vector para = {g_commonContent}; - if (hilogInfo != " ") { - result = CheckInfo(para, hilogInfo); - } else { - std::cout << "Hilogtool_type_app error"; - } - ASSERT_TRUE(true == result); -} - - -/* - * @tc.name The log tool can read core log types at a time. - * @tc.number DFX_DFT_HilogCPP_0870 - * @tc.desc The log tool can read core log types at a time -*/ -HWTEST_F(hilogtest, Hilogtool_type_core, Function|MediumTest|Level3) -{ - CleanCmd(); - std::string saveFile= "/data/local/tmp/test_data_33_2.txt"; - LogType type = LOG_CORE; - int i = 0; - while (i++ <= 5) { - usleep(1000); - HILOG_DEBUG(type, g_logContent.c_str(), i, 1.00001, 2.333333, "sse", 'a'); - } - std::string cmd = gHilogtoolExecutable + " -t core -x "; - SaveCmdOutput(cmd, saveFile); - string hilogInfo = ReadFile(saveFile); - bool result = false; - std::vector para = {g_commonContent}; - if (hilogInfo != "") { - result = CheckInfo(para, hilogInfo); - } else { - std::cout << "Hilogtool_type_app error"< para = {g_commonContent}; - if (hilogInfo != "") { - result = CheckInfo(para, hilogInfo); - } else { - std::cout << "Hilogtool_type_init error"; - } - ASSERT_TRUE(true == result); -} - -/* - * @tc.name The log tool can read Hilogtool_type_multiple log types at a time. - * @tc.number DFX_DFT_HilogCPP_0890 - * @tc.desc The log tool can read Hilogtool_type_multiple log types at a time. -*/ -HWTEST_F(hilogtest, Hilogtool_type_multiple, Function|MediumTest|Level2) -{ - CleanCmd(); - std::string saveFile= "/data/local/tmp/test_data_33_4.txt"; - LogType type = LOG_INIT; - int i = 0; - while (i++ <= 3) { - usleep(1000); - HILOG_DEBUG(type, g_logContent.c_str(), i, 1.00001, 2.333333, "sse", 'a'); - type = LOG_INIT; - HILOG_DEBUG(type, g_logContent.c_str(), i, 1.00001, 2.333333, "sse", 'a'); - type = LOG_APP; - HILOG_DEBUG(type, g_logContent.c_str(), i, 1.00001, 2.333333, "sse", 'a'); - } - std::string cmd = gHilogtoolExecutable + "-D 0xd003200 -t app core init -x "; - SaveCmdOutput(cmd, saveFile); - string hilogInfo = ReadFile(saveFile); - bool result = false; - std::vector para = {g_commonContent}; - if (hilogInfo != "") { - result = CheckInfo(para, hilogInfo); - } else { - std::cout << "Hilogtool_type_multiple error"; - } - ASSERT_TRUE(true == result); -} - -/* - * @tc.name show local time - * @tc.number DFX_DFT_HilogCPP_0950 - * @tc.desc show local time -*/ -HWTEST_F(hilogtest, Hilogtool_time, Function|MediumTest|Level3) -{ - std::string cmd = gHilogtoolExecutable + " -a 1 -v time "; - std::string saveFile= "/data/local/tmp/test_data_35_1.txt"; - SaveCmdOutput(cmd, saveFile); - string hilogInfo = ReadFile(saveFile); - bool result = false; - std::regex pattern( - "(0\\d{1}|1[0-2])-(0\\d{1}|[12]\\d{1}|3[01])\\s(0\\d{1}|1\\d{1}|2[0-3]):[0-5]\\d{1}:([0-5]\\d{1})(\\.(\\d){0,3})?$"); - std::cout << hilogInfo.substr(0, 18); - string timeBuffer = hilogInfo.substr(0, 18); - std::smatch match; - bool ismatch = regex_match(timeBuffer, match, pattern); - if (ismatch) { - std::cout<<"match successed"< para = {g_commonContent}; - if (hilogInfo != " ") { - result = CheckInfo(para, hilogInfo); - } else { - std::cout << "Hilogtool_regex_null error"; - } - ASSERT_TRUE(true == result); -} - -/* - * @tc.name Filtering by regular expression - * @tc.number DFX_DFT_HilogCPP_1880 - * @tc.desc Filtering by regular expression -*/ -HWTEST_F(hilogtest, Hilogtool_regex, Function|MediumTest|Level3) -{ - CleanCmd(); - std::string cmd1 = gHilogtoolExecutable + " -x -e \"^(123)\""; - - char saveFile462[] = "/data/local/tmp/test_data_46_2.txt"; - SaveCmdOutput(cmd1, saveFile462); - string hilogInfo = ReadFile(saveFile462); - bool result = false; - std::vector para = {"03200/HILOGTOOLTEST"}; - if (hilogInfo != "") { - result = CheckInfo(para, hilogInfo); - } else { - std::cout << "Hilogtool_regex error"; - } - ASSERT_TRUE(true == result); - CleanCmd(); - std::string cmd2 = gHilogtoolExecutable + " -x -e \"^(www)\""; - char saveFile463[] = "test_data_46_3.txt"; - SaveCmdOutput(cmd2, saveFile463); - hilogInfo = ReadFile(saveFile463); - if (hilogInfo != " ") { - result = CheckInfo(para, hilogInfo); - } else { - std::cout << "Hilogtool_regex error"; - } - ASSERT_TRUE(false == result); -} - -/* - * @tc.name show the first 1 row - * @tc.number DFX_DFT_HilogCPP_1890 - * @tc.desc show the first 1 row -*/ - -HWTEST_F(hilogtest, Hilogtool_head_1, Function|MediumTest|Level3) -{ - CleanCmd(); - LogType type = LOG_INIT; - int cnt =20; - int i = 0; - while (i++ <= cnt) { - usleep(1); - HILOG_DEBUG(type, g_logContent.c_str(), i, 1.00001, 2.333333, "sse", 'a'); - } - std::string cmd = gHilogtoolExecutable + " -a 1 -x "; - std::string saveFile = "/data/local/tmp/test_data_47_1.txt"; - SaveCmdOutput(cmd, saveFile); - string hilogInfo = ReadFile(saveFile); - bool result = false; - std::vector para = {g_commonContent}; - if (hilogInfo != " ") { - result = CheckInfo(para, hilogInfo); - } else { - std::cout << "Hilogtool_n error"; - } - ASSERT_TRUE(true == result); -} - -/* - * @tc.name show first 20 rows - * @tc.number DFX_DFT_HilogCPP_1900 - * @tc.desc show first 20 rows -*/ -HWTEST_F(hilogtest, Hilogtool_head_20, Function|MediumTest|Level4) -{ - CleanCmd(); - LogType type = LOG_INIT; - int cnt =20; - int i = 0; - while (i++ <= cnt) { - usleep(1); - HILOG_DEBUG(type, g_logContent.c_str(), i, 1.00001, 2.333333, "sse", 'a'); - } - std::string saveFile= "/data/local/tmp/test_data_47_2.txt"; - std::string cmd = gHilogtoolExecutable + " -a 20 -x "; - SaveCmdOutput(cmd, saveFile); - int n = GetTxtLine(saveFile); - ASSERT_TRUE(n == 20); -} - -/* - * @tc.name show the last 1 row - * @tc.number DFX_DFT_HilogCPP_1910 - * @tc.desc show the last 1 row -*/ -HWTEST_F(hilogtest, Hilogtool_tail_1, Function|MediumTest|Level4) -{ - CleanCmd(); - LogType type = LOG_INIT; - int cnt =20; - int i = 0; - while (i++ <= cnt) { - usleep(1); - HILOG_DEBUG(type, g_logContent.c_str(), i, 1.00001, 2.333333, "sse", 'a'); - } - std::string saveFile= "/data/local/tmp/test_data_47_3.txt"; - std::string cmd = gHilogtoolExecutable + "-t init -z 1"; - SaveCmdOutput(cmd, saveFile); - sleep(2); - string hilogInfo = ReadFile(saveFile); - bool result = false; - std::vector para = {g_commonContent}; - if (hilogInfo != " ") { - result = CheckInfo(para, hilogInfo); - } else { - std::cout << "Hilogtool_n error"; - } - ASSERT_TRUE(true == result); -} - -/* - * @tc.name show last 20 rows - * @tc.number DFX_DFT_HilogCPP_1920 - * @tc.desc show last 20 rows -*/ -HWTEST_F(hilogtest, Hilogtool_tail_20, Function|MediumTest|Level4) -{ - CleanCmd(); - LogType type = LOG_INIT; - int cnt =20; - int i = 0; - while (i++ <= cnt) { - usleep(1); - HILOG_DEBUG(type, g_logContent.c_str(), i, 1.00001, 2.333333, "sse", 'a'); - } - std::string saveFile= "/data/local/tmp/test_data_47_4.txt"; - std::string cmd = gHilogtoolExecutable + "-t init -z 20"; - SaveCmdOutput(cmd, saveFile); - int n = GetTxtLine(saveFile); - ASSERT_TRUE(n == 20); -} - -/* - * @tc.name The filtering parameter is empty. - * @tc.number DFX_DFT_HilogCPP_1930 - * @tc.desc The filtering parameter is empty. -*/ -HWTEST_F(hilogtest, Hilogtool_filter_null, Function|MediumTest|Level4) -{ - CleanCmd(); - LogType type = LOG_INIT; - - int cnt =20; - int i = 0; - while (i++ <= cnt) { - usleep(1000); - HILOG_DEBUG(type, g_logContent.c_str(), i, 1.00001, 2.333333, "sse", 'a'); - } - std::string saveFile= "/data/local/tmp/test_data_48_1.txt"; - std::string cmd = gHilogtoolExecutable + " -t init -x"; - SaveCmdOutput(cmd, saveFile); - string hilogInfo = ReadFile(saveFile); - bool result = false; - std::vector para = {g_commonContent}; - if (hilogInfo != "") { - result = CheckInfo(para, hilogInfo); - } else { - std::cout << "Hilogtool_filter error"; - } - ASSERT_TRUE(true == result); -} - -/* - * @tc.name Filter level only. - * @tc.number DFX_DFT_HilogCPP_1960 - * @tc.desc Filter level only. -*/ - -HWTEST_F(hilogtest, Hilogtool_filter_level, Function|MediumTest|Level4) -{ - CleanCmd(); - LogType type = LOG_INIT; - int cnt =20; - int i = 0; - while (i++ <= cnt) { - usleep(1); - HILOG_DEBUG(type, g_logContent.c_str(), i, 1.00001, 2.333333, "sse", 'a'); - } - std::string saveFile= "/data/local/tmp/test_data_48_4.txt"; - std::string cmd = gHilogtoolExecutable + " -t init -L D -x"; - SaveCmdOutput(cmd, saveFile); - string hilogInfo = ReadFile(saveFile); - bool result = false; - std::vector para = {g_commonContent}; - if (hilogInfo != "") { - result = CheckInfo(para, hilogInfo); - } else { - std::cout << "Hilogtool_filter error"; - } - ASSERT_TRUE(true == result); -} - -/* - * @tc.name Filter domain only. - * @tc.number DFX_DFT_HilogCPP_1970 - * @tc.desc Filter domain only. -*/ - -HWTEST_F(hilogtest, Hilogtool_filter_domain, Function|MediumTest|Level3) -{ - CleanCmd(); - LogType type = LOG_INIT; - - int cnt =20; - int i = 0; - while (i++ <= cnt) { - usleep(1); - HILOG_DEBUG(type, g_logContent.c_str(), i, 1.00001, 2.333333, "sse", 'a'); - } - std::string saveFile= "/data/local/tmp/test_data_48_3.txt"; - std::string cmd = gHilogtoolExecutable + " -t init -D 0xd003200 -x"; - SaveCmdOutput(cmd, saveFile); - string hilogInfo = ReadFile(saveFile); - bool result = false; - std::vector para = {g_commonContent}; - if (hilogInfo != "") { - result = CheckInfo(para, hilogInfo); - } else { - std::cout << "Hilogtool_filter error"; - } - ASSERT_TRUE(true == result); -} - -/* - * @tc.name Filter tag only. - * @tc.number DFX_DFT_HilogCPP_1980 - * @tc.desc Filter tag only. -*/ -HWTEST_F(hilogtest, Hilogtool_filter_tag, Function|MediumTest|Level4) -{ - CleanCmd(); - LogType type = LOG_INIT; - int cnt = 20; - int i = 0; - while (i++ <= cnt) { - usleep(1); - HILOG_DEBUG(type, g_logContent.c_str(), i, 1.00001, 2.333333, "sse", 'a'); - } - std::string saveFile= "/data/local/tmp/test_data_48_5.txt"; - std::string cmd = gHilogtoolExecutable + " -T HILOGTOOLTEST -x"; - SaveCmdOutput(cmd, saveFile); - string hilogInfo = ReadFile(saveFile); - bool result = false; - std::vector para = {g_commonContent}; - if (hilogInfo != " ") { - result = CheckInfo(para, hilogInfo); - } else { - std::cout << "Hilogtool_filter error"; - } - ASSERT_TRUE(true == result); -} - -/* - * @tc.name Filter Multi-parameter - * @tc.number DFX_DFT_HilogCPP_1990 - * @tc.desc Filter Multi-parameter -*/ - -HWTEST_F(hilogtest, Hilogtool_filter_multiple, Function|MediumTest|Level2) -{ - CleanCmd(); - LogType type = LOG_INIT; - int i = 0; - int cnt = 20; - while (i++ <= cnt) { - usleep(1); - HILOG_DEBUG(type, g_logContent.c_str(), i, 1.00001, 2.333333, "sse", 'a'); - } - std::string saveFile= "/data/local/tmp/test_data_48_6.txt"; - std::string cmd = gHilogtoolExecutable + \ - " -T HILOGTOOLTEST -L D -x"; - SaveCmdOutput(cmd, saveFile); - string hilogInfo = ReadFile(saveFile); - bool result = false; - std::vector para = {g_commonContent}; - if (hilogInfo != " ") { - result = CheckInfo(para, hilogInfo); - } else { - std::cout << "Hilogtool_filter error"; - } - ASSERT_TRUE(true == result); -} -/* - * @tc.name Logs are not duplicated and are not lost. - * @tc.number DFX_DFT_HilogCPP_2080 - * @tc.desc Logs are not duplicated and are not lost. -*/ -HWTEST_F(hilogtest, Hilogtool_count, Function|MediumTest|Level2) -{ - CleanCmd(); - std::string saveFile= "/data/local/tmp/test_data_30.txt"; - std::string cmd1 = gHilogtoolExecutable + " -r"; - std::string cmdResult; - CmdRun(cmd1, cmdResult); - LogType type = LOG_APP; - int i = 0; - int cnt = 1000; - while (i++ < cnt) { - usleep(1); - HILOG_DEBUG(type, g_logContent.c_str(), i, 1.00001, 2.333333, "sse", 'a'); - } - std::string cmd2 = gHilogtoolExecutable + "-t app -T HILOGTOOLTEST -x"; - SaveCmdOutput(cmd2, saveFile); - ASSERT_TRUE(cnt == GetTxtLine(saveFile)); - ifstream in(saveFile); - std::string filename; - std::string line; - std::vector mVec; - if (in) { - while (getline(in, line)) { - mVec.push_back(line); - } - } else { - std::cout << "no such file" << std::endl; - } - sort(mVec.begin(), mVec.end()); - vector::iterator endUnique = unique(mVec.begin(), mVec.end()); - vector vec; - while (endUnique != mVec.end()) { - vec.push_back(*endUnique++); - } - ASSERT_TRUE(0 == vec.size()); -} -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1020 - * @tc.desc Querying the buffer size of default log types (Ccore and app) -*/ -HWTEST_F(hilogtest, buff_size_default, Function|MediumTest|Level2) -{ - result = ExecuteCmd("hilog -g"); - expect = "core buffer size is 1M\napp buffer size is 1M\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1030 - * @tc.desc Queries the buffer size of a specified type (core). -*/ -HWTEST_F(hilogtest, buff_size_core, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -g -t core"); - expect = "core buffer size is 1M\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1040 - * @tc.desc Queries the buffer size of a specified type (app). -*/ -HWTEST_F(hilogtest, buff_size_app, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -g -t app"); - expect = "app buffer size is 1M\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1050 - * @tc.desc Queries the buffer size of a specified type (init). -*/ -HWTEST_F(hilogtest, buff_size_init, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -g -t init"); - expect = "init buffer size is 1M\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1060 - * @tc.desc Queries the buffer size of multiple types -*/ -HWTEST_F(hilogtest, buff_size_multiple, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -g -t 'core app'"); - expect = "core buffer size is 1M\napp buffer size is 1M\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1070 - * @tc.desc Queries the buffer size of all types -*/ -HWTEST_F(hilogtest, buff_size_all, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -g -t all"); - expect = "core buffer size is 1M\napp buffer size is 1M\ninit buffer size is 1M\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1080 - * @tc.desc Queries the buffer size of a nonexistent type -*/ -HWTEST_F(hilogtest, buff_size_illegal, Function|MediumTest|Level4) -{ - bool ret = true; - result = ExecuteCmd("hilog -g -t abc"); - ret = result.find("Invalid log type") != std::string::npos; - EXPECT_EQ(ret, true); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1090 - * @tc.desc Queries the buffer size of multiple types, including nonexistent types. -*/ -HWTEST_F(hilogtest, buff_size_illegal2, Function|MediumTest|Level4) -{ - bool ret = true; - result = ExecuteCmd("hilog -g -t 'core abc'"); - ret = result.find("Invalid log type") != std::string::npos; - EXPECT_EQ(ret, true); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1100 - * @tc.desc Set the buffer size without unit. (The default log type is core and app.) -*/ -HWTEST_F(hilogtest, buff_resize_byte, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -G 200"); - expect = "core buffer size is 200B\napp buffer size is 200B\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); - ExeCmd("hilog -G 1m -t all"); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1110 - * @tc.desc Set the buffer size to **b. -*/ -HWTEST_F(hilogtest, buff_resize_byte2, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -G 200b"); - expect = "core buffer size is 200B\napp buffer size is 200B\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); - ExeCmd("hilog -G 1m -t all"); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1120 - * @tc.desc Set the buffer size to **B -*/ -HWTEST_F(hilogtest, buff_resize_byte3, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -G 200B"); - expect = "core buffer size is 200B\napp buffer size is 200B\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); - ExeCmd("hilog -G 1m -t all"); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1130 - * @tc.desc Set the buffer size to **k -*/ -HWTEST_F(hilogtest, buff_resize_kbyte, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -G 2k"); - expect = "core buffer size is 2K\napp buffer size is 2K\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); - ExeCmd("hilog -G 1m -t all"); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1140 - * @tc.desc Set the buffer size to **K -*/ -HWTEST_F(hilogtest, buff_resize_kbyte2, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -G 2K"); - expect = "core buffer size is 2K\napp buffer size is 2K\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); - ExeCmd("hilog -G 1m -t all"); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1150 - * @tc.desc Set the buffer size to **m -*/ -HWTEST_F(hilogtest, buff_resize_mbyte, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -G 2m"); - expect = "core buffer size is 2M\napp buffer size is 2M\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); - ExeCmd("hilog -G 1m -t all"); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1160 - * @tc.desc Set the buffer size to **M -*/ -HWTEST_F(hilogtest, buff_resize_mbyte2, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -G 2M"); - expect = "core buffer size is 2M\napp buffer size is 2M\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); - ExeCmd("hilog -G 1m -t all"); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1170 - * @tc.desc Set the buffer size to **g -*/ -HWTEST_F(hilogtest, buff_resize_gbyte, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -G 1g"); - expect = "core buffer size is 1G\napp buffer size is 1G\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); - ExeCmd("hilog -G 1m -t all"); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1180 - * @tc.desc Set the buffer size to **G -*/ -HWTEST_F(hilogtest, buff_resize_gbyte2, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -G 1G"); - expect = "core buffer size is 1G\napp buffer size is 1G\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); - ExeCmd("hilog -G 1m -t all"); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1190 - * @tc.desc Set the buffer size to 0 -*/ -HWTEST_F(hilogtest, buff_resize_illegal, Function|MediumTest|Level4) -{ - bool ret = true; - result = ExecuteCmd("hilog -G 0"); - ret = result.find("Invalid buffer size") != std::string::npos; - EXPECT_EQ(ret, true); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1200 - * @tc.desc Set the buffer size to exceed the maximum length -*/ -HWTEST_F(hilogtest, buff_resize_illegal2, Function|MediumTest|Level3) -{ - bool ret = true; - result = ExecuteCmd("hilog -G 2g"); - ret = result.find("Invalid buffer size") != std::string::npos; - EXPECT_EQ(ret, true); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1210 - * @tc.desc Set the buffer size according to a single log type (core) -*/ - -HWTEST_F(hilogtest, buff_resize_core, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -G 2m -t core"); - expect = "core buffer size is 2M\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); - ExeCmd("hilog -G 1m -t all"); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1220 - * @tc.desc Set the buffer size according to a single log type (app) -*/ -HWTEST_F(hilogtest, buff_resize_app, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -G 2m -t app"); - expect = "app buffer size is 2M\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); - ExeCmd("hilog -G 1m -t all"); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1230 - * @tc.desc Set the buffer size according to a single log type (init) -*/ -HWTEST_F(hilogtest, buff_resize_init, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -G 2m -t init"); - expect = "init buffer size is 2M\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); - ExeCmd("hilog -G 1m -t all"); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1240 - * @tc.desc Set the buffer size according to multiple log types -*/ -HWTEST_F(hilogtest, buff_resize_multyple, Function|MediumTest|Level2) -{ - result = ExecuteCmd("hilog -G 2m -t 'core app'"); - expect = "core buffer size is 2M\napp buffer size is 2M\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); - ExeCmd("hilog -G 1m -t all"); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1250 - * @tc.desc Set the buffer size of all log types -*/ -HWTEST_F(hilogtest, buff_resize_all, Function|MediumTest|Level4) -{ - result = ExecuteCmd("hilog -G 1m -t all"); - expect = "core buffer size is 1M\napp buffer size is 1M\ninit buffer size is 1M\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1260 - * @tc.desc Set the non-existent log type buffer size -*/ -HWTEST_F(hilogtest, buff_resize_illegal_type, Function|MediumTest|Level4) -{ - bool ret = true; - result = ExecuteCmd("hilog -G 2m -t abc"); - ret = result.find("Invalid log type") != std::string::npos; - EXPECT_EQ(ret, true); - ExeCmd("hilog -G 1m -t all"); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1270 - * @tc.desc Set multiple log types, including non-existent log types -*/ -HWTEST_F(hilogtest, buff_resize_illegal_type2, Function|MediumTest|Level4) -{ - bool ret = true; - result = ExecuteCmd("hilog -G 2m -t 'core abc'"); - ret = result.find("Invalid log type") != std::string::npos; - EXPECT_EQ(ret, true); - ExeCmd("hilog -G 1m -t all"); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1280 - * @tc.desc Re-query the buffer size after the setting operation -*/ -HWTEST_F(hilogtest, buff_resize_check, Function|MediumTest|Level3) -{ - // re query after set - result = ExecuteCmd("hilog -g -t all"); - expect = "core buffer size is 1M\napp buffer size is 1M\ninit buffer size is 1M\n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1290 - * @tc.desc The size of the core buffer is set to 200 bytes, and the size of logs exceeds 200 bytes. -*/ -HWTEST_F(hilogtest, buff_resize_check_core, Function|MediumTest|Level3) -{ - int i = 1; - ExeCmd("hilog -G 200 -t core"); - ExeCmd("hilog -r -t all"); - i = 1; - while (i <= 10) { - HILOG_FATAL(LOG_CORE, "123456789_1234567890_public and private log test is: \ -%{public}d, %{public}lf, %{public}.2f, %{public}s, %{public}c", i, 1.00001, 2.333333, "sse", 'a'); - i++; - } - result = ExecuteCmd("hilog -x -t core |wc -l"); - expect = "10"; - EXPECT_LT(stoi(result), stoi(expect)); - // end recover default - ExeCmd("hilog -r -t all"); - ExeCmd("hilog -G 1m -t all"); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1300 - * @tc.desc The size of the app buffer is set to 200 bytes, and the size of logs exceeds 200 bytes. -*/ -HWTEST_F(hilogtest, buff_resize_check_app, Function|MediumTest|Level4) -{ - int i = 1; - ExeCmd("hilog -G 200 -t app"); - ExeCmd("hilog -r -t all"); - i = 1; - while (i <= 10) { - HILOG_FATAL(LOG_APP, "123456789_1234567890_public and private log test is: \ -%{public}d, %{public}lf, %{public}.2f, %{public}s, %{public}c", i, 1.00001, 2.333333, "sse", 'a'); - i++; - } - result = ExecuteCmd("hilog -x -t app |wc -l"); - expect = "10"; - EXPECT_LT(stoi(result), stoi(expect)); - // end recover default - ExeCmd("hilog -r -t all"); - ExeCmd("hilog -G 1m -t all"); -} - -/* - * @tc.name buffer size test - * @tc.number DFX_DFT_HilogCPP_1310 - * @tc.desc The size of the init buffer is set to 200 bytes, and the size of logs exceeds 200 bytes. -*/ -HWTEST_F(hilogtest, buff_resize_check_init, Function|MediumTest|Level4) -{ - int i = 1; - ExeCmd("hilog -G 200 -t init"); - ExeCmd("hilog -r -t all"); - i = 1; - while (i <= 10) { - HILOG_FATAL(LOG_INIT, "123456789_1234567890_public and private log test is: \ -%{public}d, %{public}lf, %{public}.2f, %{public}s, %{public}c", i, 1.00001, 2.333333, "sse", 'a'); - i++; - } - result = ExecuteCmd("hilog -x -t init |wc -l"); - expect = "10"; - EXPECT_LT(stoi(result), stoi(expect)); - // end recover default - ExeCmd("hilog -r -t all"); - ExeCmd("hilog -G 1m -t all"); -} - -/* - * @tc.name Querying and clearing statistics by log - * @tc.number DFX_DFT_HilogCPP_1320 - * @tc.desc Query the statistics of the core log -*/ -HWTEST_F(hilogtest, statistic_info_query_core, Function|MediumTest|Level2) -{ - bool ret = true; - int i = 1; - ExeCmd("hilog -r -t all"); - ExeCmd("hilog -S -t core"); - - // write and read - i = 1; - while (i <= 1000) { - HILOG_FATAL(LOG_CORE, "123456789_1234567890_public and private log test is: \ -%{public}d, %{public}lf, %{public}.2f, %{public}s, %{public}c", i, 1.00001, 2.333333, "sse", 'a'); - i++; - } - ExeCmd("hilog -x -t core >/dev/null 2>&1"); - result = ExecuteCmd("hilog -s -t core"); - std::regex reg("core print log length is [1-9]\\w+\ncore cache log length is [1-9]\\w+\n\ -core dropped log lines is \\w+\n"); - ret = std::regex_match(result, reg); - EXPECT_EQ(ret, true); -} - -/* - * @tc.name Querying and clearing statistics by log - * @tc.number DFX_DFT_HilogCPP_1330 - * @tc.desc Query the statistics of the app log -*/ -HWTEST_F(hilogtest, statistic_info_query_app, Function|MediumTest|Level3) -{ - bool ret = true; - int i = 1; - ExeCmd("hilog -r -t all"); - ExeCmd("hilog -S -t app"); - - // write and read - i = 1; - while (i <= 1000) { - HILOG_FATAL(LOG_APP, "123456789_1234567890_public and private log test is: \ -%{public}d, %{public}lf, %{public}.2f, %{public}s, %{public}c", i, 1.00001, 2.333333, "sse", 'a'); - i++; - } - ExeCmd("hilog -x -t app >/dev/null 2>&1"); - result = ExecuteCmd("hilog -s -t app"); - std::regex reg("app print log length is [1-9]\\w+\napp cache log length is [1-9]\\w+\n\ -app dropped log lines is \\w+\n"); - ret = std::regex_match(result, reg); - EXPECT_EQ(ret, true); -} - -/* - * @tc.name Querying and clearing statistics by log - * @tc.number DFX_DFT_HilogCPP_1340 - * @tc.desc Query the statistics of the init log -*/ -HWTEST_F(hilogtest, statistic_info_query_init, Function|MediumTest|Level3) -{ - bool ret = true; - int i = 1; - ExeCmd("hilog -r -t all"); - ExeCmd("hilog -S -t init"); - // write and read - i = 1; - while (i <= 1000) { - HILOG_FATAL(LOG_INIT, "123456789_1234567890_public and private log test is: \ -%{public}d, %{public}lf, %{public}.2f, %{public}s, %{public}c", i, 1.00001, 2.333333, "sse", 'a'); - i++; - } - ExeCmd("hilog -x -t init >/dev/null 2>&1"); - result = ExecuteCmd("hilog -s -t init"); - std::regex reg("init print log length is [1-9]\\w+\ninit cache log length is [1-9]\\w+\n\ -init dropped log lines is \\w+\n"); - ret = std::regex_match(result, reg); - EXPECT_EQ(ret, true); -} - -/* - * @tc.name Querying and clearing statistics by log - * @tc.number DFX_DFT_HilogCPP_1350 - * @tc.desc Clear the statistics of the core log -*/ -HWTEST_F(hilogtest, statistic_info_clear_core, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -S -t core"); - expect = "core statistic info clear success \n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - -/* - * @tc.name Querying and clearing statistics by log - * @tc.number DFX_DFT_HilogCPP_1360 - * @tc.desc Clear the statistics of the app log -*/ -HWTEST_F(hilogtest, statistic_info_clear_app, Function|MediumTest|Level4) -{ - result = ExecuteCmd("hilog -S -t app"); - expect = "app statistic info clear success \n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - -/* - * @tc.name Querying and clearing statistics by log - * @tc.number DFX_DFT_HilogCPP_1370 - * @tc.desc Clear the statistics of the init log -*/ -HWTEST_F(hilogtest, statistic_info_clear_init, Function|MediumTest|Level4) -{ - result = ExecuteCmd("hilog -S -t init"); - expect = "init statistic info clear success \n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - -/* - * @tc.name Querying and clearing statistics by log - * @tc.number DFX_DFT_HilogCPP_1380 - * @tc.desc Query statistics of non-existent log -*/ -HWTEST_F(hilogtest, statistic_info_query_illegal, Function|MediumTest|Level3) -{ - bool ret = true; - result = ExecuteCmd("hilog -s -t abc"); - ret = result.find("Invalid log type") != std::string::npos; - EXPECT_EQ(ret, true); -} - -/* - * @tc.name Querying and clearing statistics by log - * @tc.number DFX_DFT_HilogCPP_1390 - * @tc.desc Clear statistics of non-existent log -*/ -HWTEST_F(hilogtest, statistic_info_clear_illegal, Function|MediumTest|Level4) -{ - bool ret = true; - result = ExecuteCmd("hilog -S -t abc"); - ret = result.find("Invalid log type") != std::string::npos; - EXPECT_EQ(ret, true); -} - -/* - * @tc.name Querying and clearing statistics by log - * @tc.number DFX_DFT_HilogCPP_1400 - * @tc.desc Re-query after clearing -*/ -HWTEST_F(hilogtest, statistic_info_check, Function|MediumTest|Level3) -{ - bool ret = true; - // re query after clear - ExeCmd("hilog -S -t core"); - result = ExecuteCmd("hilog -s -t core"); - std::regex reg("core print log length is \\w+\ncore cache log length is \\w+\n\ -core dropped log lines is \\w+\n"); - ret = std::regex_match(result, reg); - EXPECT_EQ(ret, true); -} - -/* - * @tc.name Querying and clearing statistics by domain - * @tc.number DFX_DFT_HilogCPP_1410 - * @tc.desc Query the statistics of the specified domain -*/ -HWTEST_F(hilogtest, statistic_info_query_domain, Function|MediumTest|Level2) -{ - bool ret = true; - int i = 1; - ExeCmd("hilog -r -t all"); - ExeCmd("hilog -S -D 218116608"); - // write and read - i = 1; - while (i <= 1000) { - HILOG_FATAL(LOG_CORE, "123456789_1234567890_public and private log test is: \ -%{public}d, %{public}lf, %{public}.2f, %{public}s, %{public}c", i, 1.00001, 2.333333, "sse", 'a'); - i++; - } - ExeCmd("hilog -x -t core >/dev/null 2>&1"); - result = ExecuteCmd("hilog -s -D 218116608"); - std::regex reg("218116608 print log length is [1-9]\\w+\n218116608 cache log length is [1-9]\\w+\n\ -218116608 dropped log lines is \\w+\n"); - ret = std::regex_match(result, reg); - EXPECT_EQ(ret, true); -} - -/* - * @tc.name Querying and clearing statistics by domain - * @tc.number DFX_DFT_HilogCPP_1420 - * @tc.desc Clear the statistics of the specified domain -*/ -HWTEST_F(hilogtest, statistic_info_clear_domain, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -S -D 218116608"); - expect = "218116608 statistic info clear success \n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - -/* - * @tc.name Querying and clearing statistics by domain - * @tc.number DFX_DFT_HilogCPP_1430 - * @tc.desc Query the statistics of nonexistent domain -*/ -HWTEST_F(hilogtest, statistic_info_query_domain2, Function|MediumTest|Level3) -{ - bool ret = true; - int i = 1; - ExeCmd("hilog -r -t all"); - ExeCmd("hilog -S -D 218116608"); - // write and read - i = 1; - while (i <= 1000) { - HILOG_FATAL(LOG_CORE, "123456789_1234567890_public and private log test is: \ -%{public}d, %{public}lf, %{public}.2f, %{public}s, %{public}c", i, 1.00001, 2.333333, "sse", 'a'); - i++; - } - ExeCmd("hilog -x -t core >/dev/null 2>&1"); - result = ExecuteCmd("hilog -s -D 1"); - std::regex reg("1 print log length is \\w+\n1 cache log length is \\w+\n1 dropped log lines is \\w+\n"); - ret = std::regex_match(result, reg); - EXPECT_EQ(ret, true); -} - -/* - * @tc.name Querying and clearing statistics by domain - * @tc.number DFX_DFT_HilogCPP_1440 - * @tc.desc Clear the statistics of nonexistent domain -*/ -HWTEST_F(hilogtest, statistic_info_clear_domain2, Function|MediumTest|Level4) -{ - result = ExecuteCmd("hilog -S -D 1"); - expect = "1 statistic info clear success \n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - - -/* - * @tc.name Clearing the logs of the corresponding buffer by log type - * @tc.number DFX_DFT_HilogCPP_1630 - * @tc.desc Clear the default logs (core、app) -*/ -HWTEST_F(hilogtest, log_clear_default, Function|MediumTest|Level2) -{ - result = ExecuteCmd("hilog -r"); - expect = "core log clear success \napp log clear success \n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - -/* - * @tc.name Clearing the logs of the corresponding buffer by log type - * @tc.number DFX_DFT_HilogCPP_1640 - * @tc.desc Clear the core log -*/ -HWTEST_F(hilogtest, log_clear_core, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -r -t core"); - expect = "core log clear success \n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - -/* - * @tc.name Clearing the logs of the corresponding buffer by log type - * @tc.number DFX_DFT_HilogCPP_1650 - * @tc.desc Clear the app log -*/ -HWTEST_F(hilogtest, log_clear_app, Function|MediumTest|Level4) -{ - result = ExecuteCmd("hilog -r -t app"); - expect = "app log clear success \n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - -/* - * @tc.name Clearing the logs of the corresponding buffer by log type - * @tc.number DFX_DFT_HilogCPP_1660 - * @tc.desc Clear the init log -*/ -HWTEST_F(hilogtest, log_clear_inti, Function|MediumTest|Level4) -{ - result = ExecuteCmd("hilog -r -t init"); - expect = "init log clear success \n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - -/* - * @tc.name Clearing the logs of the corresponding buffer by log type - * @tc.number DFX_DFT_HilogCPP_1670 - * @tc.desc Clear multiple types of logs -*/ -HWTEST_F(hilogtest, log_clear_multiple, Function|MediumTest|Level3) -{ - result = ExecuteCmd("hilog -r -t 'core app'"); - expect = "core log clear success \napp log clear success \n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - -/* - * @tc.name Clearing the logs of the corresponding buffer by log type - * @tc.number DFX_DFT_HilogCPP_1680 - * @tc.desc Clear all types of logs. -*/ -HWTEST_F(hilogtest, log_clear_all, Function|MediumTest|Level4) -{ - result = ExecuteCmd("hilog -r -t all"); - expect = "core log clear success \napp log clear success \ninit log clear success \n\n"; - EXPECT_STREQ(result.c_str(), expect.c_str()); -} - -/* - * @tc.name Clearing the logs of the corresponding buffer by log type - * @tc.number DFX_DFT_HilogCPP_1690 - * @tc.desc Clear nonexistent types of logs -*/ -HWTEST_F(hilogtest, log_clear_illegal, Function|MediumTest|Level4) -{ - bool ret = true; - result = ExecuteCmd("hilog -r -t abc"); - ret = result.find("Invalid log type") != std::string::npos; - EXPECT_EQ(ret, true); -} - -/* - * @tc.name Clearing the logs of the corresponding buffer by log type - * @tc.number DFX_DFT_HilogCPP_1700 - * @tc.desc Clear multiple types of logs including nonexistent types -*/ -HWTEST_F(hilogtest, log_clear_illegal2, Function|MediumTest|Level4) -{ - bool ret = true; - result = ExecuteCmd("hilog -r -t 'abc core'"); - ret = result.find("Invalid log type") != std::string::npos; - EXPECT_EQ(ret, true); -} diff --git a/hiviewdfx/hilogtest/libhilogtest/libhilogCPPtest/BUILD.gn b/hiviewdfx/hilogtest/libhilogtest/libhilogCPPtest/BUILD.gn deleted file mode 100755 index b6cf7598911c456ac24a2e11153f8c71ac431c27..0000000000000000000000000000000000000000 --- a/hiviewdfx/hilogtest/libhilogtest/libhilogCPPtest/BUILD.gn +++ /dev/null @@ -1,38 +0,0 @@ -# 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/build/suite.gni") -module_output_path = "hits/LibhilogCPPtest" - -############################################################################### -config("hilogtest_config") { - visibility = [ ":*" ] - include_dirs = [ - "../../../utils/native", - "//utils/native/base/include/", - "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", - ] -} -ohos_moduletest_suite("ActsLibhilogCPPTest") { - module_out_path = module_output_path - sources = [ "LibhilogCPPtest.cpp" ] - deps = [ - "../../../utils/native:utilskit", - "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", - "//third_party/googletest:gtest_main", - "//utils/native/base:utils", - ] - - #external_deps = [ "hiviewdfx_hilog_native:libhilog" ] - configs = [ ":hilogtest_config" ] -} diff --git a/hiviewdfx/hilogtest/libhilogtest/libhilogCPPtest/LibhilogCPPtest.cpp b/hiviewdfx/hilogtest/libhilogtest/libhilogCPPtest/LibhilogCPPtest.cpp deleted file mode 100755 index 6ee66479c8ea5e8bb58c7ff26ef466ba8c2bc0ef..0000000000000000000000000000000000000000 --- a/hiviewdfx/hilogtest/libhilogtest/libhilogCPPtest/LibhilogCPPtest.cpp +++ /dev/null @@ -1,1004 +0,0 @@ -/* - * 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 -#include -#include -#include -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" -#include -#include "file_utils.h" -using namespace OHOS; -using namespace HiviewDFX; -using namespace testing::ext; -#define MAX_LINE ((1024) * (10)) -#define MAXBUFFSIZE 1024 -class LibhilogCPPtest : public testing::Test { -public: - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp(); - void TearDown(); -private: -}; -void LibhilogCPPtest::SetUp() -{ - CleanCmd(); -} -void LibhilogCPPtest::TearDown() -{ -} -void LibhilogCPPtest::SetUpTestCase() -{ -} -void LibhilogCPPtest::TearDownTestCase() -{ - std::cout << "TearDownTestCase" << std::endl; -} - -/** - * @tc.name Provides user-mode interfaces(CPP)INFO - * @tc.number DFX_DFT_HilogCPP_0100 - * @tc.desc Provides user-mode interfaces(CPP)INFO - */ -HWTEST_F(LibhilogCPPtest, HILOG_INFO_CPP, Function|MediumTest|Level2) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - int i = 1; - HiLog::Info(a, "123456789_1234567890_publicandprivatelogHWTEST_Fis:%{public}d," - "%{private}lf,%{public}.2f,%s,%{private}c", i, 1.00001, 2.333333, "sse", 'a'); - std::string expected{"I 03200/HWTEST_Ftag0HWTEST_Ftag0HWTEST: \ -123456789_1234567890_publicandprivatelogHWTEST_Fis:1,,2.33,,"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - std::cout<<"cmdRunResult = " + cmdRunResult<,2.33,,"}; - sleep(1); - CmdRun("hilog -L D -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - std::cout<<"cmdRunResult = " + cmdRunResult<,2.33,,"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - std::cout<<"cmdRunResult = " + cmdRunResult<,2.33,,"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - std::cout<<"cmdRunResult = " + cmdRunResult<,2.33,,"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - std::cout<<"cmdRunResult = " + cmdRunResult<,1,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-log long integer format ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2100 - * @tc.desc libhilog-log long integer format ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_INTEGER_LONG_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "INTEGER_long:%{private}ld,%{public}ld,%ld;", 2147483647L, 2147483647L, 2147483647L); - std::string expected{"INTEGER_long:,2147483647,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-log fixed-length integer format ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2110 - * @tc.desc libhilog-log fixed-length integer format ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_INTEGER_4_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "INTEGER_4:%{private}4d,%{public}4d,%4d;", 2000, 2000, 2000); - std::string expected{"INTEGER_4:,2000,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-log short integer format ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2120 - * @tc.desc libhilog-log short integer format ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_INTEGER_SHORT_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "INTEGER_short:%{private}hd,%{public}hd,%hd;", (short)1024, (short)1024, (short)1024); - std::string expected{"INTEGER_short:,1024,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-log unsigned integer format ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2130 - * @tc.desc libhilog-log unsigned integer format ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_INTEGER_UN_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "INTEGER_un:%{private}u,%{public}u,%u;", 2147483647u, 2147483647u, 2147483647u); - std::string expected{"INTEGER_un:,2147483647,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-log unsigned long integer type identifier format ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2140 - * @tc.desc libhilog-log unsigned long integer type identifier format ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_INTEGER_LONG_UN_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "INTEGER_long_un:%{private}lu,%{public}lu,%lu;", 7483647ul, 2147483647ul, 2147483647ul); - std::string expected{"INTEGER_long_un:,2147483647,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-log unsigned fixed-length integer format ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2150 - * @tc.desc libhilog-log unsigned fixed-length integer format ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_INTEGER_4_UN_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "INTEGER_4_un:%{private}4u,%{public}4u,%4u;", 4000, 4000, 4000); - std::string expected{"INTEGER_4_un:,4000,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-log unsigned short integer type identifier format ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2160 - * @tc.desc libhilog-log unsigned short integer type identifier format ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_INTEGER_SHORT_UN_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "INTEGER_short_un:%{private}hu,%{public}hu,%hu;", (unsigned short)65535, - (unsigned short)65535, (unsigned short)65535); - std::string expected{"INTEGER_short_un:,65535,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-log float type identifier format ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2170 - * @tc.desc libhilog-log float type identifier format ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_FLOAT_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "FLOAT:%{private}f,%{public}f,%f;", 1.01, 1.01, 1.01); - std::string expected{"FLOAT:,1.010000,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-log long float type identifier format ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2180 - * @tc.desc libhilog-log long float type identifier format ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_FLOAT_LONG_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "FLOAT_long:%{private}lf,%{public}lf,%lf;", 2.147483647, 2.147483647, 2.147483647); - std::string expected{"FLOAT_long:,2.147484,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Formatting of fixed-width floating-point identifiers in - * the decimal part of the log ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2190 - * @tc.desc libhilog-Formatting of fixed-width floating-point identifiers in - * the decimal part of the log ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_FLOAT_POINT2_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "FLOAT_.2:%{private}.2f,%{public}.2f,%.2f;", 2.147483647, 2.147483647, 2.147483647); - std::string expected{"FLOAT_.2:,2.15,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Formatting of floating-point identifiers for - * the decimal part and integer part of the log ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2200 - * @tc.desc libhilog-Formatting of floating-point identifiers for - * the decimal part and integer part of the log ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_FLOAT_3POINT2_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "FLOAT_3.2:%{private}3.2f,%{public}4.1f,%2.6f;", 32.147483647, 321.147483647, 23.147483647); - std::string expected{"FLOAT_3.2:,321.1,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Formatting log characters ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2210 - * @tc.desc libhilog-Formatting log characters ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_CHAR_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "CHAR:%{private}c,%{public}c,%c;", 'a', 'b', 'c'); - std::string expected{"CHAR:,b,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Formatting log octal identifier ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2250 - * @tc.desc libhilog-Formatting log octal identifier ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_OCTAL_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "OCTAL:%{private}o,%{public}o,%o;", 15, 16, 17); - std::string expected{"OCTAL:,20,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Formatting log long octal identifier ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2260 - * @tc.desc libhilog-Formatting log long octal identifier ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_OCTAL_LONG_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "OCTAL_long:%{private}lo,%{public}lo,%lo;", 18ul, 19ul, 20ul); - std::string expected{"OCTAL_long:,23,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Formatting log hexadecimal identifiers ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2270 - * @tc.desc libhilog-Formatting log hexadecimal identifiers ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_HEX_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "HEX:%{private}x,%{public}x,%x;", 15, 16, 17); - std::string expected{"HEX:,10,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Logs with prefixes in hexadecimal format ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2280 - * @tc.desc libhilog-Logs with prefixes in hexadecimal format ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_HEX_UPPER_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "HEX_#:%{private}#x,%{public}#x,%#x;", 18, 19, 20); - std::string expected{"HEX_#:,0x13,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Logs are formatted with long hexadecimal identifiers - * ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2290 - * @tc.desc libhilog-Logs are formatted with long hexadecimal identifiers - * ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_HEX_LONG_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "HEX_long:%{private}lx,%{public}lx,%lx;", 21l, 22l, 23l); - std::string expected{"HEX_long:,16,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Logs are formatted with uppercase hexadecimal flags - * ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2300 - * @tc.desc libhilog-Logs are formatted with uppercase hexadecimal flags - * ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_HEX_X_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "HEX_X:%{private}X,%{public}X,%X;", 24u, 25u, 26u); - std::string expected{"HEX_X:,19,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Logs are formatted with uppercase and prefixes in hexadecimal format - * ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2310 - * @tc.desc libhilog-Logs are formatted with uppercase and prefixes in hexadecimal format - * ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_HEX_UPPER_X_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "HEX_#X:%{private}#X,%{public}#X,%#X;", 27, 28, 28); - std::string expected{"HEX_#X:,0X1C,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Logs are formatted with uppercase long hexadecimal identifiers - * ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2320 - * @tc.desc libhilog-Logs are formatted with uppercase long hexadecimal identifiers - * ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_HEX_LONG_UPPER_X_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "HEX_long_X:%{private}lX,%{public}lX,%lX;", 30ul, 31ul, 32ul); - std::string expected{"HEX_long_X:,1F,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Formatting Log whith string identifiers ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2220 - * @tc.desc libhilog-Formatting Log whith string identifiers ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_STR_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "STRING:%{private}s,%{public}s,%s;", "STRING1", "STRING2", "STRING3"); - std::string expected{"STRING:,STRING2,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Formatting Log whith empty string identifiers ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2240 - * @tc.desc libhilog-Formatting Log whith empty string identifiers ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_STR_EMPTY_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "STRING_empty:%{private}s,%{public}s,%s;", "", "", ""); - std::string expected{"STRING_empty:,,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Formatting Log whith Chinese identifiers ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2230 - * @tc.desc libhilog-Formatting Log whith Chinese identifiers ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_STR_CHINESE_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "STRING_Chinese:%{private}s,%{public}s,%s;", "中文", "中文", "中文"); - std::string expected{"STRING_Chinese:,中文,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Formatting Log whith scientific notation identifiers ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2330 - * @tc.desc libhilog-Formatting Log whith scientific notation identifiers ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_E_DOUBLE_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "DOUBLE_e:%{private}e,%{public}e,%e;", 1e-30, 2.231e10, 3.999e-13); - std::string expected{"DOUBLE_e:,2.231000e+10,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Formatting Log whith scientific notation capitalized identifiers - * ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2340 - * @tc.desc libhilog-Formatting Log whith scientific notation capitalized identifiers - * ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_E_UPPER_DOUBLE_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "DOUBLE_E:%{private}E,%{public}E,%E;", 4.88E2, 5.676767e-2, 6.17E13); - std::string expected{"DOUBLE_E:,5.676767E-02,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Formatting Log whith scientific notation(%g AUTO) identifiers - * ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2350 - * @tc.desc libhilog-Formatting Log whith scientific notation(%g AUTO) identifiers - * ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_E_AUTO_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "AUTO:%{private}g,%{public}g,%g;", 1e-30, 2.231e10, 3.999e-13); - std::string expected{"AUTO:,2.231e+10,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-libhilog-Formatting Log whith scientific notation(%g AUTO) capitalized - * identifiers ({public}, {private}, no identifier) - * @tc.number DFX_DFT_HilogCPP_2360 - * @tc.desc libhilog-libhilog-Formatting Log whith scientific notation(%g AUTO) capitalized - * identifiers ({public}, {private}, no identifier) - */ -HWTEST_F(LibhilogCPPtest, HILOG_E_UPPER_AUTO_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "AUTO_E:%{private}G,%{public}G,%G;", 4.88E2, 5.676767e-2, 6.17E13); - std::string expected{"AUTO_E:,0.0567677,;"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-The {private} flag parameter of mixed log formatting is hidden - * @tc.number DFX_DFT_HilogCPP_31 - * @tc.desc libhilog-The {private} flag parameter of mixed log formatting is hidden - */ -HWTEST_F(LibhilogCPPtest, HILOG_PRIVATE_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "private:%{private}d,%{private}lf,%{private}.2f,%{private}s,%{private}c", - 1, 1.00001, 2.333333, "sse", 'a'); - std::string expected{"private:,,,,"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-The parameters identified by {public} in mixed log formatting are displayed - * @tc.number DFX_DFT_HilogCPP_31 - * @tc.desc libhilog-The parameters identified by {public} in mixed log formatting are displayed - */ -HWTEST_F(LibhilogCPPtest, HILOG_PUBLIC_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "public:%{public}d,%{public}lf,%{public}.2f,%{public}s,%{public}c", - 1, 1.00001, 2.333333, "sse", 'a'); - std::string expected{"public:1,1.000010,2.33,sse,a"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Parameters without any privacy flag are not displayed in mixed log formatting - * @tc.number DFX_DFT_HilogCPP_31 - * @tc.desc libhilog-Parameters without any privacy flag are not displayed in mixed log formatting - */ -HWTEST_F(LibhilogCPPtest, HILOG_NO_SIGN_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "no_sign:%d,%lf,%.2f,%s,%c", 1, 1.00001, 2.333333, "sse", 'a'); - std::string expected{"no_sign:,,,,"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-Log privacy flags are used together, and parameters are - * correctly displayed or hidden - * @tc.number DFX_DFT_HilogCPP_31 - * @tc.desc libhilog-Log privacy flags are used together, and parameters are - * correctly displayed or hidden - */ -HWTEST_F(LibhilogCPPtest, HILOG_MIX_CPP, Function|MediumTest|Level3) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tag = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tag; - HiLog::Fatal(a, "MIX:%{public}d,%{private}lf,%{public}.2f,%s,%{private}c", 1, 1.00001, 2.333333, "sse", 'a'); - std::string expected{"MIX:1,,2.33,,"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-log are not truncated with normal length tag - * @tc.number DFX_DFT_HilogCPP_0280 - * @tc.desc libhilog-log are not truncated with normal length tag - */ -HWTEST_F(LibhilogCPPtest, TAG_CHECK_CPP, Function|MediumTest|Level2) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tagNormal = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tagNormal; - HiLog::Fatal(a, "MIX:%{public}d,%{private}lf,%{public}.2f,%s,%{private}c", 1, 1.00001, 2.333333, "sse", 'a'); - std::string expected{"03200/HWTEST_Ftag0HWTEST_Ftag0HWTEST:"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-log are truncated with too long tag - * @tc.number DFX_DFT_HilogCPP_0290 - * @tc.desc libhilog-log are truncated with too long tag - */ -HWTEST_F(LibhilogCPPtest, TAG_OVER_CHECK_CPP, Function|MediumTest|Level2) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd003200; - const char *tagToolong = "HWTEST_Ftag0HWTEST_Ftag0HWTEST_Ftag0HWTEST_Ftag0HWTEST_Ftag0" - "HWTEST_Ftag0HWTEST_Ftag0HWTEST_Ftag0HWTEST_Ftag0HWTEST_Ftag0HWTEST_Ftag0HWTEST_Ftag0"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tagToolong; - HiLog::Fatal(a, "MIX:%{public}d,%{private}lf,%{public}.2f,%s,%{private}c", 1, 1.00001, 2.333333, "sse", 'a'); - std::string expected{"03200/HWTEST_Ftag0HWTEST_Ftag0HWTEST_:"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST_", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-log domain - * @tc.number DFX_DFT_HilogCPP_0270 - * @tc.desc libhilog-log domain - */ -HWTEST_F(LibhilogCPPtest, DOMAIN_CHECK_CPP, Function|MediumTest|Level1) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - const unsigned int domain = 0xd001111; - const char *tagNormal = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tagNormal; - HiLog::Fatal(a, "MIX:%{public}d,%{private}lf,%{public}.2f,%s,%{private}c", 1, 1.00001, 2.333333, "sse", 'a'); - std::string expected{"01111/HWTEST_Ftag0HWTEST_Ftag0HWTEST:"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} - -/** - * @tc.name libhilog-log LOG_APP type test - * @tc.number DFX_DFT_HilogCPP_0280 - * @tc.desc libhilog-log LOG_APP type test - */ -HWTEST_F(LibhilogCPPtest, TYPE_APP_CHECK_CPP, Function|MediumTest|Level2) -{ - std::string cmdRunResult; - LogType type = LOG_APP; - const unsigned int domain = 0xd003200; - const char *tagNormal = "HWTEST_Ftag0HWTEST_Ftag0HWTEST"; - HiLogLabel a; - a.type = type; - a.domain = domain; - a.tag = tagNormal; - HiLog::Fatal(a, "MIX:%{public}d,%{private}lf,%{public}.2f,%s,%{private}c", 1, 1.00001, 2.333333, "sse", 'a'); - std::string expected{"03200/HWTEST_Ftag0HWTEST_Ftag0HWTEST:"}; - sleep(1); - CmdRun("hilog -x | grep HWTEST_Ftag0HWTEST_Ftag0HWTEST", cmdRunResult); - ASSERT_TRUE(cmdRunResult.find(expected) != std::string::npos); -} diff --git a/hiviewdfx/hilogtest/libhilogtest/libhilogCPPtest/Test.json b/hiviewdfx/hilogtest/libhilogtest/libhilogCPPtest/Test.json deleted file mode 100755 index 31580276b235c55add1ccfc9d61a4dfaeaa9dff4..0000000000000000000000000000000000000000 --- a/hiviewdfx/hilogtest/libhilogtest/libhilogCPPtest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "kits": [ - { - "push": [ - "ActsLibhilogCPPTest->/data/local/tmp/ActsLibhilogCPPTest" - ], - "type": "PushKit" - } - ], - "driver": { - "native-test-timeout": "120000", - "type": "CppTest", - "module-name": "ActsLibhilogCPPTest", - "runtime-hint": "1s", - "native-test-device-path": "/data/local/tmp" - }, - "description": "Configuration for ActsLibhilogCPPTest Tests" -} \ No newline at end of file diff --git a/hiviewdfx/hilogtest/libhilogtest/libhilogCtest/BUILD.gn b/hiviewdfx/hilogtest/libhilogtest/libhilogCtest/BUILD.gn deleted file mode 100755 index 90ba99e2c4b5281abeacbcfa01a882a161ec1e7c..0000000000000000000000000000000000000000 --- a/hiviewdfx/hilogtest/libhilogtest/libhilogCtest/BUILD.gn +++ /dev/null @@ -1,38 +0,0 @@ -# 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/build/suite.gni") -module_output_path = "hits/libhilogCtest" - -############################################################################### -config("hilogtest_config") { - visibility = [ ":*" ] - include_dirs = [ - "../../../utils/native", - "//utils/native/base/include/", - "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", - ] -} -ohos_moduletest_suite("ActsLibhilogCTest") { - module_out_path = module_output_path - sources = [ "libhilogCtest.cpp" ] - deps = [ - "../../../utils/native:utilskit", - "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", - "//third_party/googletest:gtest_main", - "//utils/native/base:utils", - ] - - #external_deps = [ "hiviewdfx_hilog_native:libhilog" ] - configs = [ ":hilogtest_config" ] -} diff --git a/hiviewdfx/hilogtest/libhilogtest/libhilogCtest/Test.json b/hiviewdfx/hilogtest/libhilogtest/libhilogCtest/Test.json deleted file mode 100755 index 513f4fef9d5c20ea8362a799883df9ebbd937b8e..0000000000000000000000000000000000000000 --- a/hiviewdfx/hilogtest/libhilogtest/libhilogCtest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "kits": [ - { - "push": [ - "ActsLibhilogCTest->/data/local/tmp/ActsLibhilogCTest" - ], - "type": "PushKit" - } - ], - "driver": { - "native-test-timeout": "120000", - "type": "CppTest", - "module-name": "ActsLibhilogCTest", - "runtime-hint": "1s", - "native-test-device-path": "/data/local/tmp" - }, - "description": "Configuration for ActsLibhilogCTest Tests" -} \ No newline at end of file diff --git a/hiviewdfx/hilogtest/libhilogtest/libhilogCtest/libhilogCtest.cpp b/hiviewdfx/hilogtest/libhilogtest/libhilogCtest/libhilogCtest.cpp deleted file mode 100755 index 5de1310c2bee49c707fde6e3bdfbba4e2f9fe190..0000000000000000000000000000000000000000 --- a/hiviewdfx/hilogtest/libhilogtest/libhilogCtest/libhilogCtest.cpp +++ /dev/null @@ -1,796 +0,0 @@ -/* - * 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 -#include -#include -#include -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" -#include -#include "file_utils.h" - -#undef LOG_DOMAIN -#undef LOG_TAG -#define LOG_DOMAIN 0xD003E00 -#define LOG_TAG "testtag0testtag0testtag0testta" -using namespace std; -using namespace testing::ext; - -class LibhilogCtest : public testing::Test { -public: - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp(); - void TearDown(); -private: -}; -void LibhilogCtest::SetUp() -{ - CleanCmd(); -} -void LibhilogCtest::TearDown() -{ -} -void LibhilogCtest::SetUpTestCase() -{ -} -void LibhilogCtest::TearDownTestCase() -{ - std::cout << "TearDownTestCase" << std::endl; -} - -/** - * @tc.name Provides user-mode interfaces(C)INFO - * @tc.number DFX_DFT_HilogC_0180 - * @tc.desc Provides user-mode interfaces(C)INFO - */ -HWTEST_F(LibhilogCtest, HILOG_INFO, Function|MediumTest|Level2) -{ - std::string cmdRunResult; - LogType type = LOG_CORE; - int i = 1; - HILOG_INFO(type, "123456789_1234567890_publicandprivatelogtestis:%{public}d," - "%{private}lf,%{public}.2f,%s,%{private}c", i, 1.00001, 2.333333, "sse", 'a'); - std::string expected{"I 03e00/testtag0testtag0testtag0testta: \ -123456789_1234567890_publicandprivatelogtestis:1,,2.33,,"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<<"cmdRunResult = " + cmdRunResult<,2.33,,"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,2.33,,"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,2.33,,"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,2.33,,"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,1,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,2147483647,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,2000,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,1024,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,2147483647,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,2147483647,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,4000,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,65535,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,1.010000,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,2.147484,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,2.15,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,321.1,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,b,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,20,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,23,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,10,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,0x13,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,16,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,19,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,0X1C,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,1F,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,STRING2,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,中文,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,2.231000e+10,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,5.676767E-02,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,2.231e+10,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,0.0567677,;"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,,,,"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,,,,"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout<,2.33,,"}; - CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); - std::cout< - -#include "file_utils.h" -#include "hisysevent.h" - -using namespace testing; -using namespace testing::ext; -using namespace std; -using namespace OHOS::HiviewDFX; -namespace { -string g_key = "key"; -string g_reDiRectTimeout = "6"; -string g_hiLogRedirect = "/data/local/tmp/hilogredirect.log"; -} -class HiSysEventCPPTest : public testing::Test { -public: - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp(); - void TearDown(); - void RedHiSysEventLog(std::string &hilogredirect, std::string &timeout); -private: -}; -void HiSysEventCPPTest::SetUp() -{ - std::cout << "SetUp" << std::endl; - CleanCmd(); -} -void HiSysEventCPPTest::TearDown() -{ - std::cout << "TearDown" << std::endl; - std::vector cmdret; - string cmd = "rm " + g_hiLogRedirect; - ExecCmdWithRet(cmd, cmdret); -} -void HiSysEventCPPTest::SetUpTestCase() -{ - std::cout << "SetUpTestCase" << std::endl; - std::vector cmdret; - string cmd = "mkdir /data/local/tmp/"; - ExecCmdWithRet(cmd, cmdret); -} -void HiSysEventCPPTest::TearDownTestCase() -{ - std::cout << "TearDownTestCase" << std::endl; -} -void HiSysEventCPPTest::RedHiSysEventLog(std::string &hilogredirect, std::string &timeout) -{ - unsigned long i; - std::vector cmdret; - unsigned long cmdretlen; - std::string cmd = "rm " + hilogredirect; - cmdretlen = ExecCmdWithRet(cmd, cmdret); - for (i = 0; i < cmdretlen; i++) { - std::cout<" + hilogredirect; - std::cout< para = {"AAFWK", "eventNameDemo", "\"type_\":1", "\"key\":0"}; - if (!fileinfo.empty()) { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_0100 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0100 end" << endl; -} -/** -* @tc.name HiSysEvent Native Write Interface Test, Reported When the KeyValue Is of -* the boolean Type and the bool Value Is False -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_0200 -* @tc.desc The keyvalue is of the boolean type and the bool value is true. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0200, Function|MediumTest|Level3) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0200 start" << endl; - bool result = false; - bool param = true; - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::APPEXECFWK; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"APPEXECFWK", "eventNameDemo", "\"type_\":1", "\"key\":1"}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_0200 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0200 end" << endl; -} -/** -* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Keyvalue of the Boolean List Type -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_0300 -* @tc.desc The value of keyvalue is a boolean list. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0300, Function|MediumTest|Level3) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0300 start" << endl; - bool result = false; - bool param = false; - std::vector test; - test.push_back(param); - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::ACCOUNT; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"ACCOUNT", "eventNameDemo", "\"type_\":1", "\"key\":[0]"}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_0300 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0300 end" << endl; -} -/** -* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Key Value of the Char Type -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_0400 -* @tc.desc The keyvalue is of the char type. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0400, Function|MediumTest|Level3) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0400 start" << endl; - bool result = false; - char param = 'a'; - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::OTHERS; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"OTHERS", "eventNameDemo", "\"type_\":1", "\"key\":97"}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_0400 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0400 end" << endl; -} -/** -* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Keyvalue of the Char List Type -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_0500 -* @tc.desc keyvalue is of the char list type. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0500, Function|MediumTest|Level3) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0500 start" << endl; - bool result = false; - char param = 'a'; - std::vector test; - test.push_back(param); - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::WEARABLE; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"WEARABLE", "eventNameDemo", "\"type_\":1", "\"key\":[97]"}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_0500 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0500 end" << endl; -} -/** -* @tc.name HiSysEvent Natvie Write Interface Test, Reported When the KeyValue Is of the Double Type -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_0600 -* @tc.desc The keyvalue is of the double type. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0600, Function|MediumTest|Level2) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0600 start" << endl; - bool result = false; - double param = 30949.374; - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::WEARABLE_HARDWARE; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"WEARABLEHW", "eventNameDemo", "\"type_\":1", "\"key\":30949.4"}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_0600 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0600 end" << endl; -} -/** -* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Keyvalue of the Char List Type -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_0700 -* @tc.desc keyvalue is of the char list type. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0700, Function|MediumTest|Level3) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0700 start" << endl; - bool result = false; - double param = 30949.374; - std::vector test; - test.push_back(param); - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::USB; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"USB", "eventNameDemo", "\"type_\":1", "\"key\":[30949.4]"}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_0700 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0700 end" << endl; -} -/** -* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Key Value of the Floating Type -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_0800 -* @tc.desc The keyvalue is of the float type. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0800, Function|MediumTest|Level3) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0800 start" << endl; - bool result = false; - float param = 230.47; - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::UPDATE; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"UPDATE", "eventNameDemo", "\"type_\":1", "\"key\":230.47"}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_0800 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0800 end" << endl; -} -/** -* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Keyvalue of the Char List Type -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_0900 -* @tc.desc keyvalue is of the char list type. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0900, Function|MediumTest|Level3) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0900 start" << endl; - bool result = false; - float param = 230.47; - std::vector test; - test.push_back(param); - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::TELEPHONY; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"TELEPHONY", "eventNameDemo", "\"type_\":1", "\"key\":[230.47]"}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_0900 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0900 end" << endl; -} -/** -* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Keyvalue of the Int Type -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_1000 -* @tc.desc The keyvalue is of the int type. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1000, Function|MediumTest|Level3) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1000 start" << endl; - bool result = false; - int param = 100; - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::STARTUP; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"STARTUP", "eventNameDemo", "\"type_\":1", "\"key\":100"}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_1000 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1000 end" << endl; -} -/** -* @tc.name HiSysEvent Natvie Write Interface Test, Reporting of the int List of KeyValues -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_1100 -* @tc.desc keyvalue is of the int list type. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1100, Function|MediumTest|Level3) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1100 start" << endl; - bool result = false; - int param = 100; - std::vector test; - test.push_back(param); - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::SOURCE_CODE_TRANSFORMER; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"SRCTRANSFORMER", "eventNameDemo", "\"type_\":1", "\"key\":[100]"}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_1100 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1100 end" << endl; -} -/** -* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Key Value of the Long Type -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_1200 -* @tc.desc The keyvalue is of the long type. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1200, Function|MediumTest|Level3) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1200 start" << endl; - bool result = false; - long param = 1000000; - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::SENSORS; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"SENSORS", "eventNameDemo", "\"type_\":1", "\"key\":1000000"}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_1200 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1200 end" << endl; -} -/** -* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the List of the Long Key Value -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_1300 -* @tc.desc The keyvalue is of the long list type. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1300, Function|MediumTest|Level3) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1300 start" << endl; - bool result = false; - long param = 1000000; - std::vector test; - test.push_back(param); - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::SECURITY; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"SECURITY", "eventNameDemo", "\"type_\":1", "\"key\":[1000000]"}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_1300 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1300 end" << endl; -} -/** -* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Key Value of the Short Type -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_1400 -* @tc.desc The keyvalue is of the short type. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1400, Function|MediumTest|Level3) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0250 start" << endl; - bool result = false; - short param = 10; - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::ROUTER; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"ROUTER", "eventNameDemo", "\"type_\":1", "\"key\":10"}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_1400 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1400 end" << endl; -} -/** -* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the List of Short Key Values -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_1500 -* @tc.desc The keyvalue is of the short list type. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1500, Function|MediumTest|Level3) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1500 start" << endl; - bool result = false; - short param = 10; - std::vector test; - test.push_back(param); - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::POWERMGR; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"POWERMGR", "eventNameDemo", "\"type_\":2", "\"key\":[10]"}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_1500 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1500 end" << endl; -} -/** -* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Key Value of the String Type -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_1600 -* @tc.desc The keyvalue is of the string type. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1600, Function|MediumTest|Level2) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1600 start" << endl; - bool result = false; - string param = "abc"; - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::NOTIFICATION; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"NOTIFICATION", "eventNameDemo", "\"type_\":2", "\"key\":\"abc\""}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_1600 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1600 end" << endl; -} -/** -* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the List of Short Key Values -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_1700 -* @tc.desc The keyvalue is of the short list type. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1700, Function|MediumTest|Level3) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1700 start" << endl; - bool result = false; - string param = "abc"; - std::vector test; - test.push_back(param); - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::MULTI_MODAL_INPUT; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::SECURITY; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"MULTIMODALINPUT", "eventNameDemo", "\"type_\":3", "\"key\":[\"abc\"]"}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_1700 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1700 end" << endl; -} -/** -* @tc.name HiSysEvent Natvie Write Interface Test, Reporting the List of 20 List Parameters When the Key Value Is String -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_1800 -* @tc.desc The keyvalue is reported as a string list. There are 20 list parameters. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1800, Function|MediumTest|Level4) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0290 start" << endl; - bool result = false; - string param = "abc"; - std::vector test; - for (int i = 0; i < 20; i++) { - test.push_back(param); - } - string str = "\"key\":["; - for (int i = 0; i < 19; i++) { - str = str + "\"abc\","; - } - str = str + "\"abc\"]"; - GTEST_LOG_(INFO) << str << endl; - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::MULTI_MEDIA; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::SECURITY; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"MULTIMEDIA", "eventNameDemo", "\"type_\":3", str}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_1800 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1800 end" << endl; -} -/** -* @tc.name In the HiSysEvent Natvie Write interface test, 32 parameters are reported for each type of keyvalue. -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_2000 -* @tc.desc The keyvalue parameter has 32 parameters for each type. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_2000, Function|MediumTest|Level3) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_2000 start" << endl; - bool result = false; - string param = "abc"; - string str = ""; - for (int i=0; i < 31; i++){ - str = str + "\"key\":\"abc\","; - } - str += "\"key\":\"abc\""; - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::MSDP; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, - g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, - g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, - g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, - g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, - g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, - g_key, param, g_key, param); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"MSDP", "eventNameDemo", "\"type_\":4", str}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_2000 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_2000 end" << endl; -} -/** -* @tc.name In the test of the HiSysEvent Natvie Write interface, the key value is a string of 256 characters. -* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_2200 -* @tc.desc The keyvalue is a string of 256 characters. -*/ -HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_2200, Function|MediumTest|Level3) -{ - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_2200 start" << endl; - bool result = false; - string param = ""; - for (int i = 0; i < 256; i++) { - param += "a"; - } - string domain = OHOS::HiviewDFX::HiSysEvent::Domain::LOCATION; - OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR; - OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param); - RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); - string fileinfo = ""; - fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"LOCATION", "eventNameDemo", "\"type_\":4", g_key, param}; - if (fileinfo != "") { - result = CheckInfo(para, fileinfo); - } else { - std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_2200 file error" << std::endl; - } - ASSERT_TRUE(result); - GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_2200 end" << endl; -} diff --git a/hiviewdfx/hisyseventtest/hisyseventcpptest/Test.json b/hiviewdfx/hisyseventtest/hisyseventcpptest/Test.json deleted file mode 100755 index 912f686b24b439b53cb6e20a8aadeac47480cdb2..0000000000000000000000000000000000000000 --- a/hiviewdfx/hisyseventtest/hisyseventcpptest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "kits": [ - { - "push": [ - "ActsHiSysEventCPPTest->/data/local/tmp/ActsHiSysEventCPPTest" - ], - "type": "PushKit" - } - ], - "driver": { - "native-test-timeout": "120000", - "type": "CppTest", - "module-name": "ActsHiSysEventCPPTest", - "runtime-hint": "1s", - "native-test-device-path": "/data/local/tmp" - }, - "description": "Configuration for ActsHiSysEventCPPTest Tests" -} \ No newline at end of file diff --git a/hiviewdfx/hitracetest/hitracecpptest/BUILD.gn b/hiviewdfx/hitracetest/hitracecpptest/BUILD.gn deleted file mode 100644 index b74156fd5fea2781a3640a19e64e23cc46bf9bae..0000000000000000000000000000000000000000 --- a/hiviewdfx/hitracetest/hitracecpptest/BUILD.gn +++ /dev/null @@ -1,41 +0,0 @@ -# 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/build/suite.gni") -module_output_path = "hits/HitraceCPPtest" - -############################################################################### -config("hitrace_config") { - visibility = [ ":*" ] - include_dirs = [ - "../../utils/native", - "//utils/native/base/include/", - "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", - "//base/hiviewdfx/hitrace/interfaces/native/innerkits/include", - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/include", - ] -} -ohos_moduletest_suite("ActsHitraceCPPTest") { - module_out_path = module_output_path - sources = [ "HitraceCPPtest.cpp" ] - deps = [ - "../../utils/native:utilskit", - "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits:libhisysevent", - "//base/hiviewdfx/hitrace/interfaces/native/innerkits:libhitrace", - "//third_party/googletest:gtest_main", - "//utils/native/base:utils", - ] - - configs = [ ":hitrace_config" ] -} diff --git a/hiviewdfx/hitracetest/hitracecpptest/HitraceCPPtest.cpp b/hiviewdfx/hitracetest/hitracecpptest/HitraceCPPtest.cpp deleted file mode 100644 index fae376b98e0a5c7841cc81b79452621f0b503413..0000000000000000000000000000000000000000 --- a/hiviewdfx/hitracetest/hitracecpptest/HitraceCPPtest.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/* - * 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 "hitrace/hitrace.h" -#include "hitrace/hitraceid.h" -#include "hitrace/trace.h" -#include "file_utils.h" - -using namespace OHOS; -using namespace HiviewDFX; -using namespace testing; -using namespace testing::ext; -using namespace std; - -class HitraceCPPtest : public testing::Test { -public: - - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp(); - void TearDown(); - -private: -}; -void HitraceCPPtest::SetUp() -{ -} -void HitraceCPPtest::TearDown() -{ -} -void HitraceCPPtest::SetUpTestCase() -{ -} -void HitraceCPPtest::TearDownTestCase() -{ -} -/** - * @tc.name HiTrace C++ interface test - * @tc.number DFX_DFT_HiTrace_CPP_0001 - * @tc.desc HiTrace C++ interface test - */ -HWTEST_F(HitraceCPPtest, Hitrace_interface, Function|MediumTest|Level1) -{ - GTEST_LOG_(INFO) << "Hitrace_interface start" << endl; - HiTraceFlag hitraceflag = HITRACE_FLAG_INCLUDE_ASYNC; - HiTraceId hiTraceId = HiTrace::Begin("test", HITRACE_FLAG_INCLUDE_ASYNC); - HiTrace::SetId(hiTraceId); - hiTraceId = HiTrace::GetId(); - ASSERT_TRUE(hiTraceId.IsValid()); - - hiTraceId.EnableFlag(hitraceflag); - ASSERT_TRUE(hiTraceId.IsFlagEnabled(hitraceflag)); - - int hitraceflags = HITRACE_FLAG_FAULT_TRIGGER; - hiTraceId.SetFlags(hitraceflags); - hitraceflags = hiTraceId.GetFlags(); - ASSERT_TRUE(hitraceflags == HITRACE_FLAG_FAULT_TRIGGER); - - uint64_t chainId = 10000; - hiTraceId.SetChainId(chainId); - chainId = hiTraceId.GetChainId(); - ASSERT_TRUE(chainId == 10000); - - uint64_t spanId = 12345678; - hiTraceId.SetSpanId(spanId); - spanId = hiTraceId.GetSpanId(); - ASSERT_TRUE(spanId == 12345678); - - HiTraceId childId = HiTrace::CreateSpan(); - EXPECT_EQ(1, childId.IsValid()); - - /* set child id to thread id */ - HiTrace::SetId(childId); - /* continue to create child span */ - HiTraceId grandChildId = HiTrace::CreateSpan(); - EXPECT_EQ(1, grandChildId.IsValid()); - EXPECT_EQ(grandChildId.GetFlags(), childId.GetFlags()); - EXPECT_EQ(grandChildId.GetChainId(), childId.GetChainId()); - EXPECT_EQ(grandChildId.GetParentSpanId(), childId.GetSpanId()); - - grandChildId.SetChainId(chainId); - chainId = grandChildId.GetChainId(); - ASSERT_TRUE(chainId == 10000); - - grandChildId.SetSpanId(spanId); - spanId = grandChildId.GetSpanId(); - ASSERT_TRUE(spanId == 12345678); - HiTrace::ClearId(); - HiTraceId clearId = HiTrace::GetId(); - EXPECT_EQ(0, clearId.IsValid()); - HiTrace::End(hiTraceId); - GTEST_LOG_(INFO) << "Hitrace_interface end" << endl; -} - -/** - * @tc.name HiTrace C++ Begin interface, when flag is invalid. - * @tc.number DFX_DFT_HiTrace_CPP_0002 - * @tc.desc HiTrace C++ interface test - */ -HWTEST_F(HitraceCPPtest, Hitrace_interface1, Function|MediumTest|Level1) -{ - GTEST_LOG_(INFO) << "Hitrace_interface1 start" << endl; - /* begin with invalid flag */ - HiTraceId invalidFlagId = HiTrace::Begin("invalid param", HITRACE_FLAG_MAX+1); - EXPECT_EQ(0, invalidFlagId.IsValid()); - HiTrace::End(invalidFlagId); - - invalidFlagId = HiTrace::Begin("invalid param", -1); - EXPECT_EQ(0, invalidFlagId.IsValid()); - HiTrace::End(invalidFlagId); - GTEST_LOG_(INFO) << "Hitrace_interface1 end" << endl; -} -/** - * @tc.name HiTrace C++ Begin interface, when name is invalid. - * @tc.number DFX_DFT_HiTrace_CPP_0003 - * @tc.desc HiTrace C++ interface test - */ -HWTEST_F(HitraceCPPtest, Hitrace_interface2, Function|MediumTest|Level1) -{ - GTEST_LOG_(INFO) << "Hitrace_interface2 start" << endl; - /* begin with invalid name */ - HiTraceId invalidNameId = HiTrace::Begin("", HITRACE_FLAG_TP_INFO); - EXPECT_EQ(1, invalidNameId.IsValid()); - HiTrace::End(invalidNameId); - GTEST_LOG_(INFO) << "Hitrace_interface2 end" << endl; -} -/** - * @tc.name HiTrace C++ Begin interface, when name is very long. - * @tc.number DFX_DFT_HiTrace_CPP_0004 - * @tc.desc HiTrace C++ interface test - */ -HWTEST_F(HitraceCPPtest, Hitrace_interface3, Function|MediumTest|Level1) -{ - GTEST_LOG_(INFO) << "Hitrace_interface3 start" << endl; - std::string name = "test"; - for (int i = 0; i < 1000; i++) { - name += "test"; - } - HiTraceId traceId = HiTrace::Begin(name, HITRACE_FLAG_TP_INFO); - EXPECT_EQ(1, traceId.IsValid()); - HiTrace::End(traceId); - GTEST_LOG_(INFO) << "Hitrace_interface3 end" << endl; -} -/** - * @tc.name Repeated call Begin interface. - * @tc.number DFX_DFT_HiTrace_CPP_0005 - * @tc.desc HiTrace C++ interface test - */ -HWTEST_F(HitraceCPPtest, Hitrace_interface4, Function|MediumTest|Level1) -{ - GTEST_LOG_(INFO) << "Hitrace_interface4 start" << endl; - HiTraceId traceId = HiTrace::Begin("test", HITRACE_FLAG_TP_INFO); - HiTraceId traceId1 = HiTrace::Begin("test1", HITRACE_FLAG_TP_INFO); - EXPECT_EQ(1, traceId.IsValid()); - EXPECT_EQ(0, traceId1.IsValid()); - HiTrace::End(traceId); - HiTrace::End(traceId1); - GTEST_LOG_(INFO) << "Hitrace_interface4 end" << endl; -} -/** - * @tc.name End invalid traceid - * @tc.number DFX_DFT_HiTrace_CPP_0006 - * @tc.desc HiTrace C++ interface test - */ -HWTEST_F(HitraceCPPtest, Hitrace_interface5, Function|MediumTest|Level1) -{ - GTEST_LOG_(INFO) << "Hitrace_interface5 start" << endl; - HiTraceId traceId = HiTrace::Begin("test", HITRACE_FLAG_TP_INFO); - EXPECT_EQ(1, traceId.IsValid()); - HiTraceId invalidId; - invalidId.SetChainId(1000); - invalidId.SetSpanId(1000); - HiTrace::End(invalidId); - HiTraceId wrongEndId = HiTrace::GetId(); - EXPECT_EQ(1, wrongEndId.IsValid()); - ASSERT_TRUE(wrongEndId.GetChainId() == traceId.GetChainId()); - EXPECT_EQ(1, wrongEndId.IsFlagEnabled(HITRACE_FLAG_TP_INFO)); - HiTrace::End(traceId); - GTEST_LOG_(INFO) << "Hitrace_interface5 end" << endl; -} -/** - * @tc.name End traceId that has ended. - * @tc.number DFX_DFT_HiTrace_CPP_0007 - * @tc.desc HiTrace C++ interface test - */ -HWTEST_F(HitraceCPPtest, Hitrace_interface6, Function|MediumTest|Level1) -{ - GTEST_LOG_(INFO) << "Hitrace_interface6 start" << endl; - HiTraceId traceId = HiTrace::Begin("invalid param1", HITRACE_FLAG_TP_INFO); - EXPECT_EQ(1, traceId.IsValid()); - HiTrace::End(traceId); - traceId = HiTrace::GetId(); - EXPECT_EQ(0, traceId.IsValid()); - HiTrace::End(traceId); - traceId = HiTrace::GetId(); - EXPECT_EQ(0, traceId.IsValid()); - GTEST_LOG_(INFO) << "Hitrace_interface6 end" << endl; -} \ No newline at end of file diff --git a/hiviewdfx/hitracetest/hitracecpptest/Test.json b/hiviewdfx/hitracetest/hitracecpptest/Test.json deleted file mode 100644 index 28fd96f4dc4e46d05a625e8da129fea2faa93343..0000000000000000000000000000000000000000 --- a/hiviewdfx/hitracetest/hitracecpptest/Test.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "kits": [ - { - "push": [ - "ActsHitraceCPPTest->/data/local/tmp/ActsHitraceCPPTest" - ], - "type": "PushKit", - "post-push": [ - "chmod -R 777 /data/local/tmp/*" - ] - } - ], - "driver": { - "native-test-timeout": "120000", - "type": "CppTest", - "module-name": "ActsHitraceCPPTest", - "runtime-hint": "1s", - "native-test-device-path": "/data/local/tmp" - }, - "description": "Configuration for ActsHitraceCPPTest Tests" -} \ No newline at end of file diff --git a/hiviewdfx/hitracetest/hitracectest/BUILD.gn b/hiviewdfx/hitracetest/hitracectest/BUILD.gn deleted file mode 100644 index 4146b6b9aed4c37c42d4cb8d40a99f1476a52ee4..0000000000000000000000000000000000000000 --- a/hiviewdfx/hitracetest/hitracectest/BUILD.gn +++ /dev/null @@ -1,39 +0,0 @@ -# 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/build/suite.gni") -module_output_path = "hits/HitraceCtest" - -############################################################################### -config("hitrace_config") { - visibility = [ ":*" ] - include_dirs = [ - "../../utils/native", - "//utils/native/base/include/", - "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", - "//base/hiviewdfx/hitrace/interfaces/native/innerkits/include", - ] -} -ohos_moduletest_suite("ActsHitraceCTest") { - module_out_path = module_output_path - sources = [ "HitraceCtest.cpp" ] - deps = [ - "../../utils/native:utilskit", - "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", - "//base/hiviewdfx/hitrace/interfaces/native/innerkits:libhitrace", - "//third_party/googletest:gtest_main", - "//utils/native/base:utils", - ] - - configs = [ ":hitrace_config" ] -} diff --git a/hiviewdfx/hitracetest/hitracectest/HitraceCtest.cpp b/hiviewdfx/hitracetest/hitracectest/HitraceCtest.cpp deleted file mode 100644 index f834b2bf5243064de6f4396b0b52aa42efd9dc85..0000000000000000000000000000000000000000 --- a/hiviewdfx/hitracetest/hitracectest/HitraceCtest.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* - * 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 "hitrace/hitracec.h" -#include "file_utils.h" - -using namespace testing::ext; -using namespace std; - -class HitraceCtest : public testing::Test { -public: - - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp(); - void TearDown(); - -private: -}; -void HitraceCtest::SetUp() -{ -} -void HitraceCtest::TearDown() -{ -} -void HitraceCtest::SetUpTestCase() -{ -} -void HitraceCtest::TearDownTestCase() -{ -} - -/** - * @tc.name HiTrace C interface test - * @tc.number DFX_DFT_HiTrace_0001 - * @tc.desc HiTrace C interface test -*/ -HWTEST_F(HitraceCtest, HitraceC_interface, Function|MediumTest|Level1) -{ - GTEST_LOG_(INFO) << "HitraceC_interface start" << endl; - HiTraceIdStruct hiTraceId; - HiTraceFlag hitraceflag = HITRACE_FLAG_INCLUDE_ASYNC; - hiTraceId = HiTraceBegin("test", HITRACE_FLAG_INCLUDE_ASYNC); - - HiTraceSetId(&hiTraceId); - hiTraceId = HiTraceGetId(); - ASSERT_TRUE(HiTraceIsValid(&hiTraceId)); - - HiTraceEnableFlag(&hiTraceId, hitraceflag); - ASSERT_TRUE(HiTraceIsFlagEnabled(&hiTraceId, hitraceflag)); - - int hitraceflags = HITRACE_FLAG_FAULT_TRIGGER; - HiTraceSetFlags(&hiTraceId, hitraceflags); - hitraceflags = HiTraceGetFlags(&hiTraceId); - ASSERT_TRUE(hitraceflags == HITRACE_FLAG_FAULT_TRIGGER); - - uint64_t chainId = 10000; - HiTraceSetChainId(&hiTraceId, chainId); - chainId = HiTraceGetChainId(&hiTraceId); - ASSERT_TRUE(chainId==10000); - - uint64_t spanId = 12345678; - HiTraceSetSpanId(&hiTraceId, spanId); - spanId = HiTraceGetSpanId(&hiTraceId); - ASSERT_TRUE(spanId == 12345678); - - HiTraceIdStruct childId = HiTraceCreateSpan(); - ASSERT_TRUE(HiTraceIsValid(&childId)); - - /* set child id to thread id */ - HiTraceSetId(&childId); - /* continue to create child span */ - HiTraceIdStruct grandChildId = HiTraceCreateSpan(); - ASSERT_TRUE(HiTraceIsValid(&grandChildId)); - EXPECT_EQ(HiTraceGetFlags(&grandChildId), HiTraceGetFlags(&childId)); - EXPECT_EQ(HiTraceGetChainId(&grandChildId), HiTraceGetChainId(&childId)); - EXPECT_EQ(HiTraceGetParentSpanId(&grandChildId), HiTraceGetSpanId(&childId)); - - HiTraceSetChainId(&grandChildId, chainId); - chainId = HiTraceGetChainId(&grandChildId); - ASSERT_TRUE(chainId==10000); - - HiTraceSetSpanId(&grandChildId, spanId); - spanId = HiTraceGetSpanId(&grandChildId); - ASSERT_TRUE(spanId==12345678); - HiTraceClearId(); - hiTraceId = HiTraceGetId(); - ASSERT_FALSE(HiTraceIsValid(&hiTraceId)); - HiTraceEnd(&hiTraceId); - GTEST_LOG_(INFO) << "HitraceC_interface end" << endl; -} -/** - * @tc.name HiTraceBegin interface test, when flag is invalid - * @tc.number DFX_DFT_HiTrace_0002 - * @tc.desc HiTrace C interface test - */ -HWTEST_F(HitraceCtest, HitraceC_interface1, Function|MediumTest|Level1) -{ - GTEST_LOG_(INFO) << "HitraceC_interface1 start" << endl; - /* begin with invalid flag */ - HiTraceIdStruct invalidFlagId = HiTraceBegin("invalid param", HITRACE_FLAG_MAX+1); - EXPECT_EQ(0, HiTraceIsValid(&invalidFlagId)); - HiTraceEnd(&invalidFlagId); - - invalidFlagId = HiTraceBegin("invalid param1", -1); - EXPECT_EQ(0, HiTraceIsValid(&invalidFlagId)); - HiTraceEnd(&invalidFlagId); - GTEST_LOG_(INFO) << "HitraceC_interface1 end" << endl; -} -/** - * @tc.name HiTraceBegin interface test, when name is invalid. - * @tc.number DFX_DFT_HiTrace_0003 - * @tc.desc HiTrace C interface test - */ -HWTEST_F(HitraceCtest, HitraceC_interface2, Function|MediumTest|Level1) -{ - GTEST_LOG_(INFO) << "HitraceC_interface2 start" << endl; - /* begin with invalid name */ - HiTraceIdStruct invalidNameId = HiTraceBegin("", HITRACE_FLAG_TP_INFO); - EXPECT_EQ(1, HiTraceIsValid(&invalidNameId)); - HiTraceEnd(&invalidNameId); - GTEST_LOG_(INFO) << "HitraceC_interface2 end" << endl; -} -/** - * @tc.name HiTraceBegin interface test, when name is very long. - * @tc.number DFX_DFT_HiTrace_0004 - * @tc.desc HiTrace C++ interface test - */ -HWTEST_F(HitraceCtest, Hitrace_interface3, Function|MediumTest|Level1) -{ - GTEST_LOG_(INFO) << "Hitrace_interface3 start" << endl; - char name[4096] = "test"; - for (int i = 0; i < 1000; i++) - { - strcat(name, "test"); - } - HiTraceIdStruct traceId = HiTraceBegin(name, HITRACE_FLAG_TP_INFO); - EXPECT_EQ(1, HiTraceIsValid(&traceId)); - HiTraceEnd(&traceId); - GTEST_LOG_(INFO) << "Hitrace_interface3 end" << endl; -} -/** - * @tc.name Repeated call HiTraceBegin interface test. - * @tc.number DFX_DFT_HiTrace_0005 - * @tc.desc HiTrace C interface test - */ -HWTEST_F(HitraceCtest, Hitrace_interface4, Function|MediumTest|Level1) -{ - GTEST_LOG_(INFO) << "Hitrace_interface4 start" << endl; - HiTraceIdStruct traceId = HiTraceBegin("test", HITRACE_FLAG_TP_INFO); - HiTraceIdStruct traceId1 = HiTraceBegin("test1", HITRACE_FLAG_TP_INFO); - EXPECT_EQ(1, HiTraceIsValid(&traceId)); - EXPECT_EQ(0, HiTraceIsValid(&traceId1)); - HiTraceEnd(&traceId); - HiTraceEnd(&traceId1); - GTEST_LOG_(INFO) << "Hitrace_interface4 end" << endl; -} -/** - * @tc.name End invalid traceid test. - * @tc.number DFX_DFT_HiTrace_0006 - * @tc.desc HiTrace C interface test - */ -HWTEST_F(HitraceCtest, HitraceC_interface5, Function|MediumTest|Level1) -{ - GTEST_LOG_(INFO) << "HitraceC_interface5 start" << endl; - HiTraceIdStruct traceId = HiTraceBegin("test", HITRACE_FLAG_TP_INFO); - HiTraceIdStruct invalidId = {0}; - EXPECT_EQ(1, HiTraceIsValid(&traceId)); - HiTraceEnd(&invalidId); - HiTraceIdStruct wrongEndId = HiTraceGetId(); - EXPECT_EQ(1, HiTraceIsValid(&wrongEndId)); - EXPECT_EQ(HiTraceGetChainId(&wrongEndId), HiTraceGetChainId(&traceId)); - EXPECT_EQ(1, HiTraceIsFlagEnabled(&wrongEndId, HITRACE_FLAG_TP_INFO)); - HiTraceEnd(&traceId); - GTEST_LOG_(INFO) << "HitraceC_interface5 end" << endl; -} -/** - * @tc.name End traceId that has ended. - * @tc.number DFX_DFT_HiTrace_0007 - * @tc.desc HiTrace C interface test - */ -HWTEST_F(HitraceCtest, HitraceC_interface6, Function|MediumTest|Level1) -{ - GTEST_LOG_(INFO) << "HitraceC_interface6 start" << endl; - HiTraceIdStruct traceId = HiTraceBegin("test", HITRACE_FLAG_TP_INFO); - EXPECT_EQ(1, HiTraceIsValid(&traceId)); - HiTraceEnd(&traceId); - traceId = HiTraceGetId(); - EXPECT_EQ(0, HiTraceIsValid(&traceId)); - HiTraceEnd(&traceId); - traceId = HiTraceGetId(); - EXPECT_EQ(0, HiTraceIsValid(&traceId)); - GTEST_LOG_(INFO) << "HitraceC_interface6 end" << endl; -} \ No newline at end of file diff --git a/hiviewdfx/hitracetest/hitracectest/Test.json b/hiviewdfx/hitracetest/hitracectest/Test.json deleted file mode 100644 index 8bb3e93996782a5660fd72e144a5281b4c54c712..0000000000000000000000000000000000000000 --- a/hiviewdfx/hitracetest/hitracectest/Test.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "kits": [ - { - "push": [ - "ActsHitraceCTest->/data/local/tmp/ActsHitraceCTest" - ], - "type": "PushKit", - "post-push": [ - "chmod -R 777 /data/local/tmp/*" - ] - } - ], - "driver": { - "native-test-timeout": "120000", - "type": "CppTest", - "module-name": "ActsHitraceCTest", - "runtime-hint": "1s", - "native-test-device-path": "/data/local/tmp" - }, - "description": "Configuration for ActsHitraceCTest Tests" -} \ No newline at end of file diff --git a/hiviewdfx/utils/native/BUILD.gn b/hiviewdfx/utils/native/BUILD.gn deleted file mode 100755 index e2d7697a5860c0ef91a517b85658a3b8f272fb0f..0000000000000000000000000000000000000000 --- a/hiviewdfx/utils/native/BUILD.gn +++ /dev/null @@ -1,38 +0,0 @@ -# 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("//build/ohos.gni") -import("//test/xts/tools/build/suite.gni") - -############################################################################### -config("utils_config") { - visibility = [ ":*" ] - include_dirs = [ - "//third_party/cJSON/", - "//third_party/zlib/", - "//utils/native/base/", - ] -} - -sources_common = [ "file_utils.cpp" ] -ohos_static_library("utilskit") { - sources = sources_common - configs = [ ":utils_config" ] - - #external_deps = [ "hilog:libhilog" ] - deps = [ - "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", - "//base/hiviewdfx/hiview/base:hiviewbase", - "//utils/native/base:utils", - ] -} diff --git a/hiviewdfx/utils/native/file_utils.cpp b/hiviewdfx/utils/native/file_utils.cpp deleted file mode 100755 index bdfaa1cebec3dc0bb2bfc9e7379e0c6bcde1a0c8..0000000000000000000000000000000000000000 --- a/hiviewdfx/utils/native/file_utils.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* - * 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. - */ -#ifndef TEST_COMMON_H -#define TEST_COMMON_H -#include "file_utils.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "include/securec.h" -#include "string_util.h" - -using namespace OHOS::HiviewDFX; -int ExecCmdWithRet(std::string cmd, std::vector &resvec) -{ - if (cmd.size() == 0) { - return 0; - } - - std::cout<< "cmd is " + cmd < cmdret; - ExecCmdWithRet(cmd, cmdret); -} - -void CmdRun(std::string cmd, std::string &result) -{ - std::vector cmdret; - int resultlen; - int i = 0; - std::string rst; - resultlen = ExecCmdWithRet(cmd, cmdret); - while (i < resultlen) { - rst = rst + cmdret[i]; - i = i + 1; - } - result = rst; -} - -void CleanCmd() -{ - std::string cmdResult; - std::string cleanCmd = "hilog -r"; - CmdRun(cleanCmd, cmdResult); - std::cout << cmdResult; - sleep(1); -} - -std::string ExecuteCmd(std::string cmd) -{ - std::vector cmdret; - int resultlen; - int i = 0; - std::string rst; - resultlen = ExecCmdWithRet(cmd, cmdret); - while (i < resultlen) { - rst = rst + cmdret[i] + "\n"; - i = i + 1; - } - return rst; -} -void SaveCmdOutput(std::string cmd, std::string saveFile) -{ - std::fstream fstr(saveFile, std::ios::out); - std::string cmdRet = ExecuteCmd(cmd); - fstr << cmdRet; - fstr.close(); -} -void RedirecthiLog(std::string &hilogredirect, std::string &timeout) -{ - unsigned long i; - std::vector cmdret; - unsigned long cmdretlen; - std::string cmd = "rm " + hilogredirect; - cmdretlen = ExecCmdWithRet(cmd, cmdret); - for (i = 0; i < cmdretlen; i++) { - std::cout<" + hilogredirect; - std::cout< ¶, std::string info) -{ - if (info.empty()) { - return false; - } - std::vector splitStr; - StringUtil::SplitStr(info, "\n", splitStr, false, false); - unsigned long matchcnt; - bool result = false; - std::string eventinfoline; - std::cout<::iterator iter = splitStr.begin(); iter != splitStr.end(); ++iter) { - eventinfoline = std::string (iter->c_str()); - for (unsigned long i = 0; i < para.size(); i++) { - std::cout<= 0) { - matchcnt++; - } - } - std::cout<<"Expect1:"<= 0) { - len--; - } - if (len >= 0 && x[len] > y[len]) { - return false; - } - return true; -} - -int GetTxtLine(std::string filename) -{ - FILE *fd = fopen(filename.c_str(), "r"); - int count = 0; - if (fd != nullptr) { - while (!feof(fd)) { - if (fgetc(fd) == '\n') { - count++; - } - } - } - std::cout << count << std::endl; - if (fd != nullptr) { - fclose(fd); - } - return count; -} - -std::string ReadFile(std::string filename) -{ - std::ifstream ifile(filename); - std::ostringstream buf; - char ch; - if (ifile.fail()) { - std::cout<<"open file fail!"< getfileinpath(std::string path) -{ - std::vector filelist; - DIR *dir; - struct dirent *pdirent; - dir = opendir(path.c_str()); - if (dir != nullptr) { - while ((pdirent = readdir(dir)) != nullptr) { - if (strncmp(pdirent->d_name, ".", strlen(pdirent->d_name)) == 0 || - strncmp(pdirent->d_name, "..", strlen(pdirent->d_name)) == 0) { - continue; - } else if (pdirent->d_type == 4) { - continue; - } else { - filelist.push_back(pdirent->d_name); - } - } - closedir(dir); - } - return filelist; -} -#endif diff --git a/hiviewdfx/utils/native/file_utils.h b/hiviewdfx/utils/native/file_utils.h deleted file mode 100755 index 0e2dd581f1212f243ff9eaba522c6f0d10650b94..0000000000000000000000000000000000000000 --- a/hiviewdfx/utils/native/file_utils.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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. - */ -#ifndef TEST_COMMON_H -#define TEST_COMMON_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -bool CheckInfo(std::vector ¶, std::string eventinfo); -int ExecCmdWithRet(std::string cmd, std::vector &resvec); -std::string ReadFile(std::string filename); -void RedirecthiLog(std::string &hilogredirect, std::string &timeout); -void ExeCmd(std::string cmd); -void CmdRun(std::string cmd, std::string &result); -std::string ExecuteCmd(std::string cmd); -bool CompareString(const std::string& x, const std::string& y); -int GetTxtLine(std::string filename); -std::string ReadFile(std::string filename); -void CleanCmd(); -std::string ReadOneLine(std::string m_path, char* rBuf, int n); -void SaveCmdOutput(std::string cmd, std::string saveFile); -std::vector getfileinpath(std::string path); -#endif