11401458bSopenharmony_ci/* 21401458bSopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 31401458bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 41401458bSopenharmony_ci * you may not use this file except in compliance with the License. 51401458bSopenharmony_ci * You may obtain a copy of the License at 61401458bSopenharmony_ci * 71401458bSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 81401458bSopenharmony_ci * 91401458bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 101401458bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 111401458bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 121401458bSopenharmony_ci * See the License for the specific language governing permissions and 131401458bSopenharmony_ci * limitations under the License. 141401458bSopenharmony_ci */ 151401458bSopenharmony_ci 161401458bSopenharmony_ci#include "hisysevent_native_test.h" 171401458bSopenharmony_ci 181401458bSopenharmony_ci#include <functional> 191401458bSopenharmony_ci#include <iosfwd> 201401458bSopenharmony_ci#include <string> 211401458bSopenharmony_ci#include <thread> 221401458bSopenharmony_ci#include <unistd.h> 231401458bSopenharmony_ci#include <vector> 241401458bSopenharmony_ci 251401458bSopenharmony_ci#include "gtest/gtest-message.h" 261401458bSopenharmony_ci#include "gtest/gtest-test-part.h" 271401458bSopenharmony_ci#include "gtest/hwext/gtest-ext.h" 281401458bSopenharmony_ci#include "gtest/hwext/gtest-tag.h" 291401458bSopenharmony_ci#include "hilog/log.h" 301401458bSopenharmony_ci 311401458bSopenharmony_ci#include "def.h" 321401458bSopenharmony_ci#include "hisysevent.h" 331401458bSopenharmony_ci#include "hisysevent_base_manager.h" 341401458bSopenharmony_ci#include "hisysevent_manager.h" 351401458bSopenharmony_ci#include "hisysevent_record.h" 361401458bSopenharmony_ci#include "hisysevent_query_callback.h" 371401458bSopenharmony_ci#include "hisysevent_listener.h" 381401458bSopenharmony_ci#include "ret_code.h" 391401458bSopenharmony_ci#include "rule_type.h" 401401458bSopenharmony_ci 411401458bSopenharmony_ci#ifndef SYS_EVENT_PARAMS 421401458bSopenharmony_ci#define SYS_EVENT_PARAMS(A) "key"#A, 0 + (A), "keyA"#A, 1 + (A), "keyB"#A, 2 + (A), "keyC"#A, 3 + (A), \ 431401458bSopenharmony_ci "keyD"#A, 4 + (A), "keyE"#A, 5 + (A), "keyF"#A, 6 + (A), "keyG"#A, 7 + (A), "keyH"#A, 8 + (A), \ 441401458bSopenharmony_ci "keyI"#A, 9 + (A) 451401458bSopenharmony_ci#endif 461401458bSopenharmony_ciusing namespace testing::ext; 471401458bSopenharmony_ciusing namespace OHOS::HiviewDFX; 481401458bSopenharmony_ci 491401458bSopenharmony_ci#undef LOG_DOMAIN 501401458bSopenharmony_ci#define LOG_DOMAIN 0xD002D08 511401458bSopenharmony_ci 521401458bSopenharmony_ci#undef LOG_TAG 531401458bSopenharmony_ci#define LOG_TAG "HISYSEVENT_NATIVE_TEST" 541401458bSopenharmony_ci 551401458bSopenharmony_cinamespace { 561401458bSopenharmony_ciconstexpr char TEST_DOMAIN[] = "DEMO"; 571401458bSopenharmony_ciconstexpr char TEST_DOMAIN2[] = "KERNEL_VENDOR"; 581401458bSopenharmony_ciint32_t WriteSysEventByMarcoInterface() 591401458bSopenharmony_ci{ 601401458bSopenharmony_ci return HiSysEventWrite(TEST_DOMAIN, "DEMO_EVENTNAME", HiSysEvent::EventType::FAULT, 611401458bSopenharmony_ci "PARAM_KEY", "PARAM_VAL"); 621401458bSopenharmony_ci} 631401458bSopenharmony_ci 641401458bSopenharmony_ciclass Watcher : public HiSysEventListener { 651401458bSopenharmony_cipublic: 661401458bSopenharmony_ci Watcher() {} 671401458bSopenharmony_ci virtual ~Watcher() {} 681401458bSopenharmony_ci 691401458bSopenharmony_ci void OnEvent(std::shared_ptr<HiSysEventRecord> sysEvent) final 701401458bSopenharmony_ci { 711401458bSopenharmony_ci if (sysEvent == nullptr) { 721401458bSopenharmony_ci return; 731401458bSopenharmony_ci } 741401458bSopenharmony_ci HILOG_DEBUG(LOG_CORE, "domain: %{public}s, eventName: %{public}s, eventType: %{public}d, extra: %{public}s.", 751401458bSopenharmony_ci sysEvent->GetDomain().c_str(), sysEvent->GetEventName().c_str(), sysEvent->GetEventType(), 761401458bSopenharmony_ci sysEvent->AsJson().c_str()); 771401458bSopenharmony_ci } 781401458bSopenharmony_ci 791401458bSopenharmony_ci void OnServiceDied() final 801401458bSopenharmony_ci { 811401458bSopenharmony_ci HILOG_DEBUG(LOG_CORE, "OnServiceDied"); 821401458bSopenharmony_ci } 831401458bSopenharmony_ci}; 841401458bSopenharmony_ci 851401458bSopenharmony_ciusing OnQueryCallback = std::function<bool(std::shared_ptr<std::vector<HiSysEventRecord>>)>; 861401458bSopenharmony_ciusing OnCompleteCallback = std::function<bool(int32_t, int32_t)>; 871401458bSopenharmony_ci 881401458bSopenharmony_ciclass Querier : public HiSysEventQueryCallback { 891401458bSopenharmony_cipublic: 901401458bSopenharmony_ci explicit Querier(OnQueryCallback onQueryCallback = nullptr, OnCompleteCallback onCompleteCallback = nullptr) 911401458bSopenharmony_ci : onQueryCallback(onQueryCallback), onCompleteCallback(onCompleteCallback) {} 921401458bSopenharmony_ci virtual ~Querier() {} 931401458bSopenharmony_ci 941401458bSopenharmony_ci void OnQuery(std::shared_ptr<std::vector<HiSysEventRecord>> sysEvents) final 951401458bSopenharmony_ci { 961401458bSopenharmony_ci if (onQueryCallback != nullptr) { 971401458bSopenharmony_ci ASSERT_TRUE(onQueryCallback(sysEvents)); 981401458bSopenharmony_ci } 991401458bSopenharmony_ci } 1001401458bSopenharmony_ci 1011401458bSopenharmony_ci void OnComplete(int32_t reason, int32_t total) final 1021401458bSopenharmony_ci { 1031401458bSopenharmony_ci if (onCompleteCallback != nullptr) { 1041401458bSopenharmony_ci ASSERT_TRUE(onCompleteCallback(reason, total)); 1051401458bSopenharmony_ci } 1061401458bSopenharmony_ci } 1071401458bSopenharmony_ci 1081401458bSopenharmony_ciprivate: 1091401458bSopenharmony_ci OnQueryCallback onQueryCallback; 1101401458bSopenharmony_ci OnCompleteCallback onCompleteCallback; 1111401458bSopenharmony_ci}; 1121401458bSopenharmony_ci} 1131401458bSopenharmony_ci 1141401458bSopenharmony_cistatic bool WrapSysEventWriteAssertion(int32_t ret, bool cond) 1151401458bSopenharmony_ci{ 1161401458bSopenharmony_ci return cond || ret == OHOS::HiviewDFX::ERR_SEND_FAIL || 1171401458bSopenharmony_ci ret == OHOS::HiviewDFX::ERR_WRITE_IN_HIGH_FREQ || 1181401458bSopenharmony_ci ret == OHOS::HiviewDFX::ERR_DOMAIN_MASKED || 1191401458bSopenharmony_ci ret == OHOS::HiviewDFX::ERR_TOO_MANY_CONCURRENT_QUERIES || 1201401458bSopenharmony_ci ret == OHOS::HiviewDFX::ERR_QUERY_TOO_FREQUENTLY; 1211401458bSopenharmony_ci} 1221401458bSopenharmony_ci 1231401458bSopenharmony_civoid HiSysEventNativeTest::SetUpTestCase(void) 1241401458bSopenharmony_ci{ 1251401458bSopenharmony_ci} 1261401458bSopenharmony_ci 1271401458bSopenharmony_civoid HiSysEventNativeTest::TearDownTestCase(void) 1281401458bSopenharmony_ci{ 1291401458bSopenharmony_ci} 1301401458bSopenharmony_ci 1311401458bSopenharmony_civoid HiSysEventNativeTest::SetUp(void) 1321401458bSopenharmony_ci{ 1331401458bSopenharmony_ci} 1341401458bSopenharmony_ci 1351401458bSopenharmony_civoid HiSysEventNativeTest::TearDown(void) 1361401458bSopenharmony_ci{ 1371401458bSopenharmony_ci} 1381401458bSopenharmony_ci 1391401458bSopenharmony_ci/** 1401401458bSopenharmony_ci * @tc.name: TestHiSysEventManagerQueryWithInvalidQueryRules001 1411401458bSopenharmony_ci * @tc.desc: Query with query rules which contains empty domain 1421401458bSopenharmony_ci * @tc.type: FUNC 1431401458bSopenharmony_ci * @tc.require: issueI62B10 1441401458bSopenharmony_ci */ 1451401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventManagerQueryWithInvalidQueryRules001, TestSize.Level1) 1461401458bSopenharmony_ci{ 1471401458bSopenharmony_ci sleep(1); 1481401458bSopenharmony_ci auto querier = std::make_shared<Querier>(); 1491401458bSopenharmony_ci long long defaultTimeStap = -1; 1501401458bSopenharmony_ci int queryCount = 10; 1511401458bSopenharmony_ci struct OHOS::HiviewDFX::QueryArg args(defaultTimeStap, defaultTimeStap, queryCount); 1521401458bSopenharmony_ci std::vector<OHOS::HiviewDFX::QueryRule> queryRules; 1531401458bSopenharmony_ci std::vector<std::string> eventNames {"EVENT_NAME"}; 1541401458bSopenharmony_ci OHOS::HiviewDFX::QueryRule rule("", eventNames); // empty domain 1551401458bSopenharmony_ci queryRules.emplace_back(rule); 1561401458bSopenharmony_ci auto ret = OHOS::HiviewDFX::HiSysEventManager::Query(args, queryRules, querier); 1571401458bSopenharmony_ci // only process with root or shell uid return OHOS::HiviewDFX::IPC_CALL_SUCCEED 1581401458bSopenharmony_ci ASSERT_TRUE(ret == OHOS::HiviewDFX::ERR_QUERY_RULE_INVALID || ret == OHOS::HiviewDFX::IPC_CALL_SUCCEED); 1591401458bSopenharmony_ci} 1601401458bSopenharmony_ci 1611401458bSopenharmony_ci/** 1621401458bSopenharmony_ci * @tc.name: TestHiSysEventManagerQueryWithInvalidQueryRules002 1631401458bSopenharmony_ci * @tc.desc: Query with query rules which contains empty event names 1641401458bSopenharmony_ci * @tc.type: FUNC 1651401458bSopenharmony_ci * @tc.require: issueI62B10 1661401458bSopenharmony_ci */ 1671401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventManagerQueryWithInvalidQueryRules002, TestSize.Level1) 1681401458bSopenharmony_ci{ 1691401458bSopenharmony_ci sleep(1); 1701401458bSopenharmony_ci auto querier = std::make_shared<Querier>(); 1711401458bSopenharmony_ci long long defaultTimeStap = -1; 1721401458bSopenharmony_ci int queryCount = 10; 1731401458bSopenharmony_ci struct OHOS::HiviewDFX::QueryArg args(defaultTimeStap, defaultTimeStap, queryCount); 1741401458bSopenharmony_ci std::vector<OHOS::HiviewDFX::QueryRule> queryRules; 1751401458bSopenharmony_ci std::vector<std::string> eventNames; // empty event name 1761401458bSopenharmony_ci OHOS::HiviewDFX::QueryRule rule("DOMAIN", eventNames); 1771401458bSopenharmony_ci queryRules.emplace_back(rule); 1781401458bSopenharmony_ci auto ret = OHOS::HiviewDFX::HiSysEventManager::Query(args, queryRules, querier); 1791401458bSopenharmony_ci // only process with root or shell uid return OHOS::HiviewDFX::IPC_CALL_SUCCEED 1801401458bSopenharmony_ci ASSERT_TRUE(ret == OHOS::HiviewDFX::ERR_QUERY_RULE_INVALID || ret == OHOS::HiviewDFX::IPC_CALL_SUCCEED); 1811401458bSopenharmony_ci} 1821401458bSopenharmony_ci 1831401458bSopenharmony_ci/** 1841401458bSopenharmony_ci * @tc.name: TestSubscribeSysEventByTag 1851401458bSopenharmony_ci * @tc.desc: Subscribe sysevent by event tag 1861401458bSopenharmony_ci * @tc.type: FUNC 1871401458bSopenharmony_ci * @tc.require: issueI62B10 1881401458bSopenharmony_ci */ 1891401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestSubscribeSysEventByTag, TestSize.Level1) 1901401458bSopenharmony_ci{ 1911401458bSopenharmony_ci auto watcher = std::make_shared<Watcher>(); 1921401458bSopenharmony_ci OHOS::HiviewDFX::ListenerRule listenerRule("DOMAIN", "EVENT_NAME", "TAG", OHOS::HiviewDFX::RuleType::WHOLE_WORD); 1931401458bSopenharmony_ci std::vector<OHOS::HiviewDFX::ListenerRule> sysRules; 1941401458bSopenharmony_ci sysRules.emplace_back(listenerRule); 1951401458bSopenharmony_ci auto ret = OHOS::HiviewDFX::HiSysEventManager::AddListener(watcher, sysRules); 1961401458bSopenharmony_ci ASSERT_EQ(ret, IPC_CALL_SUCCEED); 1971401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventManager::RemoveListener(watcher); 1981401458bSopenharmony_ci ASSERT_EQ(ret, IPC_CALL_SUCCEED); 1991401458bSopenharmony_ci} 2001401458bSopenharmony_ci 2011401458bSopenharmony_ci/** 2021401458bSopenharmony_ci * @tc.name: TestHiSysEventNormal001 2031401458bSopenharmony_ci * @tc.desc: Test normal write. 2041401458bSopenharmony_ci * @tc.type: FUNC 2051401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 2061401458bSopenharmony_ci */ 2071401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventNormal001, TestSize.Level1) 2081401458bSopenharmony_ci{ 2091401458bSopenharmony_ci /** 2101401458bSopenharmony_ci * @tc.steps: step1.make sure SystemAbilityManager is started. 2111401458bSopenharmony_ci */ 2121401458bSopenharmony_ci static constexpr char domain[] = "DEMO"; 2131401458bSopenharmony_ci std::string eventName = "NORMAL001"; 2141401458bSopenharmony_ci 2151401458bSopenharmony_ci bool testBoolValue = true; 2161401458bSopenharmony_ci char testCharValue = 'a'; 2171401458bSopenharmony_ci short testShortValue = -100; 2181401458bSopenharmony_ci int testIntValue = -200; 2191401458bSopenharmony_ci long testLongValue = -300; 2201401458bSopenharmony_ci long long testLongLongValue = -400; 2211401458bSopenharmony_ci 2221401458bSopenharmony_ci unsigned char testUnsignedCharValue = 'a'; 2231401458bSopenharmony_ci unsigned short testUnsignedShortValue = 100; 2241401458bSopenharmony_ci unsigned int testUnsignedIntValue = 200; 2251401458bSopenharmony_ci unsigned long testUnsignedLongValue = 300; 2261401458bSopenharmony_ci unsigned long long testUnsignedLongLongValue = 400; 2271401458bSopenharmony_ci 2281401458bSopenharmony_ci float testFloatValue = 1.1; 2291401458bSopenharmony_ci double testDoubleValue = 2.2; 2301401458bSopenharmony_ci std::string testStringValue = "abc"; 2311401458bSopenharmony_ci 2321401458bSopenharmony_ci std::vector<bool> testBoolValues; 2331401458bSopenharmony_ci testBoolValues.push_back(true); 2341401458bSopenharmony_ci testBoolValues.push_back(true); 2351401458bSopenharmony_ci testBoolValues.push_back(false); 2361401458bSopenharmony_ci 2371401458bSopenharmony_ci std::vector<char> testCharValues; 2381401458bSopenharmony_ci testCharValues.push_back('a'); 2391401458bSopenharmony_ci testCharValues.push_back('b'); 2401401458bSopenharmony_ci testCharValues.push_back('c'); 2411401458bSopenharmony_ci 2421401458bSopenharmony_ci std::vector<unsigned char> testUnsignedCharValues; 2431401458bSopenharmony_ci testUnsignedCharValues.push_back('a'); 2441401458bSopenharmony_ci testUnsignedCharValues.push_back('b'); 2451401458bSopenharmony_ci testUnsignedCharValues.push_back('c'); 2461401458bSopenharmony_ci 2471401458bSopenharmony_ci std::vector<short> testShortValues; 2481401458bSopenharmony_ci testShortValues.push_back(-100); 2491401458bSopenharmony_ci testShortValues.push_back(-200); 2501401458bSopenharmony_ci testShortValues.push_back(-300); 2511401458bSopenharmony_ci 2521401458bSopenharmony_ci std::vector<unsigned short> testUnsignedShortValues; 2531401458bSopenharmony_ci testUnsignedShortValues.push_back(100); 2541401458bSopenharmony_ci testUnsignedShortValues.push_back(200); 2551401458bSopenharmony_ci testUnsignedShortValues.push_back(300); 2561401458bSopenharmony_ci 2571401458bSopenharmony_ci std::vector<int> testIntValues; 2581401458bSopenharmony_ci testIntValues.push_back(-1000); 2591401458bSopenharmony_ci testIntValues.push_back(-2000); 2601401458bSopenharmony_ci testIntValues.push_back(-3000); 2611401458bSopenharmony_ci 2621401458bSopenharmony_ci std::vector<unsigned int> testUnsignedIntValues; 2631401458bSopenharmony_ci testUnsignedIntValues.push_back(1000); 2641401458bSopenharmony_ci testUnsignedIntValues.push_back(2000); 2651401458bSopenharmony_ci testUnsignedIntValues.push_back(3000); 2661401458bSopenharmony_ci 2671401458bSopenharmony_ci std::vector<long> testLongValues; 2681401458bSopenharmony_ci testLongValues.push_back(-10000); 2691401458bSopenharmony_ci testLongValues.push_back(-20000); 2701401458bSopenharmony_ci testLongValues.push_back(-30000); 2711401458bSopenharmony_ci 2721401458bSopenharmony_ci std::vector<unsigned long> testUnsignedLongValues; 2731401458bSopenharmony_ci testUnsignedLongValues.push_back(10000); 2741401458bSopenharmony_ci testUnsignedLongValues.push_back(20000); 2751401458bSopenharmony_ci testUnsignedLongValues.push_back(30000); 2761401458bSopenharmony_ci 2771401458bSopenharmony_ci std::vector<long long> testLongLongValues; 2781401458bSopenharmony_ci testLongLongValues.push_back(-100000); 2791401458bSopenharmony_ci testLongLongValues.push_back(-200000); 2801401458bSopenharmony_ci testLongLongValues.push_back(-300000); 2811401458bSopenharmony_ci 2821401458bSopenharmony_ci std::vector<unsigned long long> testUnsignedLongLongValues; 2831401458bSopenharmony_ci testUnsignedLongLongValues.push_back(100000); 2841401458bSopenharmony_ci testUnsignedLongLongValues.push_back(200000); 2851401458bSopenharmony_ci testUnsignedLongLongValues.push_back(300000); 2861401458bSopenharmony_ci 2871401458bSopenharmony_ci std::vector<float> testFloatValues; 2881401458bSopenharmony_ci testFloatValues.push_back(1.1); 2891401458bSopenharmony_ci testFloatValues.push_back(2.2); 2901401458bSopenharmony_ci testFloatValues.push_back(3.3); 2911401458bSopenharmony_ci 2921401458bSopenharmony_ci std::vector<double> testDoubleValues; 2931401458bSopenharmony_ci testDoubleValues.push_back(10.1); 2941401458bSopenharmony_ci testDoubleValues.push_back(20.2); 2951401458bSopenharmony_ci testDoubleValues.push_back(30.3); 2961401458bSopenharmony_ci 2971401458bSopenharmony_ci std::vector<std::string> testStringValues; 2981401458bSopenharmony_ci testStringValues.push_back(std::string("a")); 2991401458bSopenharmony_ci testStringValues.push_back(std::string("b")); 3001401458bSopenharmony_ci testStringValues.push_back(std::string("c")); 3011401458bSopenharmony_ci 3021401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test hisysevent normal write"); 3031401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, 3041401458bSopenharmony_ci "keyBool", testBoolValue, "keyChar", testCharValue, "keyShort", testShortValue, 3051401458bSopenharmony_ci "keyInt", testIntValue, "KeyLong", testLongValue, "KeyLongLong", testLongLongValue, 3061401458bSopenharmony_ci "keyUnsignedChar", testUnsignedCharValue, "keyUnsignedShort", testUnsignedShortValue, 3071401458bSopenharmony_ci "keyUnsignedInt", testUnsignedIntValue, "keyUnsignedLong", testUnsignedLongValue, 3081401458bSopenharmony_ci "keyUnsignedLongLong", testUnsignedLongLongValue, "keyFloat", testFloatValue, 3091401458bSopenharmony_ci "keyDouble", testDoubleValue, "keyString1", testStringValue, "keyString2", "efg", 3101401458bSopenharmony_ci "keyBools", testBoolValues, "keyChars", testCharValues, "keyUnsignedChars", testUnsignedCharValues, 3111401458bSopenharmony_ci "keyShorts", testShortValues, "keyUnsignedShorts", testUnsignedShortValues, 3121401458bSopenharmony_ci "keyInts", testIntValues, "keyUnsignedInts", testUnsignedIntValues, "keyLongs", testLongValues, 3131401458bSopenharmony_ci "keyUnsignedLongs", testUnsignedLongValues, "keyLongLongs", testLongLongValues, 3141401458bSopenharmony_ci "keyUnsignedLongLongs", testUnsignedLongLongValues, "keyFloats", testFloatValues, 3151401458bSopenharmony_ci "keyDoubles", testDoubleValues, "keyStrings", testStringValues); 3161401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "normal write, retCode=%{public}d", result); 3171401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result == OHOS::HiviewDFX::SUCCESS)); 3181401458bSopenharmony_ci} 3191401458bSopenharmony_ci 3201401458bSopenharmony_ci/** 3211401458bSopenharmony_ci * @tc.name: TestHiSysEventDomainSpecialChar002 3221401458bSopenharmony_ci * @tc.desc: Test domain has special char. 3231401458bSopenharmony_ci * @tc.type: FUNC 3241401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 3251401458bSopenharmony_ci */ 3261401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventDomainSpecialChar002, TestSize.Level1) 3271401458bSopenharmony_ci{ 3281401458bSopenharmony_ci /** 3291401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 3301401458bSopenharmony_ci */ 3311401458bSopenharmony_ci static constexpr char domain[] = "_demo"; 3321401458bSopenharmony_ci std::string eventName = "DOMAIN_SPECIAL_CHAR"; 3331401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test hisysevent domain has special char"); 3341401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT); 3351401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "domain has special char, retCode=%{public}d", result); 3361401458bSopenharmony_ci ASSERT_LT(result, 0); 3371401458bSopenharmony_ci} 3381401458bSopenharmony_ci 3391401458bSopenharmony_ci/** 3401401458bSopenharmony_ci * @tc.name: TestHiSysEventDomainEmpty003 3411401458bSopenharmony_ci * @tc.desc: Test domain is empty. 3421401458bSopenharmony_ci * @tc.type: FUNC 3431401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 3441401458bSopenharmony_ci */ 3451401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventDomainEmpty003, TestSize.Level1) 3461401458bSopenharmony_ci{ 3471401458bSopenharmony_ci /** 3481401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 3491401458bSopenharmony_ci */ 3501401458bSopenharmony_ci static constexpr char domain[] = ""; 3511401458bSopenharmony_ci std::string eventName = "DOMAIN_EMPTY"; 3521401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test hisysevent domain is empty"); 3531401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT); 3541401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "domain is empty, retCode=%{public}d", result); 3551401458bSopenharmony_ci ASSERT_LT(result, 0); 3561401458bSopenharmony_ci} 3571401458bSopenharmony_ci 3581401458bSopenharmony_ci/** 3591401458bSopenharmony_ci * @tc.name: TestHiSysEventDomainTooLong004 3601401458bSopenharmony_ci * @tc.desc: Test domain is too long. 3611401458bSopenharmony_ci * @tc.type: FUNC 3621401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 3631401458bSopenharmony_ci */ 3641401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventDomainTooLong004, TestSize.Level1) 3651401458bSopenharmony_ci{ 3661401458bSopenharmony_ci /** 3671401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 3681401458bSopenharmony_ci */ 3691401458bSopenharmony_ci static constexpr char domain16[] = "AAAAAAAAAAAAAAAA"; 3701401458bSopenharmony_ci std::string eventName = "DOMAIN_TOO_LONG_16"; 3711401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test hisysevent domain is too long, normal length"); 3721401458bSopenharmony_ci 3731401458bSopenharmony_ci int result = 0; 3741401458bSopenharmony_ci result = HiSysEventWrite(domain16, eventName, HiSysEvent::EventType::FAULT); 3751401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "domain too long, equal 16 retCode=%{public}d", result); 3761401458bSopenharmony_ci 3771401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test hisysevent domain is too long"); 3781401458bSopenharmony_ci static constexpr char domain17[] = "AAAAAAAAAAAAAAAAL"; 3791401458bSopenharmony_ci eventName = "DOMAIN_TOO_LONG_17"; 3801401458bSopenharmony_ci result = HiSysEventWrite(domain17, eventName, HiSysEvent::EventType::FAULT); 3811401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "domain is too long, more than 16 retCode=%{public}d", result); 3821401458bSopenharmony_ci ASSERT_LT(result, 0); 3831401458bSopenharmony_ci} 3841401458bSopenharmony_ci 3851401458bSopenharmony_ci/** 3861401458bSopenharmony_ci * @tc.name: TesetHiSysEventSpecailEventName005 3871401458bSopenharmony_ci * @tc.desc: Test event name has special char. 3881401458bSopenharmony_ci * @tc.type: FUNC 3891401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 3901401458bSopenharmony_ci */ 3911401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TesetHiSysEventSpecailEventName005, TestSize.Level1) 3921401458bSopenharmony_ci{ 3931401458bSopenharmony_ci /** 3941401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 3951401458bSopenharmony_ci */ 3961401458bSopenharmony_ci static constexpr char domain[] = "SPEC_EVT_NAME"; 3971401458bSopenharmony_ci std::string eventName = "_SPECIAL_CHAR"; 3981401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test hisysevent event name has special char"); 3991401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT); 4001401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "event name has special char, retCode=%{public}d", result); 4011401458bSopenharmony_ci ASSERT_LT(result, 0); 4021401458bSopenharmony_ci} 4031401458bSopenharmony_ci 4041401458bSopenharmony_ci/** 4051401458bSopenharmony_ci * @tc.name: TestHiSysEventNameEmpty006 4061401458bSopenharmony_ci * @tc.desc: Test event name is empty. 4071401458bSopenharmony_ci * @tc.type: FUNC 4081401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 4091401458bSopenharmony_ci */ 4101401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventNameEmpty006, TestSize.Level1) 4111401458bSopenharmony_ci{ 4121401458bSopenharmony_ci /** 4131401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 4141401458bSopenharmony_ci */ 4151401458bSopenharmony_ci static constexpr char domain[] = "EMPTY"; 4161401458bSopenharmony_ci std::string eventName = ""; 4171401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test hisysevent event name is empty"); 4181401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT); 4191401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "event name is empty, retCode=%{public}d", result); 4201401458bSopenharmony_ci ASSERT_LT(result, 0); 4211401458bSopenharmony_ci} 4221401458bSopenharmony_ci 4231401458bSopenharmony_ci/** 4241401458bSopenharmony_ci * @tc.name: TesetHiSysEventNameTooLong007 4251401458bSopenharmony_ci * @tc.desc: Test event name too long. 4261401458bSopenharmony_ci * @tc.type: FUNC 4271401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 4281401458bSopenharmony_ci */ 4291401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TesetHiSysEventNameTooLong007, TestSize.Level1) 4301401458bSopenharmony_ci{ 4311401458bSopenharmony_ci /** 4321401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 4331401458bSopenharmony_ci */ 4341401458bSopenharmony_ci static constexpr char domain32[] = "NAME_32"; 4351401458bSopenharmony_ci std::string eventName = ""; 4361401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test hisysevent event name is too long, normal length"); 4371401458bSopenharmony_ci int normal = 32; 4381401458bSopenharmony_ci for (int index = 0; index < normal; index++) { 4391401458bSopenharmony_ci eventName.append("N"); 4401401458bSopenharmony_ci } 4411401458bSopenharmony_ci int result = 0; 4421401458bSopenharmony_ci result = HiSysEventWrite(domain32, eventName, HiSysEvent::EventType::FAULT); 4431401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "event name is too long, equal 32, retCode=%{public}d", result); 4441401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result == OHOS::HiviewDFX::SUCCESS)); 4451401458bSopenharmony_ci 4461401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test hisysevent event name is too long"); 4471401458bSopenharmony_ci static constexpr char domain33[] = "NAME_33"; 4481401458bSopenharmony_ci eventName.append("L"); 4491401458bSopenharmony_ci result = HiSysEventWrite(domain33, eventName, HiSysEvent::EventType::FAULT); 4501401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "event name is too long, more than 32, retCode=%{public}d", result); 4511401458bSopenharmony_ci ASSERT_LT(result, 0); 4521401458bSopenharmony_ci} 4531401458bSopenharmony_ci 4541401458bSopenharmony_ci/** 4551401458bSopenharmony_ci * @tc.name: TestHiSysEventKeySpecialChar008 4561401458bSopenharmony_ci * @tc.desc: Test key has specail char. 4571401458bSopenharmony_ci * @tc.type: FUNC 4581401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 4591401458bSopenharmony_ci */ 4601401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventKeySpecialChar008, TestSize.Level1) 4611401458bSopenharmony_ci{ 4621401458bSopenharmony_ci /** 4631401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 4641401458bSopenharmony_ci */ 4651401458bSopenharmony_ci static constexpr char domain[] = "DEMO"; 4661401458bSopenharmony_ci std::string eventName = "HiSysEvent006"; 4671401458bSopenharmony_ci std::string key1 = "_key1"; 4681401458bSopenharmony_ci std::string key2 = "key2"; 4691401458bSopenharmony_ci int result = 0; 4701401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test hisysevent key has special char"); 4711401458bSopenharmony_ci bool value1 = true; 4721401458bSopenharmony_ci result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, key1, value1, key2, value1); 4731401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 4741401458bSopenharmony_ci 4751401458bSopenharmony_ci short value2 = 2; 4761401458bSopenharmony_ci result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, key1, value2, key2, value2); 4771401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 4781401458bSopenharmony_ci 4791401458bSopenharmony_ci unsigned short value3 = 3; 4801401458bSopenharmony_ci result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, key1, value3, key2, value3); 4811401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 4821401458bSopenharmony_ci 4831401458bSopenharmony_ci int value4 = 4; 4841401458bSopenharmony_ci result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, key1, value4, key2, value4); 4851401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 4861401458bSopenharmony_ci 4871401458bSopenharmony_ci unsigned int value5 = 5; 4881401458bSopenharmony_ci result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, key1, value5, key2, value5); 4891401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 4901401458bSopenharmony_ci 4911401458bSopenharmony_ci long value6 = 6; 4921401458bSopenharmony_ci result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, key1, value6, key2, value6); 4931401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 4941401458bSopenharmony_ci 4951401458bSopenharmony_ci unsigned long value7 = 7; 4961401458bSopenharmony_ci result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, key1, value7, key2, value7); 4971401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 4981401458bSopenharmony_ci 4991401458bSopenharmony_ci long long value8 = 8; 5001401458bSopenharmony_ci result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, key1, value8, key2, value8); 5011401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 5021401458bSopenharmony_ci 5031401458bSopenharmony_ci unsigned long long value9 = 9; 5041401458bSopenharmony_ci result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, key1, value9, key2, value9); 5051401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 5061401458bSopenharmony_ci 5071401458bSopenharmony_ci char value10 = 'a'; 5081401458bSopenharmony_ci result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, key1, value10, key2, value10); 5091401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 5101401458bSopenharmony_ci 5111401458bSopenharmony_ci unsigned char value11 = 'b'; 5121401458bSopenharmony_ci result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, key1, value11, key2, value11); 5131401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 5141401458bSopenharmony_ci 5151401458bSopenharmony_ci float value12 = 12.12; 5161401458bSopenharmony_ci result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, key1, value12, key2, value12); 5171401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 5181401458bSopenharmony_ci 5191401458bSopenharmony_ci double value13 = 13.13; 5201401458bSopenharmony_ci result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, key1, value13, key2, value13); 5211401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 5221401458bSopenharmony_ci} 5231401458bSopenharmony_ci 5241401458bSopenharmony_ci 5251401458bSopenharmony_ci/** 5261401458bSopenharmony_ci * @tc.name: TestHiSysEventEscape009 5271401458bSopenharmony_ci * @tc.desc: Test key's value need escape. 5281401458bSopenharmony_ci * @tc.type: FUNC 5291401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 5301401458bSopenharmony_ci */ 5311401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventEscape009, TestSize.Level1) 5321401458bSopenharmony_ci{ 5331401458bSopenharmony_ci /** 5341401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 5351401458bSopenharmony_ci */ 5361401458bSopenharmony_ci static constexpr char domain[] = "DEMO"; 5371401458bSopenharmony_ci std::string eventName = "ESCAPE"; 5381401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test hisysevent escape char"); 5391401458bSopenharmony_ci std::string value = "\"escapeByCpp\""; 5401401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, "key1", value); 5411401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "key's value has espcae char, retCode=%{public}d", result); 5421401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result == OHOS::HiviewDFX::SUCCESS)); 5431401458bSopenharmony_ci} 5441401458bSopenharmony_ci 5451401458bSopenharmony_ci/** 5461401458bSopenharmony_ci * @tc.name: TestHiSysEventKeyEmpty010 5471401458bSopenharmony_ci * @tc.desc: Test key is empty. 5481401458bSopenharmony_ci * @tc.type: FUNC 5491401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 5501401458bSopenharmony_ci */ 5511401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventKeyEmpty010, TestSize.Level1) 5521401458bSopenharmony_ci{ 5531401458bSopenharmony_ci /** 5541401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 5551401458bSopenharmony_ci */ 5561401458bSopenharmony_ci static constexpr char domain[] = "DEMO"; 5571401458bSopenharmony_ci std::string eventName = "KEY_EMPTY"; 5581401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test hisysevent key is empty"); 5591401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, 5601401458bSopenharmony_ci "", "valueIsEmpty", "key2", "notEmpty"); 5611401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "key is empty, retCode=%{public}d", result); 5621401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 5631401458bSopenharmony_ci} 5641401458bSopenharmony_ci 5651401458bSopenharmony_ci/** 5661401458bSopenharmony_ci * @tc.name: TestHiSysEventKeySpecialChar011 5671401458bSopenharmony_ci * @tc.desc: Test key has special char. 5681401458bSopenharmony_ci * @tc.type: FUNC 5691401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 5701401458bSopenharmony_ci */ 5711401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventKeySpecialChar011, TestSize.Level1) 5721401458bSopenharmony_ci{ 5731401458bSopenharmony_ci /** 5741401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 5751401458bSopenharmony_ci */ 5761401458bSopenharmony_ci static constexpr char domain[] = "DEMO"; 5771401458bSopenharmony_ci std::string eventName = "KEY_SPECIAL_CHAR"; 5781401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test hisysevent key is special"); 5791401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, 5801401458bSopenharmony_ci "_key1", "special", "key2", "normal"); 5811401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "key has special char, retCode=%{public}d", result); 5821401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 5831401458bSopenharmony_ci} 5841401458bSopenharmony_ci 5851401458bSopenharmony_ci/** 5861401458bSopenharmony_ci * @tc.name: TestHiSysEventKeyTooLong012 5871401458bSopenharmony_ci * @tc.desc: Test key is too long. 5881401458bSopenharmony_ci * @tc.type: FUNC 5891401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 5901401458bSopenharmony_ci */ 5911401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventKeyTooLong012, TestSize.Level1) 5921401458bSopenharmony_ci{ 5931401458bSopenharmony_ci /** 5941401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 5951401458bSopenharmony_ci */ 5961401458bSopenharmony_ci static constexpr char domain[] = "DEMO"; 5971401458bSopenharmony_ci std::string eventName = "KEY_48"; 5981401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test hisysevent key 48 char"); 5991401458bSopenharmony_ci std::string key = ""; 6001401458bSopenharmony_ci int normal = 48; 6011401458bSopenharmony_ci for (int index = 0; index < normal; index++) { 6021401458bSopenharmony_ci key.append("V"); 6031401458bSopenharmony_ci } 6041401458bSopenharmony_ci int result = 0; 6051401458bSopenharmony_ci result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, key, "48length", "key2", "normal"); 6061401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "key equal 48 char, retCode=%{public}d", result); 6071401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result == OHOS::HiviewDFX::SUCCESS)); 6081401458bSopenharmony_ci 6091401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test hisysevent key 49 char"); 6101401458bSopenharmony_ci eventName = "KEY_49"; 6111401458bSopenharmony_ci key.append("V"); 6121401458bSopenharmony_ci result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, key, "49length", "key2", "normal"); 6131401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "key more than 48 char, retCode=%{public}d", result); 6141401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 6151401458bSopenharmony_ci} 6161401458bSopenharmony_ci 6171401458bSopenharmony_ci/** 6181401458bSopenharmony_ci * @tc.name: TestHiSysEvent128Keys013 6191401458bSopenharmony_ci * @tc.desc: Test 128 key. 6201401458bSopenharmony_ci * @tc.type: FUNC 6211401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 6221401458bSopenharmony_ci */ 6231401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEvent128Keys013, TestSize.Level1) 6241401458bSopenharmony_ci{ 6251401458bSopenharmony_ci /** 6261401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 6271401458bSopenharmony_ci */ 6281401458bSopenharmony_ci static constexpr char domain[] = "TEST"; 6291401458bSopenharmony_ci std::string eventName = "KEY_EQUAL_128"; 6301401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test hisysevent 128 keys"); 6311401458bSopenharmony_ci std::string k = "k"; 6321401458bSopenharmony_ci bool v = true; 6331401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, 6341401458bSopenharmony_ci SYS_EVENT_PARAMS(10), SYS_EVENT_PARAMS(20), SYS_EVENT_PARAMS(30), SYS_EVENT_PARAMS(40), SYS_EVENT_PARAMS(50), 6351401458bSopenharmony_ci SYS_EVENT_PARAMS(60), SYS_EVENT_PARAMS(70), SYS_EVENT_PARAMS(80), SYS_EVENT_PARAMS(90), SYS_EVENT_PARAMS(100), 6361401458bSopenharmony_ci SYS_EVENT_PARAMS(110), SYS_EVENT_PARAMS(120), 6371401458bSopenharmony_ci k, v, k, v, k, v, k, v, k, v, k, v, k, v, k, v); 6381401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "has 128 key, retCode=%{public}d", result); 6391401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result == OHOS::HiviewDFX::SUCCESS)); 6401401458bSopenharmony_ci} 6411401458bSopenharmony_ci 6421401458bSopenharmony_ci/** 6431401458bSopenharmony_ci * @tc.name: TestHiSysEvent129Keys014 6441401458bSopenharmony_ci * @tc.desc: Test 129 key. 6451401458bSopenharmony_ci * @tc.type: FUNC 6461401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 6471401458bSopenharmony_ci */ 6481401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEvent129Keys014, TestSize.Level1) 6491401458bSopenharmony_ci{ 6501401458bSopenharmony_ci /** 6511401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 6521401458bSopenharmony_ci */ 6531401458bSopenharmony_ci static constexpr char domain[] = "TEST"; 6541401458bSopenharmony_ci std::string eventName = "KEY_EQUAL_129"; 6551401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test hisysevent 129 key"); 6561401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, 6571401458bSopenharmony_ci SYS_EVENT_PARAMS(10), SYS_EVENT_PARAMS(20), SYS_EVENT_PARAMS(30), SYS_EVENT_PARAMS(40), SYS_EVENT_PARAMS(50), 6581401458bSopenharmony_ci SYS_EVENT_PARAMS(60), SYS_EVENT_PARAMS(70), SYS_EVENT_PARAMS(80), SYS_EVENT_PARAMS(90), SYS_EVENT_PARAMS(100), 6591401458bSopenharmony_ci SYS_EVENT_PARAMS(110), SYS_EVENT_PARAMS(120), 6601401458bSopenharmony_ci "key1", true, "key2", true, "key3", true, "key4", true, "key5", true, 6611401458bSopenharmony_ci "key6", true, "key7", true, "key8", true, "key9", true); 6621401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "has 129 key, retCode=%{public}d", result); 6631401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 6641401458bSopenharmony_ci} 6651401458bSopenharmony_ci 6661401458bSopenharmony_ci/** 6671401458bSopenharmony_ci * @tc.name: TestHiSysEventStringValueEqual256K015 6681401458bSopenharmony_ci * @tc.desc: Test 256K string. 6691401458bSopenharmony_ci * @tc.type: FUNC 6701401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 6711401458bSopenharmony_ci */ 6721401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventStringValueEqual256K015, TestSize.Level1) 6731401458bSopenharmony_ci{ 6741401458bSopenharmony_ci /** 6751401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 6761401458bSopenharmony_ci */ 6771401458bSopenharmony_ci static constexpr char domain[] = "TEST"; 6781401458bSopenharmony_ci std::string eventName = "EQUAL_256K"; 6791401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test key's value 256K string"); 6801401458bSopenharmony_ci std::string value; 6811401458bSopenharmony_ci int length = 256 * 1024; 6821401458bSopenharmony_ci for (int index = 0; index < length; index++) { 6831401458bSopenharmony_ci value.push_back('1' + index % 10); 6841401458bSopenharmony_ci } 6851401458bSopenharmony_ci sleep(1); // make sure hiview read all data before send large data 6861401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, "key1", value); 6871401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "string length is 256K, retCode=%{public}d", result); 6881401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result == OHOS::HiviewDFX::SUCCESS)); 6891401458bSopenharmony_ci} 6901401458bSopenharmony_ci 6911401458bSopenharmony_ci/** 6921401458bSopenharmony_ci * @tc.name: TestHiSysEventStringValueMoreThan256K016 6931401458bSopenharmony_ci * @tc.desc: Test 256K + 1 string. 6941401458bSopenharmony_ci * @tc.type: FUNC 6951401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 6961401458bSopenharmony_ci */ 6971401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventStringValueMoreThan256K016, TestSize.Level1) 6981401458bSopenharmony_ci{ 6991401458bSopenharmony_ci /** 7001401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 7011401458bSopenharmony_ci */ 7021401458bSopenharmony_ci static constexpr char domain[] = "DEMO"; 7031401458bSopenharmony_ci std::string eventName = "MORETHAN256K"; 7041401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test more than 256K string"); 7051401458bSopenharmony_ci std::string value; 7061401458bSopenharmony_ci int length = 256 * 1024 + 1; 7071401458bSopenharmony_ci for (int index = 0; index < length; index++) { 7081401458bSopenharmony_ci value.push_back('1' + index % 10); 7091401458bSopenharmony_ci } 7101401458bSopenharmony_ci sleep(1); // make sure hiview read all data before send large data 7111401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, "key1", value); 7121401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "string length is more than 256K, retCode=%{public}d", result); 7131401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 7141401458bSopenharmony_ci} 7151401458bSopenharmony_ci 7161401458bSopenharmony_ci/** 7171401458bSopenharmony_ci * @tc.name: TestHiSysEventArray100Item017 7181401458bSopenharmony_ci * @tc.desc: Test bool array item 100. 7191401458bSopenharmony_ci * @tc.type: FUNC 7201401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 7211401458bSopenharmony_ci */ 7221401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventArray100Item017, TestSize.Level1) 7231401458bSopenharmony_ci{ 7241401458bSopenharmony_ci /** 7251401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 7261401458bSopenharmony_ci */ 7271401458bSopenharmony_ci static constexpr char domain[] = "DEMO"; 7281401458bSopenharmony_ci std::string eventName = "BOOL_ARRAY_100"; 7291401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test bool array 100 item"); 7301401458bSopenharmony_ci std::vector<bool> values; 7311401458bSopenharmony_ci int maxItem = 100; 7321401458bSopenharmony_ci for (int index = 0; index < maxItem; index++) { 7331401458bSopenharmony_ci values.push_back(true); 7341401458bSopenharmony_ci } 7351401458bSopenharmony_ci sleep(1); // make sure hiview read all data before send large data 7361401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, "key1", values); 7371401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "array bool list 100, retCode=%{public}d", result); 7381401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result == OHOS::HiviewDFX::SUCCESS)); 7391401458bSopenharmony_ci} 7401401458bSopenharmony_ci 7411401458bSopenharmony_ci/** 7421401458bSopenharmony_ci * @tc.name: TestHiSysEventArray101Item018 7431401458bSopenharmony_ci * @tc.desc: Test bool array item 101. 7441401458bSopenharmony_ci * @tc.type: FUNC 7451401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 7461401458bSopenharmony_ci */ 7471401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventArray101Item018, TestSize.Level1) 7481401458bSopenharmony_ci{ 7491401458bSopenharmony_ci /** 7501401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 7511401458bSopenharmony_ci */ 7521401458bSopenharmony_ci static constexpr char domain[] = "DEMO"; 7531401458bSopenharmony_ci std::string eventName = "BOOL_ARRAY_101"; 7541401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test bool array 101 item"); 7551401458bSopenharmony_ci std::vector<bool> values; 7561401458bSopenharmony_ci int maxItem = 101; 7571401458bSopenharmony_ci for (int index = 0; index < maxItem; index++) { 7581401458bSopenharmony_ci values.push_back(true); 7591401458bSopenharmony_ci } 7601401458bSopenharmony_ci sleep(1); // make sure hiview read all data before send large data 7611401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, "key1", values); 7621401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "array bool list 101, retCode=%{public}d", result); 7631401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 7641401458bSopenharmony_ci} 7651401458bSopenharmony_ci 7661401458bSopenharmony_ci/** 7671401458bSopenharmony_ci * @tc.name: TestHiSysEventArray100CharItem019 7681401458bSopenharmony_ci * @tc.desc: Test char array item 100. 7691401458bSopenharmony_ci * @tc.type: FUNC 7701401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 7711401458bSopenharmony_ci */ 7721401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventArray100CharItem019, TestSize.Level1) 7731401458bSopenharmony_ci{ 7741401458bSopenharmony_ci /** 7751401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 7761401458bSopenharmony_ci */ 7771401458bSopenharmony_ci static constexpr char domain[] = "DEMO"; 7781401458bSopenharmony_ci std::string eventName = "CHAR_ARRAY_100"; 7791401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test char array 100 item"); 7801401458bSopenharmony_ci std::vector<char> values; 7811401458bSopenharmony_ci int maxItem = 100; 7821401458bSopenharmony_ci for (int index = 0; index < maxItem; index++) { 7831401458bSopenharmony_ci values.push_back('a'); 7841401458bSopenharmony_ci } 7851401458bSopenharmony_ci sleep(1); // make sure hiview read all data before send large data 7861401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, "key1", values); 7871401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "array char list 100, retCode=%{public}d", result); 7881401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result == OHOS::HiviewDFX::SUCCESS)); 7891401458bSopenharmony_ci} 7901401458bSopenharmony_ci 7911401458bSopenharmony_ci/** 7921401458bSopenharmony_ci * @tc.name: TestHiSysEventArray101CharItem020 7931401458bSopenharmony_ci * @tc.desc: Test char array item 101. 7941401458bSopenharmony_ci * @tc.type: FUNC 7951401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 7961401458bSopenharmony_ci */ 7971401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventArray101CharItem020, TestSize.Level1) 7981401458bSopenharmony_ci{ 7991401458bSopenharmony_ci /** 8001401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 8011401458bSopenharmony_ci */ 8021401458bSopenharmony_ci static constexpr char domain[] = "DEMO"; 8031401458bSopenharmony_ci std::string eventName = "CHAR_ARRAY_101"; 8041401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test char array 101 item"); 8051401458bSopenharmony_ci std::vector<char> values; 8061401458bSopenharmony_ci int maxItem = 101; 8071401458bSopenharmony_ci for (int index = 0; index < maxItem; index++) { 8081401458bSopenharmony_ci values.push_back('z'); 8091401458bSopenharmony_ci } 8101401458bSopenharmony_ci sleep(1); // make sure hiview read all data before send large data 8111401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, "key1", values); 8121401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "array char list 101, retCode=%{public}d", result); 8131401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 8141401458bSopenharmony_ci} 8151401458bSopenharmony_ci 8161401458bSopenharmony_ci/** 8171401458bSopenharmony_ci * @tc.name: TestHiSysEventArray100UnsignedCharItem021 8181401458bSopenharmony_ci * @tc.desc: Test unsigned char array item 100. 8191401458bSopenharmony_ci * @tc.type: FUNC 8201401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 8211401458bSopenharmony_ci */ 8221401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventArray100UnsignedCharItem021, TestSize.Level1) 8231401458bSopenharmony_ci{ 8241401458bSopenharmony_ci /** 8251401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 8261401458bSopenharmony_ci */ 8271401458bSopenharmony_ci static constexpr char domain[] = "DEMO"; 8281401458bSopenharmony_ci std::string eventName = "UCHAR_ARRAY_100"; 8291401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test unsigned char array 100 item"); 8301401458bSopenharmony_ci std::vector<unsigned char> values; 8311401458bSopenharmony_ci int maxItem = 100; 8321401458bSopenharmony_ci for (int index = 0; index < maxItem; index++) { 8331401458bSopenharmony_ci values.push_back('a'); 8341401458bSopenharmony_ci } 8351401458bSopenharmony_ci sleep(1); // make sure hiview read all data before send large data 8361401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, "key1", values); 8371401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "array unsigned char list 100, retCode=%{public}d", result); 8381401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result == OHOS::HiviewDFX::SUCCESS)); 8391401458bSopenharmony_ci} 8401401458bSopenharmony_ci 8411401458bSopenharmony_ci/** 8421401458bSopenharmony_ci * @tc.name: TestHiSysEventArray101UnsignedCharItem022 8431401458bSopenharmony_ci * @tc.desc: Test unsigned char array item 101. 8441401458bSopenharmony_ci * @tc.type: FUNC 8451401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 8461401458bSopenharmony_ci */ 8471401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventArray101UnsignedCharItem022, TestSize.Level1) 8481401458bSopenharmony_ci{ 8491401458bSopenharmony_ci /** 8501401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 8511401458bSopenharmony_ci */ 8521401458bSopenharmony_ci static constexpr char domain[] = "DEMO"; 8531401458bSopenharmony_ci std::string eventName = "UCHAR_ARRAY_101"; 8541401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test unsigned char array 101 item"); 8551401458bSopenharmony_ci std::vector<unsigned char> values; 8561401458bSopenharmony_ci int maxItem = 101; 8571401458bSopenharmony_ci for (int index = 0; index < maxItem; index++) { 8581401458bSopenharmony_ci values.push_back('z'); 8591401458bSopenharmony_ci } 8601401458bSopenharmony_ci sleep(1); // make sure hiview read all data before send large data 8611401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, "key1", values); 8621401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "array unsigned char list 101, retCode=%{public}d", result); 8631401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > OHOS::HiviewDFX::SUCCESS)); 8641401458bSopenharmony_ci} 8651401458bSopenharmony_ci 8661401458bSopenharmony_ci 8671401458bSopenharmony_ci/** 8681401458bSopenharmony_ci * @tc.name: TestHiSysEventArray100StringItem023 8691401458bSopenharmony_ci * @tc.desc: Test string array item 100. 8701401458bSopenharmony_ci * @tc.type: FUNC 8711401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 8721401458bSopenharmony_ci */ 8731401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventArray100StringItem023, TestSize.Level1) 8741401458bSopenharmony_ci{ 8751401458bSopenharmony_ci /** 8761401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 8771401458bSopenharmony_ci */ 8781401458bSopenharmony_ci static constexpr char domain[] = "DEMO"; 8791401458bSopenharmony_ci std::string eventName = "STR_ARRAY_100"; 8801401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test string array 100 item"); 8811401458bSopenharmony_ci std::vector<std::string> values; 8821401458bSopenharmony_ci int maxItem = 100; 8831401458bSopenharmony_ci for (int index = 0; index < maxItem; index++) { 8841401458bSopenharmony_ci values.push_back("a"); 8851401458bSopenharmony_ci } 8861401458bSopenharmony_ci sleep(1); // make sure hiview read all data before send large data 8871401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, "key1", values); 8881401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "array string list 100, retCode=%{public}d", result); 8891401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result == OHOS::HiviewDFX::SUCCESS)); 8901401458bSopenharmony_ci} 8911401458bSopenharmony_ci 8921401458bSopenharmony_ci/** 8931401458bSopenharmony_ci * @tc.name: TestHiSysEventArray101StringItem024 8941401458bSopenharmony_ci * @tc.desc: Test string array item 101. 8951401458bSopenharmony_ci * @tc.type: FUNC 8961401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 8971401458bSopenharmony_ci */ 8981401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventArray101StringItem024, TestSize.Level1) 8991401458bSopenharmony_ci{ 9001401458bSopenharmony_ci /** 9011401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 9021401458bSopenharmony_ci */ 9031401458bSopenharmony_ci static constexpr char domain[] = "DEMO"; 9041401458bSopenharmony_ci std::string eventName = "STR_ARRAY_101"; 9051401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test string array 101 item"); 9061401458bSopenharmony_ci std::vector<std::string> values; 9071401458bSopenharmony_ci int maxItem = 101; 9081401458bSopenharmony_ci for (int index = 0; index < maxItem; index++) { 9091401458bSopenharmony_ci values.push_back("z"); 9101401458bSopenharmony_ci } 9111401458bSopenharmony_ci sleep(1); // make sure hiview read all data before send large data 9121401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, "key1", values); 9131401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "array string list 101, retCode=%{public}d", result); 9141401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > 0)); 9151401458bSopenharmony_ci} 9161401458bSopenharmony_ci 9171401458bSopenharmony_ci/** 9181401458bSopenharmony_ci * @tc.name: TestHiSysEventArrayStringValueEqual256K025 9191401458bSopenharmony_ci * @tc.desc: Test array item 256K string. 9201401458bSopenharmony_ci * @tc.type: FUNC 9211401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 9221401458bSopenharmony_ci */ 9231401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventArrayStringValueEqual256K025, TestSize.Level1) 9241401458bSopenharmony_ci{ 9251401458bSopenharmony_ci /** 9261401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 9271401458bSopenharmony_ci */ 9281401458bSopenharmony_ci static constexpr char domain[] = "TEST"; 9291401458bSopenharmony_ci std::string eventName = "EQUAL_256K"; 9301401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test array item value 256K string"); 9311401458bSopenharmony_ci std::string value; 9321401458bSopenharmony_ci int length = 256 * 1024; 9331401458bSopenharmony_ci for (int index = 0; index < length; index++) { 9341401458bSopenharmony_ci value.push_back('1' + index % 10); 9351401458bSopenharmony_ci } 9361401458bSopenharmony_ci sleep(1); // make sure hiview read all data before send large data 9371401458bSopenharmony_ci std::vector<std::string> values; 9381401458bSopenharmony_ci values.push_back("c"); 9391401458bSopenharmony_ci values.push_back(value); 9401401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, "key1", values); 9411401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "array item value length is 256K, retCode=%{public}d", result); 9421401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result == 0)); 9431401458bSopenharmony_ci} 9441401458bSopenharmony_ci 9451401458bSopenharmony_ci/** 9461401458bSopenharmony_ci * @tc.name: TestHiSysEventArrayStringValueMoreThan256K016 9471401458bSopenharmony_ci * @tc.desc: Test 256K + 1 string. 9481401458bSopenharmony_ci * @tc.type: FUNC 9491401458bSopenharmony_ci * @tc.require: AR000G2QKU AR000FT2Q1 9501401458bSopenharmony_ci */ 9511401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventArrayStringValueMoreThan256K026, TestSize.Level1) 9521401458bSopenharmony_ci{ 9531401458bSopenharmony_ci /** 9541401458bSopenharmony_ci * @tc.steps: step1.make sure write sys event. 9551401458bSopenharmony_ci */ 9561401458bSopenharmony_ci static constexpr char domain[] = "DEMO"; 9571401458bSopenharmony_ci std::string eventName = "MORETHAN256K"; 9581401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "test array item value more than 256K string"); 9591401458bSopenharmony_ci std::string value; 9601401458bSopenharmony_ci int length = 256 * 1024 + 1; 9611401458bSopenharmony_ci for (int index = 0; index < length; index++) { 9621401458bSopenharmony_ci value.push_back('1' + index % 10); 9631401458bSopenharmony_ci } 9641401458bSopenharmony_ci sleep(1); // make sure hiview read all data before send large data 9651401458bSopenharmony_ci std::vector<std::string> values; 9661401458bSopenharmony_ci values.push_back("c"); 9671401458bSopenharmony_ci values.push_back(value); 9681401458bSopenharmony_ci int result = HiSysEventWrite(domain, eventName, HiSysEvent::EventType::FAULT, "key1", values); 9691401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "array item value length is more than 256K, retCode=%{public}d", result); 9701401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result > 0)); 9711401458bSopenharmony_ci} 9721401458bSopenharmony_ci 9731401458bSopenharmony_ci/** 9741401458bSopenharmony_ci * @tc.name: TestDefensingHiSysEventStorm 9751401458bSopenharmony_ci * @tc.desc: Write event more than 100 times in 5 seconds 9761401458bSopenharmony_ci * @tc.type: FUNC 9771401458bSopenharmony_ci * @tc.require: issueI5FNPQ 9781401458bSopenharmony_ci */ 9791401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestDefensingHiSysEventStorm, TestSize.Level1) 9801401458bSopenharmony_ci{ 9811401458bSopenharmony_ci int writeCount = 102; 9821401458bSopenharmony_ci for (int i = 0; i < writeCount; i++) { 9831401458bSopenharmony_ci auto result = WriteSysEventByMarcoInterface(); 9841401458bSopenharmony_ci if (i < HISYSEVENT_THRESHOLD) { 9851401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result == 0)); 9861401458bSopenharmony_ci } else { 9871401458bSopenharmony_ci ASSERT_TRUE(WrapSysEventWriteAssertion(result, result == OHOS::HiviewDFX::ERR_WRITE_IN_HIGH_FREQ)); 9881401458bSopenharmony_ci } 9891401458bSopenharmony_ci } 9901401458bSopenharmony_ci} 9911401458bSopenharmony_ci 9921401458bSopenharmony_ci/** 9931401458bSopenharmony_ci * @tc.name: TestAddAndRemoveListener 9941401458bSopenharmony_ci * @tc.desc: Add listener and then remove it 9951401458bSopenharmony_ci * @tc.type: FUNC 9961401458bSopenharmony_ci * @tc.require: issueI5KDIG 9971401458bSopenharmony_ci */ 9981401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestAddAndRemoveListener, TestSize.Level1) 9991401458bSopenharmony_ci{ 10001401458bSopenharmony_ci auto watcher = std::make_shared<Watcher>(); 10011401458bSopenharmony_ci OHOS::HiviewDFX::ListenerRule listenerRule("DOMAIN", "EVENT_NAME", "", OHOS::HiviewDFX::RuleType::WHOLE_WORD); 10021401458bSopenharmony_ci std::vector<OHOS::HiviewDFX::ListenerRule> sysRules; 10031401458bSopenharmony_ci sysRules.emplace_back(listenerRule); 10041401458bSopenharmony_ci auto ret = OHOS::HiviewDFX::HiSysEventManager::AddListener(nullptr, sysRules); 10051401458bSopenharmony_ci ASSERT_EQ(ret, ERR_LISTENER_NOT_EXIST); 10061401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventManager::AddListener(watcher, sysRules); 10071401458bSopenharmony_ci ASSERT_EQ(ret, 0); 10081401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventManager::RemoveListener(nullptr); 10091401458bSopenharmony_ci ASSERT_EQ(ret, ERR_LISTENER_NOT_EXIST); 10101401458bSopenharmony_ci auto newWatcher = std::make_shared<Watcher>(); 10111401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventManager::RemoveListener(newWatcher); 10121401458bSopenharmony_ci ASSERT_EQ(ret, ERR_LISTENER_NOT_EXIST); 10131401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventManager::RemoveListener(watcher); 10141401458bSopenharmony_ci ASSERT_EQ(ret, 0); 10151401458bSopenharmony_ci} 10161401458bSopenharmony_ci 10171401458bSopenharmony_ci/** 10181401458bSopenharmony_ci * @tc.name: TestEnableAndDisableDebugMode 10191401458bSopenharmony_ci * @tc.desc: Enable debug mode and then disable it on listener 10201401458bSopenharmony_ci * @tc.type: FUNC 10211401458bSopenharmony_ci * @tc.require: issueI5KDIG 10221401458bSopenharmony_ci */ 10231401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestEnableAndDisableDebugMode, TestSize.Level1) 10241401458bSopenharmony_ci{ 10251401458bSopenharmony_ci auto watcher = std::make_shared<Watcher>(); 10261401458bSopenharmony_ci OHOS::HiviewDFX::ListenerRule listenerRule("DOMAIN", "EVENT_NAME", "", OHOS::HiviewDFX::RuleType::WHOLE_WORD); 10271401458bSopenharmony_ci std::vector<OHOS::HiviewDFX::ListenerRule> sysRules; 10281401458bSopenharmony_ci sysRules.emplace_back(listenerRule); 10291401458bSopenharmony_ci auto ret = OHOS::HiviewDFX::HiSysEventManager::AddListener(watcher, sysRules); 10301401458bSopenharmony_ci ASSERT_EQ(ret, 0); 10311401458bSopenharmony_ci auto firstDebugRet = OHOS::HiviewDFX::HiSysEventManager::SetDebugMode(watcher, true); 10321401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventManager::SetDebugMode(nullptr, true); 10331401458bSopenharmony_ci ASSERT_EQ(ret, ERR_LISTENER_NOT_EXIST); 10341401458bSopenharmony_ci if (firstDebugRet == 0 || ret == ERR_DEBUG_MODE_SET_REPEAT) { 10351401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventManager::SetDebugMode(watcher, true); 10361401458bSopenharmony_ci ASSERT_EQ(ret, ERR_DEBUG_MODE_SET_REPEAT); 10371401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventManager::SetDebugMode(watcher, false); 10381401458bSopenharmony_ci ASSERT_EQ(ret, 0); 10391401458bSopenharmony_ci } 10401401458bSopenharmony_ci auto newWatcher = std::make_shared<Watcher>(); 10411401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventManager::SetDebugMode(newWatcher, true); 10421401458bSopenharmony_ci ASSERT_EQ(ret, ERR_LISTENER_NOT_EXIST); 10431401458bSopenharmony_ci} 10441401458bSopenharmony_ci 10451401458bSopenharmony_ci/** 10461401458bSopenharmony_ci * @tc.name: TestHiSysEventBaseManagerAddAndRemoveListener 10471401458bSopenharmony_ci * @tc.desc: Add a base listener and then remove it 10481401458bSopenharmony_ci * @tc.type: FUNC 10491401458bSopenharmony_ci * @tc.require: issueI5OA3F 10501401458bSopenharmony_ci */ 10511401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventBaseManagerAddAndRemoveListener, TestSize.Level1) 10521401458bSopenharmony_ci{ 10531401458bSopenharmony_ci auto watcher = std::make_shared<Watcher>(); 10541401458bSopenharmony_ci auto baseWatcher = std::make_shared<HiSysEventBaseListener>(watcher); 10551401458bSopenharmony_ci OHOS::HiviewDFX::ListenerRule listenerRule("DOMAIN", "EVENT_NAME", "", OHOS::HiviewDFX::RuleType::WHOLE_WORD); 10561401458bSopenharmony_ci std::vector<OHOS::HiviewDFX::ListenerRule> sysRules; 10571401458bSopenharmony_ci sysRules.emplace_back(listenerRule); 10581401458bSopenharmony_ci auto ret = OHOS::HiviewDFX::HiSysEventBaseManager::AddListener(nullptr, sysRules); 10591401458bSopenharmony_ci ASSERT_EQ(ret, ERR_LISTENER_NOT_EXIST); 10601401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventBaseManager::AddListener(baseWatcher, sysRules); 10611401458bSopenharmony_ci ASSERT_EQ(ret, 0); 10621401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventBaseManager::RemoveListener(nullptr); 10631401458bSopenharmony_ci ASSERT_EQ(ret, ERR_LISTENER_NOT_EXIST); 10641401458bSopenharmony_ci auto newBaseWatcher = std::make_shared<HiSysEventBaseListener>(watcher); 10651401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventBaseManager::RemoveListener(newBaseWatcher); 10661401458bSopenharmony_ci ASSERT_EQ(ret, ERR_LISTENER_NOT_EXIST); 10671401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventBaseManager::RemoveListener(baseWatcher); 10681401458bSopenharmony_ci ASSERT_EQ(ret, 0); 10691401458bSopenharmony_ci} 10701401458bSopenharmony_ci 10711401458bSopenharmony_ci/** 10721401458bSopenharmony_ci * @tc.name: TestHiSysEventBaseManagerSetDebugMode 10731401458bSopenharmony_ci * @tc.desc: Enable debug mode and then disable it on base listener 10741401458bSopenharmony_ci * @tc.type: FUNC 10751401458bSopenharmony_ci * @tc.require: issueI5KDIG 10761401458bSopenharmony_ci */ 10771401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventBaseManagerSetDebugMode, TestSize.Level1) 10781401458bSopenharmony_ci{ 10791401458bSopenharmony_ci auto watcher = std::make_shared<Watcher>(); 10801401458bSopenharmony_ci auto baseWatcher = std::make_shared<HiSysEventBaseListener>(watcher); 10811401458bSopenharmony_ci OHOS::HiviewDFX::ListenerRule listenerRule("DOMAIN", "EVENT_NAME", "", OHOS::HiviewDFX::RuleType::WHOLE_WORD); 10821401458bSopenharmony_ci std::vector<OHOS::HiviewDFX::ListenerRule> sysRules; 10831401458bSopenharmony_ci sysRules.emplace_back(listenerRule); 10841401458bSopenharmony_ci auto ret = OHOS::HiviewDFX::HiSysEventBaseManager::AddListener(baseWatcher, sysRules); 10851401458bSopenharmony_ci ASSERT_EQ(ret, 0); 10861401458bSopenharmony_ci auto firstDebugRet = OHOS::HiviewDFX::HiSysEventBaseManager::SetDebugMode(baseWatcher, true); 10871401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventBaseManager::SetDebugMode(nullptr, true); 10881401458bSopenharmony_ci ASSERT_EQ(ret, ERR_LISTENER_NOT_EXIST); 10891401458bSopenharmony_ci if (firstDebugRet == 0 || ret == ERR_DEBUG_MODE_SET_REPEAT) { 10901401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventBaseManager::SetDebugMode(baseWatcher, true); 10911401458bSopenharmony_ci ASSERT_EQ(ret, ERR_DEBUG_MODE_SET_REPEAT); 10921401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventBaseManager::SetDebugMode(baseWatcher, false); 10931401458bSopenharmony_ci ASSERT_EQ(ret, 0); 10941401458bSopenharmony_ci } 10951401458bSopenharmony_ci auto newBaseWatcher = std::make_shared<HiSysEventBaseListener>(watcher); 10961401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventBaseManager::SetDebugMode(newBaseWatcher, true); 10971401458bSopenharmony_ci ASSERT_EQ(ret, ERR_LISTENER_NOT_EXIST); 10981401458bSopenharmony_ci} 10991401458bSopenharmony_ci 11001401458bSopenharmony_ci/** 11011401458bSopenharmony_ci * @tc.name: TestHiSysEventBaseManagerQueryEvent 11021401458bSopenharmony_ci * @tc.desc: Query sys events by base manager 11031401458bSopenharmony_ci * @tc.type: FUNC 11041401458bSopenharmony_ci * @tc.require: issueI5KDIG 11051401458bSopenharmony_ci */ 11061401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventBaseManagerQueryEvent, TestSize.Level1) 11071401458bSopenharmony_ci{ 11081401458bSopenharmony_ci auto querier = std::make_shared<Querier>(); 11091401458bSopenharmony_ci long long defaultTimeStap = -1; 11101401458bSopenharmony_ci int queryCount = 10; 11111401458bSopenharmony_ci struct OHOS::HiviewDFX::QueryArg args(defaultTimeStap, defaultTimeStap, queryCount); 11121401458bSopenharmony_ci std::vector<OHOS::HiviewDFX::QueryRule> queryRules; 11131401458bSopenharmony_ci auto baseQuerier = std::make_shared<HiSysEventBaseQueryCallback>(querier); 11141401458bSopenharmony_ci auto ret = OHOS::HiviewDFX::HiSysEventBaseManager::Query(args, queryRules, baseQuerier); 11151401458bSopenharmony_ci ASSERT_EQ(ret, 0); 11161401458bSopenharmony_ci} 11171401458bSopenharmony_ci 11181401458bSopenharmony_ci/** 11191401458bSopenharmony_ci * @tc.name: TestHiSysEventManagerAddListenerWithTooManyRules 11201401458bSopenharmony_ci * @tc.desc: Add listener with more than 20 rules 11211401458bSopenharmony_ci * @tc.type: FUNC 11221401458bSopenharmony_ci * @tc.require: issueI5KDIG 11231401458bSopenharmony_ci */ 11241401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventManagerAddListenerWithTooManyRules, TestSize.Level1) 11251401458bSopenharmony_ci{ 11261401458bSopenharmony_ci auto watcher = std::make_shared<Watcher>(); 11271401458bSopenharmony_ci OHOS::HiviewDFX::ListenerRule listenerRule("DOMAIN", "EVENT_NAME", "", OHOS::HiviewDFX::RuleType::WHOLE_WORD); 11281401458bSopenharmony_ci int ruleCount = 20; 11291401458bSopenharmony_ci std::vector<OHOS::HiviewDFX::ListenerRule> sysRules; 11301401458bSopenharmony_ci while (ruleCount-- > 0) { 11311401458bSopenharmony_ci sysRules.emplace_back(listenerRule); 11321401458bSopenharmony_ci } 11331401458bSopenharmony_ci auto ret = OHOS::HiviewDFX::HiSysEventManager::AddListener(watcher, sysRules); 11341401458bSopenharmony_ci ASSERT_EQ(ret, 0); 11351401458bSopenharmony_ci sysRules.emplace_back(listenerRule); 11361401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventManager::AddListener(watcher, sysRules); 11371401458bSopenharmony_ci ASSERT_EQ(ret, OHOS::HiviewDFX::ERR_TOO_MANY_WATCH_RULES); 11381401458bSopenharmony_ci} 11391401458bSopenharmony_ci 11401401458bSopenharmony_ci/** 11411401458bSopenharmony_ci * @tc.name: TestHiSysEventManagerAddTooManyEventListener 11421401458bSopenharmony_ci * @tc.desc: Adding more than 30 event listener 11431401458bSopenharmony_ci * @tc.type: FUNC 11441401458bSopenharmony_ci * @tc.require: issueI5KDIG 11451401458bSopenharmony_ci */ 11461401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventManagerAddTooManyEventListener, TestSize.Level1) 11471401458bSopenharmony_ci{ 11481401458bSopenharmony_ci OHOS::HiviewDFX::ListenerRule listenerRule("DOMAIN", "EVENT_NAME", "", OHOS::HiviewDFX::RuleType::WHOLE_WORD); 11491401458bSopenharmony_ci std::vector<OHOS::HiviewDFX::ListenerRule> sysRules; 11501401458bSopenharmony_ci sysRules.emplace_back(listenerRule); 11511401458bSopenharmony_ci int cnt = 30; 11521401458bSopenharmony_ci int32_t ret = 0; 11531401458bSopenharmony_ci while (cnt-- > 0) { 11541401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventManager::AddListener(std::make_shared<Watcher>(), sysRules); 11551401458bSopenharmony_ci } 11561401458bSopenharmony_ci ASSERT_EQ(ret, OHOS::HiviewDFX::ERR_TOO_MANY_WATCHERS); 11571401458bSopenharmony_ci} 11581401458bSopenharmony_ci 11591401458bSopenharmony_ci/** 11601401458bSopenharmony_ci * @tc.name: TestHiSysEventManagerQueryWithTooManyRules 11611401458bSopenharmony_ci * @tc.desc: Query with 11 query rules 11621401458bSopenharmony_ci * @tc.type: FUNC 11631401458bSopenharmony_ci * @tc.require: issueI5L2RV 11641401458bSopenharmony_ci */ 11651401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventManagerQueryWithTooManyRules, TestSize.Level1) 11661401458bSopenharmony_ci{ 11671401458bSopenharmony_ci auto querier = std::make_shared<Querier>(); 11681401458bSopenharmony_ci long long defaultTimeStap = -1; 11691401458bSopenharmony_ci int queryCount = 10; 11701401458bSopenharmony_ci struct OHOS::HiviewDFX::QueryArg args(defaultTimeStap, defaultTimeStap, queryCount); 11711401458bSopenharmony_ci std::vector<OHOS::HiviewDFX::QueryRule> queryRules; 11721401458bSopenharmony_ci int rulesCount = 101; // limit to 100 11731401458bSopenharmony_ci while (rulesCount-- > 0) { 11741401458bSopenharmony_ci std::vector<std::string> eventNames {"EVENT_NAME"}; 11751401458bSopenharmony_ci OHOS::HiviewDFX::QueryRule rule("DOMAIN", eventNames); 11761401458bSopenharmony_ci queryRules.emplace_back(rule); 11771401458bSopenharmony_ci } 11781401458bSopenharmony_ci auto ret = OHOS::HiviewDFX::HiSysEventManager::Query(args, queryRules, querier); 11791401458bSopenharmony_ci ASSERT_EQ(ret, OHOS::HiviewDFX::ERR_TOO_MANY_QUERY_RULES); 11801401458bSopenharmony_ci} 11811401458bSopenharmony_ci 11821401458bSopenharmony_ci/** 11831401458bSopenharmony_ci * @tc.name: TestHiSysEventManagerTooManyConcurrentQueries 11841401458bSopenharmony_ci * @tc.desc: Query more than 4 times at same time 11851401458bSopenharmony_ci * @tc.type: FUNC 11861401458bSopenharmony_ci * @tc.require: issueI5L2RV 11871401458bSopenharmony_ci */ 11881401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventManagerTooManyConcurrentQueries, TestSize.Level1) 11891401458bSopenharmony_ci{ 11901401458bSopenharmony_ci auto querier = std::make_shared<Querier>(); 11911401458bSopenharmony_ci long long defaultTimeStap = -1; 11921401458bSopenharmony_ci int queryCount = 10; 11931401458bSopenharmony_ci struct OHOS::HiviewDFX::QueryArg args(defaultTimeStap, defaultTimeStap, queryCount); 11941401458bSopenharmony_ci std::vector<OHOS::HiviewDFX::QueryRule> queryRules; 11951401458bSopenharmony_ci int threadCount = 5; 11961401458bSopenharmony_ci auto ret = OHOS::HiviewDFX::IPC_CALL_SUCCEED; 11971401458bSopenharmony_ci for (int i = 0; i < threadCount; i++) { 11981401458bSopenharmony_ci std::thread t([&ret, &args, &queryRules, &querier] () { 11991401458bSopenharmony_ci ret = OHOS::HiviewDFX::HiSysEventManager::Query(args, queryRules, querier); 12001401458bSopenharmony_ci }); 12011401458bSopenharmony_ci t.join(); 12021401458bSopenharmony_ci } 12031401458bSopenharmony_ci ASSERT_TRUE((ret == OHOS::HiviewDFX::ERR_TOO_MANY_CONCURRENT_QUERIES) || 12041401458bSopenharmony_ci (ret == OHOS::HiviewDFX::ERR_QUERY_TOO_FREQUENTLY) || 12051401458bSopenharmony_ci (ret == OHOS::HiviewDFX::IPC_CALL_SUCCEED)); 12061401458bSopenharmony_ci} 12071401458bSopenharmony_ci 12081401458bSopenharmony_ci/** 12091401458bSopenharmony_ci * @tc.name: TestHiSysEventManagerQueryTooFrequently 12101401458bSopenharmony_ci * @tc.desc: Query twice in 1 seconds 12111401458bSopenharmony_ci * @tc.type: FUNC 12121401458bSopenharmony_ci * @tc.require: issueI5L2RV 12131401458bSopenharmony_ci */ 12141401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventManagerQueryTooFrequently, TestSize.Level1) 12151401458bSopenharmony_ci{ 12161401458bSopenharmony_ci auto querier = std::make_shared<Querier>(); 12171401458bSopenharmony_ci long long defaultTimeStap = -1; 12181401458bSopenharmony_ci int queryCount = 10; 12191401458bSopenharmony_ci struct OHOS::HiviewDFX::QueryArg args(defaultTimeStap, defaultTimeStap, queryCount); 12201401458bSopenharmony_ci std::vector<OHOS::HiviewDFX::QueryRule> queryRules; 12211401458bSopenharmony_ci const int threshhold = 50; 12221401458bSopenharmony_ci const int delayDuration = 1; // 1 second 12231401458bSopenharmony_ci for (int i = 0; i < 2; i++) { // 2 cycles 12241401458bSopenharmony_ci sleep(delayDuration); 12251401458bSopenharmony_ci for (int j = 0; j <= threshhold; j++) { // more than 50 queries in 1 second is never allowed 12261401458bSopenharmony_ci auto ret = OHOS::HiviewDFX::HiSysEventManager::Query(args, queryRules, querier); 12271401458bSopenharmony_ci ASSERT_TRUE((ret == OHOS::HiviewDFX::ERR_QUERY_TOO_FREQUENTLY) || 12281401458bSopenharmony_ci (ret == OHOS::HiviewDFX::IPC_CALL_SUCCEED)); 12291401458bSopenharmony_ci } 12301401458bSopenharmony_ci } 12311401458bSopenharmony_ci} 12321401458bSopenharmony_ci 12331401458bSopenharmony_ci/** 12341401458bSopenharmony_ci * @tc.name: TestInitHiSysEventRecordWithIncorrectStr 12351401458bSopenharmony_ci * @tc.desc: Init a hisysevent record with an incorrect string 12361401458bSopenharmony_ci * @tc.type: FUNC 12371401458bSopenharmony_ci * @tc.require: issueI5OA3F 12381401458bSopenharmony_ci */ 12391401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestInitHiSysEventRecordWithIncorrectStr, TestSize.Level1) 12401401458bSopenharmony_ci{ 12411401458bSopenharmony_ci constexpr char JSON_STR[] = "{\"domain_\":\"DEMO\",\"name_\":\"EVENT_NAME_A\",\"type_\":4,\ 12421401458bSopenharmony_ci \"PARAM_A\":\"param a\","; 12431401458bSopenharmony_ci HiSysEventRecord record(JSON_STR); 12441401458bSopenharmony_ci int64_t val = 0; 12451401458bSopenharmony_ci int ret = record.GetParamValue("type_", val); 12461401458bSopenharmony_ci ASSERT_EQ(ret, ERR_INIT_FAILED); 12471401458bSopenharmony_ci} 12481401458bSopenharmony_ci 12491401458bSopenharmony_ci/** 12501401458bSopenharmony_ci * @tc.name: TestParseValueByInvalidKeyFromHiSysEventRecord 12511401458bSopenharmony_ci * @tc.desc: Parse value by a invalid key from a hisysevent record 12521401458bSopenharmony_ci * @tc.type: FUNC 12531401458bSopenharmony_ci * @tc.require: issueI5OA3F 12541401458bSopenharmony_ci */ 12551401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestParseValueByInvalidKeyFromHiSysEventRecord, TestSize.Level1) 12561401458bSopenharmony_ci{ 12571401458bSopenharmony_ci constexpr char JSON_STR[] = "{\"domain_\":\"DEMO\",\"name_\":\"EVENT_NAME_A\",\"type_\":4,\ 12581401458bSopenharmony_ci \"PARAM_A\":\"param a\",\"PARAM_B\":\"param b\"}"; 12591401458bSopenharmony_ci HiSysEventRecord record(JSON_STR); 12601401458bSopenharmony_ci int64_t val = 0; 12611401458bSopenharmony_ci int ret = record.GetParamValue("XXX", val); 12621401458bSopenharmony_ci ASSERT_EQ(ret, ERR_KEY_NOT_EXIST); 12631401458bSopenharmony_ci} 12641401458bSopenharmony_ci 12651401458bSopenharmony_ci/** 12661401458bSopenharmony_ci * @tc.name: TestParseValueByInvalidTypeFromHiSysEventRecord 12671401458bSopenharmony_ci * @tc.desc: Parse value by a invalid type from a hisysevent record 12681401458bSopenharmony_ci * @tc.type: FUNC 12691401458bSopenharmony_ci * @tc.require: issueI5OA3F 12701401458bSopenharmony_ci */ 12711401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestParseValueByInvalidTypeFromHiSysEventRecord, TestSize.Level1) 12721401458bSopenharmony_ci{ 12731401458bSopenharmony_ci constexpr char JSON_STR[] = "{\"domain_\":\"DEMO\",\"name_\":\"EVENT_NAME_A\",\"type_\":4,\ 12741401458bSopenharmony_ci \"PARAM_A\":\"param a\",\"PARAM_B\":\"param b\"}"; 12751401458bSopenharmony_ci HiSysEventRecord record(JSON_STR); 12761401458bSopenharmony_ci int64_t val = 0; 12771401458bSopenharmony_ci int ret = record.GetParamValue("PARAM_B", val); 12781401458bSopenharmony_ci ASSERT_EQ(ret, ERR_TYPE_NOT_MATCH); 12791401458bSopenharmony_ci} 12801401458bSopenharmony_ci 12811401458bSopenharmony_ci/** 12821401458bSopenharmony_ci * @tc.name: TestParseEventDomainNameTypeFromHiSysEventRecord 12831401458bSopenharmony_ci * @tc.desc: Parse event domain, name and type from a hisysevent record 12841401458bSopenharmony_ci * @tc.type: FUNC 12851401458bSopenharmony_ci * @tc.require: issueI5OA3F 12861401458bSopenharmony_ci */ 12871401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestParseEventDomainNameTypeFromHiSysEventRecord, TestSize.Level1) 12881401458bSopenharmony_ci{ 12891401458bSopenharmony_ci constexpr char JSON_STR[] = "{\"domain_\":\"DEMO\",\"name_\":\"EVENT_NAME_A\",\"type_\":4,\ 12901401458bSopenharmony_ci \"PARAM_A\":\"param a\",\"PARAM_B\":\"param b\"}"; 12911401458bSopenharmony_ci HiSysEventRecord record(JSON_STR); 12921401458bSopenharmony_ci ASSERT_EQ(record.GetDomain(), "DEMO"); 12931401458bSopenharmony_ci ASSERT_EQ(record.GetEventName(), "EVENT_NAME_A"); 12941401458bSopenharmony_ci ASSERT_EQ(record.GetEventType(), 4); 12951401458bSopenharmony_ci} 12961401458bSopenharmony_ci 12971401458bSopenharmony_ci/** 12981401458bSopenharmony_ci * @tc.name: TestParseInt64ValueFromHiSysEventRecord 12991401458bSopenharmony_ci * @tc.desc: Parse int64 value from a hisysevent record 13001401458bSopenharmony_ci * @tc.type: FUNC 13011401458bSopenharmony_ci * @tc.require: issueI5OA3F 13021401458bSopenharmony_ci */ 13031401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestParseInt64ValueFromHiSysEventRecord, TestSize.Level1) 13041401458bSopenharmony_ci{ 13051401458bSopenharmony_ci constexpr char JSON_STR[] = "{\"domain_\":\"DEMO\",\"name_\":\"EVENT_NAME_A\",\"type_\":4,\ 13061401458bSopenharmony_ci \"PARAM_A\":-1,\"PARAM_B\":\"param b\"}"; 13071401458bSopenharmony_ci HiSysEventRecord record(JSON_STR); 13081401458bSopenharmony_ci int64_t val = 0; 13091401458bSopenharmony_ci int ret = record.GetParamValue("PARAM_A", val); 13101401458bSopenharmony_ci ASSERT_EQ(ret, VALUE_PARSED_SUCCEED); 13111401458bSopenharmony_ci ASSERT_EQ(val, -1); 13121401458bSopenharmony_ci} 13131401458bSopenharmony_ci 13141401458bSopenharmony_ci/** 13151401458bSopenharmony_ci * @tc.name: TestParseUInt64ValueFromHiSysEventRecord 13161401458bSopenharmony_ci * @tc.desc: Parse uint64 value from a hisysevent record 13171401458bSopenharmony_ci * @tc.type: FUNC 13181401458bSopenharmony_ci * @tc.require: issueI5OA3F 13191401458bSopenharmony_ci */ 13201401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestParseUInt64ValueFromHiSysEventRecord, TestSize.Level1) 13211401458bSopenharmony_ci{ 13221401458bSopenharmony_ci constexpr char JSON_STR[] = "{\"domain_\":\"DEMO\",\"name_\":\"EVENT_NAME_A\",\"type_\":4,\ 13231401458bSopenharmony_ci \"PARAM_A\":3,\"PARAM_B\":\"param b\"}"; 13241401458bSopenharmony_ci HiSysEventRecord record(JSON_STR); 13251401458bSopenharmony_ci uint64_t val = 0; 13261401458bSopenharmony_ci int ret = record.GetParamValue("PARAM_A", val); 13271401458bSopenharmony_ci ASSERT_EQ(ret, VALUE_PARSED_SUCCEED); 13281401458bSopenharmony_ci ASSERT_EQ(val, 3); 13291401458bSopenharmony_ci} 13301401458bSopenharmony_ci 13311401458bSopenharmony_ci/** 13321401458bSopenharmony_ci * @tc.name: TestParseDoubleValueFromHiSysEventRecord 13331401458bSopenharmony_ci * @tc.desc: Parse double value from a hisysevent record 13341401458bSopenharmony_ci * @tc.type: FUNC 13351401458bSopenharmony_ci * @tc.require: issueI5OA3F 13361401458bSopenharmony_ci */ 13371401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestParseDoubleValueFromHiSysEventRecord, TestSize.Level1) 13381401458bSopenharmony_ci{ 13391401458bSopenharmony_ci constexpr char JSON_STR[] = "{\"domain_\":\"DEMO\",\"name_\":\"EVENT_NAME_A\",\"type_\":4,\ 13401401458bSopenharmony_ci \"PARAM_A\":3.4,\"PARAM_B\":\"param b\"}"; 13411401458bSopenharmony_ci HiSysEventRecord record(JSON_STR); 13421401458bSopenharmony_ci double val = 0; 13431401458bSopenharmony_ci int ret = record.GetParamValue("PARAM_A", val); 13441401458bSopenharmony_ci ASSERT_EQ(ret, VALUE_PARSED_SUCCEED); 13451401458bSopenharmony_ci ASSERT_LT(abs(val - 3.4), 1e-8); 13461401458bSopenharmony_ci} 13471401458bSopenharmony_ci 13481401458bSopenharmony_ci/** 13491401458bSopenharmony_ci * @tc.name: TestParseStringValueFromHiSysEventRecord 13501401458bSopenharmony_ci * @tc.desc: Parse string value from a hisysevent record 13511401458bSopenharmony_ci * @tc.type: FUNC 13521401458bSopenharmony_ci * @tc.require: issueI5OA3F 13531401458bSopenharmony_ci */ 13541401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestParseStringValueFromHiSysEventRecord, TestSize.Level1) 13551401458bSopenharmony_ci{ 13561401458bSopenharmony_ci constexpr char JSON_STR[] = "{\"domain_\":\"DEMO\",\"name_\":\"EVENT_NAME_A\",\"type_\":4,\ 13571401458bSopenharmony_ci \"PARAM_A\":3.4,\"PARAM_B\":\"param b\"}"; 13581401458bSopenharmony_ci HiSysEventRecord record(JSON_STR); 13591401458bSopenharmony_ci std::string val; 13601401458bSopenharmony_ci int ret = record.GetParamValue("PARAM_B", val); 13611401458bSopenharmony_ci ASSERT_EQ(ret, VALUE_PARSED_SUCCEED); 13621401458bSopenharmony_ci ASSERT_EQ(val, "param b"); 13631401458bSopenharmony_ci} 13641401458bSopenharmony_ci 13651401458bSopenharmony_ci/** 13661401458bSopenharmony_ci * @tc.name: TestParseInt64ArrayFromHiSysEventRecord 13671401458bSopenharmony_ci * @tc.desc: Parse int64 array from a hisysevent record 13681401458bSopenharmony_ci * @tc.type: FUNC 13691401458bSopenharmony_ci * @tc.require: issueI5OA3F 13701401458bSopenharmony_ci */ 13711401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestParseInt64ArrayFromHiSysEventRecord, TestSize.Level1) 13721401458bSopenharmony_ci{ 13731401458bSopenharmony_ci constexpr char JSON_STR[] = "{\"domain_\":\"DEMO\",\"name_\":\"EVENT_NAME_A\",\"type_\":4,\ 13741401458bSopenharmony_ci \"PARAM_A\":3.4,\"PARAM_B\":[-1, 0, 1]}"; 13751401458bSopenharmony_ci HiSysEventRecord record(JSON_STR); 13761401458bSopenharmony_ci std::vector<int64_t> val; 13771401458bSopenharmony_ci int ret = record.GetParamValue("PARAM_B", val); 13781401458bSopenharmony_ci ASSERT_EQ(ret, VALUE_PARSED_SUCCEED); 13791401458bSopenharmony_ci ASSERT_EQ(val.size(), 3); 13801401458bSopenharmony_ci ASSERT_EQ(val[0], -1); 13811401458bSopenharmony_ci} 13821401458bSopenharmony_ci 13831401458bSopenharmony_ci/** 13841401458bSopenharmony_ci * @tc.name: TestParseUInt64ArrayFromHiSysEventRecord 13851401458bSopenharmony_ci * @tc.desc: Parse uint64 array from a hisysevent record 13861401458bSopenharmony_ci * @tc.type: FUNC 13871401458bSopenharmony_ci * @tc.require: issueI5OA3F 13881401458bSopenharmony_ci */ 13891401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestParseUInt64ArrayFromHiSysEventRecord, TestSize.Level1) 13901401458bSopenharmony_ci{ 13911401458bSopenharmony_ci constexpr char JSON_STR[] = "{\"domain_\":\"DEMO\",\"name_\":\"EVENT_NAME_A\",\"type_\":4,\ 13921401458bSopenharmony_ci \"PARAM_A\":3.4,\"PARAM_B\":[1, 2, 3]}"; 13931401458bSopenharmony_ci HiSysEventRecord record(JSON_STR); 13941401458bSopenharmony_ci std::vector<uint64_t> val; 13951401458bSopenharmony_ci int ret = record.GetParamValue("PARAM_B", val); 13961401458bSopenharmony_ci ASSERT_EQ(ret, VALUE_PARSED_SUCCEED); 13971401458bSopenharmony_ci ASSERT_EQ(val.size(), 3); 13981401458bSopenharmony_ci ASSERT_EQ(val[0], 1); 13991401458bSopenharmony_ci} 14001401458bSopenharmony_ci 14011401458bSopenharmony_ci/** 14021401458bSopenharmony_ci * @tc.name: TestParseDoubleArrayFromHiSysEventRecord 14031401458bSopenharmony_ci * @tc.desc: Parse double array from a hisysevent record 14041401458bSopenharmony_ci * @tc.type: FUNC 14051401458bSopenharmony_ci * @tc.require: issueI5OA3F 14061401458bSopenharmony_ci */ 14071401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestParseDoubleArrayFromHiSysEventRecord, TestSize.Level1) 14081401458bSopenharmony_ci{ 14091401458bSopenharmony_ci constexpr char JSON_STR[] = "{\"domain_\":\"DEMO\",\"name_\":\"EVENT_NAME_A\",\"type_\":4,\ 14101401458bSopenharmony_ci \"PARAM_A\":3.4,\"PARAM_B\":[2.1, 0.0, 3.3]}"; 14111401458bSopenharmony_ci HiSysEventRecord record(JSON_STR); 14121401458bSopenharmony_ci std::vector<double> val; 14131401458bSopenharmony_ci int ret = record.GetParamValue("PARAM_B", val); 14141401458bSopenharmony_ci ASSERT_EQ(ret, VALUE_PARSED_SUCCEED); 14151401458bSopenharmony_ci ASSERT_EQ(val.size(), 3); 14161401458bSopenharmony_ci ASSERT_LT(abs(val[0] - 2.1), 1e-8); 14171401458bSopenharmony_ci} 14181401458bSopenharmony_ci 14191401458bSopenharmony_ci/** 14201401458bSopenharmony_ci * @tc.name: TestParseStringArrayFromHiSysEventRecord 14211401458bSopenharmony_ci * @tc.desc: Parse string array from a hisysevent record 14221401458bSopenharmony_ci * @tc.type: FUNC 14231401458bSopenharmony_ci * @tc.require: issueI5OA3F 14241401458bSopenharmony_ci */ 14251401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestParseStringArrayFromHiSysEventRecord, TestSize.Level1) 14261401458bSopenharmony_ci{ 14271401458bSopenharmony_ci constexpr char JSON_STR[] = "{\"domain_\":\"DEMO\",\"name_\":\"EVENT_NAME_A\",\"type_\":4,\ 14281401458bSopenharmony_ci \"PARAM_A\":3.4,\"PARAM_B\":[\"123\", \"456\", \"789\"]}"; 14291401458bSopenharmony_ci HiSysEventRecord record(JSON_STR); 14301401458bSopenharmony_ci std::vector<std::string> val; 14311401458bSopenharmony_ci int ret = record.GetParamValue("PARAM_B", val); 14321401458bSopenharmony_ci ASSERT_EQ(ret, VALUE_PARSED_SUCCEED); 14331401458bSopenharmony_ci ASSERT_EQ(val.size(), 3); 14341401458bSopenharmony_ci ASSERT_EQ(val[0], "123"); 14351401458bSopenharmony_ci} 14361401458bSopenharmony_ci 14371401458bSopenharmony_ci/** 14381401458bSopenharmony_ci * @tc.name: TestParseParamsFromHiSysEventRecord 14391401458bSopenharmony_ci * @tc.desc: Parse some inlined parameters from a hisysevent record 14401401458bSopenharmony_ci * @tc.type: FUNC 14411401458bSopenharmony_ci * @tc.require: issueI5OA3F 14421401458bSopenharmony_ci */ 14431401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestParseParamsFromHiSysEventRecord, TestSize.Level1) 14441401458bSopenharmony_ci{ 14451401458bSopenharmony_ci constexpr char JSON_STR[] = "{\"domain_\":\"SAMGR\",\"name_\":\"SAMGR_ADD_SYSTEMABILITY_FAIL\",\"type_\":1,\ 14461401458bSopenharmony_ci \"time_\":1502114170549,\"tz_\":\"+0000\",\"pid_\":398,\"tid_\":398,\"uid_\":1099,\"SAID\":1155,\ 14471401458bSopenharmony_ci \"FILE_NAME\":\"libexternal_vpn_service.z.so\",\"level_\":\"CRITICAL\",\"tag_\":\"fault\",\ 14481401458bSopenharmony_ci \"id_\":\"14947264126694503475\",\"traceid_\":243156040590758234, \"spanid_\":11870123,\ 14491401458bSopenharmony_ci \"pspanid_\":28408891,\"trace_flag_\":1,\"info_\":\"\"}"; 14501401458bSopenharmony_ci HiSysEventRecord record(JSON_STR); 14511401458bSopenharmony_ci auto time = record.GetTime(); 14521401458bSopenharmony_ci ASSERT_GT(time, 0); 14531401458bSopenharmony_ci auto timeZone = record.GetTimeZone(); 14541401458bSopenharmony_ci ASSERT_EQ(timeZone.size(), 5); 14551401458bSopenharmony_ci auto pid = record.GetPid(); 14561401458bSopenharmony_ci ASSERT_GT(pid, 0); 14571401458bSopenharmony_ci auto tid = record.GetTid(); 14581401458bSopenharmony_ci ASSERT_GT(tid, 0); 14591401458bSopenharmony_ci auto uid = record.GetUid(); 14601401458bSopenharmony_ci ASSERT_GT(uid, 0); 14611401458bSopenharmony_ci auto traceId = record.GetTraceId(); 14621401458bSopenharmony_ci ASSERT_GE(traceId, 0); 14631401458bSopenharmony_ci auto spanId = record.GetSpanId(); 14641401458bSopenharmony_ci ASSERT_GE(spanId, 0); 14651401458bSopenharmony_ci auto pspanId = record.GetPspanId(); 14661401458bSopenharmony_ci ASSERT_GE(pspanId, 0); 14671401458bSopenharmony_ci auto traceFlag = record.GetTraceFlag(); 14681401458bSopenharmony_ci ASSERT_GE(traceFlag, 0); 14691401458bSopenharmony_ci auto level = record.GetLevel(); 14701401458bSopenharmony_ci ASSERT_EQ(level, "CRITICAL"); 14711401458bSopenharmony_ci auto tag = record.GetTag(); 14721401458bSopenharmony_ci ASSERT_GE(timeZone.size(), 0); 14731401458bSopenharmony_ci std::vector<std::string> paramNames; 14741401458bSopenharmony_ci record.GetParamNames(paramNames); 14751401458bSopenharmony_ci ASSERT_TRUE(std::any_of(paramNames.begin(), paramNames.end(), [] (auto& name) { 14761401458bSopenharmony_ci return name == "domain_" || name == "name_" || name == "type_"; 14771401458bSopenharmony_ci })); 14781401458bSopenharmony_ci} 14791401458bSopenharmony_ci 14801401458bSopenharmony_ci/** 14811401458bSopenharmony_ci * @tc.name: TestParseParamsFromUninitializedHiSysEventRecord 14821401458bSopenharmony_ci * @tc.desc: Parse parameters from a uninitialized hisysevent record 14831401458bSopenharmony_ci * @tc.type: FUNC 14841401458bSopenharmony_ci * @tc.require: issueI5OA3F 14851401458bSopenharmony_ci */ 14861401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestParseParamsFromUninitializedHiSysEventRecord, TestSize.Level1) 14871401458bSopenharmony_ci{ 14881401458bSopenharmony_ci constexpr char JSON_STR[] = ""; 14891401458bSopenharmony_ci HiSysEventRecord record(JSON_STR); 14901401458bSopenharmony_ci auto time = record.GetTime(); 14911401458bSopenharmony_ci ASSERT_EQ(time, 0); 14921401458bSopenharmony_ci auto timeZone = record.GetTimeZone(); 14931401458bSopenharmony_ci ASSERT_EQ(timeZone.size(), 0); 14941401458bSopenharmony_ci auto traceId = record.GetTraceId(); 14951401458bSopenharmony_ci ASSERT_EQ(traceId, 0); 14961401458bSopenharmony_ci} 14971401458bSopenharmony_ci 14981401458bSopenharmony_ci/** 14991401458bSopenharmony_ci * @tc.name: TestParseWrongTypeParamsFromUninitializedHiSysEventRecord 15001401458bSopenharmony_ci * @tc.desc: Parse parameters with unmatched type from a hisysevent record 15011401458bSopenharmony_ci * @tc.type: FUNC 15021401458bSopenharmony_ci * @tc.require: issueI5OA3F 15031401458bSopenharmony_ci */ 15041401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestParseWrongTypeParamsFromUninitializedHiSysEventRecord, TestSize.Level1) 15051401458bSopenharmony_ci{ 15061401458bSopenharmony_ci constexpr char JSON_STR[] = "{\"domain_\":\"DEMO\",\"name_\":\"EVENT_NAME_A\",\"type_\":4,\ 15071401458bSopenharmony_ci \"PARAM_A\":3.4,\"UINT64_T\":18446744073709551610,\"DOUBLE_T\":3.3,\"INT64_T\":9223372036854775800,\ 15081401458bSopenharmony_ci \"PARAM_B\":[\"123\", \"456\", \"789\"],\"PARAM_C\":[]}"; 15091401458bSopenharmony_ci HiSysEventRecord record(JSON_STR); 15101401458bSopenharmony_ci double num = 0; 15111401458bSopenharmony_ci auto ret = record.GetParamValue("domain_", num); 15121401458bSopenharmony_ci ASSERT_EQ(ret, ERR_TYPE_NOT_MATCH); 15131401458bSopenharmony_ci std::vector<std::string> paramC; 15141401458bSopenharmony_ci ret = record.GetParamValue("name_", paramC); 15151401458bSopenharmony_ci ASSERT_EQ(ret, ERR_TYPE_NOT_MATCH); 15161401458bSopenharmony_ci ret = record.GetParamValue("PARAM_C", paramC); 15171401458bSopenharmony_ci ASSERT_EQ(ret, VALUE_PARSED_SUCCEED); 15181401458bSopenharmony_ci uint64_t uint64TypeParam = 0; 15191401458bSopenharmony_ci ret = record.GetParamValue("UINT64_T", uint64TypeParam); 15201401458bSopenharmony_ci ASSERT_EQ(ret, VALUE_PARSED_SUCCEED); 15211401458bSopenharmony_ci int64_t int64TypeParam = 0; 15221401458bSopenharmony_ci ret = record.GetParamValue("INT64_T", int64TypeParam); 15231401458bSopenharmony_ci ASSERT_EQ(ret, VALUE_PARSED_SUCCEED); 15241401458bSopenharmony_ci double doubleTypeParam = 0; 15251401458bSopenharmony_ci ret = record.GetParamValue("DOUBLE_T", doubleTypeParam); 15261401458bSopenharmony_ci ASSERT_EQ(ret, VALUE_PARSED_SUCCEED); 15271401458bSopenharmony_ci double doubleTypeParam2 = 0; 15281401458bSopenharmony_ci ret = record.GetParamValue("DOUBLE_T_NOT_EXIST", doubleTypeParam2); 15291401458bSopenharmony_ci ASSERT_EQ(ret, ERR_KEY_NOT_EXIST); 15301401458bSopenharmony_ci} 15311401458bSopenharmony_ci 15321401458bSopenharmony_ci/** 15331401458bSopenharmony_ci * @tc.name: TestHiSysEventManagerQueryWithDefaultQueryArgument 15341401458bSopenharmony_ci * @tc.desc: Query with default arugumen 15351401458bSopenharmony_ci * @tc.type: FUNC 15361401458bSopenharmony_ci * @tc.require: issueI5L2RV 15371401458bSopenharmony_ci */ 15381401458bSopenharmony_ciHWTEST_F(HiSysEventNativeTest, TestHiSysEventManagerQueryWithDefaultQueryArgument, TestSize.Level1) 15391401458bSopenharmony_ci{ 15401401458bSopenharmony_ci int eventWroiteCnt = 3; 15411401458bSopenharmony_ci for (int index = 0; index < eventWroiteCnt; index++) { 15421401458bSopenharmony_ci HiSysEventWrite(TEST_DOMAIN2, "POWER_KEY", HiSysEvent::EventType::FAULT, "DESC", "in test case"); 15431401458bSopenharmony_ci } 15441401458bSopenharmony_ci sleep(2); 15451401458bSopenharmony_ci auto querier = std::make_shared<Querier>([] (std::shared_ptr<std::vector<HiSysEventRecord>> sysEvents) { 15461401458bSopenharmony_ci return true; 15471401458bSopenharmony_ci }, [] (int32_t reason, int32_t total) { 15481401458bSopenharmony_ci return total > 0; 15491401458bSopenharmony_ci }); 15501401458bSopenharmony_ci long long defaultTimeStap = -1; // default value 15511401458bSopenharmony_ci int queryCount = -1; // default value 15521401458bSopenharmony_ci struct OHOS::HiviewDFX::QueryArg args(defaultTimeStap, defaultTimeStap, queryCount); 15531401458bSopenharmony_ci std::vector<OHOS::HiviewDFX::QueryRule> queryRules; 15541401458bSopenharmony_ci std::vector<std::string> eventNames {"POWER_KEY"}; 15551401458bSopenharmony_ci OHOS::HiviewDFX::QueryRule rule("KERNEL_VENDOR", eventNames); // empty domain 15561401458bSopenharmony_ci queryRules.emplace_back(rule); 15571401458bSopenharmony_ci auto ret = OHOS::HiviewDFX::HiSysEventManager::Query(args, queryRules, querier); 15581401458bSopenharmony_ci ASSERT_EQ(ret, OHOS::HiviewDFX::IPC_CALL_SUCCEED); 15591401458bSopenharmony_ci} 15601401458bSopenharmony_ci 1561