11401458bSopenharmony_ci/*
21401458bSopenharmony_ci * Copyright (c) 2022-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#include "hisysevent_c_test.h"
161401458bSopenharmony_ci
171401458bSopenharmony_ci#include <climits>
181401458bSopenharmony_ci#include <securec.h>
191401458bSopenharmony_ci#include "def.h"
201401458bSopenharmony_ci#include "hisysevent_c.h"
211401458bSopenharmony_ci
221401458bSopenharmony_ciusing namespace OHOS::HiviewDFX;
231401458bSopenharmony_ciusing namespace testing::ext;
241401458bSopenharmony_ci
251401458bSopenharmony_cinamespace {
261401458bSopenharmony_ciconst char TEST_DOMAIN[] = "TEST_DOMAIN";
271401458bSopenharmony_ciconst char TEST_NAME[] = "TEST_NAME";
281401458bSopenharmony_ci}
291401458bSopenharmony_ci
301401458bSopenharmony_civoid HiSysEventCTest::SetUp()
311401458bSopenharmony_ci{}
321401458bSopenharmony_ci
331401458bSopenharmony_civoid HiSysEventCTest::TearDown()
341401458bSopenharmony_ci{}
351401458bSopenharmony_ci
361401458bSopenharmony_ci/**
371401458bSopenharmony_ci * @tc.name: HiSysEventCTest001
381401458bSopenharmony_ci * @tc.desc: Test writing of basic type data.
391401458bSopenharmony_ci * @tc.type: FUNC
401401458bSopenharmony_ci * @tc.require: issueI5O9JB
411401458bSopenharmony_ci */
421401458bSopenharmony_ciHWTEST_F(HiSysEventCTest, HiSysEventCTest001, TestSize.Level3)
431401458bSopenharmony_ci{
441401458bSopenharmony_ci    /**
451401458bSopenharmony_ci     * @tc.steps: step1. create event.
461401458bSopenharmony_ci     * @tc.steps: step2. write event.
471401458bSopenharmony_ci     * @tc.steps: step3. check the result of writing.
481401458bSopenharmony_ci     */
491401458bSopenharmony_ci    HiSysEventParam param1 = {
501401458bSopenharmony_ci        .name = "KEY_BOOL_F",
511401458bSopenharmony_ci        .t = HISYSEVENT_BOOL,
521401458bSopenharmony_ci        .v = { .b = false },
531401458bSopenharmony_ci        .arraySize = 0,
541401458bSopenharmony_ci    };
551401458bSopenharmony_ci    HiSysEventParam param2 = {
561401458bSopenharmony_ci        .name = "KEY_BOOL_T",
571401458bSopenharmony_ci        .t = HISYSEVENT_BOOL,
581401458bSopenharmony_ci        .v = { .b = true },
591401458bSopenharmony_ci        .arraySize = 0,
601401458bSopenharmony_ci    };
611401458bSopenharmony_ci    HiSysEventParam param3 = {
621401458bSopenharmony_ci        .name = "KEY_INT8_MIN",
631401458bSopenharmony_ci        .t = HISYSEVENT_INT8,
641401458bSopenharmony_ci        .v = { .i8 = SCHAR_MIN },
651401458bSopenharmony_ci        .arraySize = 0,
661401458bSopenharmony_ci    };
671401458bSopenharmony_ci    HiSysEventParam param4 = {
681401458bSopenharmony_ci        .name = "KEY_INT8_MAX",
691401458bSopenharmony_ci        .t = HISYSEVENT_INT8,
701401458bSopenharmony_ci        .v = { .i8 = SCHAR_MAX },
711401458bSopenharmony_ci        .arraySize = 0,
721401458bSopenharmony_ci    };
731401458bSopenharmony_ci    HiSysEventParam param5 = {
741401458bSopenharmony_ci        .name = "KEY_UINT8_MIN",
751401458bSopenharmony_ci        .t = HISYSEVENT_UINT8,
761401458bSopenharmony_ci        .v = { .ui8 = 0 },
771401458bSopenharmony_ci        .arraySize = 0,
781401458bSopenharmony_ci    };
791401458bSopenharmony_ci    HiSysEventParam param6 = {
801401458bSopenharmony_ci        .name = "KEY_UINT8_MAX",
811401458bSopenharmony_ci        .t = HISYSEVENT_UINT8,
821401458bSopenharmony_ci        .v = { .ui8 = UCHAR_MAX },
831401458bSopenharmony_ci        .arraySize = 0,
841401458bSopenharmony_ci    };
851401458bSopenharmony_ci    HiSysEventParam param7 = {
861401458bSopenharmony_ci        .name = "KEY_INT16_MIN",
871401458bSopenharmony_ci        .t = HISYSEVENT_INT16,
881401458bSopenharmony_ci        .v = { .i16 = SHRT_MIN },
891401458bSopenharmony_ci        .arraySize = 0,
901401458bSopenharmony_ci    };
911401458bSopenharmony_ci    HiSysEventParam param8 = {
921401458bSopenharmony_ci        .name = "KEY_INT16_MAX",
931401458bSopenharmony_ci        .t = HISYSEVENT_INT16,
941401458bSopenharmony_ci        .v = { .i16 = SHRT_MAX },
951401458bSopenharmony_ci        .arraySize = 0,
961401458bSopenharmony_ci    };
971401458bSopenharmony_ci    HiSysEventParam param9 = {
981401458bSopenharmony_ci        .name = "KEY_UINT16_MIN",
991401458bSopenharmony_ci        .t = HISYSEVENT_UINT16,
1001401458bSopenharmony_ci        .v = { .ui16 = 0 },
1011401458bSopenharmony_ci        .arraySize = 0,
1021401458bSopenharmony_ci    };
1031401458bSopenharmony_ci    HiSysEventParam param10 = {
1041401458bSopenharmony_ci        .name = "KEY_UINT16_MAX",
1051401458bSopenharmony_ci        .t = HISYSEVENT_UINT16,
1061401458bSopenharmony_ci        .v = { .ui16 = USHRT_MAX },
1071401458bSopenharmony_ci        .arraySize = 0,
1081401458bSopenharmony_ci    };
1091401458bSopenharmony_ci    HiSysEventParam param11 = {
1101401458bSopenharmony_ci        .name = "KEY_INT32_MIN",
1111401458bSopenharmony_ci        .t = HISYSEVENT_INT32,
1121401458bSopenharmony_ci        .v = { .i32 = INT_MIN },
1131401458bSopenharmony_ci        .arraySize = 0,
1141401458bSopenharmony_ci    };
1151401458bSopenharmony_ci    HiSysEventParam param12 = {
1161401458bSopenharmony_ci        .name = "KEY_INT32_MAX",
1171401458bSopenharmony_ci        .t = HISYSEVENT_INT32,
1181401458bSopenharmony_ci        .v = { .i32 = INT_MAX },
1191401458bSopenharmony_ci        .arraySize = 0,
1201401458bSopenharmony_ci    };
1211401458bSopenharmony_ci    HiSysEventParam param13 = {
1221401458bSopenharmony_ci        .name = "KEY_UINT32_MIN",
1231401458bSopenharmony_ci        .t = HISYSEVENT_UINT32,
1241401458bSopenharmony_ci        .v = { .ui32 = 0 },
1251401458bSopenharmony_ci        .arraySize = 0,
1261401458bSopenharmony_ci    };
1271401458bSopenharmony_ci    HiSysEventParam param14 = {
1281401458bSopenharmony_ci        .name = "KEY_UINT32_MAX",
1291401458bSopenharmony_ci        .t = HISYSEVENT_UINT32,
1301401458bSopenharmony_ci        .v = { .ui32 = UINT_MAX },
1311401458bSopenharmony_ci        .arraySize = 0,
1321401458bSopenharmony_ci    };
1331401458bSopenharmony_ci    HiSysEventParam param15 = {
1341401458bSopenharmony_ci        .name = "KEY_INT64_MIN",
1351401458bSopenharmony_ci        .t = HISYSEVENT_INT64,
1361401458bSopenharmony_ci        .v = { .i64 = LLONG_MIN },
1371401458bSopenharmony_ci        .arraySize = 0,
1381401458bSopenharmony_ci    };
1391401458bSopenharmony_ci    HiSysEventParam param16 = {
1401401458bSopenharmony_ci        .name = "KEY_INT64_MAX",
1411401458bSopenharmony_ci        .t = HISYSEVENT_INT64,
1421401458bSopenharmony_ci        .v = { .i64 = LLONG_MAX },
1431401458bSopenharmony_ci        .arraySize = 0,
1441401458bSopenharmony_ci    };
1451401458bSopenharmony_ci    HiSysEventParam param17 = {
1461401458bSopenharmony_ci        .name = "KEY_UINT64_MIN",
1471401458bSopenharmony_ci        .t = HISYSEVENT_UINT64,
1481401458bSopenharmony_ci        .v = { .ui64 = 0 },
1491401458bSopenharmony_ci        .arraySize = 0,
1501401458bSopenharmony_ci    };
1511401458bSopenharmony_ci    HiSysEventParam param18 = {
1521401458bSopenharmony_ci        .name = "KEY_UINT64_MAX",
1531401458bSopenharmony_ci        .t = HISYSEVENT_UINT64,
1541401458bSopenharmony_ci        .v = { .ui64 = ULLONG_MAX },
1551401458bSopenharmony_ci        .arraySize = 0,
1561401458bSopenharmony_ci    };
1571401458bSopenharmony_ci    HiSysEventParam param19 = {
1581401458bSopenharmony_ci        .name = "KEY_FLOAT",
1591401458bSopenharmony_ci        .t = HISYSEVENT_FLOAT,
1601401458bSopenharmony_ci        .v = { .f = 123.456 },
1611401458bSopenharmony_ci        .arraySize = 0,
1621401458bSopenharmony_ci    };
1631401458bSopenharmony_ci    HiSysEventParam param20 = {
1641401458bSopenharmony_ci        .name = "KEY_DOUBLE",
1651401458bSopenharmony_ci        .t = HISYSEVENT_DOUBLE,
1661401458bSopenharmony_ci        .v = { .d = 123.456789 },
1671401458bSopenharmony_ci        .arraySize = 0,
1681401458bSopenharmony_ci    };
1691401458bSopenharmony_ci    char testStr[] = "STR_VALUE";
1701401458bSopenharmony_ci    HiSysEventParam param21 = {
1711401458bSopenharmony_ci        .name = "KEY_STRING",
1721401458bSopenharmony_ci        .t = HISYSEVENT_STRING,
1731401458bSopenharmony_ci        .v = { .s = testStr },
1741401458bSopenharmony_ci        .arraySize = 0,
1751401458bSopenharmony_ci    };
1761401458bSopenharmony_ci
1771401458bSopenharmony_ci    HiSysEventParam params[] = {
1781401458bSopenharmony_ci        param1, param2, param3, param4, param5, param6, param7,
1791401458bSopenharmony_ci        param8, param9, param10, param11, param12, param13, param14,
1801401458bSopenharmony_ci        param15, param16, param17, param18, param19, param20, param21,
1811401458bSopenharmony_ci    };
1821401458bSopenharmony_ci    size_t len = sizeof(params) / sizeof(params[0]);
1831401458bSopenharmony_ci    int res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_FAULT, params, len);
1841401458bSopenharmony_ci    ASSERT_EQ(res, 0);
1851401458bSopenharmony_ci}
1861401458bSopenharmony_ci
1871401458bSopenharmony_ci/**
1881401458bSopenharmony_ci * @tc.name: HiSysEventCTest002
1891401458bSopenharmony_ci * @tc.desc: Test writing of array type data.
1901401458bSopenharmony_ci * @tc.type: FUNC
1911401458bSopenharmony_ci * @tc.require: issueI5O9JB
1921401458bSopenharmony_ci */
1931401458bSopenharmony_ciHWTEST_F(HiSysEventCTest, HiSysEventCTest002, TestSize.Level3)
1941401458bSopenharmony_ci{
1951401458bSopenharmony_ci    /**
1961401458bSopenharmony_ci     * @tc.steps: step1. create event.
1971401458bSopenharmony_ci     * @tc.steps: step2. write event.
1981401458bSopenharmony_ci     * @tc.steps: step3. check the result of writing.
1991401458bSopenharmony_ci     */
2001401458bSopenharmony_ci    bool bArr[] = { true, false };
2011401458bSopenharmony_ci    HiSysEventParam param1 = {
2021401458bSopenharmony_ci        .name = "KEY_BOOL_ARR",
2031401458bSopenharmony_ci        .t = HISYSEVENT_BOOL_ARRAY,
2041401458bSopenharmony_ci        .v = { .array = bArr },
2051401458bSopenharmony_ci        .arraySize = sizeof(bArr) / sizeof(bArr[0]),
2061401458bSopenharmony_ci    };
2071401458bSopenharmony_ci    int8_t int8Arr[] = { -1, 2, -3 };
2081401458bSopenharmony_ci    HiSysEventParam param2 = {
2091401458bSopenharmony_ci        .name = "KEY_INT8_ARR",
2101401458bSopenharmony_ci        .t = HISYSEVENT_INT8_ARRAY,
2111401458bSopenharmony_ci        .v = { .array = int8Arr },
2121401458bSopenharmony_ci        .arraySize = sizeof(int8Arr) / sizeof(int8Arr[0]),
2131401458bSopenharmony_ci    };
2141401458bSopenharmony_ci    uint8_t uint8Arr[] = { 4, 5, 6 };
2151401458bSopenharmony_ci    HiSysEventParam param3 = {
2161401458bSopenharmony_ci        .name = "KEY_UINT8_ARR",
2171401458bSopenharmony_ci        .t = HISYSEVENT_UINT8_ARRAY,
2181401458bSopenharmony_ci        .v = { .array = uint8Arr },
2191401458bSopenharmony_ci        .arraySize = sizeof(uint8Arr) / sizeof(uint8Arr[0]),
2201401458bSopenharmony_ci    };
2211401458bSopenharmony_ci    int16_t int16Arr[] = { -7, 8, -9 };
2221401458bSopenharmony_ci    HiSysEventParam param4 = {
2231401458bSopenharmony_ci        .name = "KEY_INT16_ARR",
2241401458bSopenharmony_ci        .t = HISYSEVENT_INT16_ARRAY,
2251401458bSopenharmony_ci        .v = { .array = int16Arr },
2261401458bSopenharmony_ci        .arraySize = sizeof(int16Arr) / sizeof(int16Arr[0]),
2271401458bSopenharmony_ci    };
2281401458bSopenharmony_ci    uint16_t uint16Arr[] = { 10, 11, 12 };
2291401458bSopenharmony_ci    HiSysEventParam param5 = {
2301401458bSopenharmony_ci        .name = "KEY_UINT16_ARR",
2311401458bSopenharmony_ci        .t = HISYSEVENT_UINT16_ARRAY,
2321401458bSopenharmony_ci        .v = { .array = uint16Arr },
2331401458bSopenharmony_ci        .arraySize = sizeof(uint16Arr) / sizeof(uint16Arr[0]),
2341401458bSopenharmony_ci    };
2351401458bSopenharmony_ci    int32_t int32Arr[] = { -13, 14, -15 };
2361401458bSopenharmony_ci    HiSysEventParam param6 = {
2371401458bSopenharmony_ci        .name = "KEY_INT32_ARR",
2381401458bSopenharmony_ci        .t = HISYSEVENT_INT32_ARRAY,
2391401458bSopenharmony_ci        .v = { .array = int32Arr },
2401401458bSopenharmony_ci        .arraySize = sizeof(int32Arr) / sizeof(int32Arr[0]),
2411401458bSopenharmony_ci    };
2421401458bSopenharmony_ci    uint32_t uint32Arr[] = { 16, 17, 18 };
2431401458bSopenharmony_ci    HiSysEventParam param7 = {
2441401458bSopenharmony_ci        .name = "KEY_UINT32_ARR",
2451401458bSopenharmony_ci        .t = HISYSEVENT_UINT32_ARRAY,
2461401458bSopenharmony_ci        .v = { .array = uint32Arr },
2471401458bSopenharmony_ci        .arraySize = sizeof(uint32Arr) / sizeof(uint32Arr[0]),
2481401458bSopenharmony_ci    };
2491401458bSopenharmony_ci    int64_t int64Arr[] = { -19, 20, -21 };
2501401458bSopenharmony_ci    HiSysEventParam param8 = {
2511401458bSopenharmony_ci        .name = "KEY_INT64_ARR",
2521401458bSopenharmony_ci        .t = HISYSEVENT_INT64_ARRAY,
2531401458bSopenharmony_ci        .v = { .array = int64Arr },
2541401458bSopenharmony_ci        .arraySize = sizeof(int64Arr) / sizeof(int64Arr[0]),
2551401458bSopenharmony_ci    };
2561401458bSopenharmony_ci    uint64_t uint64Arr[] = { 22, 23, 24 };
2571401458bSopenharmony_ci    HiSysEventParam param9 = {
2581401458bSopenharmony_ci        .name = "KEY_UINT64_ARR",
2591401458bSopenharmony_ci        .t = HISYSEVENT_UINT64_ARRAY,
2601401458bSopenharmony_ci        .v = { .array = uint64Arr },
2611401458bSopenharmony_ci        .arraySize = sizeof(uint64Arr) / sizeof(uint64Arr[0]),
2621401458bSopenharmony_ci    };
2631401458bSopenharmony_ci    float fArr[] = { 1.1, 2.2, 3.3 };
2641401458bSopenharmony_ci    HiSysEventParam param10 = {
2651401458bSopenharmony_ci        .name = "KEY_FLOAT_ARR",
2661401458bSopenharmony_ci        .t = HISYSEVENT_FLOAT_ARRAY,
2671401458bSopenharmony_ci        .v = { .array = fArr },
2681401458bSopenharmony_ci        .arraySize = sizeof(fArr) / sizeof(fArr[0]),
2691401458bSopenharmony_ci    };
2701401458bSopenharmony_ci    double dArr[] = { 4.4, 5.5, 6.6 };
2711401458bSopenharmony_ci    HiSysEventParam param11 = {
2721401458bSopenharmony_ci        .name = "KEY_DOUBLE_ARR",
2731401458bSopenharmony_ci        .t = HISYSEVENT_DOUBLE_ARRAY,
2741401458bSopenharmony_ci        .v = { .array = dArr },
2751401458bSopenharmony_ci        .arraySize = sizeof(dArr) / sizeof(dArr[0]),
2761401458bSopenharmony_ci    };
2771401458bSopenharmony_ci    char s1[] = "str1";
2781401458bSopenharmony_ci    char s2[] = "str2";
2791401458bSopenharmony_ci    char s3[] = "str3";
2801401458bSopenharmony_ci    char* sArr[] = { s1, s2, s3 };
2811401458bSopenharmony_ci    HiSysEventParam param12 = {
2821401458bSopenharmony_ci        .name = "KEY_STRING_ARR",
2831401458bSopenharmony_ci        .t = HISYSEVENT_STRING_ARRAY,
2841401458bSopenharmony_ci        .v = { .array = sArr },
2851401458bSopenharmony_ci        .arraySize = sizeof(sArr) / sizeof(sArr[0]),
2861401458bSopenharmony_ci    };
2871401458bSopenharmony_ci
2881401458bSopenharmony_ci    HiSysEventParam params[] = {
2891401458bSopenharmony_ci        param1, param2, param3, param4, param5, param6,
2901401458bSopenharmony_ci        param7, param8, param9, param10, param11, param12,
2911401458bSopenharmony_ci    };
2921401458bSopenharmony_ci    size_t len = sizeof(params) / sizeof(params[0]);
2931401458bSopenharmony_ci    int res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_STATISTIC, params, len);
2941401458bSopenharmony_ci    ASSERT_EQ(res, 0);
2951401458bSopenharmony_ci}
2961401458bSopenharmony_ci
2971401458bSopenharmony_ci/**
2981401458bSopenharmony_ci * @tc.name: HiSysEventCTest003
2991401458bSopenharmony_ci * @tc.desc: Test writing of base data.
3001401458bSopenharmony_ci * @tc.type: FUNC
3011401458bSopenharmony_ci * @tc.require: issueI5O9JB
3021401458bSopenharmony_ci */
3031401458bSopenharmony_ciHWTEST_F(HiSysEventCTest, HiSysEventCTest003, TestSize.Level3)
3041401458bSopenharmony_ci{
3051401458bSopenharmony_ci    /**
3061401458bSopenharmony_ci     * @tc.steps: step1. create event.
3071401458bSopenharmony_ci     * @tc.steps: step2. write event.
3081401458bSopenharmony_ci     * @tc.steps: step3. check the result of writing.
3091401458bSopenharmony_ci     */
3101401458bSopenharmony_ci    int res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_SECURITY, nullptr, 0);
3111401458bSopenharmony_ci    ASSERT_EQ(res, 0);
3121401458bSopenharmony_ci
3131401458bSopenharmony_ci    HiSysEventParam params1[] = {};
3141401458bSopenharmony_ci    res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_SECURITY, params1, 0);
3151401458bSopenharmony_ci    ASSERT_EQ(res, 0);
3161401458bSopenharmony_ci
3171401458bSopenharmony_ci    char* sArr[] = {};
3181401458bSopenharmony_ci    HiSysEventParam param = {
3191401458bSopenharmony_ci        .name = "KEY_STRING_ARR",
3201401458bSopenharmony_ci        .t = HISYSEVENT_STRING_ARRAY,
3211401458bSopenharmony_ci        .v = { .array = sArr },
3221401458bSopenharmony_ci        .arraySize = sizeof(sArr) / sizeof(sArr[0]),
3231401458bSopenharmony_ci    };
3241401458bSopenharmony_ci    HiSysEventParam params2[] = { param };
3251401458bSopenharmony_ci    size_t len = sizeof(params2) / sizeof(params2[0]);
3261401458bSopenharmony_ci    res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_BEHAVIOR, params2, len);
3271401458bSopenharmony_ci    ASSERT_EQ(res, 0);
3281401458bSopenharmony_ci}
3291401458bSopenharmony_ci
3301401458bSopenharmony_ci/**
3311401458bSopenharmony_ci * @tc.name: HiSysEventCTest004
3321401458bSopenharmony_ci * @tc.desc: Test writing of invalid data.
3331401458bSopenharmony_ci * @tc.type: FUNC
3341401458bSopenharmony_ci * @tc.require: issueI5O9JB
3351401458bSopenharmony_ci */
3361401458bSopenharmony_ciHWTEST_F(HiSysEventCTest, HiSysEventCTest004, TestSize.Level3)
3371401458bSopenharmony_ci{
3381401458bSopenharmony_ci    /**
3391401458bSopenharmony_ci     * @tc.steps: step1. create event.
3401401458bSopenharmony_ci     * @tc.steps: step2. write event.
3411401458bSopenharmony_ci     * @tc.steps: step3. check the result of writing.
3421401458bSopenharmony_ci     */
3431401458bSopenharmony_ci    int res = OH_HiSysEvent_Write(nullptr, TEST_NAME, HISYSEVENT_SECURITY, nullptr, 0);
3441401458bSopenharmony_ci    ASSERT_EQ(res, ERR_DOMAIN_NAME_INVALID);
3451401458bSopenharmony_ci
3461401458bSopenharmony_ci    res = OH_HiSysEvent_Write(TEST_DOMAIN, nullptr, HISYSEVENT_SECURITY, nullptr, 0);
3471401458bSopenharmony_ci    ASSERT_EQ(res, ERR_EVENT_NAME_INVALID);
3481401458bSopenharmony_ci
3491401458bSopenharmony_ci    HiSysEventParam param = {
3501401458bSopenharmony_ci        .name = "KEY_STRING",
3511401458bSopenharmony_ci        .t = HISYSEVENT_STRING,
3521401458bSopenharmony_ci        .v = { .s = nullptr },
3531401458bSopenharmony_ci        .arraySize = 0,
3541401458bSopenharmony_ci    };
3551401458bSopenharmony_ci    HiSysEventParam params[] = { param };
3561401458bSopenharmony_ci    size_t len = sizeof(params) / sizeof(params[0]);
3571401458bSopenharmony_ci    res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_BEHAVIOR, params, len);
3581401458bSopenharmony_ci    ASSERT_EQ(res, ERR_VALUE_INVALID);
3591401458bSopenharmony_ci
3601401458bSopenharmony_ci    HiSysEventParam param1 = {
3611401458bSopenharmony_ci        .name = "KEY_STRING_ARR",
3621401458bSopenharmony_ci        .t = HISYSEVENT_STRING_ARRAY,
3631401458bSopenharmony_ci        .v = { .array = nullptr },
3641401458bSopenharmony_ci        .arraySize = 0,
3651401458bSopenharmony_ci    };
3661401458bSopenharmony_ci    HiSysEventParam params1[] = { param1 };
3671401458bSopenharmony_ci    len = sizeof(params1) / sizeof(params1[0]);
3681401458bSopenharmony_ci    res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_BEHAVIOR, params1, len);
3691401458bSopenharmony_ci    ASSERT_EQ(res, ERR_VALUE_INVALID);
3701401458bSopenharmony_ci
3711401458bSopenharmony_ci    HiSysEventParam param2 = {
3721401458bSopenharmony_ci        .name = "KEY_INT32_ARR",
3731401458bSopenharmony_ci        .t = HISYSEVENT_INT32_ARRAY,
3741401458bSopenharmony_ci        .v = { .array = nullptr },
3751401458bSopenharmony_ci        .arraySize = 2,
3761401458bSopenharmony_ci    };
3771401458bSopenharmony_ci    HiSysEventParam params2[] = { param2 };
3781401458bSopenharmony_ci    len = sizeof(params2) / sizeof(params2[0]);
3791401458bSopenharmony_ci    res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_BEHAVIOR, params2, len);
3801401458bSopenharmony_ci    ASSERT_EQ(res, ERR_VALUE_INVALID);
3811401458bSopenharmony_ci
3821401458bSopenharmony_ci    char c1[] = "str1";
3831401458bSopenharmony_ci    char* strs[] = { nullptr,  c1 };
3841401458bSopenharmony_ci    HiSysEventParam param3 = {
3851401458bSopenharmony_ci        .name = "KEY_STRING_ARR",
3861401458bSopenharmony_ci        .t = HISYSEVENT_STRING_ARRAY,
3871401458bSopenharmony_ci        .v = { .array = strs },
3881401458bSopenharmony_ci        .arraySize = 2,
3891401458bSopenharmony_ci    };
3901401458bSopenharmony_ci    HiSysEventParam params3[] = { param3 };
3911401458bSopenharmony_ci    len = sizeof(params3) / sizeof(params3[0]);
3921401458bSopenharmony_ci    res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_BEHAVIOR, params3, len);
3931401458bSopenharmony_ci    ASSERT_EQ(res, ERR_VALUE_INVALID);
3941401458bSopenharmony_ci}
3951401458bSopenharmony_ci
3961401458bSopenharmony_ci/**
3971401458bSopenharmony_ci * @tc.name: HiSysEventCTest005
3981401458bSopenharmony_ci * @tc.desc: Test writing of invalid domain.
3991401458bSopenharmony_ci * @tc.type: FUNC
4001401458bSopenharmony_ci * @tc.require: issueI5O9JB
4011401458bSopenharmony_ci */
4021401458bSopenharmony_ciHWTEST_F(HiSysEventCTest, HiSysEventCTest005, TestSize.Level3)
4031401458bSopenharmony_ci{
4041401458bSopenharmony_ci    /**
4051401458bSopenharmony_ci     * @tc.steps: step1. create event.
4061401458bSopenharmony_ci     * @tc.steps: step2. write event.
4071401458bSopenharmony_ci     * @tc.steps: step3. check the result of writing.
4081401458bSopenharmony_ci     */
4091401458bSopenharmony_ci    const char* domain1 = "123domain";
4101401458bSopenharmony_ci    int res = OH_HiSysEvent_Write(domain1, TEST_NAME, HISYSEVENT_SECURITY, nullptr, 0);
4111401458bSopenharmony_ci    ASSERT_EQ(res, ERR_DOMAIN_NAME_INVALID);
4121401458bSopenharmony_ci
4131401458bSopenharmony_ci    const char* domain2 = "_domain";
4141401458bSopenharmony_ci    res = OH_HiSysEvent_Write(domain2, TEST_NAME, HISYSEVENT_SECURITY, nullptr, 0);
4151401458bSopenharmony_ci    ASSERT_EQ(res, ERR_DOMAIN_NAME_INVALID);
4161401458bSopenharmony_ci
4171401458bSopenharmony_ci    const char* domain3 = "";
4181401458bSopenharmony_ci    res = OH_HiSysEvent_Write(domain3, TEST_NAME, HISYSEVENT_SECURITY, nullptr, 0);
4191401458bSopenharmony_ci    ASSERT_EQ(res, ERR_DOMAIN_NAME_INVALID);
4201401458bSopenharmony_ci
4211401458bSopenharmony_ci    std::string domain4(MAX_DOMAIN_LENGTH + 1, 'a');
4221401458bSopenharmony_ci    res = OH_HiSysEvent_Write(domain4.c_str(), TEST_NAME, HISYSEVENT_SECURITY, nullptr, 0);
4231401458bSopenharmony_ci    ASSERT_EQ(res, ERR_DOMAIN_NAME_INVALID);
4241401458bSopenharmony_ci
4251401458bSopenharmony_ci    const char* domain5 = "domain##5";
4261401458bSopenharmony_ci    res = OH_HiSysEvent_Write(domain5, TEST_NAME, HISYSEVENT_SECURITY, nullptr, 0);
4271401458bSopenharmony_ci    ASSERT_EQ(res, ERR_DOMAIN_NAME_INVALID);
4281401458bSopenharmony_ci}
4291401458bSopenharmony_ci
4301401458bSopenharmony_ci/**
4311401458bSopenharmony_ci * @tc.name: HiSysEventCTest006
4321401458bSopenharmony_ci * @tc.desc: Test writing of invalid event name.
4331401458bSopenharmony_ci * @tc.type: FUNC
4341401458bSopenharmony_ci * @tc.require: issueI5O9JB
4351401458bSopenharmony_ci */
4361401458bSopenharmony_ciHWTEST_F(HiSysEventCTest, HiSysEventCTest006, TestSize.Level3)
4371401458bSopenharmony_ci{
4381401458bSopenharmony_ci    /**
4391401458bSopenharmony_ci     * @tc.steps: step1. create event.
4401401458bSopenharmony_ci     * @tc.steps: step2. write event.
4411401458bSopenharmony_ci     * @tc.steps: step3. check the result of writing.
4421401458bSopenharmony_ci     */
4431401458bSopenharmony_ci    const char* name1 = "123name";
4441401458bSopenharmony_ci    int res = OH_HiSysEvent_Write(TEST_DOMAIN, name1, HISYSEVENT_SECURITY, nullptr, 0);
4451401458bSopenharmony_ci    ASSERT_EQ(res, ERR_EVENT_NAME_INVALID);
4461401458bSopenharmony_ci
4471401458bSopenharmony_ci    const char* name2 = "_name";
4481401458bSopenharmony_ci    res = OH_HiSysEvent_Write(TEST_DOMAIN, name2, HISYSEVENT_SECURITY, nullptr, 0);
4491401458bSopenharmony_ci    ASSERT_EQ(res, ERR_EVENT_NAME_INVALID);
4501401458bSopenharmony_ci
4511401458bSopenharmony_ci    const char* name3 = "";
4521401458bSopenharmony_ci    res = OH_HiSysEvent_Write(TEST_DOMAIN, name3, HISYSEVENT_SECURITY, nullptr, 0);
4531401458bSopenharmony_ci    ASSERT_EQ(res, ERR_EVENT_NAME_INVALID);
4541401458bSopenharmony_ci
4551401458bSopenharmony_ci    std::string name4(MAX_EVENT_NAME_LENGTH + 1, 'a');
4561401458bSopenharmony_ci    res = OH_HiSysEvent_Write(TEST_DOMAIN, name4.c_str(), HISYSEVENT_SECURITY, nullptr, 0);
4571401458bSopenharmony_ci    ASSERT_EQ(res, ERR_EVENT_NAME_INVALID);
4581401458bSopenharmony_ci
4591401458bSopenharmony_ci    const char* name5 = "name##5";
4601401458bSopenharmony_ci    res = OH_HiSysEvent_Write(TEST_DOMAIN, name5, HISYSEVENT_SECURITY, nullptr, 0);
4611401458bSopenharmony_ci    ASSERT_EQ(res, ERR_EVENT_NAME_INVALID);
4621401458bSopenharmony_ci}
4631401458bSopenharmony_ci
4641401458bSopenharmony_ci/**
4651401458bSopenharmony_ci * @tc.name: HiSysEventCTest007
4661401458bSopenharmony_ci * @tc.desc: Test writing of invalid key.
4671401458bSopenharmony_ci * @tc.type: FUNC
4681401458bSopenharmony_ci * @tc.require: issueI5O9JB
4691401458bSopenharmony_ci */
4701401458bSopenharmony_ciHWTEST_F(HiSysEventCTest, HiSysEventCTest007, TestSize.Level3)
4711401458bSopenharmony_ci{
4721401458bSopenharmony_ci    /**
4731401458bSopenharmony_ci     * @tc.steps: step1. create event.
4741401458bSopenharmony_ci     * @tc.steps: step2. write event.
4751401458bSopenharmony_ci     * @tc.steps: step3. check the result of writing.
4761401458bSopenharmony_ci     */
4771401458bSopenharmony_ci    HiSysEventParam param1 = {
4781401458bSopenharmony_ci        .name = "",
4791401458bSopenharmony_ci        .t = HISYSEVENT_INT32,
4801401458bSopenharmony_ci        .v = { .i32 = 0 },
4811401458bSopenharmony_ci        .arraySize = 0,
4821401458bSopenharmony_ci    };
4831401458bSopenharmony_ci    HiSysEventParam params1[] = { param1 };
4841401458bSopenharmony_ci    int res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_BEHAVIOR, params1, 1);
4851401458bSopenharmony_ci    ASSERT_EQ(res, ERR_KEY_NAME_INVALID);
4861401458bSopenharmony_ci
4871401458bSopenharmony_ci    HiSysEventParam param2 = {
4881401458bSopenharmony_ci        .name = "_key1",
4891401458bSopenharmony_ci        .t = HISYSEVENT_INT32,
4901401458bSopenharmony_ci        .v = { .i32 = 0 },
4911401458bSopenharmony_ci        .arraySize = 0,
4921401458bSopenharmony_ci    };
4931401458bSopenharmony_ci    HiSysEventParam params2[] = { param2 };
4941401458bSopenharmony_ci    res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_BEHAVIOR, params2, 1);
4951401458bSopenharmony_ci    ASSERT_EQ(res, ERR_KEY_NAME_INVALID);
4961401458bSopenharmony_ci
4971401458bSopenharmony_ci    HiSysEventParam param3 = {
4981401458bSopenharmony_ci        .name = "123_key2",
4991401458bSopenharmony_ci        .t = HISYSEVENT_INT32,
5001401458bSopenharmony_ci        .v = { .i32 = 0 },
5011401458bSopenharmony_ci        .arraySize = 0,
5021401458bSopenharmony_ci    };
5031401458bSopenharmony_ci    HiSysEventParam params3[] = { param3 };
5041401458bSopenharmony_ci    res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_BEHAVIOR, params3, 1);
5051401458bSopenharmony_ci    ASSERT_EQ(res, ERR_KEY_NAME_INVALID);
5061401458bSopenharmony_ci
5071401458bSopenharmony_ci    HiSysEventParam param4 = {
5081401458bSopenharmony_ci        .name = "key3**",
5091401458bSopenharmony_ci        .t = HISYSEVENT_INT32,
5101401458bSopenharmony_ci        .v = { .i32 = 0 },
5111401458bSopenharmony_ci        .arraySize = 0,
5121401458bSopenharmony_ci    };
5131401458bSopenharmony_ci    HiSysEventParam params4[] = { param4 };
5141401458bSopenharmony_ci    res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_BEHAVIOR, params4, 1);
5151401458bSopenharmony_ci    ASSERT_EQ(res, ERR_KEY_NAME_INVALID);
5161401458bSopenharmony_ci
5171401458bSopenharmony_ci    HiSysEventParam param5 = {
5181401458bSopenharmony_ci        .name = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5191401458bSopenharmony_ci        .t = HISYSEVENT_INT32,
5201401458bSopenharmony_ci        .v = { .i32 = 0 },
5211401458bSopenharmony_ci        .arraySize = 0,
5221401458bSopenharmony_ci    };
5231401458bSopenharmony_ci    HiSysEventParam params5[] = { param5 };
5241401458bSopenharmony_ci    res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_BEHAVIOR, params5, 1);
5251401458bSopenharmony_ci    ASSERT_EQ(res, 0);
5261401458bSopenharmony_ci}
5271401458bSopenharmony_ci
5281401458bSopenharmony_ci/**
5291401458bSopenharmony_ci * @tc.name: HiSysEventCTest008
5301401458bSopenharmony_ci * @tc.desc: Test writing of 129 params.
5311401458bSopenharmony_ci * @tc.type: FUNC
5321401458bSopenharmony_ci * @tc.require: issueI5O9JB
5331401458bSopenharmony_ci */
5341401458bSopenharmony_ciHWTEST_F(HiSysEventCTest, HiSysEventCTest008, TestSize.Level3)
5351401458bSopenharmony_ci{
5361401458bSopenharmony_ci    /**
5371401458bSopenharmony_ci     * @tc.steps: step1. create event.
5381401458bSopenharmony_ci     * @tc.steps: step2. write event.
5391401458bSopenharmony_ci     * @tc.steps: step3. check the result of writing.
5401401458bSopenharmony_ci     */
5411401458bSopenharmony_ci    HiSysEventParam params[MAX_PARAM_NUMBER + 1];
5421401458bSopenharmony_ci    for (size_t i = 0; i <= MAX_PARAM_NUMBER; ++i) {
5431401458bSopenharmony_ci        HiSysEventParam param = {
5441401458bSopenharmony_ci            .t = HISYSEVENT_INT32,
5451401458bSopenharmony_ci            .v = { .i32 = 0 },
5461401458bSopenharmony_ci            .arraySize = 0,
5471401458bSopenharmony_ci        };
5481401458bSopenharmony_ci        std::string key = "key" + std::to_string(i);
5491401458bSopenharmony_ci        if (strcpy_s(param.name, sizeof(param.name), key.c_str()) != EOK) {
5501401458bSopenharmony_ci            ASSERT_TRUE(false);
5511401458bSopenharmony_ci        }
5521401458bSopenharmony_ci        params[i] = param;
5531401458bSopenharmony_ci    }
5541401458bSopenharmony_ci    int res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_BEHAVIOR, params, MAX_PARAM_NUMBER + 1);
5551401458bSopenharmony_ci    ASSERT_EQ(res, ERR_KEY_NUMBER_TOO_MUCH);
5561401458bSopenharmony_ci}
5571401458bSopenharmony_ci
5581401458bSopenharmony_ci/**
5591401458bSopenharmony_ci * @tc.name: HiSysEventCTest010
5601401458bSopenharmony_ci * @tc.desc: Test writing of long string params.
5611401458bSopenharmony_ci * @tc.type: FUNC
5621401458bSopenharmony_ci * @tc.require: issueI5O9JB
5631401458bSopenharmony_ci */
5641401458bSopenharmony_ciHWTEST_F(HiSysEventCTest, HiSysEventCTest010, TestSize.Level3)
5651401458bSopenharmony_ci{
5661401458bSopenharmony_ci    /**
5671401458bSopenharmony_ci     * @tc.steps: step1. create event.
5681401458bSopenharmony_ci     * @tc.steps: step2. write event.
5691401458bSopenharmony_ci     * @tc.steps: step3. check the result of writing.
5701401458bSopenharmony_ci     */
5711401458bSopenharmony_ci    size_t strLen = MAX_STRING_LENGTH + 1;
5721401458bSopenharmony_ci    char* longStr = new char[strLen + 1];
5731401458bSopenharmony_ci    for (size_t i = 0; i < strLen; ++i) {
5741401458bSopenharmony_ci        longStr[i] = 'a';
5751401458bSopenharmony_ci    }
5761401458bSopenharmony_ci    longStr[strLen] = '\0';
5771401458bSopenharmony_ci    HiSysEventParam param = {
5781401458bSopenharmony_ci        .name = "KEY_STRING",
5791401458bSopenharmony_ci        .t = HISYSEVENT_STRING,
5801401458bSopenharmony_ci        .v = { .s = longStr },
5811401458bSopenharmony_ci        .arraySize = 0,
5821401458bSopenharmony_ci    };
5831401458bSopenharmony_ci    HiSysEventParam params[] = { param };
5841401458bSopenharmony_ci    size_t len = sizeof(params) / sizeof(params[0]);
5851401458bSopenharmony_ci    int res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_BEHAVIOR, params, len);
5861401458bSopenharmony_ci    ASSERT_EQ(res, ERR_VALUE_LENGTH_TOO_LONG);
5871401458bSopenharmony_ci
5881401458bSopenharmony_ci    char* srts[] = { longStr };
5891401458bSopenharmony_ci    HiSysEventParam param2 = {
5901401458bSopenharmony_ci        .name = "KEY_STRING_ARR",
5911401458bSopenharmony_ci        .t = HISYSEVENT_STRING_ARRAY,
5921401458bSopenharmony_ci        .v = { .array = srts },
5931401458bSopenharmony_ci        .arraySize = 1,
5941401458bSopenharmony_ci    };
5951401458bSopenharmony_ci    HiSysEventParam params2[] = { param2 };
5961401458bSopenharmony_ci    len = sizeof(params2) / sizeof(params2[0]);
5971401458bSopenharmony_ci    res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_BEHAVIOR, params2, len);
5981401458bSopenharmony_ci    ASSERT_EQ(res, ERR_VALUE_LENGTH_TOO_LONG);
5991401458bSopenharmony_ci
6001401458bSopenharmony_ci    delete[] longStr;
6011401458bSopenharmony_ci}
6021401458bSopenharmony_ci
6031401458bSopenharmony_ci/**
6041401458bSopenharmony_ci * @tc.name: HiSysEventCTest011
6051401458bSopenharmony_ci * @tc.desc: Test writing of long array params.
6061401458bSopenharmony_ci * @tc.type: FUNC
6071401458bSopenharmony_ci * @tc.require: issueI5O9JB
6081401458bSopenharmony_ci */
6091401458bSopenharmony_ciHWTEST_F(HiSysEventCTest, HiSysEventCTest011, TestSize.Level3)
6101401458bSopenharmony_ci{
6111401458bSopenharmony_ci    /**
6121401458bSopenharmony_ci     * @tc.steps: step1. create event.
6131401458bSopenharmony_ci     * @tc.steps: step2. write event.
6141401458bSopenharmony_ci     * @tc.steps: step3. check the result of writing.
6151401458bSopenharmony_ci     */
6161401458bSopenharmony_ci    int32_t int32s[MAX_ARRAY_SIZE + 1] = { 0 };
6171401458bSopenharmony_ci    for (size_t i = 0; i <= MAX_ARRAY_SIZE; ++i) {
6181401458bSopenharmony_ci        int32s[i] = 1;
6191401458bSopenharmony_ci    }
6201401458bSopenharmony_ci    HiSysEventParam param = {
6211401458bSopenharmony_ci        .name = "KEY_INT32_ARR",
6221401458bSopenharmony_ci        .t = HISYSEVENT_INT32_ARRAY,
6231401458bSopenharmony_ci        .v = { .array = int32s },
6241401458bSopenharmony_ci        .arraySize = MAX_ARRAY_SIZE + 1,
6251401458bSopenharmony_ci    };
6261401458bSopenharmony_ci    HiSysEventParam params[] = { param };
6271401458bSopenharmony_ci    size_t len = sizeof(params) / sizeof(params[0]);
6281401458bSopenharmony_ci    int res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_BEHAVIOR, params, len);
6291401458bSopenharmony_ci    ASSERT_EQ(res, ERR_ARRAY_TOO_MUCH);
6301401458bSopenharmony_ci}
6311401458bSopenharmony_ci
6321401458bSopenharmony_ci/**
6331401458bSopenharmony_ci * @tc.name: HiSysEventCTest012
6341401458bSopenharmony_ci * @tc.desc: Test writing of oversize event.
6351401458bSopenharmony_ci * @tc.type: FUNC
6361401458bSopenharmony_ci * @tc.require: issueI5O9JB
6371401458bSopenharmony_ci */
6381401458bSopenharmony_ciHWTEST_F(HiSysEventCTest, HiSysEventCTest012, TestSize.Level3)
6391401458bSopenharmony_ci{
6401401458bSopenharmony_ci    /**
6411401458bSopenharmony_ci     * @tc.steps: step1. create event.
6421401458bSopenharmony_ci     * @tc.steps: step2. write event.
6431401458bSopenharmony_ci     * @tc.steps: step3. check the result of writing.
6441401458bSopenharmony_ci     */
6451401458bSopenharmony_ci    size_t strLen = MAX_STRING_LENGTH;
6461401458bSopenharmony_ci    char* longStr = new char[strLen + 1];
6471401458bSopenharmony_ci    for (size_t i = 0; i < strLen; ++i) {
6481401458bSopenharmony_ci        longStr[i] = 'a';
6491401458bSopenharmony_ci    }
6501401458bSopenharmony_ci    longStr[strLen] = '\0';
6511401458bSopenharmony_ci    char* srts[] = { longStr, longStr };
6521401458bSopenharmony_ci    HiSysEventParam param = {
6531401458bSopenharmony_ci        .name = "KEY_STRING_ARR",
6541401458bSopenharmony_ci        .t = HISYSEVENT_STRING_ARRAY,
6551401458bSopenharmony_ci        .v = { .array = srts },
6561401458bSopenharmony_ci        .arraySize = 2,
6571401458bSopenharmony_ci    };
6581401458bSopenharmony_ci    HiSysEventParam params[] = { param };
6591401458bSopenharmony_ci    size_t len = sizeof(params) / sizeof(params[0]);
6601401458bSopenharmony_ci    int res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_BEHAVIOR, params, len);
6611401458bSopenharmony_ci    ASSERT_EQ(res, ERR_OVER_SIZE);
6621401458bSopenharmony_ci    delete[] longStr;
6631401458bSopenharmony_ci}
6641401458bSopenharmony_ci
6651401458bSopenharmony_ci/**
6661401458bSopenharmony_ci * @tc.name: HiSysEventCTest013
6671401458bSopenharmony_ci * @tc.desc: Test writing events too frequently.
6681401458bSopenharmony_ci * @tc.type: FUNC
6691401458bSopenharmony_ci * @tc.require: issueI5O9JB
6701401458bSopenharmony_ci */
6711401458bSopenharmony_ciHWTEST_F(HiSysEventCTest, HiSysEventCTest013, TestSize.Level3)
6721401458bSopenharmony_ci{
6731401458bSopenharmony_ci    /**
6741401458bSopenharmony_ci     * @tc.steps: step1. create event.
6751401458bSopenharmony_ci     * @tc.steps: step2. write event.
6761401458bSopenharmony_ci     * @tc.steps: step3. check the result of writing.
6771401458bSopenharmony_ci     */
6781401458bSopenharmony_ci    for (int i = 0; i <= 100; i++) { // the frequency is limited to 100 events every 5 seconds
6791401458bSopenharmony_ci        int res = OH_HiSysEvent_Write(TEST_DOMAIN, TEST_NAME, HISYSEVENT_BEHAVIOR, {}, 0);
6801401458bSopenharmony_ci        if (i == 100) {
6811401458bSopenharmony_ci            ASSERT_EQ(res, ERR_WRITE_IN_HIGH_FREQ);
6821401458bSopenharmony_ci        } else {
6831401458bSopenharmony_ci            ASSERT_EQ(res, 0);
6841401458bSopenharmony_ci        }
6851401458bSopenharmony_ci    }
6861401458bSopenharmony_ci}
687