14514f5e3Sopenharmony_ci/*
24514f5e3Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License.
54514f5e3Sopenharmony_ci * You may obtain a copy of the License at
64514f5e3Sopenharmony_ci *
74514f5e3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
84514f5e3Sopenharmony_ci *
94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and
134514f5e3Sopenharmony_ci * limitations under the License.
144514f5e3Sopenharmony_ci */
154514f5e3Sopenharmony_ci
164514f5e3Sopenharmony_ci#include "containersplainarray_fuzzer.h"
174514f5e3Sopenharmony_ci
184514f5e3Sopenharmony_ci#include "ecmascript/base/builtins_base.h"
194514f5e3Sopenharmony_ci#include "ecmascript/containers/containers_plainarray.h"
204514f5e3Sopenharmony_ci#include "ecmascript/containers/containers_private.h"
214514f5e3Sopenharmony_ci#include "ecmascript/ecma_string-inl.h"
224514f5e3Sopenharmony_ci#include "ecmascript/ecma_vm.h"
234514f5e3Sopenharmony_ci#include "ecmascript/global_env.h"
244514f5e3Sopenharmony_ci#include "ecmascript/js_api/js_api_plain_array.h"
254514f5e3Sopenharmony_ci#include "ecmascript/js_handle.h"
264514f5e3Sopenharmony_ci#include "ecmascript/napi/include/jsnapi.h"
274514f5e3Sopenharmony_ci
284514f5e3Sopenharmony_ciusing namespace panda;
294514f5e3Sopenharmony_ciusing namespace panda::ecmascript;
304514f5e3Sopenharmony_ciusing namespace panda::ecmascript::base;
314514f5e3Sopenharmony_ciusing namespace panda::ecmascript::containers;
324514f5e3Sopenharmony_ci
334514f5e3Sopenharmony_cinamespace OHOS {
344514f5e3Sopenharmony_ci    JSFunction *JSObjectCreate(JSThread *thread)
354514f5e3Sopenharmony_ci    {
364514f5e3Sopenharmony_ci        JSHandle<GlobalEnv> globalEnv = thread->GetEcmaVM()->GetGlobalEnv();
374514f5e3Sopenharmony_ci        return globalEnv->GetObjectFunction().GetObject<JSFunction>();
384514f5e3Sopenharmony_ci    }
394514f5e3Sopenharmony_ci
404514f5e3Sopenharmony_ci    EcmaRuntimeCallInfo *CreateEcmaRuntimeCallInfo(JSThread *thread, uint32_t numArgs)
414514f5e3Sopenharmony_ci    {
424514f5e3Sopenharmony_ci        auto factory = thread->GetEcmaVM()->GetFactory();
434514f5e3Sopenharmony_ci        JSHandle<JSTaggedValue> hclass(thread, JSObjectCreate(thread));
444514f5e3Sopenharmony_ci        JSHandle<JSTaggedValue> callee(factory->NewJSObjectByConstructor(JSHandle<JSFunction>::Cast(hclass), hclass));
454514f5e3Sopenharmony_ci        JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
464514f5e3Sopenharmony_ci        EcmaRuntimeCallInfo *objCallInfo =
474514f5e3Sopenharmony_ci            EcmaInterpreter::NewRuntimeCallInfo(thread, undefined, callee, undefined, numArgs);
484514f5e3Sopenharmony_ci        return objCallInfo;
494514f5e3Sopenharmony_ci    }
504514f5e3Sopenharmony_ci
514514f5e3Sopenharmony_ci    JSTaggedValue InitializePlainArrayConstructor(JSThread *thread)
524514f5e3Sopenharmony_ci    {
534514f5e3Sopenharmony_ci        auto factory = thread->GetEcmaVM()->GetFactory();
544514f5e3Sopenharmony_ci        JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
554514f5e3Sopenharmony_ci        JSHandle<JSTaggedValue> globalObject = env->GetJSGlobalObject();
564514f5e3Sopenharmony_ci        JSHandle<JSTaggedValue> key(factory->NewFromASCII("ArkPrivate"));
574514f5e3Sopenharmony_ci        JSHandle<JSTaggedValue> value =
584514f5e3Sopenharmony_ci            JSObject::GetProperty(thread, JSHandle<JSTaggedValue>(globalObject), key).GetValue();
594514f5e3Sopenharmony_ci
604514f5e3Sopenharmony_ci        auto objCallInfo = CreateEcmaRuntimeCallInfo(thread, 6); // 6 : means the argv length
614514f5e3Sopenharmony_ci        objCallInfo->SetFunction(JSTaggedValue::Undefined());
624514f5e3Sopenharmony_ci        objCallInfo->SetThis(value.GetTaggedValue());
634514f5e3Sopenharmony_ci        objCallInfo->SetCallArg(0, JSTaggedValue(static_cast<int>(ContainerTag::PlainArray)));
644514f5e3Sopenharmony_ci        JSTaggedValue result = ContainersPrivate::Load(objCallInfo);
654514f5e3Sopenharmony_ci        return result;
664514f5e3Sopenharmony_ci    }
674514f5e3Sopenharmony_ci
684514f5e3Sopenharmony_ci    JSHandle<JSAPIPlainArray> CreateJSAPIPlainArray(JSThread *thread)
694514f5e3Sopenharmony_ci    {
704514f5e3Sopenharmony_ci        JSHandle<JSFunction> newTarget(thread, InitializePlainArrayConstructor(thread));
714514f5e3Sopenharmony_ci        auto objCallInfo = CreateEcmaRuntimeCallInfo(thread, 4);
724514f5e3Sopenharmony_ci        objCallInfo->SetFunction(newTarget.GetTaggedValue());
734514f5e3Sopenharmony_ci        objCallInfo->SetNewTarget(newTarget.GetTaggedValue());
744514f5e3Sopenharmony_ci        objCallInfo->SetThis(JSTaggedValue::Undefined());
754514f5e3Sopenharmony_ci        JSTaggedValue result = ContainersPlainArray::PlainArrayConstructor(objCallInfo);
764514f5e3Sopenharmony_ci        JSHandle<JSAPIPlainArray> array(thread, result);
774514f5e3Sopenharmony_ci        return array;
784514f5e3Sopenharmony_ci    }
794514f5e3Sopenharmony_ci
804514f5e3Sopenharmony_ci    void ContainersPlainArray_Constructor_FuzzTest(const uint8_t* data, size_t size)
814514f5e3Sopenharmony_ci    {
824514f5e3Sopenharmony_ci        if (data == nullptr || size <= 0) {
834514f5e3Sopenharmony_ci            std::cout << "illegal input!";
844514f5e3Sopenharmony_ci            return;
854514f5e3Sopenharmony_ci        }
864514f5e3Sopenharmony_ci        RuntimeOption option;
874514f5e3Sopenharmony_ci        option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
884514f5e3Sopenharmony_ci        EcmaVM *vm = JSNApi::CreateJSVM(option);
894514f5e3Sopenharmony_ci        {
904514f5e3Sopenharmony_ci            JsiFastNativeScope scope(vm);
914514f5e3Sopenharmony_ci            auto thread = vm->GetAssociatedJSThread();
924514f5e3Sopenharmony_ci            uint32_t input = 0;
934514f5e3Sopenharmony_ci            const uint32_t MAXBYTELEN = 4;
944514f5e3Sopenharmony_ci            if (size > MAXBYTELEN) {
954514f5e3Sopenharmony_ci                size = MAXBYTELEN;
964514f5e3Sopenharmony_ci            }
974514f5e3Sopenharmony_ci            if (memcpy_s(&input, MAXBYTELEN, data, size) != 0) {
984514f5e3Sopenharmony_ci                std::cout << "memcpy_s failed!";
994514f5e3Sopenharmony_ci                UNREACHABLE();
1004514f5e3Sopenharmony_ci            }
1014514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> plainArray = CreateJSAPIPlainArray(thread);
1024514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 6); // 6 : means the argv length
1034514f5e3Sopenharmony_ci            callInfo->SetFunction(JSTaggedValue::Undefined());
1044514f5e3Sopenharmony_ci            callInfo->SetThis(plainArray.GetTaggedValue());
1054514f5e3Sopenharmony_ci            callInfo->SetCallArg(0, JSTaggedValue(input));
1064514f5e3Sopenharmony_ci            ContainersPlainArray::PlainArrayConstructor(callInfo);
1074514f5e3Sopenharmony_ci        }
1084514f5e3Sopenharmony_ci        JSNApi::DestroyJSVM(vm);
1094514f5e3Sopenharmony_ci    }
1104514f5e3Sopenharmony_ci
1114514f5e3Sopenharmony_ci    void ContainersPlainArray_Add_Has_FuzzTest(const uint8_t* data, size_t size)
1124514f5e3Sopenharmony_ci    {
1134514f5e3Sopenharmony_ci        if (data == nullptr || size <= 0) {
1144514f5e3Sopenharmony_ci            std::cout << "illegal input!";
1154514f5e3Sopenharmony_ci            return;
1164514f5e3Sopenharmony_ci        }
1174514f5e3Sopenharmony_ci        RuntimeOption option;
1184514f5e3Sopenharmony_ci        option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
1194514f5e3Sopenharmony_ci        EcmaVM *vm = JSNApi::CreateJSVM(option);
1204514f5e3Sopenharmony_ci        {
1214514f5e3Sopenharmony_ci            JsiFastNativeScope scope(vm);
1224514f5e3Sopenharmony_ci            auto thread = vm->GetAssociatedJSThread();
1234514f5e3Sopenharmony_ci            auto factory = vm->GetFactory();
1244514f5e3Sopenharmony_ci
1254514f5e3Sopenharmony_ci            uint32_t inputNum = 0;
1264514f5e3Sopenharmony_ci            std::string inputStr(data, data + size);
1274514f5e3Sopenharmony_ci            const uint32_t MAXBYTELEN = 4;
1284514f5e3Sopenharmony_ci            if (size > MAXBYTELEN) {
1294514f5e3Sopenharmony_ci                size = MAXBYTELEN;
1304514f5e3Sopenharmony_ci            }
1314514f5e3Sopenharmony_ci            if (memcpy_s(&inputNum, MAXBYTELEN, data, size) != 0) {
1324514f5e3Sopenharmony_ci                std::cout << "memcpy_s failed!";
1334514f5e3Sopenharmony_ci                UNREACHABLE();
1344514f5e3Sopenharmony_ci            }
1354514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> plainArray = CreateJSAPIPlainArray(thread);
1364514f5e3Sopenharmony_ci            const uint32_t addTimes = 3;
1374514f5e3Sopenharmony_ci            for (uint32_t i = 0; i < addTimes; i++) {
1384514f5e3Sopenharmony_ci                JSHandle<EcmaString> inputEcmaStr = factory->NewFromStdString(inputStr);
1394514f5e3Sopenharmony_ci                EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
1404514f5e3Sopenharmony_ci                callInfo->SetFunction(JSTaggedValue::Undefined());
1414514f5e3Sopenharmony_ci                callInfo->SetThis(plainArray.GetTaggedValue());
1424514f5e3Sopenharmony_ci                callInfo->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum + i))); // set key
1434514f5e3Sopenharmony_ci                callInfo->SetCallArg(1, inputEcmaStr.GetTaggedValue()); // set value
1444514f5e3Sopenharmony_ci                ContainersPlainArray::Add(callInfo);
1454514f5e3Sopenharmony_ci            }
1464514f5e3Sopenharmony_ci
1474514f5e3Sopenharmony_ci            for (uint32_t i = 0; i < addTimes; i++) {
1484514f5e3Sopenharmony_ci                EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 6); // 6 : means the argv length
1494514f5e3Sopenharmony_ci                callInfo->SetFunction(JSTaggedValue::Undefined());
1504514f5e3Sopenharmony_ci                callInfo->SetThis(plainArray.GetTaggedValue());
1514514f5e3Sopenharmony_ci                callInfo->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum + i)));
1524514f5e3Sopenharmony_ci                ContainersPlainArray::Has(callInfo);  // expected to return true
1534514f5e3Sopenharmony_ci            }
1544514f5e3Sopenharmony_ci        }
1554514f5e3Sopenharmony_ci        JSNApi::DestroyJSVM(vm);
1564514f5e3Sopenharmony_ci    }
1574514f5e3Sopenharmony_ci
1584514f5e3Sopenharmony_ci    void ContainersPlainArray_Clone_FuzzTest(const uint8_t* data, size_t size)
1594514f5e3Sopenharmony_ci    {
1604514f5e3Sopenharmony_ci        if (data == nullptr || size <= 0) {
1614514f5e3Sopenharmony_ci            std::cout << "illegal input!";
1624514f5e3Sopenharmony_ci            return;
1634514f5e3Sopenharmony_ci        }
1644514f5e3Sopenharmony_ci        RuntimeOption option;
1654514f5e3Sopenharmony_ci        option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
1664514f5e3Sopenharmony_ci        EcmaVM *vm = JSNApi::CreateJSVM(option);
1674514f5e3Sopenharmony_ci        {
1684514f5e3Sopenharmony_ci            JsiFastNativeScope scope(vm);
1694514f5e3Sopenharmony_ci            auto thread = vm->GetAssociatedJSThread();
1704514f5e3Sopenharmony_ci            auto factory = vm->GetFactory();
1714514f5e3Sopenharmony_ci
1724514f5e3Sopenharmony_ci            uint32_t inputNum = 0;
1734514f5e3Sopenharmony_ci            std::string inputStr(data, data + size);
1744514f5e3Sopenharmony_ci            const uint32_t MAXBYTELEN = 4;
1754514f5e3Sopenharmony_ci            if (size > MAXBYTELEN) {
1764514f5e3Sopenharmony_ci                size = MAXBYTELEN;
1774514f5e3Sopenharmony_ci            }
1784514f5e3Sopenharmony_ci            if (memcpy_s(&inputNum, MAXBYTELEN, data, size) != 0) {
1794514f5e3Sopenharmony_ci                std::cout << "memcpy_s failed!";
1804514f5e3Sopenharmony_ci                UNREACHABLE();
1814514f5e3Sopenharmony_ci            }
1824514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> plainArray = CreateJSAPIPlainArray(thread);
1834514f5e3Sopenharmony_ci            JSHandle<EcmaString> inputEcmaStr = factory->NewFromStdString(inputStr);
1844514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
1854514f5e3Sopenharmony_ci            callInfo->SetFunction(JSTaggedValue::Undefined());
1864514f5e3Sopenharmony_ci            callInfo->SetThis(plainArray.GetTaggedValue());
1874514f5e3Sopenharmony_ci            callInfo->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum)));
1884514f5e3Sopenharmony_ci            callInfo->SetCallArg(1, inputEcmaStr.GetTaggedValue());
1894514f5e3Sopenharmony_ci            ContainersPlainArray::Add(callInfo);
1904514f5e3Sopenharmony_ci
1914514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *cfForClone = CreateEcmaRuntimeCallInfo(thread, 4); // 4 : means the argv length
1924514f5e3Sopenharmony_ci            cfForClone->SetFunction(JSTaggedValue::Undefined());
1934514f5e3Sopenharmony_ci            cfForClone->SetThis(plainArray.GetTaggedValue());
1944514f5e3Sopenharmony_ci            ContainersPlainArray::Clone(cfForClone); // expected to return new plain array
1954514f5e3Sopenharmony_ci        }
1964514f5e3Sopenharmony_ci        JSNApi::DestroyJSVM(vm);
1974514f5e3Sopenharmony_ci    }
1984514f5e3Sopenharmony_ci
1994514f5e3Sopenharmony_ci    void ContainersPlainArray_Clear_FuzzTest(const uint8_t* data, size_t size)
2004514f5e3Sopenharmony_ci    {
2014514f5e3Sopenharmony_ci        if (data == nullptr || size <= 0) {
2024514f5e3Sopenharmony_ci            std::cout << "illegal input!";
2034514f5e3Sopenharmony_ci            return;
2044514f5e3Sopenharmony_ci        }
2054514f5e3Sopenharmony_ci        RuntimeOption option;
2064514f5e3Sopenharmony_ci        option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
2074514f5e3Sopenharmony_ci        EcmaVM *vm = JSNApi::CreateJSVM(option);
2084514f5e3Sopenharmony_ci        {
2094514f5e3Sopenharmony_ci            JsiFastNativeScope scope(vm);
2104514f5e3Sopenharmony_ci            auto thread = vm->GetAssociatedJSThread();
2114514f5e3Sopenharmony_ci            auto factory = vm->GetFactory();
2124514f5e3Sopenharmony_ci
2134514f5e3Sopenharmony_ci            uint32_t inputNum = 0;
2144514f5e3Sopenharmony_ci            std::string inputStr(data, data + size);
2154514f5e3Sopenharmony_ci            const uint32_t MAXBYTELEN = 4;
2164514f5e3Sopenharmony_ci            if (size > MAXBYTELEN) {
2174514f5e3Sopenharmony_ci                size = MAXBYTELEN;
2184514f5e3Sopenharmony_ci            }
2194514f5e3Sopenharmony_ci            if (memcpy_s(&inputNum, MAXBYTELEN, data, size) != 0) {
2204514f5e3Sopenharmony_ci                std::cout << "memcpy_s failed!";
2214514f5e3Sopenharmony_ci                UNREACHABLE();
2224514f5e3Sopenharmony_ci            }
2234514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> plainArray = CreateJSAPIPlainArray(thread);
2244514f5e3Sopenharmony_ci            JSHandle<EcmaString> inputEcmaStr = factory->NewFromStdString(inputStr);
2254514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
2264514f5e3Sopenharmony_ci            callInfo->SetFunction(JSTaggedValue::Undefined());
2274514f5e3Sopenharmony_ci            callInfo->SetThis(plainArray.GetTaggedValue());
2284514f5e3Sopenharmony_ci            callInfo->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum)));
2294514f5e3Sopenharmony_ci            callInfo->SetCallArg(1, inputEcmaStr.GetTaggedValue());
2304514f5e3Sopenharmony_ci            ContainersPlainArray::Add(callInfo);
2314514f5e3Sopenharmony_ci
2324514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *cfForClear = CreateEcmaRuntimeCallInfo(thread, 4); // 4 : means the argv length
2334514f5e3Sopenharmony_ci            cfForClear->SetFunction(JSTaggedValue::Undefined());
2344514f5e3Sopenharmony_ci            cfForClear->SetThis(plainArray.GetTaggedValue());
2354514f5e3Sopenharmony_ci            ContainersPlainArray::Clear(cfForClear); // expected to return true
2364514f5e3Sopenharmony_ci        }
2374514f5e3Sopenharmony_ci        JSNApi::DestroyJSVM(vm);
2384514f5e3Sopenharmony_ci    }
2394514f5e3Sopenharmony_ci
2404514f5e3Sopenharmony_ci    void ContainersPlainArray_Get_FuzzTest(const uint8_t* data, size_t size)
2414514f5e3Sopenharmony_ci    {
2424514f5e3Sopenharmony_ci        if (data == nullptr || size <= 0) {
2434514f5e3Sopenharmony_ci            std::cout << "illegal input!";
2444514f5e3Sopenharmony_ci            return;
2454514f5e3Sopenharmony_ci        }
2464514f5e3Sopenharmony_ci        RuntimeOption option;
2474514f5e3Sopenharmony_ci        option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
2484514f5e3Sopenharmony_ci        EcmaVM *vm = JSNApi::CreateJSVM(option);
2494514f5e3Sopenharmony_ci        {
2504514f5e3Sopenharmony_ci            JsiFastNativeScope scope(vm);
2514514f5e3Sopenharmony_ci            auto thread = vm->GetAssociatedJSThread();
2524514f5e3Sopenharmony_ci            auto factory = vm->GetFactory();
2534514f5e3Sopenharmony_ci
2544514f5e3Sopenharmony_ci            uint32_t inputNum = 0;
2554514f5e3Sopenharmony_ci            std::string inputStr(data, data + size);
2564514f5e3Sopenharmony_ci            const uint32_t MAXBYTELEN = 4;
2574514f5e3Sopenharmony_ci            if (size > MAXBYTELEN) {
2584514f5e3Sopenharmony_ci                size = MAXBYTELEN;
2594514f5e3Sopenharmony_ci            }
2604514f5e3Sopenharmony_ci            if (memcpy_s(&inputNum, MAXBYTELEN, data, size) != 0) {
2614514f5e3Sopenharmony_ci                std::cout << "memcpy_s failed!";
2624514f5e3Sopenharmony_ci                UNREACHABLE();
2634514f5e3Sopenharmony_ci            }
2644514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> plainArray = CreateJSAPIPlainArray(thread);
2654514f5e3Sopenharmony_ci            JSHandle<EcmaString> inputEcmaStr = factory->NewFromStdString(inputStr);
2664514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
2674514f5e3Sopenharmony_ci            callInfo->SetFunction(JSTaggedValue::Undefined());
2684514f5e3Sopenharmony_ci            callInfo->SetThis(plainArray.GetTaggedValue());
2694514f5e3Sopenharmony_ci            callInfo->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum)));
2704514f5e3Sopenharmony_ci            callInfo->SetCallArg(1, inputEcmaStr.GetTaggedValue());
2714514f5e3Sopenharmony_ci            ContainersPlainArray::Add(callInfo);
2724514f5e3Sopenharmony_ci
2734514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *cfForGet = CreateEcmaRuntimeCallInfo(thread, 6); // 6 : means the argv length
2744514f5e3Sopenharmony_ci            cfForGet->SetFunction(JSTaggedValue::Undefined());
2754514f5e3Sopenharmony_ci            cfForGet->SetThis(plainArray.GetTaggedValue());
2764514f5e3Sopenharmony_ci            cfForGet->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum))); // set key get value
2774514f5e3Sopenharmony_ci            ContainersPlainArray::Get(cfForGet); // expected to return value
2784514f5e3Sopenharmony_ci        }
2794514f5e3Sopenharmony_ci        JSNApi::DestroyJSVM(vm);
2804514f5e3Sopenharmony_ci    }
2814514f5e3Sopenharmony_ci
2824514f5e3Sopenharmony_ci    void ContainersPlainArray_GetIteratorObj_FuzzTest(const uint8_t* data, size_t size)
2834514f5e3Sopenharmony_ci    {
2844514f5e3Sopenharmony_ci        if (data == nullptr || size <= 0) {
2854514f5e3Sopenharmony_ci            std::cout << "illegal input!";
2864514f5e3Sopenharmony_ci            return;
2874514f5e3Sopenharmony_ci        }
2884514f5e3Sopenharmony_ci        RuntimeOption option;
2894514f5e3Sopenharmony_ci        option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
2904514f5e3Sopenharmony_ci        EcmaVM *vm = JSNApi::CreateJSVM(option);
2914514f5e3Sopenharmony_ci        {
2924514f5e3Sopenharmony_ci            JsiFastNativeScope scope(vm);
2934514f5e3Sopenharmony_ci            auto thread = vm->GetAssociatedJSThread();
2944514f5e3Sopenharmony_ci            auto factory = vm->GetFactory();
2954514f5e3Sopenharmony_ci
2964514f5e3Sopenharmony_ci            uint32_t inputNum = 0;
2974514f5e3Sopenharmony_ci            std::string inputStr(data, data + size);
2984514f5e3Sopenharmony_ci            const uint32_t MAXBYTELEN = 4;
2994514f5e3Sopenharmony_ci            if (size > MAXBYTELEN) {
3004514f5e3Sopenharmony_ci                size = MAXBYTELEN;
3014514f5e3Sopenharmony_ci            }
3024514f5e3Sopenharmony_ci            if (memcpy_s(&inputNum, MAXBYTELEN, data, size) != 0) {
3034514f5e3Sopenharmony_ci                std::cout << "memcpy_s failed!";
3044514f5e3Sopenharmony_ci                UNREACHABLE();
3054514f5e3Sopenharmony_ci            }
3064514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> plainArray = CreateJSAPIPlainArray(thread);
3074514f5e3Sopenharmony_ci            JSHandle<EcmaString> inputEcmaStr = factory->NewFromStdString(inputStr);
3084514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
3094514f5e3Sopenharmony_ci            callInfo->SetFunction(JSTaggedValue::Undefined());
3104514f5e3Sopenharmony_ci            callInfo->SetThis(plainArray.GetTaggedValue());
3114514f5e3Sopenharmony_ci            callInfo->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum)));
3124514f5e3Sopenharmony_ci            callInfo->SetCallArg(1, inputEcmaStr.GetTaggedValue());
3134514f5e3Sopenharmony_ci            ContainersPlainArray::Add(callInfo);
3144514f5e3Sopenharmony_ci
3154514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *cfForGetIteratorObj =
3164514f5e3Sopenharmony_ci                CreateEcmaRuntimeCallInfo(thread, 4); // 4 : means the argv length
3174514f5e3Sopenharmony_ci            cfForGetIteratorObj->SetFunction(JSTaggedValue::Undefined());
3184514f5e3Sopenharmony_ci            cfForGetIteratorObj->SetThis(plainArray.GetTaggedValue());
3194514f5e3Sopenharmony_ci            ContainersPlainArray::GetIteratorObj(cfForGetIteratorObj); // expected to return iterator
3204514f5e3Sopenharmony_ci        }
3214514f5e3Sopenharmony_ci        JSNApi::DestroyJSVM(vm);
3224514f5e3Sopenharmony_ci    }
3234514f5e3Sopenharmony_ci
3244514f5e3Sopenharmony_ci    static JSTaggedValue TestForEachFunc(EcmaRuntimeCallInfo *argv)
3254514f5e3Sopenharmony_ci    {
3264514f5e3Sopenharmony_ci        JSThread *thread = argv->GetThread();
3274514f5e3Sopenharmony_ci        JSHandle<JSTaggedValue> key = BuiltinsBase::GetCallArg(argv, 0);  // 0 means the value
3284514f5e3Sopenharmony_ci        JSHandle<JSTaggedValue> value = BuiltinsBase::GetCallArg(argv, 1); // 1 means the value
3294514f5e3Sopenharmony_ci        JSHandle<JSAPIPlainArray> plainArray(BuiltinsBase::GetCallArg(argv, 2)); // 2 means the value
3304514f5e3Sopenharmony_ci        JSHandle<JSTaggedValue> newValue(thread, value.GetTaggedValue());
3314514f5e3Sopenharmony_ci        JSAPIPlainArray::Add(thread, plainArray, key, newValue);
3324514f5e3Sopenharmony_ci        return JSTaggedValue::True();
3334514f5e3Sopenharmony_ci    }
3344514f5e3Sopenharmony_ci
3354514f5e3Sopenharmony_ci    void ContainersPlainArray_ForEach_FuzzTest(const uint8_t* data, size_t size)
3364514f5e3Sopenharmony_ci    {
3374514f5e3Sopenharmony_ci        if (data == nullptr || size <= 0) {
3384514f5e3Sopenharmony_ci            std::cout << "illegal input!";
3394514f5e3Sopenharmony_ci            return;
3404514f5e3Sopenharmony_ci        }
3414514f5e3Sopenharmony_ci        RuntimeOption option;
3424514f5e3Sopenharmony_ci        option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
3434514f5e3Sopenharmony_ci        EcmaVM *vm = JSNApi::CreateJSVM(option);
3444514f5e3Sopenharmony_ci        {
3454514f5e3Sopenharmony_ci            JsiFastNativeScope scope(vm);
3464514f5e3Sopenharmony_ci            auto thread = vm->GetAssociatedJSThread();
3474514f5e3Sopenharmony_ci            auto factory = vm->GetFactory();
3484514f5e3Sopenharmony_ci            JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
3494514f5e3Sopenharmony_ci
3504514f5e3Sopenharmony_ci            uint32_t inputNum = 0;
3514514f5e3Sopenharmony_ci            std::string inputStr(data, data + size);
3524514f5e3Sopenharmony_ci            const uint32_t MAXBYTELEN = 4;
3534514f5e3Sopenharmony_ci            if (size > MAXBYTELEN) {
3544514f5e3Sopenharmony_ci                size = MAXBYTELEN;
3554514f5e3Sopenharmony_ci            }
3564514f5e3Sopenharmony_ci            if (memcpy_s(&inputNum, MAXBYTELEN, data, size) != 0) {
3574514f5e3Sopenharmony_ci                std::cout << "memcpy_s failed!";
3584514f5e3Sopenharmony_ci                UNREACHABLE();
3594514f5e3Sopenharmony_ci            }
3604514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> plainArray = CreateJSAPIPlainArray(thread);
3614514f5e3Sopenharmony_ci            JSHandle<EcmaString> inputEcmaStr = factory->NewFromStdString(inputStr);
3624514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
3634514f5e3Sopenharmony_ci            callInfo->SetFunction(JSTaggedValue::Undefined());
3644514f5e3Sopenharmony_ci            callInfo->SetThis(plainArray.GetTaggedValue());
3654514f5e3Sopenharmony_ci            callInfo->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum)));
3664514f5e3Sopenharmony_ci            callInfo->SetCallArg(1, inputEcmaStr.GetTaggedValue());
3674514f5e3Sopenharmony_ci            ContainersPlainArray::Add(callInfo);
3684514f5e3Sopenharmony_ci
3694514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> thisArg = CreateJSAPIPlainArray(thread);
3704514f5e3Sopenharmony_ci            JSHandle<JSFunction> cbFunc = factory->NewJSFunction(env, reinterpret_cast<void *>(TestForEachFunc));
3714514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *cfForForEach = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
3724514f5e3Sopenharmony_ci            cfForForEach->SetFunction(JSTaggedValue::Undefined());
3734514f5e3Sopenharmony_ci            cfForForEach->SetThis(plainArray.GetTaggedValue());
3744514f5e3Sopenharmony_ci            cfForForEach->SetCallArg(0, cbFunc.GetTaggedValue());
3754514f5e3Sopenharmony_ci            cfForForEach->SetCallArg(1, thisArg.GetTaggedValue());
3764514f5e3Sopenharmony_ci            ContainersPlainArray::ForEach(cfForForEach); // expected to return undefined
3774514f5e3Sopenharmony_ci        }
3784514f5e3Sopenharmony_ci        JSNApi::DestroyJSVM(vm);
3794514f5e3Sopenharmony_ci    }
3804514f5e3Sopenharmony_ci
3814514f5e3Sopenharmony_ci    void ContainersPlainArray_ToString_FuzzTest(const uint8_t* data, size_t size)
3824514f5e3Sopenharmony_ci    {
3834514f5e3Sopenharmony_ci        if (data == nullptr || size <= 0) {
3844514f5e3Sopenharmony_ci            std::cout << "illegal input!";
3854514f5e3Sopenharmony_ci            return;
3864514f5e3Sopenharmony_ci        }
3874514f5e3Sopenharmony_ci        RuntimeOption option;
3884514f5e3Sopenharmony_ci        option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
3894514f5e3Sopenharmony_ci        EcmaVM *vm = JSNApi::CreateJSVM(option);
3904514f5e3Sopenharmony_ci        {
3914514f5e3Sopenharmony_ci            JsiFastNativeScope scope(vm);
3924514f5e3Sopenharmony_ci            auto thread = vm->GetAssociatedJSThread();
3934514f5e3Sopenharmony_ci            auto factory = vm->GetFactory();
3944514f5e3Sopenharmony_ci
3954514f5e3Sopenharmony_ci            uint32_t inputNum = 0;
3964514f5e3Sopenharmony_ci            std::string inputStr(data, data + size);
3974514f5e3Sopenharmony_ci            const uint32_t MAXBYTELEN = 4;
3984514f5e3Sopenharmony_ci            if (size > MAXBYTELEN) {
3994514f5e3Sopenharmony_ci                size = MAXBYTELEN;
4004514f5e3Sopenharmony_ci            }
4014514f5e3Sopenharmony_ci            if (memcpy_s(&inputNum, MAXBYTELEN, data, size) != 0) {
4024514f5e3Sopenharmony_ci                std::cout << "memcpy_s failed!";
4034514f5e3Sopenharmony_ci                UNREACHABLE();
4044514f5e3Sopenharmony_ci            }
4054514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> plainArray = CreateJSAPIPlainArray(thread);
4064514f5e3Sopenharmony_ci            JSHandle<EcmaString> inputEcmaStr = factory->NewFromStdString(inputStr);
4074514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
4084514f5e3Sopenharmony_ci            callInfo->SetFunction(JSTaggedValue::Undefined());
4094514f5e3Sopenharmony_ci            callInfo->SetThis(plainArray.GetTaggedValue());
4104514f5e3Sopenharmony_ci            callInfo->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum)));
4114514f5e3Sopenharmony_ci            callInfo->SetCallArg(1, inputEcmaStr.GetTaggedValue());
4124514f5e3Sopenharmony_ci            ContainersPlainArray::Add(callInfo);
4134514f5e3Sopenharmony_ci
4144514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *cfForToString = CreateEcmaRuntimeCallInfo(thread, 4); // 4 : means the argv length
4154514f5e3Sopenharmony_ci            cfForToString->SetFunction(JSTaggedValue::Undefined());
4164514f5e3Sopenharmony_ci            cfForToString->SetThis(plainArray.GetTaggedValue());
4174514f5e3Sopenharmony_ci            ContainersPlainArray::ToString(cfForToString); // expected to return string object
4184514f5e3Sopenharmony_ci        }
4194514f5e3Sopenharmony_ci        JSNApi::DestroyJSVM(vm);
4204514f5e3Sopenharmony_ci    }
4214514f5e3Sopenharmony_ci
4224514f5e3Sopenharmony_ci    void ContainersPlainArray_GetIndexOfKey_FuzzTest(const uint8_t* data, size_t size)
4234514f5e3Sopenharmony_ci    {
4244514f5e3Sopenharmony_ci        if (data == nullptr || size <= 0) {
4254514f5e3Sopenharmony_ci            std::cout << "illegal input!";
4264514f5e3Sopenharmony_ci            return;
4274514f5e3Sopenharmony_ci        }
4284514f5e3Sopenharmony_ci        RuntimeOption option;
4294514f5e3Sopenharmony_ci        option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
4304514f5e3Sopenharmony_ci        EcmaVM *vm = JSNApi::CreateJSVM(option);
4314514f5e3Sopenharmony_ci        {
4324514f5e3Sopenharmony_ci            JsiFastNativeScope scope(vm);
4334514f5e3Sopenharmony_ci            auto thread = vm->GetAssociatedJSThread();
4344514f5e3Sopenharmony_ci            auto factory = vm->GetFactory();
4354514f5e3Sopenharmony_ci
4364514f5e3Sopenharmony_ci            uint32_t inputNum = 0;
4374514f5e3Sopenharmony_ci            std::string inputStr(data, data + size);
4384514f5e3Sopenharmony_ci            const uint32_t MAXBYTELEN = 4;
4394514f5e3Sopenharmony_ci            if (size > MAXBYTELEN) {
4404514f5e3Sopenharmony_ci                size = MAXBYTELEN;
4414514f5e3Sopenharmony_ci            }
4424514f5e3Sopenharmony_ci            if (memcpy_s(&inputNum, MAXBYTELEN, data, size) != 0) {
4434514f5e3Sopenharmony_ci                std::cout << "memcpy_s failed!";
4444514f5e3Sopenharmony_ci                UNREACHABLE();
4454514f5e3Sopenharmony_ci            }
4464514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> plainArray = CreateJSAPIPlainArray(thread);
4474514f5e3Sopenharmony_ci            JSHandle<EcmaString> inputEcmaStr = factory->NewFromStdString(inputStr);
4484514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
4494514f5e3Sopenharmony_ci            callInfo->SetFunction(JSTaggedValue::Undefined());
4504514f5e3Sopenharmony_ci            callInfo->SetThis(plainArray.GetTaggedValue());
4514514f5e3Sopenharmony_ci            callInfo->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum)));
4524514f5e3Sopenharmony_ci            callInfo->SetCallArg(1, inputEcmaStr.GetTaggedValue());
4534514f5e3Sopenharmony_ci            ContainersPlainArray::Add(callInfo);
4544514f5e3Sopenharmony_ci
4554514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *cfForGetIndexOfKey =
4564514f5e3Sopenharmony_ci                CreateEcmaRuntimeCallInfo(thread, 6); // 6 : means the argv length
4574514f5e3Sopenharmony_ci            cfForGetIndexOfKey->SetFunction(JSTaggedValue::Undefined());
4584514f5e3Sopenharmony_ci            cfForGetIndexOfKey->SetThis(plainArray.GetTaggedValue());
4594514f5e3Sopenharmony_ci            cfForGetIndexOfKey->SetCallArg(0, inputEcmaStr.GetTaggedValue()); // value
4604514f5e3Sopenharmony_ci            ContainersPlainArray::GetIndexOfKey(cfForGetIndexOfKey); // expected to return the index of key
4614514f5e3Sopenharmony_ci        }
4624514f5e3Sopenharmony_ci        JSNApi::DestroyJSVM(vm);
4634514f5e3Sopenharmony_ci    }
4644514f5e3Sopenharmony_ci
4654514f5e3Sopenharmony_ci    void ContainersPlainArray_GetIndexOfValue_FuzzTest(const uint8_t* data, size_t size)
4664514f5e3Sopenharmony_ci    {
4674514f5e3Sopenharmony_ci        if (data == nullptr || size <= 0) {
4684514f5e3Sopenharmony_ci            std::cout << "illegal input!";
4694514f5e3Sopenharmony_ci            return;
4704514f5e3Sopenharmony_ci        }
4714514f5e3Sopenharmony_ci        RuntimeOption option;
4724514f5e3Sopenharmony_ci        option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
4734514f5e3Sopenharmony_ci        EcmaVM *vm = JSNApi::CreateJSVM(option);
4744514f5e3Sopenharmony_ci        {
4754514f5e3Sopenharmony_ci            JsiFastNativeScope scope(vm);
4764514f5e3Sopenharmony_ci            auto thread = vm->GetAssociatedJSThread();
4774514f5e3Sopenharmony_ci            auto factory = vm->GetFactory();
4784514f5e3Sopenharmony_ci
4794514f5e3Sopenharmony_ci            uint32_t inputNum = 0;
4804514f5e3Sopenharmony_ci            std::string inputStr(data, data + size);
4814514f5e3Sopenharmony_ci            const uint32_t MAXBYTELEN = 4;
4824514f5e3Sopenharmony_ci            if (size > MAXBYTELEN) {
4834514f5e3Sopenharmony_ci                size = MAXBYTELEN;
4844514f5e3Sopenharmony_ci            }
4854514f5e3Sopenharmony_ci            if (memcpy_s(&inputNum, MAXBYTELEN, data, size) != 0) {
4864514f5e3Sopenharmony_ci                std::cout << "memcpy_s failed!";
4874514f5e3Sopenharmony_ci                UNREACHABLE();
4884514f5e3Sopenharmony_ci            }
4894514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> plainArray = CreateJSAPIPlainArray(thread);
4904514f5e3Sopenharmony_ci            JSHandle<EcmaString> inputEcmaStr = factory->NewFromStdString(inputStr);
4914514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
4924514f5e3Sopenharmony_ci            callInfo->SetFunction(JSTaggedValue::Undefined());
4934514f5e3Sopenharmony_ci            callInfo->SetThis(plainArray.GetTaggedValue());
4944514f5e3Sopenharmony_ci            callInfo->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum)));
4954514f5e3Sopenharmony_ci            callInfo->SetCallArg(1, inputEcmaStr.GetTaggedValue());
4964514f5e3Sopenharmony_ci            ContainersPlainArray::Add(callInfo);
4974514f5e3Sopenharmony_ci
4984514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *cfForGetIndexOfValue =
4994514f5e3Sopenharmony_ci                CreateEcmaRuntimeCallInfo(thread, 6); // 6 : means the argv length
5004514f5e3Sopenharmony_ci            cfForGetIndexOfValue->SetFunction(JSTaggedValue::Undefined());
5014514f5e3Sopenharmony_ci            cfForGetIndexOfValue->SetThis(plainArray.GetTaggedValue());
5024514f5e3Sopenharmony_ci            cfForGetIndexOfValue->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum))); // key
5034514f5e3Sopenharmony_ci            ContainersPlainArray::GetIndexOfValue(cfForGetIndexOfValue); // expected to return the index of value
5044514f5e3Sopenharmony_ci        }
5054514f5e3Sopenharmony_ci        JSNApi::DestroyJSVM(vm);
5064514f5e3Sopenharmony_ci    }
5074514f5e3Sopenharmony_ci
5084514f5e3Sopenharmony_ci    void ContainersPlainArray_IsEmpty_FuzzTest(const uint8_t* data, size_t size)
5094514f5e3Sopenharmony_ci    {
5104514f5e3Sopenharmony_ci        if (data == nullptr || size <= 0) {
5114514f5e3Sopenharmony_ci            std::cout << "illegal input!";
5124514f5e3Sopenharmony_ci            return;
5134514f5e3Sopenharmony_ci        }
5144514f5e3Sopenharmony_ci        RuntimeOption option;
5154514f5e3Sopenharmony_ci        option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
5164514f5e3Sopenharmony_ci        EcmaVM *vm = JSNApi::CreateJSVM(option);
5174514f5e3Sopenharmony_ci        {
5184514f5e3Sopenharmony_ci            JsiFastNativeScope scope(vm);
5194514f5e3Sopenharmony_ci            auto thread = vm->GetAssociatedJSThread();
5204514f5e3Sopenharmony_ci            auto factory = vm->GetFactory();
5214514f5e3Sopenharmony_ci
5224514f5e3Sopenharmony_ci            uint32_t inputNum = 0;
5234514f5e3Sopenharmony_ci            std::string inputStr(data, data + size);
5244514f5e3Sopenharmony_ci            const uint32_t MAXBYTELEN = 4;
5254514f5e3Sopenharmony_ci            if (size > MAXBYTELEN) {
5264514f5e3Sopenharmony_ci                size = MAXBYTELEN;
5274514f5e3Sopenharmony_ci            }
5284514f5e3Sopenharmony_ci            if (memcpy_s(&inputNum, MAXBYTELEN, data, size) != 0) {
5294514f5e3Sopenharmony_ci                std::cout << "memcpy_s failed!";
5304514f5e3Sopenharmony_ci                UNREACHABLE();
5314514f5e3Sopenharmony_ci            }
5324514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> plainArray = CreateJSAPIPlainArray(thread);
5334514f5e3Sopenharmony_ci            JSHandle<EcmaString> inputEcmaStr = factory->NewFromStdString(inputStr);
5344514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
5354514f5e3Sopenharmony_ci            callInfo->SetFunction(JSTaggedValue::Undefined());
5364514f5e3Sopenharmony_ci            callInfo->SetThis(plainArray.GetTaggedValue());
5374514f5e3Sopenharmony_ci            callInfo->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum)));
5384514f5e3Sopenharmony_ci            callInfo->SetCallArg(1, inputEcmaStr.GetTaggedValue());
5394514f5e3Sopenharmony_ci            ContainersPlainArray::Add(callInfo);
5404514f5e3Sopenharmony_ci
5414514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *cfForIsEmpty = CreateEcmaRuntimeCallInfo(thread, 4); // 4 : means the argv length
5424514f5e3Sopenharmony_ci            cfForIsEmpty->SetFunction(JSTaggedValue::Undefined());
5434514f5e3Sopenharmony_ci            cfForIsEmpty->SetThis(plainArray.GetTaggedValue());
5444514f5e3Sopenharmony_ci            ContainersPlainArray::IsEmpty(cfForIsEmpty); // expected to return true or false
5454514f5e3Sopenharmony_ci        }
5464514f5e3Sopenharmony_ci        JSNApi::DestroyJSVM(vm);
5474514f5e3Sopenharmony_ci    }
5484514f5e3Sopenharmony_ci
5494514f5e3Sopenharmony_ci    void ContainersPlainArray_GetKeyAt_FuzzTest(const uint8_t* data, size_t size)
5504514f5e3Sopenharmony_ci    {
5514514f5e3Sopenharmony_ci        if (data == nullptr || size <= 0) {
5524514f5e3Sopenharmony_ci            std::cout << "illegal input!";
5534514f5e3Sopenharmony_ci            return;
5544514f5e3Sopenharmony_ci        }
5554514f5e3Sopenharmony_ci        RuntimeOption option;
5564514f5e3Sopenharmony_ci        option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
5574514f5e3Sopenharmony_ci        EcmaVM *vm = JSNApi::CreateJSVM(option);
5584514f5e3Sopenharmony_ci        {
5594514f5e3Sopenharmony_ci            JsiFastNativeScope scope(vm);
5604514f5e3Sopenharmony_ci            auto thread = vm->GetAssociatedJSThread();
5614514f5e3Sopenharmony_ci            auto factory = vm->GetFactory();
5624514f5e3Sopenharmony_ci
5634514f5e3Sopenharmony_ci            uint32_t inputNum = 0;
5644514f5e3Sopenharmony_ci            std::string inputStr(data, data + size);
5654514f5e3Sopenharmony_ci            const uint32_t MAXBYTELEN = 4;
5664514f5e3Sopenharmony_ci            if (size > MAXBYTELEN) {
5674514f5e3Sopenharmony_ci                size = MAXBYTELEN;
5684514f5e3Sopenharmony_ci            }
5694514f5e3Sopenharmony_ci            if (memcpy_s(&inputNum, MAXBYTELEN, data, size) != 0) {
5704514f5e3Sopenharmony_ci                std::cout << "memcpy_s failed!";
5714514f5e3Sopenharmony_ci                UNREACHABLE();
5724514f5e3Sopenharmony_ci            }
5734514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> plainArray = CreateJSAPIPlainArray(thread);
5744514f5e3Sopenharmony_ci            JSHandle<EcmaString> inputEcmaStr = factory->NewFromStdString(inputStr);
5754514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
5764514f5e3Sopenharmony_ci            callInfo->SetFunction(JSTaggedValue::Undefined());
5774514f5e3Sopenharmony_ci            callInfo->SetThis(plainArray.GetTaggedValue());
5784514f5e3Sopenharmony_ci            callInfo->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum)));
5794514f5e3Sopenharmony_ci            callInfo->SetCallArg(1, inputEcmaStr.GetTaggedValue());
5804514f5e3Sopenharmony_ci            ContainersPlainArray::Add(callInfo);
5814514f5e3Sopenharmony_ci
5824514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *cfForGetKeyAt = CreateEcmaRuntimeCallInfo(thread, 6); // 6 : means the argv length
5834514f5e3Sopenharmony_ci            cfForGetKeyAt->SetFunction(JSTaggedValue::Undefined());
5844514f5e3Sopenharmony_ci            cfForGetKeyAt->SetThis(plainArray.GetTaggedValue());
5854514f5e3Sopenharmony_ci            cfForGetKeyAt->SetCallArg(0, inputEcmaStr.GetTaggedValue()); // value
5864514f5e3Sopenharmony_ci            ContainersPlainArray::GetKeyAt(cfForGetKeyAt); // expected to return the key
5874514f5e3Sopenharmony_ci        }
5884514f5e3Sopenharmony_ci        JSNApi::DestroyJSVM(vm);
5894514f5e3Sopenharmony_ci    }
5904514f5e3Sopenharmony_ci
5914514f5e3Sopenharmony_ci    void ContainersPlainArray_Remove_FuzzTest(const uint8_t* data, size_t size)
5924514f5e3Sopenharmony_ci    {
5934514f5e3Sopenharmony_ci        if (data == nullptr || size <= 0) {
5944514f5e3Sopenharmony_ci            std::cout << "illegal input!";
5954514f5e3Sopenharmony_ci            return;
5964514f5e3Sopenharmony_ci        }
5974514f5e3Sopenharmony_ci        RuntimeOption option;
5984514f5e3Sopenharmony_ci        option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
5994514f5e3Sopenharmony_ci        EcmaVM *vm = JSNApi::CreateJSVM(option);
6004514f5e3Sopenharmony_ci        {
6014514f5e3Sopenharmony_ci            JsiFastNativeScope scope(vm);
6024514f5e3Sopenharmony_ci            auto thread = vm->GetAssociatedJSThread();
6034514f5e3Sopenharmony_ci            auto factory = vm->GetFactory();
6044514f5e3Sopenharmony_ci
6054514f5e3Sopenharmony_ci            uint32_t inputNum = 0;
6064514f5e3Sopenharmony_ci            std::string inputStr(data, data + size);
6074514f5e3Sopenharmony_ci            const uint32_t MAXBYTELEN = 4;
6084514f5e3Sopenharmony_ci            if (size > MAXBYTELEN) {
6094514f5e3Sopenharmony_ci                size = MAXBYTELEN;
6104514f5e3Sopenharmony_ci            }
6114514f5e3Sopenharmony_ci            if (memcpy_s(&inputNum, MAXBYTELEN, data, size) != 0) {
6124514f5e3Sopenharmony_ci                std::cout << "memcpy_s failed!";
6134514f5e3Sopenharmony_ci                UNREACHABLE();
6144514f5e3Sopenharmony_ci            }
6154514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> plainArray = CreateJSAPIPlainArray(thread);
6164514f5e3Sopenharmony_ci            JSHandle<EcmaString> inputEcmaStr = factory->NewFromStdString(inputStr);
6174514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
6184514f5e3Sopenharmony_ci            callInfo->SetFunction(JSTaggedValue::Undefined());
6194514f5e3Sopenharmony_ci            callInfo->SetThis(plainArray.GetTaggedValue());
6204514f5e3Sopenharmony_ci            callInfo->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum)));
6214514f5e3Sopenharmony_ci            callInfo->SetCallArg(1, inputEcmaStr.GetTaggedValue());
6224514f5e3Sopenharmony_ci            ContainersPlainArray::Add(callInfo);
6234514f5e3Sopenharmony_ci
6244514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *cfForRemove = CreateEcmaRuntimeCallInfo(thread, 6); // 6 : means the argv length
6254514f5e3Sopenharmony_ci            cfForRemove->SetFunction(JSTaggedValue::Undefined());
6264514f5e3Sopenharmony_ci            cfForRemove->SetThis(plainArray.GetTaggedValue());
6274514f5e3Sopenharmony_ci            cfForRemove->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum)));
6284514f5e3Sopenharmony_ci            ContainersPlainArray::Remove(cfForRemove); // expected to return the value
6294514f5e3Sopenharmony_ci        }
6304514f5e3Sopenharmony_ci        JSNApi::DestroyJSVM(vm);
6314514f5e3Sopenharmony_ci    }
6324514f5e3Sopenharmony_ci
6334514f5e3Sopenharmony_ci    void ContainersPlainArray_RemoveAt_FuzzTest(const uint8_t* data, size_t size)
6344514f5e3Sopenharmony_ci    {
6354514f5e3Sopenharmony_ci        if (data == nullptr || size <= 0) {
6364514f5e3Sopenharmony_ci            std::cout << "illegal input!";
6374514f5e3Sopenharmony_ci            return;
6384514f5e3Sopenharmony_ci        }
6394514f5e3Sopenharmony_ci        RuntimeOption option;
6404514f5e3Sopenharmony_ci        option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
6414514f5e3Sopenharmony_ci        EcmaVM *vm = JSNApi::CreateJSVM(option);
6424514f5e3Sopenharmony_ci        {
6434514f5e3Sopenharmony_ci            JsiFastNativeScope scope(vm);
6444514f5e3Sopenharmony_ci            auto thread = vm->GetAssociatedJSThread();
6454514f5e3Sopenharmony_ci            auto factory = vm->GetFactory();
6464514f5e3Sopenharmony_ci
6474514f5e3Sopenharmony_ci            uint32_t inputNum = 0;
6484514f5e3Sopenharmony_ci            std::string inputStr(data, data + size);
6494514f5e3Sopenharmony_ci            const uint32_t MAXBYTELEN = 4;
6504514f5e3Sopenharmony_ci            if (size > MAXBYTELEN) {
6514514f5e3Sopenharmony_ci                size = MAXBYTELEN;
6524514f5e3Sopenharmony_ci            }
6534514f5e3Sopenharmony_ci            if (memcpy_s(&inputNum, MAXBYTELEN, data, size) != 0) {
6544514f5e3Sopenharmony_ci                std::cout << "memcpy_s failed!";
6554514f5e3Sopenharmony_ci                UNREACHABLE();
6564514f5e3Sopenharmony_ci            }
6574514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> plainArray = CreateJSAPIPlainArray(thread);
6584514f5e3Sopenharmony_ci            JSHandle<EcmaString> inputEcmaStr = factory->NewFromStdString(inputStr);
6594514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
6604514f5e3Sopenharmony_ci            callInfo->SetFunction(JSTaggedValue::Undefined());
6614514f5e3Sopenharmony_ci            callInfo->SetThis(plainArray.GetTaggedValue());
6624514f5e3Sopenharmony_ci            callInfo->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum)));
6634514f5e3Sopenharmony_ci            callInfo->SetCallArg(1, inputEcmaStr.GetTaggedValue());
6644514f5e3Sopenharmony_ci            ContainersPlainArray::Add(callInfo);
6654514f5e3Sopenharmony_ci
6664514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *cfForRemoveAt = CreateEcmaRuntimeCallInfo(thread, 6); // 6 : means the argv length
6674514f5e3Sopenharmony_ci            cfForRemoveAt->SetFunction(JSTaggedValue::Undefined());
6684514f5e3Sopenharmony_ci            cfForRemoveAt->SetThis(plainArray.GetTaggedValue());
6694514f5e3Sopenharmony_ci            cfForRemoveAt->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum)));
6704514f5e3Sopenharmony_ci            ContainersPlainArray::RemoveAt(cfForRemoveAt); // expected to return the value
6714514f5e3Sopenharmony_ci        }
6724514f5e3Sopenharmony_ci        JSNApi::DestroyJSVM(vm);
6734514f5e3Sopenharmony_ci    }
6744514f5e3Sopenharmony_ci
6754514f5e3Sopenharmony_ci    void ContainersPlainArray_RemoveRangeFrom_FuzzTest(const uint8_t* data, size_t size)
6764514f5e3Sopenharmony_ci    {
6774514f5e3Sopenharmony_ci        if (data == nullptr || size <= 0) {
6784514f5e3Sopenharmony_ci            std::cout << "illegal input!";
6794514f5e3Sopenharmony_ci            return;
6804514f5e3Sopenharmony_ci        }
6814514f5e3Sopenharmony_ci        RuntimeOption option;
6824514f5e3Sopenharmony_ci        option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
6834514f5e3Sopenharmony_ci        EcmaVM *vm = JSNApi::CreateJSVM(option);
6844514f5e3Sopenharmony_ci        {
6854514f5e3Sopenharmony_ci            JsiFastNativeScope scope(vm);
6864514f5e3Sopenharmony_ci            auto thread = vm->GetAssociatedJSThread();
6874514f5e3Sopenharmony_ci            auto factory = vm->GetFactory();
6884514f5e3Sopenharmony_ci
6894514f5e3Sopenharmony_ci            uint32_t inputNum = 0;
6904514f5e3Sopenharmony_ci            std::string inputStr(data, data + size);
6914514f5e3Sopenharmony_ci            const uint32_t MAXBYTELEN = 4;
6924514f5e3Sopenharmony_ci            if (size > MAXBYTELEN) {
6934514f5e3Sopenharmony_ci                size = MAXBYTELEN;
6944514f5e3Sopenharmony_ci            }
6954514f5e3Sopenharmony_ci            if (memcpy_s(&inputNum, MAXBYTELEN, data, size) != 0) {
6964514f5e3Sopenharmony_ci                std::cout << "memcpy_s failed!";
6974514f5e3Sopenharmony_ci                UNREACHABLE();
6984514f5e3Sopenharmony_ci            }
6994514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> plainArray = CreateJSAPIPlainArray(thread);
7004514f5e3Sopenharmony_ci            JSHandle<EcmaString> inputEcmaStr = factory->NewFromStdString(inputStr);
7014514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
7024514f5e3Sopenharmony_ci            callInfo->SetFunction(JSTaggedValue::Undefined());
7034514f5e3Sopenharmony_ci            callInfo->SetThis(plainArray.GetTaggedValue());
7044514f5e3Sopenharmony_ci            callInfo->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum)));
7054514f5e3Sopenharmony_ci            callInfo->SetCallArg(1, inputEcmaStr.GetTaggedValue());
7064514f5e3Sopenharmony_ci            ContainersPlainArray::Add(callInfo);
7074514f5e3Sopenharmony_ci
7084514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *cfForRemoveRangeFrom =
7094514f5e3Sopenharmony_ci                CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
7104514f5e3Sopenharmony_ci            cfForRemoveRangeFrom->SetFunction(JSTaggedValue::Undefined());
7114514f5e3Sopenharmony_ci            cfForRemoveRangeFrom->SetThis(plainArray.GetTaggedValue());
7124514f5e3Sopenharmony_ci            cfForRemoveRangeFrom->SetCallArg(0, JSTaggedValue(0)); // set index as the head of array
7134514f5e3Sopenharmony_ci            cfForRemoveRangeFrom->SetCallArg(1, JSTaggedValue(static_cast<uint32_t>(inputNum))); // number to delete
7144514f5e3Sopenharmony_ci            ContainersPlainArray::RemoveRangeFrom(cfForRemoveRangeFrom); // expected to return the safe size
7154514f5e3Sopenharmony_ci        }
7164514f5e3Sopenharmony_ci        JSNApi::DestroyJSVM(vm);
7174514f5e3Sopenharmony_ci    }
7184514f5e3Sopenharmony_ci
7194514f5e3Sopenharmony_ci    void ContainersPlainArray_SetValueAt_FuzzTest(const uint8_t* data, size_t size)
7204514f5e3Sopenharmony_ci    {
7214514f5e3Sopenharmony_ci        if (data == nullptr || size <= 0) {
7224514f5e3Sopenharmony_ci            std::cout << "illegal input!";
7234514f5e3Sopenharmony_ci            return;
7244514f5e3Sopenharmony_ci        }
7254514f5e3Sopenharmony_ci        RuntimeOption option;
7264514f5e3Sopenharmony_ci        option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
7274514f5e3Sopenharmony_ci        EcmaVM *vm = JSNApi::CreateJSVM(option);
7284514f5e3Sopenharmony_ci        {
7294514f5e3Sopenharmony_ci            JsiFastNativeScope scope(vm);
7304514f5e3Sopenharmony_ci            auto thread = vm->GetAssociatedJSThread();
7314514f5e3Sopenharmony_ci            auto factory = vm->GetFactory();
7324514f5e3Sopenharmony_ci
7334514f5e3Sopenharmony_ci            uint32_t inputNum = 0;
7344514f5e3Sopenharmony_ci            std::string inputStr(data, data + size);
7354514f5e3Sopenharmony_ci            const uint32_t MAXBYTELEN = 4;
7364514f5e3Sopenharmony_ci            if (size > MAXBYTELEN) {
7374514f5e3Sopenharmony_ci                size = MAXBYTELEN;
7384514f5e3Sopenharmony_ci            }
7394514f5e3Sopenharmony_ci            if (memcpy_s(&inputNum, MAXBYTELEN, data, size) != 0) {
7404514f5e3Sopenharmony_ci                std::cout << "memcpy_s failed!";
7414514f5e3Sopenharmony_ci                UNREACHABLE();
7424514f5e3Sopenharmony_ci            }
7434514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> plainArray = CreateJSAPIPlainArray(thread);
7444514f5e3Sopenharmony_ci            JSHandle<EcmaString> inputEcmaStr = factory->NewFromStdString(inputStr);
7454514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
7464514f5e3Sopenharmony_ci            callInfo->SetFunction(JSTaggedValue::Undefined());
7474514f5e3Sopenharmony_ci            callInfo->SetThis(plainArray.GetTaggedValue());
7484514f5e3Sopenharmony_ci            callInfo->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum)));
7494514f5e3Sopenharmony_ci            callInfo->SetCallArg(1, inputEcmaStr.GetTaggedValue());
7504514f5e3Sopenharmony_ci            ContainersPlainArray::Add(callInfo);
7514514f5e3Sopenharmony_ci
7524514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *cfForSetValueAt = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
7534514f5e3Sopenharmony_ci            cfForSetValueAt->SetFunction(JSTaggedValue::Undefined());
7544514f5e3Sopenharmony_ci            cfForSetValueAt->SetThis(plainArray.GetTaggedValue());
7554514f5e3Sopenharmony_ci            cfForSetValueAt->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum))); // set index to set
7564514f5e3Sopenharmony_ci            cfForSetValueAt->SetCallArg(1, JSTaggedValue(static_cast<uint32_t>(inputNum))); // set new value
7574514f5e3Sopenharmony_ci            ContainersPlainArray::SetValueAt(cfForSetValueAt); // expected to return undefined
7584514f5e3Sopenharmony_ci        }
7594514f5e3Sopenharmony_ci        JSNApi::DestroyJSVM(vm);
7604514f5e3Sopenharmony_ci    }
7614514f5e3Sopenharmony_ci
7624514f5e3Sopenharmony_ci    void ContainersPlainArray_GetValueAt_FuzzTest(const uint8_t* data, size_t size)
7634514f5e3Sopenharmony_ci    {
7644514f5e3Sopenharmony_ci        if (data == nullptr || size <= 0) {
7654514f5e3Sopenharmony_ci            std::cout << "illegal input!";
7664514f5e3Sopenharmony_ci            return;
7674514f5e3Sopenharmony_ci        }
7684514f5e3Sopenharmony_ci        RuntimeOption option;
7694514f5e3Sopenharmony_ci        option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
7704514f5e3Sopenharmony_ci        EcmaVM *vm = JSNApi::CreateJSVM(option);
7714514f5e3Sopenharmony_ci        {
7724514f5e3Sopenharmony_ci            JsiFastNativeScope scope(vm);
7734514f5e3Sopenharmony_ci            auto thread = vm->GetAssociatedJSThread();
7744514f5e3Sopenharmony_ci            auto factory = vm->GetFactory();
7754514f5e3Sopenharmony_ci
7764514f5e3Sopenharmony_ci            uint32_t inputNum = 0;
7774514f5e3Sopenharmony_ci            std::string inputStr(data, data + size);
7784514f5e3Sopenharmony_ci            const uint32_t MAXBYTELEN = 4;
7794514f5e3Sopenharmony_ci            if (size > MAXBYTELEN) {
7804514f5e3Sopenharmony_ci                size = MAXBYTELEN;
7814514f5e3Sopenharmony_ci            }
7824514f5e3Sopenharmony_ci            if (memcpy_s(&inputNum, MAXBYTELEN, data, size) != 0) {
7834514f5e3Sopenharmony_ci                std::cout << "memcpy_s failed!";
7844514f5e3Sopenharmony_ci                UNREACHABLE();
7854514f5e3Sopenharmony_ci            }
7864514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> plainArray = CreateJSAPIPlainArray(thread);
7874514f5e3Sopenharmony_ci            JSHandle<EcmaString> inputEcmaStr = factory->NewFromStdString(inputStr);
7884514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
7894514f5e3Sopenharmony_ci            callInfo->SetFunction(JSTaggedValue::Undefined());
7904514f5e3Sopenharmony_ci            callInfo->SetThis(plainArray.GetTaggedValue());
7914514f5e3Sopenharmony_ci            callInfo->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum)));
7924514f5e3Sopenharmony_ci            callInfo->SetCallArg(1, inputEcmaStr.GetTaggedValue());
7934514f5e3Sopenharmony_ci            ContainersPlainArray::Add(callInfo);
7944514f5e3Sopenharmony_ci
7954514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *cfForGetValueAt = CreateEcmaRuntimeCallInfo(thread, 6); // 6 : means the argv length
7964514f5e3Sopenharmony_ci            cfForGetValueAt->SetFunction(JSTaggedValue::Undefined());
7974514f5e3Sopenharmony_ci            cfForGetValueAt->SetThis(plainArray.GetTaggedValue());
7984514f5e3Sopenharmony_ci            cfForGetValueAt->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum))); // set index to get
7994514f5e3Sopenharmony_ci            ContainersPlainArray::GetValueAt(cfForGetValueAt); // expected to return value
8004514f5e3Sopenharmony_ci        }
8014514f5e3Sopenharmony_ci        JSNApi::DestroyJSVM(vm);
8024514f5e3Sopenharmony_ci    }
8034514f5e3Sopenharmony_ci
8044514f5e3Sopenharmony_ci    void ContainersPlainArray_GetSize_FuzzTest(const uint8_t* data, size_t size)
8054514f5e3Sopenharmony_ci    {
8064514f5e3Sopenharmony_ci        if (data == nullptr || size <= 0) {
8074514f5e3Sopenharmony_ci            std::cout << "illegal input!";
8084514f5e3Sopenharmony_ci            return;
8094514f5e3Sopenharmony_ci        }
8104514f5e3Sopenharmony_ci        RuntimeOption option;
8114514f5e3Sopenharmony_ci        option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
8124514f5e3Sopenharmony_ci        EcmaVM *vm = JSNApi::CreateJSVM(option);
8134514f5e3Sopenharmony_ci        {
8144514f5e3Sopenharmony_ci            JsiFastNativeScope scope(vm);
8154514f5e3Sopenharmony_ci            auto thread = vm->GetAssociatedJSThread();
8164514f5e3Sopenharmony_ci            auto factory = vm->GetFactory();
8174514f5e3Sopenharmony_ci
8184514f5e3Sopenharmony_ci            uint32_t inputNum = 0;
8194514f5e3Sopenharmony_ci            std::string inputStr(data, data + size);
8204514f5e3Sopenharmony_ci            const uint32_t MAXBYTELEN = 4;
8214514f5e3Sopenharmony_ci            if (size > MAXBYTELEN) {
8224514f5e3Sopenharmony_ci                size = MAXBYTELEN;
8234514f5e3Sopenharmony_ci            }
8244514f5e3Sopenharmony_ci            if (memcpy_s(&inputNum, MAXBYTELEN, data, size) != 0) {
8254514f5e3Sopenharmony_ci                std::cout << "memcpy_s failed!";
8264514f5e3Sopenharmony_ci                UNREACHABLE();
8274514f5e3Sopenharmony_ci            }
8284514f5e3Sopenharmony_ci            JSHandle<JSAPIPlainArray> plainArray = CreateJSAPIPlainArray(thread);
8294514f5e3Sopenharmony_ci            JSHandle<EcmaString> inputEcmaStr = factory->NewFromStdString(inputStr);
8304514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *callInfo = CreateEcmaRuntimeCallInfo(thread, 8); // 8 : means the argv length
8314514f5e3Sopenharmony_ci            callInfo->SetFunction(JSTaggedValue::Undefined());
8324514f5e3Sopenharmony_ci            callInfo->SetThis(plainArray.GetTaggedValue());
8334514f5e3Sopenharmony_ci            callInfo->SetCallArg(0, JSTaggedValue(static_cast<uint32_t>(inputNum)));
8344514f5e3Sopenharmony_ci            callInfo->SetCallArg(1, inputEcmaStr.GetTaggedValue());
8354514f5e3Sopenharmony_ci            ContainersPlainArray::Add(callInfo);
8364514f5e3Sopenharmony_ci
8374514f5e3Sopenharmony_ci            EcmaRuntimeCallInfo *cfForGetSize = CreateEcmaRuntimeCallInfo(thread, 4); // 4 : means the argv length
8384514f5e3Sopenharmony_ci            cfForGetSize->SetFunction(JSTaggedValue::Undefined());
8394514f5e3Sopenharmony_ci            cfForGetSize->SetThis(plainArray.GetTaggedValue());
8404514f5e3Sopenharmony_ci            ContainersPlainArray::GetSize(cfForGetSize); // expected to return the size
8414514f5e3Sopenharmony_ci        }
8424514f5e3Sopenharmony_ci        JSNApi::DestroyJSVM(vm);
8434514f5e3Sopenharmony_ci    }
8444514f5e3Sopenharmony_ci}
8454514f5e3Sopenharmony_ci
8464514f5e3Sopenharmony_ci// Fuzzer entry point.
8474514f5e3Sopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
8484514f5e3Sopenharmony_ci{
8494514f5e3Sopenharmony_ci    // Run your code on data.
8504514f5e3Sopenharmony_ci    OHOS::ContainersPlainArray_Constructor_FuzzTest(data, size);
8514514f5e3Sopenharmony_ci    OHOS::ContainersPlainArray_Add_Has_FuzzTest(data, size);
8524514f5e3Sopenharmony_ci    OHOS::ContainersPlainArray_Clone_FuzzTest(data, size);
8534514f5e3Sopenharmony_ci    OHOS::ContainersPlainArray_Clear_FuzzTest(data, size);
8544514f5e3Sopenharmony_ci    OHOS::ContainersPlainArray_Get_FuzzTest(data, size);
8554514f5e3Sopenharmony_ci    OHOS::ContainersPlainArray_GetIteratorObj_FuzzTest(data, size);
8564514f5e3Sopenharmony_ci    OHOS::ContainersPlainArray_ForEach_FuzzTest(data, size);
8574514f5e3Sopenharmony_ci    OHOS::ContainersPlainArray_ToString_FuzzTest(data, size);
8584514f5e3Sopenharmony_ci    OHOS::ContainersPlainArray_GetIndexOfKey_FuzzTest(data, size);
8594514f5e3Sopenharmony_ci    OHOS::ContainersPlainArray_GetIndexOfValue_FuzzTest(data, size);
8604514f5e3Sopenharmony_ci    OHOS::ContainersPlainArray_IsEmpty_FuzzTest(data, size);
8614514f5e3Sopenharmony_ci    OHOS::ContainersPlainArray_GetKeyAt_FuzzTest(data, size);
8624514f5e3Sopenharmony_ci    OHOS::ContainersPlainArray_Remove_FuzzTest(data, size);
8634514f5e3Sopenharmony_ci    OHOS::ContainersPlainArray_RemoveAt_FuzzTest(data, size);
8644514f5e3Sopenharmony_ci    OHOS::ContainersPlainArray_RemoveRangeFrom_FuzzTest(data, size);
8654514f5e3Sopenharmony_ci    OHOS::ContainersPlainArray_SetValueAt_FuzzTest(data, size);
8664514f5e3Sopenharmony_ci    OHOS::ContainersPlainArray_GetValueAt_FuzzTest(data, size);
8674514f5e3Sopenharmony_ci    OHOS::ContainersPlainArray_GetSize_FuzzTest(data, size);
8684514f5e3Sopenharmony_ci    return 0;
8694514f5e3Sopenharmony_ci}