diff --git a/BUILD.gn b/BUILD.gn index 13fd728264075d5181ec4a16ee334af773782972..a5409fe9a21d1388ae4cb74dc9457838ade91200 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -604,8 +604,7 @@ source_set("libark_jsruntime_set") { } deps = [ - "$ark_root/libpandabase:libarkbase", - "$ark_root/libpandafile:libarkfile", + "$ark_root/libpandafile:libarkfile_static", sdk_libc_secshared_dep, ] @@ -643,8 +642,7 @@ source_set("libark_js_intl_set") { ] deps = [ - "$ark_root/libpandabase:libarkbase", - "$ark_root/libpandafile:libarkfile", + "$ark_root/libpandafile:libarkfile_static", "$third_party_gn_path/icu/icu4c:shared_icui18n", "$third_party_gn_path/icu/icu4c:shared_icuuc", sdk_libc_secshared_dep, @@ -658,8 +656,7 @@ source_set("libark_jsruntime_test_set") { sources += ecma_debugger_source deps = [ - "$ark_root/libpandabase:libarkbase", - "$ark_root/libpandafile:libarkfile", + "$ark_root/libpandafile:libarkfile_static", "$third_party_gn_path/icu/icu4c:shared_icui18n", "$third_party_gn_path/icu/icu4c:shared_icuuc", sdk_libc_secshared_dep, diff --git a/ecmascript/base/tests/BUILD.gn b/ecmascript/base/tests/BUILD.gn index ea808d308e3e74191c96185bdb683e4a0b586ead..257821c933641fe0a07b53188a44e36ac98d3446 100644 --- a/ecmascript/base/tests/BUILD.gn +++ b/ecmascript/base/tests/BUILD.gn @@ -34,7 +34,6 @@ host_unittest_action("BaseTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime_test", sdk_libc_secshared_dep, ] diff --git a/ecmascript/builtins/tests/BUILD.gn b/ecmascript/builtins/tests/BUILD.gn index 1a59b4067bd52035cbb32cebce193f21cdf785b6..cb3e6e5bcf06ecb75aef9b9826e60d1517d0f82a 100755 --- a/ecmascript/builtins/tests/BUILD.gn +++ b/ecmascript/builtins/tests/BUILD.gn @@ -34,7 +34,6 @@ host_unittest_action("BuiltinsInternational_001_Test") { ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime_test", sdk_libc_secshared_dep, ] @@ -59,7 +58,6 @@ host_unittest_action("BuiltinsInternational_002_Test") { ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime_test", sdk_libc_secshared_dep, ] @@ -103,7 +101,6 @@ host_unittest_action("BuiltinsNaturalTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime_test", sdk_libc_secshared_dep, ] diff --git a/ecmascript/compiler/BUILD.gn b/ecmascript/compiler/BUILD.gn index 513d943ac244b40ee11a7c9ebab53df428d1fb0b..228b2f7ef31b67ccf58d9dc86f84603ccfb04af9 100644 --- a/ecmascript/compiler/BUILD.gn +++ b/ecmascript/compiler/BUILD.gn @@ -150,10 +150,7 @@ source_set("libark_jsoptimizer_set") { "LLVMBitWriter", ] - deps = [ - "$ark_root/libpandabase:libarkbase", - "$ark_root/libpandafile:libarkfile", - ] + deps = [ "$ark_root/libpandafile:libarkfile_static" ] if (compile_llvm_online) { deps += [ ":build_llvm_libs" ] @@ -173,7 +170,6 @@ source_set("ark_stub_compiler_set") { deps = [ ":libark_jsoptimizer_set", ":libark_mock_stub_set", - "$ark_root/libpandabase:libarkbase", "$js_root:libark_js_intl_set", "$js_root:libark_jsruntime_set", ] @@ -194,7 +190,6 @@ source_set("ark_aot_compiler_set") { ] deps = [ - "$ark_root/libpandabase:libarkbase", "$js_root:libark_jsruntime", "$js_root/ecmascript/compiler:libark_jsoptimizer", ] diff --git a/ecmascript/compiler/tests/BUILD.gn b/ecmascript/compiler/tests/BUILD.gn index a20fac893d55b3b7bb786dc5148a56d268871570..ea7c6beec9204cc102f41ab7d5b5fd0ec070d383 100644 --- a/ecmascript/compiler/tests/BUILD.gn +++ b/ecmascript/compiler/tests/BUILD.gn @@ -112,7 +112,6 @@ host_unittest_action("StubTest") { ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime/ecmascript/compiler:libark_jsoptimizer_test", sdk_libc_secshared_dep, ] @@ -200,7 +199,6 @@ host_unittest_action("AssemblerTest") { ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime/ecmascript/compiler:libark_jsoptimizer_test", sdk_libc_secshared_dep, ] @@ -286,7 +284,6 @@ host_unittest_action("CircuitOptimizerTest") { ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime/ecmascript/compiler:libark_jsoptimizer_test", sdk_libc_secshared_dep, ] diff --git a/ecmascript/containers/tests/BUILD.gn b/ecmascript/containers/tests/BUILD.gn index 2a7e5ca0ee136a0ab5e4805b26e4a5c3959e6aec..e3611e489d704faba9b450f372da62dd73623ed8 100644 --- a/ecmascript/containers/tests/BUILD.gn +++ b/ecmascript/containers/tests/BUILD.gn @@ -39,7 +39,6 @@ host_unittest_action("ContainersTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime_test", sdk_libc_secshared_dep, ] diff --git a/ecmascript/dfx/hprof/tests/BUILD.gn b/ecmascript/dfx/hprof/tests/BUILD.gn index 31295c4e35dba952e532d2dc9f3147ef5f0378b6..e0121a3af247a73ba2c41b502b004fc9fa4debc0 100644 --- a/ecmascript/dfx/hprof/tests/BUILD.gn +++ b/ecmascript/dfx/hprof/tests/BUILD.gn @@ -28,7 +28,6 @@ host_unittest_action("HeapTrackerTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime_test", sdk_libc_secshared_dep, ] @@ -45,7 +44,6 @@ host_unittest_action("HprofTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime_test", sdk_libc_secshared_dep, ] diff --git a/ecmascript/ic/tests/BUILD.gn b/ecmascript/ic/tests/BUILD.gn index f2a1fce9de8316d2f8ea8834dbf6ee8e80482131..59a66f03db5e9a4fb7ecfaab6b054f0a60b0a148 100644 --- a/ecmascript/ic/tests/BUILD.gn +++ b/ecmascript/ic/tests/BUILD.gn @@ -36,7 +36,6 @@ host_unittest_action("ICTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime_test", sdk_libc_secshared_dep, ] diff --git a/ecmascript/jobs/tests/BUILD.gn b/ecmascript/jobs/tests/BUILD.gn index dd81ac4f3cb706f57a94717d5ce578a9d25ac91f..1c02eae8b69b2c205938c00d96f8e1bf52563318 100644 --- a/ecmascript/jobs/tests/BUILD.gn +++ b/ecmascript/jobs/tests/BUILD.gn @@ -29,7 +29,6 @@ host_unittest_action("JobTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime_test", sdk_libc_secshared_dep, ] diff --git a/ecmascript/js_vm/BUILD.gn b/ecmascript/js_vm/BUILD.gn index 8ef8b3f0fe24ef24d75dfd55b506cd471fbbf430..e238ef9b0bd569e48e16e9ed1d593f3ce7ad949c 100644 --- a/ecmascript/js_vm/BUILD.gn +++ b/ecmascript/js_vm/BUILD.gn @@ -27,10 +27,7 @@ source_set("ark_js_vm_set") { "$js_root:ark_jsruntime_public_config", ] - deps = [ - "$ark_root/libpandabase:libarkbase", - "$js_root:libark_jsruntime", - ] + deps = [ "$js_root:libark_jsruntime" ] } ohos_executable("ark_js_vm") { diff --git a/ecmascript/napi/jsnapi.cpp b/ecmascript/napi/jsnapi.cpp index 3846abbe06826efe23d6f98ce8003d51f698225e..3f421edbbc59ccd55b7c45e3ac84f4e44b52f2b4 100644 --- a/ecmascript/napi/jsnapi.cpp +++ b/ecmascript/napi/jsnapi.cpp @@ -595,6 +595,9 @@ EscapeLocalScope::EscapeLocalScope(const EcmaVM *vm) : LocalScope(vm, JSTaggedVa Local NumberRef::New(const EcmaVM *vm, double input) { JSThread *thread = vm->GetJSThread(); + if (std::isnan(input)) { + input = ecmascript::base::NAN_VALUE; + } JSHandle number(thread, JSTaggedValue(input)); return JSNApiHelper::ToLocal(number); } diff --git a/ecmascript/napi/test/BUILD.gn b/ecmascript/napi/test/BUILD.gn index 8fe188385b3f45a6f77c92559b1c9b7af9650559..03c74bfbe22c79f5dfe10e7dd2c02f7bae66d2a4 100644 --- a/ecmascript/napi/test/BUILD.gn +++ b/ecmascript/napi/test/BUILD.gn @@ -28,7 +28,6 @@ host_unittest_action("JsnapiTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime_test", sdk_libc_secshared_dep, ] diff --git a/ecmascript/regexp/tests/BUILD.gn b/ecmascript/regexp/tests/BUILD.gn index ac0845050e45943452e8d77003d400c05581200a..90b0aaa02efce18b1cd3d3ba6713401056adc5a7 100644 --- a/ecmascript/regexp/tests/BUILD.gn +++ b/ecmascript/regexp/tests/BUILD.gn @@ -29,7 +29,6 @@ host_unittest_action("RegexpTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime_test", sdk_libc_secshared_dep, ] diff --git a/ecmascript/snapshot/tests/BUILD.gn b/ecmascript/snapshot/tests/BUILD.gn index 0e71ef560ce7872be030af12f0b37832517f71ab..5978e728d3f8495643862051a41175c77b3effcb 100644 --- a/ecmascript/snapshot/tests/BUILD.gn +++ b/ecmascript/snapshot/tests/BUILD.gn @@ -28,7 +28,6 @@ host_unittest_action("SnapshotTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime_test", sdk_libc_secshared_dep, ] diff --git a/ecmascript/tests/BUILD.gn b/ecmascript/tests/BUILD.gn index 7124ddd2be8e449f65b0c0037dca15f2f87d85bb..a3633c00a899e91c103901c7ac69ea40f61cd132 100644 --- a/ecmascript/tests/BUILD.gn +++ b/ecmascript/tests/BUILD.gn @@ -67,7 +67,6 @@ host_unittest_action("EcmaVm_001_Test") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime_test", sdk_libc_secshared_dep, ] @@ -135,7 +134,6 @@ host_unittest_action("EcmaVm_002_Test") { ] deps = [ - "$ark_root/libpandabase:libarkbase", "$third_party_gn_path/icu/icu4c:shared_icui18n", "$third_party_gn_path/icu/icu4c:shared_icuuc", "//arkcompiler/ets_runtime:libark_jsruntime_test", diff --git a/ecmascript/tooling/BUILD.gn b/ecmascript/tooling/BUILD.gn index e018b02bc0e01b948b3a436864ba2121f7b3a2bc..4eba3d043eaedd3431be76291e91216b2a89c56b 100644 --- a/ecmascript/tooling/BUILD.gn +++ b/ecmascript/tooling/BUILD.gn @@ -53,11 +53,7 @@ source_set("libark_ecma_debugger_set") { public_configs = [ ":ark_ecma_debugger_config" ] - deps = [ - "$ark_root/libpandabase:libarkbase", - "$ark_root/libpandafile:libarkfile", - "//third_party/cJSON:cjson_static", - ] + deps = [ "//third_party/cJSON:cjson_static" ] if (is_ohos && is_standard_system) { if (enable_hilog) { @@ -107,11 +103,7 @@ source_set("libark_ecma_debugger_test_set") { } } - deps = [ - "$ark_root/libpandabase:libarkbase", - "$ark_root/libpandafile:libarkfile", - "//third_party/cJSON:cjson_static", - ] + deps = [ "//third_party/cJSON:cjson_static" ] } ohos_shared_library("libark_ecma_debugger_test") { diff --git a/ecmascript/tooling/test/BUILD.gn b/ecmascript/tooling/test/BUILD.gn index 854595f7634e003fe29913af25ca85946d8c67eb..155654361cab56b05598ca204f228e64afc760cd 100644 --- a/ecmascript/tooling/test/BUILD.gn +++ b/ecmascript/tooling/test/BUILD.gn @@ -151,8 +151,6 @@ source_set("debugger_entry_set") { ":ark_syntaxException_abc", ":ark_throwException_abc", ":jsdebugtest", - "$ark_root/libpandabase:libarkbase", - "$ark_root/libpandafile:libarkfile", ] } @@ -196,8 +194,6 @@ source_set("jsdebugtest_set") { } deps = [ - "$ark_root/libpandabase:libarkbase", - "$ark_root/libpandafile:libarkfile", "//arkcompiler/ets_runtime:libark_jsruntime_test", "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_test", ] @@ -235,8 +231,6 @@ host_unittest_action("DebuggerEntryTest") { deps = [ ":debugger_entry_resource", ":jsdebugtest", - "$ark_root/libpandabase:libarkbase", - "$ark_root/libpandafile:libarkfile", "//arkcompiler/ets_runtime:libark_jsruntime_test", "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_test", ] @@ -261,7 +255,6 @@ host_unittest_action("DebuggerTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime_test", "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_test", sdk_libc_secshared_dep, diff --git a/ecmascript/ts_types/tests/BUILD.gn b/ecmascript/ts_types/tests/BUILD.gn index 896c520799b5836d7e76380ef0f6241810f8f622..74b5463d2ddb43d683635eeb0b065c96dfe2d29d 100644 --- a/ecmascript/ts_types/tests/BUILD.gn +++ b/ecmascript/ts_types/tests/BUILD.gn @@ -28,7 +28,6 @@ host_unittest_action("TSTypeTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime_test", sdk_libc_secshared_dep, ] diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index e2ebb29e5df007f1f01cb01ed9de24ba0108240d..d8a30df5157cd80a9cdb859071a3f80e711aa247 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -16,18 +16,33 @@ group("fuzztest") { deps = [] deps += [ + "arraybufferrefnew_fuzzer:fuzztest", + "arraybufferrefnewwithtwoparameters_fuzzer:fuzztest", + "bigint64arrayrefnew_fuzzer:fuzztest", "biginttoint64_fuzzer:fuzztest", "biginttouint64_fuzzer:fuzztest", + "biguint64arrayrefnew_fuzzer:fuzztest", "booleanrefnewbool_fuzzer:fuzztest", "createbigwords_fuzzer:fuzztest", + "dataviewrefnew_fuzzer:fuzztest", "dispatchprotocolmessage_fuzzer:fuzztest", "execute_fuzzer:fuzztest", + "float32arrayrefnew_fuzzer:fuzztest", + "float64arrayrefnew_fuzzer:fuzztest", "getwordsarray_fuzzer:fuzztest", "initializedebugger_fuzzer:fuzztest", + "int16arrayrefnew_fuzzer:fuzztest", + "int32arrayrefnew_fuzzer:fuzztest", + "int8arrayrefnew_fuzzer:fuzztest", "newbigintbyint64_fuzzer:fuzztest", "newbigintbyuint64_fuzzer:fuzztest", + "numberrefnewdouble_fuzzer:fuzztest", "numberrefnewint32_fuzzer:fuzztest", "numberrefnewint64_fuzzer:fuzztest", "numberrefnewuint32_fuzzer:fuzztest", + "uint16arrayrefnew_fuzzer:fuzztest", + "uint32arrayrefnew_fuzzer:fuzztest", + "uint8arrayrefnew_fuzzer:fuzztest", + "uint8clampedarrayrefnew_fuzzer:fuzztest", ] } diff --git a/test/fuzztest/arraybufferrefnew_fuzzer/BUILD.gn b/test/fuzztest/arraybufferrefnew_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e382ca778dda546165a81aa63257575ff50d8366 --- /dev/null +++ b/test/fuzztest/arraybufferrefnew_fuzzer/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +##################################hydra-fuzz################################### +import("//arkcompiler/ets_runtime/js_runtime_config.gni") +import("//arkcompiler/ets_runtime/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("ArrayBufferRefNewFuzzTest") { + module_out_path = "arkcompiler/ets_runtime" + + fuzz_config_file = + "//arkcompiler/ets_runtime/test/fuzztest/arraybufferrefnew_fuzzer" + + sources = [ "arraybufferrefnew_fuzzer.cpp" ] + + configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":ArrayBufferRefNewFuzzTest" ] +} diff --git a/test/fuzztest/arraybufferrefnew_fuzzer/arraybufferrefnew_fuzzer.cpp b/test/fuzztest/arraybufferrefnew_fuzzer/arraybufferrefnew_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e7fecd7e7f8e78967484afcc683e2addbb394e28 --- /dev/null +++ b/test/fuzztest/arraybufferrefnew_fuzzer/arraybufferrefnew_fuzzer.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "arraybufferrefnew_fuzzer.h" + +#include "ecmascript/ecma_string-inl.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "ecmascript/tooling/debugger_service.h" + +using namespace panda; +using namespace panda::ecmascript; + +namespace OHOS { + void ArrayBufferRefNewFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + EcmaVM *vm = JSNApi::CreateJSVM(option); + [[maybe_unused]] LocalScope scope(vm); + Deleter deleter = nullptr; + ArrayBufferRef::New(vm, (void*)data, (int32_t)size, deleter, (void*)data); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::ArrayBufferRefNewFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/arraybufferrefnew_fuzzer/arraybufferrefnew_fuzzer.h b/test/fuzztest/arraybufferrefnew_fuzzer/arraybufferrefnew_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..5618e6d8b0b3d5327e24a762f990145b94875bf0 --- /dev/null +++ b/test/fuzztest/arraybufferrefnew_fuzzer/arraybufferrefnew_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARRAYBUFFERREFNEW_FUZZER_H +#define ARRAYBUFFERREFNEW_FUZZER_H + +#define FUZZ_PROJECT_NAME "arraybufferrefnew_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/arraybufferrefnew_fuzzer/corpus/init b/test/fuzztest/arraybufferrefnew_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d175fac243eb62fa23e3e87a601b71218bb32507 --- /dev/null +++ b/test/fuzztest/arraybufferrefnew_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/arraybufferrefnew_fuzzer/project.xml b/test/fuzztest/arraybufferrefnew_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/arraybufferrefnew_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/arraybufferrefnewwithtwoparameters_fuzzer/BUILD.gn b/test/fuzztest/arraybufferrefnewwithtwoparameters_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c3d86052a5fdec248ee44cdf7f27cb82326f2afd --- /dev/null +++ b/test/fuzztest/arraybufferrefnewwithtwoparameters_fuzzer/BUILD.gn @@ -0,0 +1,43 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +##################################hydra-fuzz################################### +import("//arkcompiler/ets_runtime/js_runtime_config.gni") +import("//arkcompiler/ets_runtime/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("ArrayBufferRefNewWithTwoParametersFuzzTest") { + module_out_path = "arkcompiler/ets_runtime" + + fuzz_config_file = "//arkcompiler/ets_runtime/test/fuzztest/arraybufferrefnewwithtwoparameters_fuzzer" + + sources = [ "arraybufferrefnewwithtwoparameters_fuzzer.cpp" ] + + configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":ArrayBufferRefNewWithTwoParametersFuzzTest" ] +} diff --git a/test/fuzztest/arraybufferrefnewwithtwoparameters_fuzzer/arraybufferrefnewwithtwoparameters_fuzzer.cpp b/test/fuzztest/arraybufferrefnewwithtwoparameters_fuzzer/arraybufferrefnewwithtwoparameters_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f79bef754696565e8f2cf853fcb7e36ea6ba9055 --- /dev/null +++ b/test/fuzztest/arraybufferrefnewwithtwoparameters_fuzzer/arraybufferrefnewwithtwoparameters_fuzzer.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "arraybufferrefnewwithtwoparameters_fuzzer.h" + +#include "ecmascript/ecma_string-inl.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "ecmascript/tooling/debugger_service.h" + +using namespace panda; +using namespace panda::ecmascript; + +#define MAXBYTELEN sizeof(int32_t) + +namespace OHOS { + void ArrayBufferRefNewWithTwoParametersFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + EcmaVM *vm = JSNApi::CreateJSVM(option); + [[maybe_unused]] LocalScope scope(vm); + int32_t input; + + if (size > MAXBYTELEN) { + size = MAXBYTELEN; + } + if (memcpy_s(&input, MAXBYTELEN, data, size) != 0) { + std::cout << "memcpy_s failed!"; + UNREACHABLE(); + } + ArrayBufferRef::New(vm, input); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::ArrayBufferRefNewWithTwoParametersFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/arraybufferrefnewwithtwoparameters_fuzzer/arraybufferrefnewwithtwoparameters_fuzzer.h b/test/fuzztest/arraybufferrefnewwithtwoparameters_fuzzer/arraybufferrefnewwithtwoparameters_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..023d51bc15d95a4783bd0b4034f47ca9bf3a46e6 --- /dev/null +++ b/test/fuzztest/arraybufferrefnewwithtwoparameters_fuzzer/arraybufferrefnewwithtwoparameters_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ARRAYBUFFERREFNEWWITHTWOPARAMETERS_FUZZER_H +#define ARRAYBUFFERREFNEWWITHTWOPARAMETERS_FUZZER_H + +#define FUZZ_PROJECT_NAME "arraybufferrefnewwithtwoparameters_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/arraybufferrefnewwithtwoparameters_fuzzer/corpus/init b/test/fuzztest/arraybufferrefnewwithtwoparameters_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d175fac243eb62fa23e3e87a601b71218bb32507 --- /dev/null +++ b/test/fuzztest/arraybufferrefnewwithtwoparameters_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/arraybufferrefnewwithtwoparameters_fuzzer/project.xml b/test/fuzztest/arraybufferrefnewwithtwoparameters_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/arraybufferrefnewwithtwoparameters_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/bigint64arrayrefnew_fuzzer/BUILD.gn b/test/fuzztest/bigint64arrayrefnew_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..983bb656cc63343721df4e79d1d3626498c56c19 --- /dev/null +++ b/test/fuzztest/bigint64arrayrefnew_fuzzer/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +##################################hydra-fuzz################################### +import("//arkcompiler/ets_runtime/js_runtime_config.gni") +import("//arkcompiler/ets_runtime/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("BigInt64ArrayRefNewFuzzTest") { + module_out_path = "arkcompiler/ets_runtime" + + fuzz_config_file = + "//arkcompiler/ets_runtime/test/fuzztest/bigint64arrayrefnew_fuzzer" + + sources = [ "bigint64arrayrefnew_fuzzer.cpp" ] + + configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":BigInt64ArrayRefNewFuzzTest" ] +} diff --git a/test/fuzztest/bigint64arrayrefnew_fuzzer/bigint64arrayrefnew_fuzzer.cpp b/test/fuzztest/bigint64arrayrefnew_fuzzer/bigint64arrayrefnew_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..28e0bd0ab18b0ae1f75cf9445b322db046e228ce --- /dev/null +++ b/test/fuzztest/bigint64arrayrefnew_fuzzer/bigint64arrayrefnew_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "bigint64arrayrefnew_fuzzer.h" + +#include "ecmascript/ecma_string-inl.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "ecmascript/tooling/debugger_service.h" + +using namespace panda; +using namespace panda::ecmascript; + +#define MAXBYTELEN sizeof(int32_t) + +namespace OHOS { + void BigInt64ArrayRefNewFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + EcmaVM *vm = JSNApi::CreateJSVM(option); + [[maybe_unused]] LocalScope scope(vm); + int32_t input; + + if (size > MAXBYTELEN) { + size = MAXBYTELEN; + } + if (memcpy_s(&input, MAXBYTELEN, data, size) != 0) { + std::cout << "memcpy_s failed!"; + UNREACHABLE(); + } + Local ref = ArrayBufferRef::New(vm, input); + BigInt64ArrayRef::New(vm, ref, (int32_t)size, (int32_t)size); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::BigInt64ArrayRefNewFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/bigint64arrayrefnew_fuzzer/bigint64arrayrefnew_fuzzer.h b/test/fuzztest/bigint64arrayrefnew_fuzzer/bigint64arrayrefnew_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..bddb5d115387f90584fcba54bfd3b8e4745a5456 --- /dev/null +++ b/test/fuzztest/bigint64arrayrefnew_fuzzer/bigint64arrayrefnew_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BIGINT64ARRAYREFNEW_FUZZER_H +#define BIGINT64ARRAYREFNEW_FUZZER_H + +#define FUZZ_PROJECT_NAME "bigint64arrayrefnew_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/bigint64arrayrefnew_fuzzer/corpus/init b/test/fuzztest/bigint64arrayrefnew_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d175fac243eb62fa23e3e87a601b71218bb32507 --- /dev/null +++ b/test/fuzztest/bigint64arrayrefnew_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/bigint64arrayrefnew_fuzzer/project.xml b/test/fuzztest/bigint64arrayrefnew_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/bigint64arrayrefnew_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/biginttoint64_fuzzer/BUILD.gn b/test/fuzztest/biginttoint64_fuzzer/BUILD.gn index d0ef87315b7a9cd4734ee55f8f9946deb041a2fe..0c710805bba6cd6df9ae68fb7619503f99e1508f 100644 --- a/test/fuzztest/biginttoint64_fuzzer/BUILD.gn +++ b/test/fuzztest/biginttoint64_fuzzer/BUILD.gn @@ -30,7 +30,6 @@ ohos_fuzztest("BigIntToInt64FuzzTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime", sdk_libc_secshared_dep, ] diff --git a/test/fuzztest/biginttouint64_fuzzer/BUILD.gn b/test/fuzztest/biginttouint64_fuzzer/BUILD.gn index 805311e8f26142e4bdb95d20bdcef8c1d357a917..8d6a3d0008f67761692aee5a2a84b366a17662b2 100644 --- a/test/fuzztest/biginttouint64_fuzzer/BUILD.gn +++ b/test/fuzztest/biginttouint64_fuzzer/BUILD.gn @@ -30,7 +30,6 @@ ohos_fuzztest("BigIntToUint64FuzzTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime", sdk_libc_secshared_dep, ] diff --git a/test/fuzztest/biguint64arrayrefnew_fuzzer/BUILD.gn b/test/fuzztest/biguint64arrayrefnew_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..7e6fe722c19518a15d52bd927c62323348b0a389 --- /dev/null +++ b/test/fuzztest/biguint64arrayrefnew_fuzzer/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +##################################hydra-fuzz################################### +import("//arkcompiler/ets_runtime/js_runtime_config.gni") +import("//arkcompiler/ets_runtime/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("BigUint64ArrayRefNewFuzzTest") { + module_out_path = "arkcompiler/ets_runtime" + + fuzz_config_file = + "//arkcompiler/ets_runtime/test/fuzztest/biguint64arrayrefnew_fuzzer" + + sources = [ "biguint64arrayrefnew_fuzzer.cpp" ] + + configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":BigUint64ArrayRefNewFuzzTest" ] +} diff --git a/test/fuzztest/biguint64arrayrefnew_fuzzer/biguint64arrayrefnew_fuzzer.cpp b/test/fuzztest/biguint64arrayrefnew_fuzzer/biguint64arrayrefnew_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a8ae03d38254e8d2876f8332963aa2b70202d804 --- /dev/null +++ b/test/fuzztest/biguint64arrayrefnew_fuzzer/biguint64arrayrefnew_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "biguint64arrayrefnew_fuzzer.h" + +#include "ecmascript/ecma_string-inl.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "ecmascript/tooling/debugger_service.h" + +using namespace panda; +using namespace panda::ecmascript; + +#define MAXBYTELEN sizeof(int32_t) + +namespace OHOS { + void BigUint64ArrayRefNewFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + EcmaVM *vm = JSNApi::CreateJSVM(option); + [[maybe_unused]] LocalScope scope(vm); + int32_t input; + + if (size > MAXBYTELEN) { + size = MAXBYTELEN; + } + if (memcpy_s(&input, MAXBYTELEN, data, size) != 0) { + std::cout << "memcpy_s failed!"; + UNREACHABLE(); + } + Local ref = ArrayBufferRef::New(vm, input); + BigUint64ArrayRef::New(vm, ref, (int32_t)size, (int32_t)size); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::BigUint64ArrayRefNewFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/biguint64arrayrefnew_fuzzer/biguint64arrayrefnew_fuzzer.h b/test/fuzztest/biguint64arrayrefnew_fuzzer/biguint64arrayrefnew_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..f0cce485f2eb601e2ee3e827d29d46b87e955aa4 --- /dev/null +++ b/test/fuzztest/biguint64arrayrefnew_fuzzer/biguint64arrayrefnew_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BIGUINT64ARRAYREFNEW_FUZZER_H +#define BIGUINT64ARRAYREFNEW_FUZZER_H + +#define FUZZ_PROJECT_NAME "biguint64arrayrefnew_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/biguint64arrayrefnew_fuzzer/corpus/init b/test/fuzztest/biguint64arrayrefnew_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d175fac243eb62fa23e3e87a601b71218bb32507 --- /dev/null +++ b/test/fuzztest/biguint64arrayrefnew_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/biguint64arrayrefnew_fuzzer/project.xml b/test/fuzztest/biguint64arrayrefnew_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/biguint64arrayrefnew_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/booleanrefnewbool_fuzzer/BUILD.gn b/test/fuzztest/booleanrefnewbool_fuzzer/BUILD.gn index 7b54e15dad2fce89ee272cd4fb063fb64f828ff2..25e6d092dabd64503b78c1827266379112392dd9 100644 --- a/test/fuzztest/booleanrefnewbool_fuzzer/BUILD.gn +++ b/test/fuzztest/booleanrefnewbool_fuzzer/BUILD.gn @@ -30,7 +30,6 @@ ohos_fuzztest("BooleanRefNewBoolFuzzTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime", "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", diff --git a/test/fuzztest/createbigwords_fuzzer/BUILD.gn b/test/fuzztest/createbigwords_fuzzer/BUILD.gn index 79e5a56f72f949a88152186413b2a99e9ad5cbce..06078504a6fadb2bdfbb81950c5b88b1d6a3e8ac 100644 --- a/test/fuzztest/createbigwords_fuzzer/BUILD.gn +++ b/test/fuzztest/createbigwords_fuzzer/BUILD.gn @@ -30,7 +30,6 @@ ohos_fuzztest("CreateBigWordsFuzzTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime", sdk_libc_secshared_dep, ] diff --git a/test/fuzztest/dataviewrefnew_fuzzer/BUILD.gn b/test/fuzztest/dataviewrefnew_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..61c061d1576c6ff36b074451e2a0eee6f837b60e --- /dev/null +++ b/test/fuzztest/dataviewrefnew_fuzzer/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +##################################hydra-fuzz################################### +import("//arkcompiler/ets_runtime/js_runtime_config.gni") +import("//arkcompiler/ets_runtime/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("DataViewRefNewFuzzTest") { + module_out_path = "arkcompiler/ets_runtime" + + fuzz_config_file = + "//arkcompiler/ets_runtime/test/fuzztest/dataviewrefnew_fuzzer" + + sources = [ "dataviewrefnew_fuzzer.cpp" ] + + configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":DataViewRefNewFuzzTest" ] +} diff --git a/test/fuzztest/dataviewrefnew_fuzzer/corpus/init b/test/fuzztest/dataviewrefnew_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d175fac243eb62fa23e3e87a601b71218bb32507 --- /dev/null +++ b/test/fuzztest/dataviewrefnew_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/dataviewrefnew_fuzzer/dataviewrefnew_fuzzer.cpp b/test/fuzztest/dataviewrefnew_fuzzer/dataviewrefnew_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..943ce105c8832fadcd60a07ce712041683bbf4ff --- /dev/null +++ b/test/fuzztest/dataviewrefnew_fuzzer/dataviewrefnew_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dataviewrefnew_fuzzer.h" + +#include "ecmascript/ecma_string-inl.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "ecmascript/tooling/debugger_service.h" + +using namespace panda; +using namespace panda::ecmascript; + +#define MAXBYTELEN sizeof(int32_t) + +namespace OHOS { + void DataViewRefNewFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + EcmaVM *vm = JSNApi::CreateJSVM(option); + [[maybe_unused]] LocalScope scope(vm); + int32_t input; + + if (size > MAXBYTELEN) { + size = MAXBYTELEN; + } + if (memcpy_s(&input, MAXBYTELEN, data, size) != 0) { + std::cout << "memcpy_s failed!"; + UNREACHABLE(); + } + Local ref = ArrayBufferRef::New(vm, input); + DataViewRef::New(vm, ref, (uint32_t)size, (uint32_t)size); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::DataViewRefNewFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/dataviewrefnew_fuzzer/dataviewrefnew_fuzzer.h b/test/fuzztest/dataviewrefnew_fuzzer/dataviewrefnew_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..d54da0fd6fac19d5b7d589dbfa00a9741c56fc74 --- /dev/null +++ b/test/fuzztest/dataviewrefnew_fuzzer/dataviewrefnew_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DATAVIEWREFNEW_FUZZER_H +#define DATAVIEWREFNEW_FUZZER_H + +#define FUZZ_PROJECT_NAME "dataviewrefnew_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/dataviewrefnew_fuzzer/project.xml b/test/fuzztest/dataviewrefnew_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/dataviewrefnew_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/dispatchprotocolmessage_fuzzer/BUILD.gn b/test/fuzztest/dispatchprotocolmessage_fuzzer/BUILD.gn index f604fc0fb414ba9971ef81f595b868a09bc089bf..c9c6f305a67e465c6e203092759391256bbe1cf8 100644 --- a/test/fuzztest/dispatchprotocolmessage_fuzzer/BUILD.gn +++ b/test/fuzztest/dispatchprotocolmessage_fuzzer/BUILD.gn @@ -30,7 +30,6 @@ ohos_fuzztest("DispatchProtocolMessageFuzzTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime", "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", diff --git a/test/fuzztest/execute_fuzzer/BUILD.gn b/test/fuzztest/execute_fuzzer/BUILD.gn index b497a9431280db3de1dd74e9a2ba4b52baf3d0e4..aa1be357043050ab10f7ec59596cdc8c2f498a35 100644 --- a/test/fuzztest/execute_fuzzer/BUILD.gn +++ b/test/fuzztest/execute_fuzzer/BUILD.gn @@ -29,7 +29,6 @@ ohos_fuzztest("ExecuteFuzzTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime", sdk_libc_secshared_dep, ] diff --git a/test/fuzztest/float32arrayrefnew_fuzzer/BUILD.gn b/test/fuzztest/float32arrayrefnew_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e1a4d3791c2e3bc90df4eda668f79f5d5d4b124b --- /dev/null +++ b/test/fuzztest/float32arrayrefnew_fuzzer/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +##################################hydra-fuzz################################### +import("//arkcompiler/ets_runtime/js_runtime_config.gni") +import("//arkcompiler/ets_runtime/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("Float32ArrayRefNewFuzzTest") { + module_out_path = "arkcompiler/ets_runtime" + + fuzz_config_file = + "//arkcompiler/ets_runtime/test/fuzztest/float32arrayrefnew_fuzzer" + + sources = [ "float32arrayrefnew_fuzzer.cpp" ] + + configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":Float32ArrayRefNewFuzzTest" ] +} diff --git a/test/fuzztest/float32arrayrefnew_fuzzer/corpus/init b/test/fuzztest/float32arrayrefnew_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d175fac243eb62fa23e3e87a601b71218bb32507 --- /dev/null +++ b/test/fuzztest/float32arrayrefnew_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/float32arrayrefnew_fuzzer/float32arrayrefnew_fuzzer.cpp b/test/fuzztest/float32arrayrefnew_fuzzer/float32arrayrefnew_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..edf3e521b366515f018391fd4b6f1a858f8d0f92 --- /dev/null +++ b/test/fuzztest/float32arrayrefnew_fuzzer/float32arrayrefnew_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "float32arrayrefnew_fuzzer.h" + +#include "ecmascript/ecma_string-inl.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "ecmascript/tooling/debugger_service.h" + +using namespace panda; +using namespace panda::ecmascript; + +#define MAXBYTELEN sizeof(int32_t) + +namespace OHOS { + void Float32ArrayRefNewFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + EcmaVM *vm = JSNApi::CreateJSVM(option); + [[maybe_unused]] LocalScope scope(vm); + int32_t input; + + if (size > MAXBYTELEN) { + size = MAXBYTELEN; + } + if (memcpy_s(&input, MAXBYTELEN, data, size) != 0) { + std::cout << "memcpy_s failed!"; + UNREACHABLE(); + } + Local ref = ArrayBufferRef::New(vm, input); + Float32ArrayRef::New(vm, ref, (int32_t)size, (int32_t)size); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::Float32ArrayRefNewFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/float32arrayrefnew_fuzzer/float32arrayrefnew_fuzzer.h b/test/fuzztest/float32arrayrefnew_fuzzer/float32arrayrefnew_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..a209623ddb3c6ad8ee1053126c72b45eb21c72d8 --- /dev/null +++ b/test/fuzztest/float32arrayrefnew_fuzzer/float32arrayrefnew_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FLOAT32ARRAYREFNEW_FUZZER_H +#define FLOAT32ARRAYREFNEW_FUZZER_H + +#define FUZZ_PROJECT_NAME "float32arrayrefnew_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/float32arrayrefnew_fuzzer/project.xml b/test/fuzztest/float32arrayrefnew_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/float32arrayrefnew_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/float64arrayrefnew_fuzzer/BUILD.gn b/test/fuzztest/float64arrayrefnew_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9ec268fc140b678426f34d4b2905bb221d690874 --- /dev/null +++ b/test/fuzztest/float64arrayrefnew_fuzzer/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +##################################hydra-fuzz################################### +import("//arkcompiler/ets_runtime/js_runtime_config.gni") +import("//arkcompiler/ets_runtime/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("Float64ArrayRefNewFuzzTest") { + module_out_path = "arkcompiler/ets_runtime" + + fuzz_config_file = + "//arkcompiler/ets_runtime/test/fuzztest/float64arrayrefnew_fuzzer" + + sources = [ "float64arrayrefnew_fuzzer.cpp" ] + + configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":Float64ArrayRefNewFuzzTest" ] +} diff --git a/test/fuzztest/float64arrayrefnew_fuzzer/corpus/init b/test/fuzztest/float64arrayrefnew_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d175fac243eb62fa23e3e87a601b71218bb32507 --- /dev/null +++ b/test/fuzztest/float64arrayrefnew_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/float64arrayrefnew_fuzzer/float64arrayrefnew_fuzzer.cpp b/test/fuzztest/float64arrayrefnew_fuzzer/float64arrayrefnew_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..11ff837018cb6df3e27f466116e9838b88d5231b --- /dev/null +++ b/test/fuzztest/float64arrayrefnew_fuzzer/float64arrayrefnew_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "float64arrayrefnew_fuzzer.h" + +#include "ecmascript/ecma_string-inl.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "ecmascript/tooling/debugger_service.h" + +using namespace panda; +using namespace panda::ecmascript; + +#define MAXBYTELEN sizeof(int32_t) + +namespace OHOS { + void Float64ArrayRefNewFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + EcmaVM *vm = JSNApi::CreateJSVM(option); + [[maybe_unused]] LocalScope scope(vm); + int32_t input; + + if (size > MAXBYTELEN) { + size = MAXBYTELEN; + } + if (memcpy_s(&input, MAXBYTELEN, data, size) != 0) { + std::cout << "memcpy_s failed!"; + UNREACHABLE(); + } + Local ref = ArrayBufferRef::New(vm, input); + Float64ArrayRef::New(vm, ref, (int32_t)size, (int32_t)size); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::Float64ArrayRefNewFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/float64arrayrefnew_fuzzer/float64arrayrefnew_fuzzer.h b/test/fuzztest/float64arrayrefnew_fuzzer/float64arrayrefnew_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..9027b0fb53b5dc560a4ad6adb5b78b5f4337adbe --- /dev/null +++ b/test/fuzztest/float64arrayrefnew_fuzzer/float64arrayrefnew_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FLOAT64ARRAYREFNEW_FUZZER_H +#define FLOAT64ARRAYREFNEW_FUZZER_H + +#define FUZZ_PROJECT_NAME "float64arrayrefnew_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/float64arrayrefnew_fuzzer/project.xml b/test/fuzztest/float64arrayrefnew_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/float64arrayrefnew_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/getwordsarray_fuzzer/BUILD.gn b/test/fuzztest/getwordsarray_fuzzer/BUILD.gn index c8ad9e9c2efd96e615a1bbaa7b32840c508542f1..c9ee3c4fc2eba7966c7d7321a6558ac7b65ae26f 100644 --- a/test/fuzztest/getwordsarray_fuzzer/BUILD.gn +++ b/test/fuzztest/getwordsarray_fuzzer/BUILD.gn @@ -30,7 +30,6 @@ ohos_fuzztest("GetWordsArrayFuzzTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime", sdk_libc_secshared_dep, ] diff --git a/test/fuzztest/initializedebugger_fuzzer/BUILD.gn b/test/fuzztest/initializedebugger_fuzzer/BUILD.gn index fc94701e5988a3667a1fb7cd29fc2f95ae66d7e9..89121f81168d41daad6d7da84a3aba2a9f034879 100644 --- a/test/fuzztest/initializedebugger_fuzzer/BUILD.gn +++ b/test/fuzztest/initializedebugger_fuzzer/BUILD.gn @@ -30,7 +30,6 @@ ohos_fuzztest("InitializeDebuggerFuzzTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime", "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", diff --git a/test/fuzztest/int16arrayrefnew_fuzzer/BUILD.gn b/test/fuzztest/int16arrayrefnew_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8f749fe2c3b85de7bd747e6b4583015349f51a37 --- /dev/null +++ b/test/fuzztest/int16arrayrefnew_fuzzer/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +##################################hydra-fuzz################################### +import("//arkcompiler/ets_runtime/js_runtime_config.gni") +import("//arkcompiler/ets_runtime/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("Int16ArrayRefNewFuzzTest") { + module_out_path = "arkcompiler/ets_runtime" + + fuzz_config_file = + "//arkcompiler/ets_runtime/test/fuzztest/int16arrayrefnew_fuzzer" + + sources = [ "int16arrayrefnew_fuzzer.cpp" ] + + configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":Int16ArrayRefNewFuzzTest" ] +} diff --git a/test/fuzztest/int16arrayrefnew_fuzzer/corpus/init b/test/fuzztest/int16arrayrefnew_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d175fac243eb62fa23e3e87a601b71218bb32507 --- /dev/null +++ b/test/fuzztest/int16arrayrefnew_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/int16arrayrefnew_fuzzer/int16arrayrefnew_fuzzer.cpp b/test/fuzztest/int16arrayrefnew_fuzzer/int16arrayrefnew_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e47ae6eb2b045eba6ae82bb9ae24eef41c26a2d4 --- /dev/null +++ b/test/fuzztest/int16arrayrefnew_fuzzer/int16arrayrefnew_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "int16arrayrefnew_fuzzer.h" + +#include "ecmascript/ecma_string-inl.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "ecmascript/tooling/debugger_service.h" + +using namespace panda; +using namespace panda::ecmascript; + +#define MAXBYTELEN sizeof(int32_t) + +namespace OHOS { + void Int16ArrayRefNewFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + EcmaVM *vm = JSNApi::CreateJSVM(option); + [[maybe_unused]] LocalScope scope(vm); + int32_t input; + + if (size > MAXBYTELEN) { + size = MAXBYTELEN; + } + if (memcpy_s(&input, MAXBYTELEN, data, size) != 0) { + std::cout << "memcpy_s failed!"; + UNREACHABLE(); + } + Local ref = ArrayBufferRef::New(vm, input); + Int16ArrayRef::New(vm, ref, (int32_t)size, (int32_t)size); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::Int16ArrayRefNewFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/int16arrayrefnew_fuzzer/int16arrayrefnew_fuzzer.h b/test/fuzztest/int16arrayrefnew_fuzzer/int16arrayrefnew_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..f09790210d135c22761f72dc0bae1ff937392240 --- /dev/null +++ b/test/fuzztest/int16arrayrefnew_fuzzer/int16arrayrefnew_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef INT16ARRAYREFNEW_FUZZER_H +#define INT16ARRAYREFNEW_FUZZER_H + +#define FUZZ_PROJECT_NAME "int16arrayrefnew_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/int16arrayrefnew_fuzzer/project.xml b/test/fuzztest/int16arrayrefnew_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/int16arrayrefnew_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/int32arrayrefnew_fuzzer/BUILD.gn b/test/fuzztest/int32arrayrefnew_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..019b9e06b359294ab32e43dedc5df0a3a6f9a38e --- /dev/null +++ b/test/fuzztest/int32arrayrefnew_fuzzer/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +##################################hydra-fuzz################################### +import("//arkcompiler/ets_runtime/js_runtime_config.gni") +import("//arkcompiler/ets_runtime/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("Int32ArrayRefNewFuzzTest") { + module_out_path = "arkcompiler/ets_runtime" + + fuzz_config_file = + "//arkcompiler/ets_runtime/test/fuzztest/int32arrayrefnew_fuzzer" + + sources = [ "int32arrayrefnew_fuzzer.cpp" ] + + configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":Int32ArrayRefNewFuzzTest" ] +} diff --git a/test/fuzztest/int32arrayrefnew_fuzzer/corpus/init b/test/fuzztest/int32arrayrefnew_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d175fac243eb62fa23e3e87a601b71218bb32507 --- /dev/null +++ b/test/fuzztest/int32arrayrefnew_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/int32arrayrefnew_fuzzer/int32arrayrefnew_fuzzer.cpp b/test/fuzztest/int32arrayrefnew_fuzzer/int32arrayrefnew_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..29ae5dfe8e36f9b11a974d2503784776507a5efb --- /dev/null +++ b/test/fuzztest/int32arrayrefnew_fuzzer/int32arrayrefnew_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "int32arrayrefnew_fuzzer.h" + +#include "ecmascript/ecma_string-inl.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "ecmascript/tooling/debugger_service.h" + +using namespace panda; +using namespace panda::ecmascript; + +#define MAXBYTELEN sizeof(int32_t) + +namespace OHOS { + void Int32ArrayRefNewFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + EcmaVM *vm = JSNApi::CreateJSVM(option); + [[maybe_unused]] LocalScope scope(vm); + int32_t input; + + if (size > MAXBYTELEN) { + size = MAXBYTELEN; + } + if (memcpy_s(&input, MAXBYTELEN, data, size) != 0) { + std::cout << "memcpy_s failed!"; + UNREACHABLE(); + } + Local ref = ArrayBufferRef::New(vm, input); + Int32ArrayRef::New(vm, ref, (int32_t)size, (int32_t)size); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::Int32ArrayRefNewFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/int32arrayrefnew_fuzzer/int32arrayrefnew_fuzzer.h b/test/fuzztest/int32arrayrefnew_fuzzer/int32arrayrefnew_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..fc95c7789cd0b4361456f240722988f61df093ff --- /dev/null +++ b/test/fuzztest/int32arrayrefnew_fuzzer/int32arrayrefnew_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef INT32ARRAYREFNEW_FUZZER_H +#define INT32ARRAYREFNEW_FUZZER_H + +#define FUZZ_PROJECT_NAME "int32arrayrefnew_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/int32arrayrefnew_fuzzer/project.xml b/test/fuzztest/int32arrayrefnew_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/int32arrayrefnew_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/int8arrayrefnew_fuzzer/BUILD.gn b/test/fuzztest/int8arrayrefnew_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e75de82e2b463da3b295ab399beb1ed5e3e84f11 --- /dev/null +++ b/test/fuzztest/int8arrayrefnew_fuzzer/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +##################################hydra-fuzz################################### +import("//arkcompiler/ets_runtime/js_runtime_config.gni") +import("//arkcompiler/ets_runtime/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("Int8ArrayRefNewFuzzTest") { + module_out_path = "arkcompiler/ets_runtime" + + fuzz_config_file = + "//arkcompiler/ets_runtime/test/fuzztest/int8arrayrefnew_fuzzer" + + sources = [ "int8arrayrefnew_fuzzer.cpp" ] + + configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":Int8ArrayRefNewFuzzTest" ] +} diff --git a/test/fuzztest/int8arrayrefnew_fuzzer/corpus/init b/test/fuzztest/int8arrayrefnew_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d175fac243eb62fa23e3e87a601b71218bb32507 --- /dev/null +++ b/test/fuzztest/int8arrayrefnew_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/int8arrayrefnew_fuzzer/int8arrayrefnew_fuzzer.cpp b/test/fuzztest/int8arrayrefnew_fuzzer/int8arrayrefnew_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..38cfc95a16e54af39c62af293db501e23d1c8689 --- /dev/null +++ b/test/fuzztest/int8arrayrefnew_fuzzer/int8arrayrefnew_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "int8arrayrefnew_fuzzer.h" + +#include "ecmascript/ecma_string-inl.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "ecmascript/tooling/debugger_service.h" + +using namespace panda; +using namespace panda::ecmascript; + +#define MAXBYTELEN sizeof(int32_t) + +namespace OHOS { + void Int8ArrayRefNewFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + EcmaVM *vm = JSNApi::CreateJSVM(option); + [[maybe_unused]] LocalScope scope(vm); + int32_t input; + + if (size > MAXBYTELEN) { + size = MAXBYTELEN; + } + if (memcpy_s(&input, MAXBYTELEN, data, size) != 0) { + std::cout << "memcpy_s failed!"; + UNREACHABLE(); + } + Local ref = ArrayBufferRef::New(vm, input); + Int8ArrayRef::New(vm, ref, (int32_t)size, (int32_t)size); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::Int8ArrayRefNewFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/int8arrayrefnew_fuzzer/int8arrayrefnew_fuzzer.h b/test/fuzztest/int8arrayrefnew_fuzzer/int8arrayrefnew_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..0bef61449808a15b60a404f04aa5d39e95105002 --- /dev/null +++ b/test/fuzztest/int8arrayrefnew_fuzzer/int8arrayrefnew_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef INT8ARRAYREFNEW_FUZZER_H +#define INT8ARRAYREFNEW_FUZZER_H + +#define FUZZ_PROJECT_NAME "int8arrayrefnew_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/int8arrayrefnew_fuzzer/project.xml b/test/fuzztest/int8arrayrefnew_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/int8arrayrefnew_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/newbigintbyint64_fuzzer/BUILD.gn b/test/fuzztest/newbigintbyint64_fuzzer/BUILD.gn index d6c86d0e8c088e19809242fef3e1c25e1d562e26..19c3cdfeb25490f22fafeed8511b2a107b2a881a 100644 --- a/test/fuzztest/newbigintbyint64_fuzzer/BUILD.gn +++ b/test/fuzztest/newbigintbyint64_fuzzer/BUILD.gn @@ -30,7 +30,6 @@ ohos_fuzztest("NewBigIntByInt64FuzzTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime", sdk_libc_secshared_dep, ] diff --git a/test/fuzztest/newbigintbyuint64_fuzzer/BUILD.gn b/test/fuzztest/newbigintbyuint64_fuzzer/BUILD.gn index 740e631d2e89aab61b0853c37be1cd79a79c7ca1..bc1a3c8c68e1a4d350b29f4135808f829fe8e5af 100644 --- a/test/fuzztest/newbigintbyuint64_fuzzer/BUILD.gn +++ b/test/fuzztest/newbigintbyuint64_fuzzer/BUILD.gn @@ -30,7 +30,6 @@ ohos_fuzztest("NewBigIntByUint64FuzzTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime", sdk_libc_secshared_dep, ] diff --git a/test/fuzztest/numberrefnewdouble_fuzzer/BUILD.gn b/test/fuzztest/numberrefnewdouble_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8572139ee9dcc5c73a4679ee4e89841c787a2f42 --- /dev/null +++ b/test/fuzztest/numberrefnewdouble_fuzzer/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +##################################hydra-fuzz################################### +import("//arkcompiler/ets_runtime/js_runtime_config.gni") +import("//arkcompiler/ets_runtime/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("NumberRefNewDoubleFuzzTest") { + module_out_path = "arkcompiler/ets_runtime" + + fuzz_config_file = + "//arkcompiler/ets_runtime/test/fuzztest/numberrefnewdouble_fuzzer" + + sources = [ "numberrefnewdouble_fuzzer.cpp" ] + + configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":NumberRefNewDoubleFuzzTest" ] +} diff --git a/test/fuzztest/numberrefnewdouble_fuzzer/corpus/init b/test/fuzztest/numberrefnewdouble_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d175fac243eb62fa23e3e87a601b71218bb32507 --- /dev/null +++ b/test/fuzztest/numberrefnewdouble_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/numberrefnewdouble_fuzzer/numberrefnewdouble_fuzzer.cpp b/test/fuzztest/numberrefnewdouble_fuzzer/numberrefnewdouble_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e3a3fb74ed2e27bfd5c64cb25c3042e626e4291b --- /dev/null +++ b/test/fuzztest/numberrefnewdouble_fuzzer/numberrefnewdouble_fuzzer.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "numberrefnewdouble_fuzzer.h" + +#include "ecmascript/ecma_string-inl.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "ecmascript/tooling/debugger_service.h" + +using namespace panda; +using namespace panda::ecmascript; + +#define MAXBYTELEN sizeof(double) + +namespace OHOS { + void NumberRefNewDoubleFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + [[maybe_unused]] LocalScope scope(vm); + double input = 0; + if (size > MAXBYTELEN) { + size = MAXBYTELEN; + } + if (memcpy_s(&input, MAXBYTELEN, data, size) != 0) { + std::cout << "memcpy_s failed"; + UNREACHABLE(); + } + [[maybe_unused]] Local number = NumberRef::New(vm, input); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::NumberRefNewDoubleFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/numberrefnewdouble_fuzzer/numberrefnewdouble_fuzzer.h b/test/fuzztest/numberrefnewdouble_fuzzer/numberrefnewdouble_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..29c95a5935ab62676102a69edaa4529801422aec --- /dev/null +++ b/test/fuzztest/numberrefnewdouble_fuzzer/numberrefnewdouble_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NUMBERREFNEWDOUBLE_FUZZER_H +#define NUMBERREFNEWDOUBLE_FUZZER_H + +#define FUZZ_PROJECT_NAME "numberrefnewdouble_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/numberrefnewdouble_fuzzer/project.xml b/test/fuzztest/numberrefnewdouble_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/numberrefnewdouble_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/numberrefnewint32_fuzzer/BUILD.gn b/test/fuzztest/numberrefnewint32_fuzzer/BUILD.gn index 1d2ea10027dee9e53663ff3bd54c2880094c9c6b..8d8c1aa507c1fa855769e34e5f84fbcddc3287ad 100644 --- a/test/fuzztest/numberrefnewint32_fuzzer/BUILD.gn +++ b/test/fuzztest/numberrefnewint32_fuzzer/BUILD.gn @@ -30,7 +30,6 @@ ohos_fuzztest("NumberRefNewInt32FuzzTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime", "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", diff --git a/test/fuzztest/numberrefnewint64_fuzzer/BUILD.gn b/test/fuzztest/numberrefnewint64_fuzzer/BUILD.gn index 0ad00e70732172fa5bd9f3f8eaa66897857418f3..c8ec6584b16526a9f31df21d63a6b6dfb8c44aa5 100644 --- a/test/fuzztest/numberrefnewint64_fuzzer/BUILD.gn +++ b/test/fuzztest/numberrefnewint64_fuzzer/BUILD.gn @@ -30,7 +30,6 @@ ohos_fuzztest("NumberRefNewInt64FuzzTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime", "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", diff --git a/test/fuzztest/numberrefnewuint32_fuzzer/BUILD.gn b/test/fuzztest/numberrefnewuint32_fuzzer/BUILD.gn index 543fb1335790b9d4d44218f5304eedfb8600cba4..b123408f1b6c0181529ca3278a6f9a5bec534cad 100644 --- a/test/fuzztest/numberrefnewuint32_fuzzer/BUILD.gn +++ b/test/fuzztest/numberrefnewuint32_fuzzer/BUILD.gn @@ -30,7 +30,6 @@ ohos_fuzztest("NumberRefNewUint32FuzzTest") { configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] deps = [ - "$ark_root/libpandabase:libarkbase", "//arkcompiler/ets_runtime:libark_jsruntime", "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", diff --git a/test/fuzztest/uint16arrayrefnew_fuzzer/BUILD.gn b/test/fuzztest/uint16arrayrefnew_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..2b9c71b9742cc3e6665571f5c7fe1bbaf7f62a17 --- /dev/null +++ b/test/fuzztest/uint16arrayrefnew_fuzzer/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +##################################hydra-fuzz################################### +import("//arkcompiler/ets_runtime/js_runtime_config.gni") +import("//arkcompiler/ets_runtime/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("Uint16ArrayRefNewFuzzTest") { + module_out_path = "arkcompiler/ets_runtime" + + fuzz_config_file = + "//arkcompiler/ets_runtime/test/fuzztest/uint16arrayrefnew_fuzzer" + + sources = [ "uint16arrayrefnew_fuzzer.cpp" ] + + configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":Uint16ArrayRefNewFuzzTest" ] +} diff --git a/test/fuzztest/uint16arrayrefnew_fuzzer/corpus/init b/test/fuzztest/uint16arrayrefnew_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d175fac243eb62fa23e3e87a601b71218bb32507 --- /dev/null +++ b/test/fuzztest/uint16arrayrefnew_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/uint16arrayrefnew_fuzzer/project.xml b/test/fuzztest/uint16arrayrefnew_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/uint16arrayrefnew_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/uint16arrayrefnew_fuzzer/uint16arrayrefnew_fuzzer.cpp b/test/fuzztest/uint16arrayrefnew_fuzzer/uint16arrayrefnew_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..820d31a39b0da2aa35c98e4388819d59c6865921 --- /dev/null +++ b/test/fuzztest/uint16arrayrefnew_fuzzer/uint16arrayrefnew_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "uint16arrayrefnew_fuzzer.h" + +#include "ecmascript/ecma_string-inl.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "ecmascript/tooling/debugger_service.h" + +using namespace panda; +using namespace panda::ecmascript; + +#define MAXBYTELEN sizeof(int32_t) + +namespace OHOS { + void Uint16ArrayRefNewFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + EcmaVM *vm = JSNApi::CreateJSVM(option); + [[maybe_unused]] LocalScope scope(vm); + int32_t input; + + if (size > MAXBYTELEN) { + size = MAXBYTELEN; + } + if (memcpy_s(&input, MAXBYTELEN, data, size) != 0) { + std::cout << "memcpy_s failed!"; + UNREACHABLE(); + } + Local ref = ArrayBufferRef::New(vm, input); + Uint16ArrayRef::New(vm, ref, (int32_t)size, (int32_t)size); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::Uint16ArrayRefNewFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/uint16arrayrefnew_fuzzer/uint16arrayrefnew_fuzzer.h b/test/fuzztest/uint16arrayrefnew_fuzzer/uint16arrayrefnew_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..e0726fd29ae104e30a8a0b854a3d63e2b038e52f --- /dev/null +++ b/test/fuzztest/uint16arrayrefnew_fuzzer/uint16arrayrefnew_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef UINT16ARRAYREFNEW_FUZZER_H +#define UINT16ARRAYREFNEW_FUZZER_H + +#define FUZZ_PROJECT_NAME "uint16arrayrefnew_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/uint32arrayrefnew_fuzzer/BUILD.gn b/test/fuzztest/uint32arrayrefnew_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e664b3898d17657ba5f375184d8057daf1c5715b --- /dev/null +++ b/test/fuzztest/uint32arrayrefnew_fuzzer/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +##################################hydra-fuzz################################### +import("//arkcompiler/ets_runtime/js_runtime_config.gni") +import("//arkcompiler/ets_runtime/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("Uint32ArrayRefNewFuzzTest") { + module_out_path = "arkcompiler/ets_runtime" + + fuzz_config_file = + "//arkcompiler/ets_runtime/test/fuzztest/uint32arrayrefnew_fuzzer" + + sources = [ "uint32arrayrefnew_fuzzer.cpp" ] + + configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":Uint32ArrayRefNewFuzzTest" ] +} diff --git a/test/fuzztest/uint32arrayrefnew_fuzzer/corpus/init b/test/fuzztest/uint32arrayrefnew_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d175fac243eb62fa23e3e87a601b71218bb32507 --- /dev/null +++ b/test/fuzztest/uint32arrayrefnew_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/uint32arrayrefnew_fuzzer/project.xml b/test/fuzztest/uint32arrayrefnew_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/uint32arrayrefnew_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/uint32arrayrefnew_fuzzer/uint32arrayrefnew_fuzzer.cpp b/test/fuzztest/uint32arrayrefnew_fuzzer/uint32arrayrefnew_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3fd657bd0f0fca83457d5d73c72a1a540c251065 --- /dev/null +++ b/test/fuzztest/uint32arrayrefnew_fuzzer/uint32arrayrefnew_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "uint32arrayrefnew_fuzzer.h" + +#include "ecmascript/ecma_string-inl.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "ecmascript/tooling/debugger_service.h" + +using namespace panda; +using namespace panda::ecmascript; + +#define MAXBYTELEN sizeof(int32_t) + +namespace OHOS { + void Uint32ArrayRefNewFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + EcmaVM *vm = JSNApi::CreateJSVM(option); + [[maybe_unused]] LocalScope scope(vm); + int32_t input; + + if (size > MAXBYTELEN) { + size = MAXBYTELEN; + } + if (memcpy_s(&input, MAXBYTELEN, data, size) != 0) { + std::cout << "memcpy_s failed!"; + UNREACHABLE(); + } + Local ref = ArrayBufferRef::New(vm, input); + Uint32ArrayRef::New(vm, ref, (int32_t)size, (int32_t)size); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::Uint32ArrayRefNewFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/uint32arrayrefnew_fuzzer/uint32arrayrefnew_fuzzer.h b/test/fuzztest/uint32arrayrefnew_fuzzer/uint32arrayrefnew_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..52f13f19ffae73e0aef77ab2b320afc83e154e60 --- /dev/null +++ b/test/fuzztest/uint32arrayrefnew_fuzzer/uint32arrayrefnew_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef UINT32ARRAYREFNEW_FUZZER_H +#define UINT32ARRAYREFNEW_FUZZER_H + +#define FUZZ_PROJECT_NAME "uint32arrayrefnew_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/uint8arrayrefnew_fuzzer/BUILD.gn b/test/fuzztest/uint8arrayrefnew_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c63d1643c4f13b152cd7072a47dd90f9dc56453f --- /dev/null +++ b/test/fuzztest/uint8arrayrefnew_fuzzer/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +##################################hydra-fuzz################################### +import("//arkcompiler/ets_runtime/js_runtime_config.gni") +import("//arkcompiler/ets_runtime/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("Uint8ArrayRefNewFuzzTest") { + module_out_path = "arkcompiler/ets_runtime" + + fuzz_config_file = + "//arkcompiler/ets_runtime/test/fuzztest/uint8arrayrefnew_fuzzer" + + sources = [ "uint8arrayrefnew_fuzzer.cpp" ] + + configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":Uint8ArrayRefNewFuzzTest" ] +} diff --git a/test/fuzztest/uint8arrayrefnew_fuzzer/corpus/init b/test/fuzztest/uint8arrayrefnew_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d175fac243eb62fa23e3e87a601b71218bb32507 --- /dev/null +++ b/test/fuzztest/uint8arrayrefnew_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/uint8arrayrefnew_fuzzer/project.xml b/test/fuzztest/uint8arrayrefnew_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/uint8arrayrefnew_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/uint8arrayrefnew_fuzzer/uint8arrayrefnew_fuzzer.cpp b/test/fuzztest/uint8arrayrefnew_fuzzer/uint8arrayrefnew_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cf5cb83bcee0c5014a4bd57736b8edd15b6eb514 --- /dev/null +++ b/test/fuzztest/uint8arrayrefnew_fuzzer/uint8arrayrefnew_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "uint8arrayrefnew_fuzzer.h" + +#include "ecmascript/ecma_string-inl.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "ecmascript/tooling/debugger_service.h" + +using namespace panda; +using namespace panda::ecmascript; + +#define MAXBYTELEN sizeof(int32_t) + +namespace OHOS { + void Uint8ArrayRefNewFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + EcmaVM *vm = JSNApi::CreateJSVM(option); + [[maybe_unused]] LocalScope scope(vm); + int32_t input; + + if (size > MAXBYTELEN) { + size = MAXBYTELEN; + } + if (memcpy_s(&input, MAXBYTELEN, data, size) != 0) { + std::cout << "memcpy_s failed!"; + UNREACHABLE(); + } + Local ref = ArrayBufferRef::New(vm, input); + Uint8ArrayRef::New(vm, ref, (int32_t)size, (int32_t)size); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::Uint8ArrayRefNewFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/uint8arrayrefnew_fuzzer/uint8arrayrefnew_fuzzer.h b/test/fuzztest/uint8arrayrefnew_fuzzer/uint8arrayrefnew_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..55d255717885ced8e248f9408e3a66300e341d8d --- /dev/null +++ b/test/fuzztest/uint8arrayrefnew_fuzzer/uint8arrayrefnew_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef UINT8ARRAYREFNEW_FUZZER_H +#define UINT8ARRAYREFNEW_FUZZER_H + +#define FUZZ_PROJECT_NAME "Uint8arrayrefnew_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/uint8clampedarrayrefnew_fuzzer/BUILD.gn b/test/fuzztest/uint8clampedarrayrefnew_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8f40ce7d17f09c7d1b092e0bd8c5bf851519c636 --- /dev/null +++ b/test/fuzztest/uint8clampedarrayrefnew_fuzzer/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +##################################hydra-fuzz################################### +import("//arkcompiler/ets_runtime/js_runtime_config.gni") +import("//arkcompiler/ets_runtime/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("Uint8ClampedArrayRefNewFuzzTest") { + module_out_path = "arkcompiler/ets_runtime" + + fuzz_config_file = + "//arkcompiler/ets_runtime/test/fuzztest/uint8clampedarrayrefnew_fuzzer" + + sources = [ "uint8clampedarrayrefnew_fuzzer.cpp" ] + + configs = [ "//arkcompiler/ets_runtime:ecma_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/ets_runtime/ecmascript/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":Uint8ClampedArrayRefNewFuzzTest" ] +} diff --git a/test/fuzztest/uint8clampedarrayrefnew_fuzzer/corpus/init b/test/fuzztest/uint8clampedarrayrefnew_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d175fac243eb62fa23e3e87a601b71218bb32507 --- /dev/null +++ b/test/fuzztest/uint8clampedarrayrefnew_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/uint8clampedarrayrefnew_fuzzer/project.xml b/test/fuzztest/uint8clampedarrayrefnew_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/uint8clampedarrayrefnew_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/uint8clampedarrayrefnew_fuzzer/uint8clampedarrayrefnew_fuzzer.cpp b/test/fuzztest/uint8clampedarrayrefnew_fuzzer/uint8clampedarrayrefnew_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3e3a00231970d7234a33f691a21e6fc9cce1dc0c --- /dev/null +++ b/test/fuzztest/uint8clampedarrayrefnew_fuzzer/uint8clampedarrayrefnew_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "uint8clampedarrayrefnew_fuzzer.h" + +#include "ecmascript/ecma_string-inl.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "ecmascript/tooling/debugger_service.h" + +using namespace panda; +using namespace panda::ecmascript; + +#define MAXBYTELEN sizeof(int32_t) + +namespace OHOS { + void Uint8ClampedArrayRefNewFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + EcmaVM *vm = JSNApi::CreateJSVM(option); + [[maybe_unused]] LocalScope scope(vm); + int32_t input; + + if (size > MAXBYTELEN) { + size = MAXBYTELEN; + } + if (memcpy_s(&input, MAXBYTELEN, data, size) != 0) { + std::cout << "memcpy_s failed!"; + UNREACHABLE(); + } + Local ref = ArrayBufferRef::New(vm, input); + Uint8ClampedArrayRef::New(vm, ref, (int32_t)size, (int32_t)size); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::Uint8ClampedArrayRefNewFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/uint8clampedarrayrefnew_fuzzer/uint8clampedarrayrefnew_fuzzer.h b/test/fuzztest/uint8clampedarrayrefnew_fuzzer/uint8clampedarrayrefnew_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..fe5afc31582083de9cfda8545f5475da10111e17 --- /dev/null +++ b/test/fuzztest/uint8clampedarrayrefnew_fuzzer/uint8clampedarrayrefnew_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef UINT8CLAMPEDARRAYREFNEW_FUZZER_H +#define UINT8CLAMPEDARRAYREFNEW_FUZZER_H + +#define FUZZ_PROJECT_NAME "uint8clampedarrayrefnew_fuzzer" + +#endif \ No newline at end of file