diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 0746cd736e26c1040c0f6fd03d8ee52054e14ec4..f4c9c8a6af1f8d874b8f2fbf318245e0ed8f463b 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -18,5 +18,43 @@ group("fuzztest") { deps += [ "dispatchprotocolmessage_fuzzer:fuzztest", "initializedebugger_fuzzer:fuzztest", + "protocolhandler_fuzzer:fuzztest", + "protocolhandlerdispatch_fuzzer:fuzztest", + "protocolhandlerget_fuzzer:fuzztest", + "protocolhandlernotif_fuzzer:fuzztest", + "protocolhandlerprocess_fuzzer:fuzztest", + "protocolhandlerresponse_fuzzer:fuzztest", + "protocolhandlerrun_fuzzer:fuzztest", + "pttypesbreakpointparseid_fuzzer:fuzztest", + "pttypesbreakpointtostring_fuzzer:fuzztest", + "pttypesexceptiondetails_fuzzer:fuzztest", + "pttypesexceptiondetailscolumn_fuzzer:fuzztest", + "pttypesexceptiondetailscreate_fuzzer:fuzztest", + "pttypesexceptiondetailsexception_fuzzer:fuzztest", + "pttypesexceptiondetailsexceptionid_fuzzer:fuzztest", + "pttypesexceptiondetailsexecutioncontextid_fuzzer:fuzztest", + "pttypesexceptiondetailsline_fuzzer:fuzztest", + "pttypesexceptiondetailsscriptid_fuzzer:fuzztest", + "pttypesexceptiondetailstext_fuzzer:fuzztest", + "pttypesexceptiondetailstojson_fuzzer:fuzztest", + "pttypesexceptiondetailsurl_fuzzer:fuzztest", + "pttypesobjectremoteobject_fuzzer:fuzztest", + "pttypesprimitiveremoteobject_fuzzer:fuzztest", + "pttypesremoteobject_fuzzer:fuzztest", + "pttypesremoteobjectdescription_fuzzer:fuzztest", + "pttypesremoteobjectgetclassname_fuzzer:fuzztest", + "pttypesremoteobjectgetsubtype_fuzzer:fuzztest", + "pttypesremoteobjectgettype_fuzzer:fuzztest", + "pttypesremoteobjectgetvalue_fuzzer:fuzztest", + "pttypesremoteobjecthasclassname_fuzzer:fuzztest", + "pttypesremoteobjecthassubtype_fuzzer:fuzztest", + "pttypesremoteobjectobjectid_fuzzer:fuzztest", + "pttypesremoteobjectsetclassname_fuzzer:fuzztest", + "pttypesremoteobjectsetsubtype_fuzzer:fuzztest", + "pttypesremoteobjectsettype_fuzzer:fuzztest", + "pttypesremoteobjectsetvalue_fuzzer:fuzztest", + "pttypesremoteobjectunserializablevalue_fuzzer:fuzztest", + "pttypesstringremoteobject_fuzzer:fuzztest", + "pttypessymbolremoteobject_fuzzer:fuzztest", ] } diff --git a/test/fuzztest/dispatchprotocolmessage_fuzzer/BUILD.gn b/test/fuzztest/dispatchprotocolmessage_fuzzer/BUILD.gn index a1a6254e8f4caba17e7474f438c340720e71df00..cb592d95c2d38aea5e1bad075470f6f44c9d9958 100644 --- a/test/fuzztest/dispatchprotocolmessage_fuzzer/BUILD.gn +++ b/test/fuzztest/dispatchprotocolmessage_fuzzer/BUILD.gn @@ -12,7 +12,6 @@ # limitations under the License. ##################################hydra-fuzz################################### -# import("//arkcompiler/ets_runtime/js_runtime_config.gni") import("//arkcompiler/toolchain/test/test_helper.gni") import("//build/config/features.gni") import("//build/ohos.gni") diff --git a/test/fuzztest/dispatchprotocolmessage_fuzzer/dispatchprotocolmessage_fuzzer.cpp b/test/fuzztest/dispatchprotocolmessage_fuzzer/dispatchprotocolmessage_fuzzer.cpp index bff19b9ec5878568b72aac0a886a57db8926d81a..5aab538534b3a76113b58f8127ce834787fa1b36 100644 --- a/test/fuzztest/dispatchprotocolmessage_fuzzer/dispatchprotocolmessage_fuzzer.cpp +++ b/test/fuzztest/dispatchprotocolmessage_fuzzer/dispatchprotocolmessage_fuzzer.cpp @@ -27,11 +27,11 @@ namespace OHOS { RuntimeOption option; option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); auto vm = JSNApi::CreateJSVM(option); - if (size <= 0) { + if (size <= 0 || data == NULL) { return; } - std::string message(data, data+size); - OnMessage(vm, std::move(message)); + std::string message((const char*)data, size); + OnMessage(vm, message+"hello"); JSNApi::DestroyJSVM(vm); } } diff --git a/test/fuzztest/initializedebugger_fuzzer/BUILD.gn b/test/fuzztest/initializedebugger_fuzzer/BUILD.gn index cfde7f605c40dbf091696740bb7d5bb62095ef49..d9bb7786b2e89de57bc062b73eb4e3c664b9b452 100644 --- a/test/fuzztest/initializedebugger_fuzzer/BUILD.gn +++ b/test/fuzztest/initializedebugger_fuzzer/BUILD.gn @@ -12,7 +12,6 @@ # limitations under the License. #####################################hydra-fuzz############################### -# import("//arkcompiler/ets_runtime/js_runtime_config.gni") import("//arkcompiler/toolchain/test/test_helper.gni") import("//build/config/features.gni") import("//build/ohos.gni") diff --git a/test/fuzztest/protocolhandler_fuzzer/BUILD.gn b/test/fuzztest/protocolhandler_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..76e4c4de0b9089f733650a17e4f9cdddf5c80ed8 --- /dev/null +++ b/test/fuzztest/protocolhandler_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("ProtocolHandlerFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/protocolhandler_fuzzer" + + sources = [ "protocolhandler_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":ProtocolHandlerFuzzTest" ] +} diff --git a/test/fuzztest/protocolhandler_fuzzer/corpus/init b/test/fuzztest/protocolhandler_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/protocolhandler_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/protocolhandler_fuzzer/project.xml b/test/fuzztest/protocolhandler_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/protocolhandler_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/protocolhandler_fuzzer/protocolhandler_fuzzer.cpp b/test/fuzztest/protocolhandler_fuzzer/protocolhandler_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2a34b627da5bce9e2c73797a29264287bec157e5 --- /dev/null +++ b/test/fuzztest/protocolhandler_fuzzer/protocolhandler_fuzzer.cpp @@ -0,0 +1,48 @@ +/* + * 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 "protocolhandler_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/protocol_handler.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void ProtocolHandlerFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0) { + return; + } + using ProtoHandler = const std::function; + ProtoHandler ph = [data, size](const void *d, [[maybe_unused]] const std::string &s) -> void { + d = data + size; + }; + ProtocolHandler handler(ph, vm); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::ProtocolHandlerFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/protocolhandler_fuzzer/protocolhandler_fuzzer.h b/test/fuzztest/protocolhandler_fuzzer/protocolhandler_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..ffe2547470a2bd6716fb58a8c8f6beaede3fa935 --- /dev/null +++ b/test/fuzztest/protocolhandler_fuzzer/protocolhandler_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "protocolhandler_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/protocolhandlerdispatch_fuzzer/BUILD.gn b/test/fuzztest/protocolhandlerdispatch_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9918bddcfb08eeefd9603fa428d24089e803366d --- /dev/null +++ b/test/fuzztest/protocolhandlerdispatch_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("ProtocolHandlerDispatchFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/protocolhandlerdispatch_fuzzer" + + sources = [ "protocolhandlerdispatch_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":ProtocolHandlerDispatchFuzzTest" ] +} diff --git a/test/fuzztest/protocolhandlerdispatch_fuzzer/corpus/init b/test/fuzztest/protocolhandlerdispatch_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/protocolhandlerdispatch_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/protocolhandlerdispatch_fuzzer/project.xml b/test/fuzztest/protocolhandlerdispatch_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/protocolhandlerdispatch_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/protocolhandlerdispatch_fuzzer/protocolhandlerdispatch_fuzzer.cpp b/test/fuzztest/protocolhandlerdispatch_fuzzer/protocolhandlerdispatch_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..87dd99e366765015340ec976758f334adac64085 --- /dev/null +++ b/test/fuzztest/protocolhandlerdispatch_fuzzer/protocolhandlerdispatch_fuzzer.cpp @@ -0,0 +1,50 @@ +/* + * 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 "protocolhandlerdispatch_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/protocol_handler.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void ProtocolHandlerDispatchFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0) { + return; + } + using ProtoHandler = const std::function; + ProtoHandler ph = [data, size](const void *d, [[maybe_unused]] const std::string &s) -> void { + d = data + size; + }; + ProtocolHandler handler(ph, vm); + std::string msg((const char*)data, size); + handler.DispatchCommand(msg + std::string("hello")); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::ProtocolHandlerDispatchFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/protocolhandlerdispatch_fuzzer/protocolhandlerdispatch_fuzzer.h b/test/fuzztest/protocolhandlerdispatch_fuzzer/protocolhandlerdispatch_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..238ebbf6113fa2d63b972fe8d70a7c9e5520eb38 --- /dev/null +++ b/test/fuzztest/protocolhandlerdispatch_fuzzer/protocolhandlerdispatch_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "protocolhandlerdispatch_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/protocolhandlerget_fuzzer/BUILD.gn b/test/fuzztest/protocolhandlerget_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a1c81f5512074e4aa5fe815b7b4ddbde7bad5ddc --- /dev/null +++ b/test/fuzztest/protocolhandlerget_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("ProtocolHandlerGetFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/protocolhandlerget_fuzzer" + + sources = [ "protocolhandlerget_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":ProtocolHandlerGetFuzzTest" ] +} diff --git a/test/fuzztest/protocolhandlerget_fuzzer/corpus/init b/test/fuzztest/protocolhandlerget_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/protocolhandlerget_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/protocolhandlerget_fuzzer/project.xml b/test/fuzztest/protocolhandlerget_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/protocolhandlerget_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/protocolhandlerget_fuzzer/protocolhandlerget_fuzzer.cpp b/test/fuzztest/protocolhandlerget_fuzzer/protocolhandlerget_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2ad3c28eee6cd8e83e97a6273fce0c7648984d7e --- /dev/null +++ b/test/fuzztest/protocolhandlerget_fuzzer/protocolhandlerget_fuzzer.cpp @@ -0,0 +1,49 @@ +/* + * 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 "protocolhandlerget_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/protocol_handler.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void ProtocolHandlerGetFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0) { + return; + } + using ProtoHandler = const std::function; + ProtoHandler ph = [data, size](const void *d, [[maybe_unused]] const std::string &s) -> void { + d = data + size; + }; + ProtocolHandler handler(ph, vm); + handler.GetDispatchStatus(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::ProtocolHandlerGetFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/protocolhandlerget_fuzzer/protocolhandlerget_fuzzer.h b/test/fuzztest/protocolhandlerget_fuzzer/protocolhandlerget_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..2857546319faf27cb173fcf240ae74eac057d253 --- /dev/null +++ b/test/fuzztest/protocolhandlerget_fuzzer/protocolhandlerget_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "protocolhandlerget_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/protocolhandlernotif_fuzzer/BUILD.gn b/test/fuzztest/protocolhandlernotif_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..80533060dcad3179dd28880d560bf28b1043a199 --- /dev/null +++ b/test/fuzztest/protocolhandlernotif_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("ProtocolHandlerNotifFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/protocolhandlernotif_fuzzer" + + sources = [ "protocolhandlernotif_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":ProtocolHandlerNotifFuzzTest" ] +} diff --git a/test/fuzztest/protocolhandlernotif_fuzzer/corpus/init b/test/fuzztest/protocolhandlernotif_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/protocolhandlernotif_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/protocolhandlernotif_fuzzer/project.xml b/test/fuzztest/protocolhandlernotif_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/protocolhandlernotif_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/protocolhandlernotif_fuzzer/protocolhandlernotif_fuzzer.cpp b/test/fuzztest/protocolhandlernotif_fuzzer/protocolhandlernotif_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6e91e46c6dd0c06fe236127f8b7697202fa5e25b --- /dev/null +++ b/test/fuzztest/protocolhandlernotif_fuzzer/protocolhandlernotif_fuzzer.cpp @@ -0,0 +1,50 @@ +/* + * 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 "protocolhandlernotif_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/protocol_handler.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void ProtocolHandlerNotifFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0) { + return; + } + using ProtoHandler = const std::function; + ProtoHandler ph = [data, size](const void *d, [[maybe_unused]] const std::string &s) -> void { + d = data + size; + }; + ProtocolHandler handler(ph, vm); + Paused event; + handler.SendNotification(event); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::ProtocolHandlerNotifFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/protocolhandlernotif_fuzzer/protocolhandlernotif_fuzzer.h b/test/fuzztest/protocolhandlernotif_fuzzer/protocolhandlernotif_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..9aa24a1dd3a46e71d3ceaba075a27c6d17a41ddf --- /dev/null +++ b/test/fuzztest/protocolhandlernotif_fuzzer/protocolhandlernotif_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "protocolhandlernotif_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/protocolhandlerprocess_fuzzer/BUILD.gn b/test/fuzztest/protocolhandlerprocess_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..7537b02d9db0cc121a21762427deb806370104a2 --- /dev/null +++ b/test/fuzztest/protocolhandlerprocess_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("ProtocolHandlerProcessFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/protocolhandlerprocess_fuzzer" + + sources = [ "protocolhandlerprocess_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":ProtocolHandlerProcessFuzzTest" ] +} diff --git a/test/fuzztest/protocolhandlerprocess_fuzzer/corpus/init b/test/fuzztest/protocolhandlerprocess_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/protocolhandlerprocess_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/protocolhandlerprocess_fuzzer/project.xml b/test/fuzztest/protocolhandlerprocess_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/protocolhandlerprocess_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/protocolhandlerprocess_fuzzer/protocolhandlerprocess_fuzzer.cpp b/test/fuzztest/protocolhandlerprocess_fuzzer/protocolhandlerprocess_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..926b91e1ad4e3fc121739e5301c3ffebaa1b560f --- /dev/null +++ b/test/fuzztest/protocolhandlerprocess_fuzzer/protocolhandlerprocess_fuzzer.cpp @@ -0,0 +1,49 @@ +/* + * 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 "protocolhandlerprocess_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/protocol_handler.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void ProtocolHandlerProcessFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0) { + return; + } + using ProtoHandler = const std::function; + ProtoHandler ph = [data, size](const void *d, [[maybe_unused]] const std::string &s) -> void { + d = data + size; + }; + ProtocolHandler handler(ph, vm); + handler.ProcessCommand(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::ProtocolHandlerProcessFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/protocolhandlerprocess_fuzzer/protocolhandlerprocess_fuzzer.h b/test/fuzztest/protocolhandlerprocess_fuzzer/protocolhandlerprocess_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..ce0fe6272c029d0505b47c09276442e15e4d0763 --- /dev/null +++ b/test/fuzztest/protocolhandlerprocess_fuzzer/protocolhandlerprocess_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "protocolhandlerprocess_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/protocolhandlerresponse_fuzzer/BUILD.gn b/test/fuzztest/protocolhandlerresponse_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..06c492185cb30c6bb6274d956d4fa67e1dbaed45 --- /dev/null +++ b/test/fuzztest/protocolhandlerresponse_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("ProtocolHandlerResponseFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/protocolhandlerresponse_fuzzer" + + sources = [ "protocolhandlerresponse_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":ProtocolHandlerResponseFuzzTest" ] +} diff --git a/test/fuzztest/protocolhandlerresponse_fuzzer/corpus/init b/test/fuzztest/protocolhandlerresponse_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/protocolhandlerresponse_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/protocolhandlerresponse_fuzzer/project.xml b/test/fuzztest/protocolhandlerresponse_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/protocolhandlerresponse_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/protocolhandlerresponse_fuzzer/protocolhandlerresponse_fuzzer.cpp b/test/fuzztest/protocolhandlerresponse_fuzzer/protocolhandlerresponse_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0848d6844c697bb02695782e5fb334ff6c36c377 --- /dev/null +++ b/test/fuzztest/protocolhandlerresponse_fuzzer/protocolhandlerresponse_fuzzer.cpp @@ -0,0 +1,52 @@ +/* + * 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 "protocolhandlerresponse_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/protocol_handler.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void ProtocolHandlerResponseFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0) { + return; + } + using ProtoHandler = const std::function; + ProtoHandler ph = [data, size](const void *d, [[maybe_unused]] const std::string &s) -> void { + d = data + size; + }; + ProtocolHandler handler(ph, vm); + std::string str((const char*)data, size); + DispatchRequest req(str); + PtBaseReturns ret; + handler.SendResponse(req, DispatchResponse::Ok(), ret); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::ProtocolHandlerResponseFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/protocolhandlerresponse_fuzzer/protocolhandlerresponse_fuzzer.h b/test/fuzztest/protocolhandlerresponse_fuzzer/protocolhandlerresponse_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..e1a2cce68777fa9e0d250f7e137ad0ebe99d297b --- /dev/null +++ b/test/fuzztest/protocolhandlerresponse_fuzzer/protocolhandlerresponse_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "protocolhandlerresponse_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/protocolhandlerrun_fuzzer/BUILD.gn b/test/fuzztest/protocolhandlerrun_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..eba006901ee00bd784938024c7db5a66b68648bb --- /dev/null +++ b/test/fuzztest/protocolhandlerrun_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("ProtocolHandlerRunFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/protocolhandlerrun_fuzzer" + + sources = [ "protocolhandlerrun_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":ProtocolHandlerRunFuzzTest" ] +} diff --git a/test/fuzztest/protocolhandlerrun_fuzzer/corpus/init b/test/fuzztest/protocolhandlerrun_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/protocolhandlerrun_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/protocolhandlerrun_fuzzer/project.xml b/test/fuzztest/protocolhandlerrun_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/protocolhandlerrun_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/protocolhandlerrun_fuzzer/protocolhandlerrun_fuzzer.cpp b/test/fuzztest/protocolhandlerrun_fuzzer/protocolhandlerrun_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ff981660a2b27dad6664e15e7f27d3b261cdabb5 --- /dev/null +++ b/test/fuzztest/protocolhandlerrun_fuzzer/protocolhandlerrun_fuzzer.cpp @@ -0,0 +1,49 @@ +/* + * 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 "protocolhandlerrun_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/protocol_handler.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void ProtocolHandlerRunFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0) { + return; + } + using ProtoHandler = const std::function; + ProtoHandler ph = [data, size](const void *d, [[maybe_unused]] const std::string &s) -> void { + d = data + size; + }; + ProtocolHandler handler(ph, vm); + handler.RunIfWaitingForDebugger(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::ProtocolHandlerRunFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/protocolhandlerrun_fuzzer/protocolhandlerrun_fuzzer.h b/test/fuzztest/protocolhandlerrun_fuzzer/protocolhandlerrun_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..bb6044d5d16d1417f9e41e4265870767f6ce5493 --- /dev/null +++ b/test/fuzztest/protocolhandlerrun_fuzzer/protocolhandlerrun_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "protocolhandlerrun_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/protocolhandlerwait_fuzzer/BUILD.gn b/test/fuzztest/protocolhandlerwait_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0010a0c04e95535c4079dc31b0f47dbe34cea9b8 --- /dev/null +++ b/test/fuzztest/protocolhandlerwait_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("ProtocolHandlerWaitFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/protocolhandlerwait_fuzzer" + + sources = [ "protocolhandlerwait_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":ProtocolHandlerWaitFuzzTest" ] +} diff --git a/test/fuzztest/protocolhandlerwait_fuzzer/corpus/init b/test/fuzztest/protocolhandlerwait_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/protocolhandlerwait_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/protocolhandlerwait_fuzzer/project.xml b/test/fuzztest/protocolhandlerwait_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/protocolhandlerwait_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/protocolhandlerwait_fuzzer/protocolhandlerwait_fuzzer.cpp b/test/fuzztest/protocolhandlerwait_fuzzer/protocolhandlerwait_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..493b212435f970ec0a495eb82a341fbb4197e45c --- /dev/null +++ b/test/fuzztest/protocolhandlerwait_fuzzer/protocolhandlerwait_fuzzer.cpp @@ -0,0 +1,49 @@ +/* + * 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 "protocolhandlerwait_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/protocol_handler.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void ProtocolHandlerWaitFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + using ProtoHandler = const std::function; + ProtoHandler ph = [data, size](const void *d, [[maybe_unused]] const std::string &s) -> void { + d = data + size; + }; + ProtocolHandler handler(ph, vm); + handler.WaitForDebugger(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::ProtocolHandlerWaitFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/protocolhandlerwait_fuzzer/protocolhandlerwait_fuzzer.h b/test/fuzztest/protocolhandlerwait_fuzzer/protocolhandlerwait_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..f90f44e06d88508f9aeb231bb32ded40889a9f72 --- /dev/null +++ b/test/fuzztest/protocolhandlerwait_fuzzer/protocolhandlerwait_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "protocolhandlerwait_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesbreakpointparseid_fuzzer/BUILD.gn b/test/fuzztest/pttypesbreakpointparseid_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..fd9c290c5fa45c4d48b21ce0e5ba8e8ea7282984 --- /dev/null +++ b/test/fuzztest/pttypesbreakpointparseid_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesBreakpointParseIdFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/pttypesbreakpointparseid_fuzzer" + + sources = [ "pttypesbreakpointparseid_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesBreakpointParseIdFuzzTest" ] +} diff --git a/test/fuzztest/pttypesbreakpointparseid_fuzzer/corpus/init b/test/fuzztest/pttypesbreakpointparseid_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesbreakpointparseid_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesbreakpointparseid_fuzzer/project.xml b/test/fuzztest/pttypesbreakpointparseid_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesbreakpointparseid_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesbreakpointparseid_fuzzer/pttypesbreakpointparseid_fuzzer.cpp b/test/fuzztest/pttypesbreakpointparseid_fuzzer/pttypesbreakpointparseid_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..77fe9a7bb4d8b51756bbbd9581bb51f7a3682887 --- /dev/null +++ b/test/fuzztest/pttypesbreakpointparseid_fuzzer/pttypesbreakpointparseid_fuzzer.cpp @@ -0,0 +1,46 @@ +/* + * 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 "pttypesbreakpointparseid_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesBreakpointParseIdFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0) { + return; + } + BreakpointDetails details = { .line_ = size, .column_ = size, .url_ = std::string((const char*)data, size)}; + BreakpointId id = BreakpointDetails::ToString(details); + BreakpointDetails::ParseBreakpointId(id, &details); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesBreakpointParseIdFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesbreakpointparseid_fuzzer/pttypesbreakpointparseid_fuzzer.h b/test/fuzztest/pttypesbreakpointparseid_fuzzer/pttypesbreakpointparseid_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..5553c795fbaa52854eae900b4bd4b14758d85c8c --- /dev/null +++ b/test/fuzztest/pttypesbreakpointparseid_fuzzer/pttypesbreakpointparseid_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesbreakpointparseid_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesbreakpointtostring_fuzzer/BUILD.gn b/test/fuzztest/pttypesbreakpointtostring_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..7c4341eed177c237295e37f4087e6821ba2b74fa --- /dev/null +++ b/test/fuzztest/pttypesbreakpointtostring_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesBreakpointToStringFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/pttypesbreakpointtostring_fuzzer" + + sources = [ "pttypesbreakpointtostring_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesBreakpointToStringFuzzTest" ] +} diff --git a/test/fuzztest/pttypesbreakpointtostring_fuzzer/corpus/init b/test/fuzztest/pttypesbreakpointtostring_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesbreakpointtostring_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesbreakpointtostring_fuzzer/project.xml b/test/fuzztest/pttypesbreakpointtostring_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesbreakpointtostring_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesbreakpointtostring_fuzzer/pttypesbreakpointtostring_fuzzer.cpp b/test/fuzztest/pttypesbreakpointtostring_fuzzer/pttypesbreakpointtostring_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4283e2e0e6370c33457a6b351ed2cd8ebaca48ab --- /dev/null +++ b/test/fuzztest/pttypesbreakpointtostring_fuzzer/pttypesbreakpointtostring_fuzzer.cpp @@ -0,0 +1,45 @@ +/* + * 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 "pttypesbreakpointtostring_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesBreakpointToStringFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0) { + return; + } + BreakpointDetails details = { .line_ = size, .column_ = size, .url_ = std::string((const char*)data, size)}; + BreakpointId id = BreakpointDetails::ToString(details); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesBreakpointToStringFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesbreakpointtostring_fuzzer/pttypesbreakpointtostring_fuzzer.h b/test/fuzztest/pttypesbreakpointtostring_fuzzer/pttypesbreakpointtostring_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..e4f6f9432f69c4a8ffc845afa309e755fcb62762 --- /dev/null +++ b/test/fuzztest/pttypesbreakpointtostring_fuzzer/pttypesbreakpointtostring_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesbreakpointtostring_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetails_fuzzer/BUILD.gn b/test/fuzztest/pttypesexceptiondetails_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e63f82c86668181e79267c9006c55614bbd7eb28 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetails_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesExceptionDetailsFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/pttypesexceptiondetails_fuzzer" + + sources = [ "pttypesexceptiondetails_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesExceptionDetailsFuzzTest" ] +} diff --git a/test/fuzztest/pttypesexceptiondetails_fuzzer/corpus/init b/test/fuzztest/pttypesexceptiondetails_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetails_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetails_fuzzer/project.xml b/test/fuzztest/pttypesexceptiondetails_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetails_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetails_fuzzer/pttypesexceptiondetails_fuzzer.cpp b/test/fuzztest/pttypesexceptiondetails_fuzzer/pttypesexceptiondetails_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e6c510550197715085ce0e54d77e684aa2934ad0 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetails_fuzzer/pttypesexceptiondetails_fuzzer.cpp @@ -0,0 +1,45 @@ +/* + * 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 "pttypesexceptiondetails_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesExceptionDetailsFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + ExceptionDetails details; + + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesExceptionDetailsFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesexceptiondetails_fuzzer/pttypesexceptiondetails_fuzzer.h b/test/fuzztest/pttypesexceptiondetails_fuzzer/pttypesexceptiondetails_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..7b031a6b08018f07f51eff263ffe0d67d952e1db --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetails_fuzzer/pttypesexceptiondetails_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesexceptiondetails_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailscolumn_fuzzer/BUILD.gn b/test/fuzztest/pttypesexceptiondetailscolumn_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..121b4bfc6876410feec44dbb2d2a50fcae01675e --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailscolumn_fuzzer/BUILD.gn @@ -0,0 +1,42 @@ +# 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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesExceptionDetailsColumnFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = "//arkcompiler/toolchain/test/fuzztest/pttypesexceptiondetailscolumn_fuzzer" + + sources = [ "pttypesexceptiondetailscolumn_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesExceptionDetailsColumnFuzzTest" ] +} diff --git a/test/fuzztest/pttypesexceptiondetailscolumn_fuzzer/corpus/init b/test/fuzztest/pttypesexceptiondetailscolumn_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailscolumn_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailscolumn_fuzzer/project.xml b/test/fuzztest/pttypesexceptiondetailscolumn_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailscolumn_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailscolumn_fuzzer/pttypesexceptiondetailscolumn_fuzzer.cpp b/test/fuzztest/pttypesexceptiondetailscolumn_fuzzer/pttypesexceptiondetailscolumn_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7e27654e2ea1baef6be37ac75ef997799855d6db --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailscolumn_fuzzer/pttypesexceptiondetailscolumn_fuzzer.cpp @@ -0,0 +1,47 @@ +/* + * 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 "pttypesexceptiondetailscolumn_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesExceptionDetailsColumnFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + int line = (int)*data; + ExceptionDetails details; + details.SetColumn(line); + details.GetColumn(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesExceptionDetailsColumnFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesexceptiondetailscolumn_fuzzer/pttypesexceptiondetailscolumn_fuzzer.h b/test/fuzztest/pttypesexceptiondetailscolumn_fuzzer/pttypesexceptiondetailscolumn_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..74f3896ebe825ab2c0205e6034f4160714dcb6b8 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailscolumn_fuzzer/pttypesexceptiondetailscolumn_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesexceptiondetailscolumn_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailscreate_fuzzer/BUILD.gn b/test/fuzztest/pttypesexceptiondetailscreate_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..523a630504b44cd4c3b736847d0d6a40eb7d3fc2 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailscreate_fuzzer/BUILD.gn @@ -0,0 +1,42 @@ +# 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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesExceptionDetailsCreateFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = "//arkcompiler/toolchain/test/fuzztest/pttypesexceptiondetailscreate_fuzzer" + + sources = [ "pttypesexceptiondetailscreate_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesExceptionDetailsCreateFuzzTest" ] +} diff --git a/test/fuzztest/pttypesexceptiondetailscreate_fuzzer/corpus/init b/test/fuzztest/pttypesexceptiondetailscreate_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailscreate_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailscreate_fuzzer/project.xml b/test/fuzztest/pttypesexceptiondetailscreate_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailscreate_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailscreate_fuzzer/pttypesexceptiondetailscreate_fuzzer.cpp b/test/fuzztest/pttypesexceptiondetailscreate_fuzzer/pttypesexceptiondetailscreate_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7996ae3d266fa81d28769600f2e7ba13bd8c01c4 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailscreate_fuzzer/pttypesexceptiondetailscreate_fuzzer.cpp @@ -0,0 +1,50 @@ +/* + * 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 "pttypesexceptiondetailscreate_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesExceptionDetailsCreateFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + cJSON* cjson = cJSON_ParseWithLength((const char*)data, size); + if (cjson != NULL) { + PtJson pjson(cjson); + auto details = ExceptionDetails::Create(pjson); + cJSON_Delete(cjson); + } + + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesExceptionDetailsCreateFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesexceptiondetailscreate_fuzzer/pttypesexceptiondetailscreate_fuzzer.h b/test/fuzztest/pttypesexceptiondetailscreate_fuzzer/pttypesexceptiondetailscreate_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..da1493683fd81a9df7e203163aab8c52dd7337b7 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailscreate_fuzzer/pttypesexceptiondetailscreate_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesexceptiondetailscreate_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailsexception_fuzzer/BUILD.gn b/test/fuzztest/pttypesexceptiondetailsexception_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..fc8e4fe5f25e67afd3bc755c49fbfc593dd65e15 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsexception_fuzzer/BUILD.gn @@ -0,0 +1,42 @@ +# 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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesExceptionDetailsExceptionFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = "//arkcompiler/toolchain/test/fuzztest/pttypesexceptiondetailsexception_fuzzer" + + sources = [ "pttypesexceptiondetailsexception_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesExceptionDetailsExceptionFuzzTest" ] +} diff --git a/test/fuzztest/pttypesexceptiondetailsexception_fuzzer/corpus/init b/test/fuzztest/pttypesexceptiondetailsexception_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsexception_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailsexception_fuzzer/project.xml b/test/fuzztest/pttypesexceptiondetailsexception_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsexception_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailsexception_fuzzer/pttypesexceptiondetailsexception_fuzzer.cpp b/test/fuzztest/pttypesexceptiondetailsexception_fuzzer/pttypesexceptiondetailsexception_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dd3ffb2496ae8492491148e712e98661e6c29e9a --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsexception_fuzzer/pttypesexceptiondetailsexception_fuzzer.cpp @@ -0,0 +1,48 @@ +/* + * 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 "pttypesexceptiondetailsexception_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesExceptionDetailsExceptionFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + ExceptionDetails details; + std::unique_ptr obj = std::make_unique(); + details.SetException(std::move(obj)); + details.GetException(); + details.HasException(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesExceptionDetailsExceptionFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesexceptiondetailsexception_fuzzer/pttypesexceptiondetailsexception_fuzzer.h b/test/fuzztest/pttypesexceptiondetailsexception_fuzzer/pttypesexceptiondetailsexception_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..2e08012e062f23662f3beb11e34e7867acdcee90 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsexception_fuzzer/pttypesexceptiondetailsexception_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesexceptiondetailsexception_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailsexceptionid_fuzzer/BUILD.gn b/test/fuzztest/pttypesexceptiondetailsexceptionid_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9e559ac1d943b3e8afbffef6c333adfd215e71d4 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsexceptionid_fuzzer/BUILD.gn @@ -0,0 +1,42 @@ +# 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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesExceptionDetailsExceptionIdFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = "//arkcompiler/toolchain/test/fuzztest/pttypesexceptiondetailsexceptionid_fuzzer" + + sources = [ "pttypesexceptiondetailsexceptionid_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesExceptionDetailsExceptionIdFuzzTest" ] +} diff --git a/test/fuzztest/pttypesexceptiondetailsexceptionid_fuzzer/corpus/init b/test/fuzztest/pttypesexceptiondetailsexceptionid_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsexceptionid_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailsexceptionid_fuzzer/project.xml b/test/fuzztest/pttypesexceptiondetailsexceptionid_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsexceptionid_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailsexceptionid_fuzzer/pttypesexceptiondetailsexceptionid_fuzzer.cpp b/test/fuzztest/pttypesexceptiondetailsexceptionid_fuzzer/pttypesexceptiondetailsexceptionid_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4cd252a9da662c071db2612ed1be5252e42ebc93 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsexceptionid_fuzzer/pttypesexceptiondetailsexceptionid_fuzzer.cpp @@ -0,0 +1,47 @@ +/* + * 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 "pttypesexceptiondetailsexceptionid_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesExceptionDetailsExceptionIdFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + ExceptionDetails details; + int32_t id = (int32_t)*data; + details.SetExceptionId(id); + details.GetExceptionId(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesExceptionDetailsExceptionIdFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesexceptiondetailsexceptionid_fuzzer/pttypesexceptiondetailsexceptionid_fuzzer.h b/test/fuzztest/pttypesexceptiondetailsexceptionid_fuzzer/pttypesexceptiondetailsexceptionid_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..23a195e9577942c9225d35679db112ed1074b285 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsexceptionid_fuzzer/pttypesexceptiondetailsexceptionid_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesexceptiondetailsexceptionid_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailsexecutioncontextid_fuzzer/BUILD.gn b/test/fuzztest/pttypesexceptiondetailsexecutioncontextid_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..6733176eae580d44f41c43458388ef39817358a5 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsexecutioncontextid_fuzzer/BUILD.gn @@ -0,0 +1,42 @@ +# 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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesExceptionDetailsExecutionContextIdFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = "//arkcompiler/toolchain/test/fuzztest/pttypesexceptiondetailsexecutioncontextid_fuzzer" + + sources = [ "pttypesexceptiondetailsexecutioncontextid_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesExceptionDetailsExecutionContextIdFuzzTest" ] +} diff --git a/test/fuzztest/pttypesexceptiondetailsexecutioncontextid_fuzzer/corpus/init b/test/fuzztest/pttypesexceptiondetailsexecutioncontextid_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsexecutioncontextid_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailsexecutioncontextid_fuzzer/project.xml b/test/fuzztest/pttypesexceptiondetailsexecutioncontextid_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsexecutioncontextid_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailsexecutioncontextid_fuzzer/pttypesexceptiondetailsexecutioncontextid_fuzzer.cpp b/test/fuzztest/pttypesexceptiondetailsexecutioncontextid_fuzzer/pttypesexceptiondetailsexecutioncontextid_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ca7b1ea86c3080c813a8e14464c325897fdab61d --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsexecutioncontextid_fuzzer/pttypesexceptiondetailsexecutioncontextid_fuzzer.cpp @@ -0,0 +1,48 @@ +/* + * 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 "pttypesexceptiondetailsexecutioncontextid_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesExceptionDetailsExecutionContextIdFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + ExceptionDetails details; + ExecutionContextId id = (ExecutionContextId)*data; + details.SetExecutionContextId(id); + details.GetExecutionContextId(); + details.HasExecutionContextId(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesExceptionDetailsExecutionContextIdFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesexceptiondetailsexecutioncontextid_fuzzer/pttypesexceptiondetailsexecutioncontextid_fuzzer.h b/test/fuzztest/pttypesexceptiondetailsexecutioncontextid_fuzzer/pttypesexceptiondetailsexecutioncontextid_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..457fa4b2d08187cb00d87e68701cc700c4d8d59d --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsexecutioncontextid_fuzzer/pttypesexceptiondetailsexecutioncontextid_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesexceptiondetailsexecutioncontextid_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailsline_fuzzer/BUILD.gn b/test/fuzztest/pttypesexceptiondetailsline_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..96a4d50a2763b1854bda7ebe87fa1737e64e5107 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsline_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesExceptionDetailsLineFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/pttypesexceptiondetailsline_fuzzer" + + sources = [ "pttypesexceptiondetailsline_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesExceptionDetailsLineFuzzTest" ] +} diff --git a/test/fuzztest/pttypesexceptiondetailsline_fuzzer/corpus/init b/test/fuzztest/pttypesexceptiondetailsline_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsline_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailsline_fuzzer/project.xml b/test/fuzztest/pttypesexceptiondetailsline_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsline_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailsline_fuzzer/pttypesexceptiondetailsline_fuzzer.cpp b/test/fuzztest/pttypesexceptiondetailsline_fuzzer/pttypesexceptiondetailsline_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..34b5c4f6a7daaa51996ff28c61ddce65566917c4 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsline_fuzzer/pttypesexceptiondetailsline_fuzzer.cpp @@ -0,0 +1,47 @@ +/* + * 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 "pttypesexceptiondetailsline_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesExceptionDetailsLineFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + int line = (int) *data; + ExceptionDetails details; + details.SetLine(line); + details.GetLine(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesExceptionDetailsLineFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesexceptiondetailsline_fuzzer/pttypesexceptiondetailsline_fuzzer.h b/test/fuzztest/pttypesexceptiondetailsline_fuzzer/pttypesexceptiondetailsline_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..7d5e3847fef948732b814cbb2048703ee732743e --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsline_fuzzer/pttypesexceptiondetailsline_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesexceptiondetailsline_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailsscriptid_fuzzer/BUILD.gn b/test/fuzztest/pttypesexceptiondetailsscriptid_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e6526a4436f253f012e770d36dead7ebd4d8377e --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsscriptid_fuzzer/BUILD.gn @@ -0,0 +1,42 @@ +# 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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesExceptionDetailsScriptIdFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = "//arkcompiler/toolchain/test/fuzztest/pttypesexceptiondetailsscriptid_fuzzer" + + sources = [ "pttypesexceptiondetailsscriptid_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesExceptionDetailsScriptIdFuzzTest" ] +} diff --git a/test/fuzztest/pttypesexceptiondetailsscriptid_fuzzer/corpus/init b/test/fuzztest/pttypesexceptiondetailsscriptid_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsscriptid_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailsscriptid_fuzzer/project.xml b/test/fuzztest/pttypesexceptiondetailsscriptid_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsscriptid_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailsscriptid_fuzzer/pttypesexceptiondetailsscriptid_fuzzer.cpp b/test/fuzztest/pttypesexceptiondetailsscriptid_fuzzer/pttypesexceptiondetailsscriptid_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a8e568fc179ca667bf7b2de789e1733b6459f1e8 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsscriptid_fuzzer/pttypesexceptiondetailsscriptid_fuzzer.cpp @@ -0,0 +1,48 @@ +/* + * 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 "pttypesexceptiondetailsscriptid_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesExceptionDetailsScriptIdFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + ScriptId id = (ScriptId)*data; + ExceptionDetails details; + details.SetScriptId(id); + details.GetScriptId(); + details.HasScriptId(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesExceptionDetailsScriptIdFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesexceptiondetailsscriptid_fuzzer/pttypesexceptiondetailsscriptid_fuzzer.h b/test/fuzztest/pttypesexceptiondetailsscriptid_fuzzer/pttypesexceptiondetailsscriptid_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..517cd8f13b3c59ca28b541bb843a09e700442504 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsscriptid_fuzzer/pttypesexceptiondetailsscriptid_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesexceptiondetailsscriptid_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailstext_fuzzer/BUILD.gn b/test/fuzztest/pttypesexceptiondetailstext_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..77741d45087f3d3795d5e5ee9e4eb037f30b37d7 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailstext_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesExceptionDetailsTextFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/pttypesexceptiondetailstext_fuzzer" + + sources = [ "pttypesexceptiondetailstext_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesExceptionDetailsTextFuzzTest" ] +} diff --git a/test/fuzztest/pttypesexceptiondetailstext_fuzzer/corpus/init b/test/fuzztest/pttypesexceptiondetailstext_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailstext_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailstext_fuzzer/project.xml b/test/fuzztest/pttypesexceptiondetailstext_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailstext_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailstext_fuzzer/pttypesexceptiondetailstext_fuzzer.cpp b/test/fuzztest/pttypesexceptiondetailstext_fuzzer/pttypesexceptiondetailstext_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a7449f7a70351103d8bf333fe50d61221cb844d0 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailstext_fuzzer/pttypesexceptiondetailstext_fuzzer.cpp @@ -0,0 +1,46 @@ +/* + * 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 "pttypesexceptiondetailstext_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesExceptionDetailsTextFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + ExceptionDetails details; + details.SetText(std::string((const char*)data, size)); + details.GetText(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesExceptionDetailsTextFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesexceptiondetailstext_fuzzer/pttypesexceptiondetailstext_fuzzer.h b/test/fuzztest/pttypesexceptiondetailstext_fuzzer/pttypesexceptiondetailstext_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..a076d41dffdb9533d5f636e36af58fdfb36a5d52 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailstext_fuzzer/pttypesexceptiondetailstext_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesexceptiondetailstext_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailstojson_fuzzer/BUILD.gn b/test/fuzztest/pttypesexceptiondetailstojson_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8b90d1a732c260aaa000fbd9a6a83681e0f02685 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailstojson_fuzzer/BUILD.gn @@ -0,0 +1,42 @@ +# 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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesExceptionDetailsToJsonFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = "//arkcompiler/toolchain/test/fuzztest/pttypesexceptiondetailstojson_fuzzer" + + sources = [ "pttypesexceptiondetailstojson_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesExceptionDetailsToJsonFuzzTest" ] +} diff --git a/test/fuzztest/pttypesexceptiondetailstojson_fuzzer/corpus/init b/test/fuzztest/pttypesexceptiondetailstojson_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailstojson_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailstojson_fuzzer/project.xml b/test/fuzztest/pttypesexceptiondetailstojson_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailstojson_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailstojson_fuzzer/pttypesexceptiondetailstojson_fuzzer.cpp b/test/fuzztest/pttypesexceptiondetailstojson_fuzzer/pttypesexceptiondetailstojson_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..315db3fce29a89958f3c3dce65b794990cfe3583 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailstojson_fuzzer/pttypesexceptiondetailstojson_fuzzer.cpp @@ -0,0 +1,45 @@ +/* + * 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 "pttypesexceptiondetailstojson_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesExceptionDetailsToJsonFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + ExceptionDetails details; + auto pj = details.ToJson(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesExceptionDetailsToJsonFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesexceptiondetailstojson_fuzzer/pttypesexceptiondetailstojson_fuzzer.h b/test/fuzztest/pttypesexceptiondetailstojson_fuzzer/pttypesexceptiondetailstojson_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..dfa5affd3b1bad10a76a9b85b8cc085bd2162727 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailstojson_fuzzer/pttypesexceptiondetailstojson_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesexceptiondetailstojson_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailsurl_fuzzer/BUILD.gn b/test/fuzztest/pttypesexceptiondetailsurl_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f1dc9cf7424a5f52bbff4b43ac036cf322964956 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsurl_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesExceptionDetailsUrlFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/pttypesexceptiondetailsurl_fuzzer" + + sources = [ "pttypesexceptiondetailsurl_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesExceptionDetailsUrlFuzzTest" ] +} diff --git a/test/fuzztest/pttypesexceptiondetailsurl_fuzzer/corpus/init b/test/fuzztest/pttypesexceptiondetailsurl_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsurl_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailsurl_fuzzer/project.xml b/test/fuzztest/pttypesexceptiondetailsurl_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsurl_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesexceptiondetailsurl_fuzzer/pttypesexceptiondetailsurl_fuzzer.cpp b/test/fuzztest/pttypesexceptiondetailsurl_fuzzer/pttypesexceptiondetailsurl_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c78a8bd58997c1a1814396b39321b77eeefa8481 --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsurl_fuzzer/pttypesexceptiondetailsurl_fuzzer.cpp @@ -0,0 +1,47 @@ +/* + * 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 "pttypesexceptiondetailsurl_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesExceptionDetailsUrlFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + ExceptionDetails details; + details.SetUrl(std::string((const char*)data, size)); + details.GetUrl(); + details.HasUrl(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesExceptionDetailsUrlFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesexceptiondetailsurl_fuzzer/pttypesexceptiondetailsurl_fuzzer.h b/test/fuzztest/pttypesexceptiondetailsurl_fuzzer/pttypesexceptiondetailsurl_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..fa5d591ccedd3c3b7f2b630d9dc67f2948e7137a --- /dev/null +++ b/test/fuzztest/pttypesexceptiondetailsurl_fuzzer/pttypesexceptiondetailsurl_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesexceptiondetailsurl_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesfunctionremoteobject_fuzzer/BUILD.gn b/test/fuzztest/pttypesfunctionremoteobject_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d11bb07e230e3185ad87acd562e85e9511c04595 --- /dev/null +++ b/test/fuzztest/pttypesfunctionremoteobject_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesFunctionRemoteObjectFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/pttypesfunctionremoteobject_fuzzer" + + sources = [ "pttypesfunctionremoteobject_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesFunctionRemoteObjectFuzzTest" ] +} diff --git a/test/fuzztest/pttypesfunctionremoteobject_fuzzer/corpus/init b/test/fuzztest/pttypesfunctionremoteobject_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesfunctionremoteobject_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesfunctionremoteobject_fuzzer/project.xml b/test/fuzztest/pttypesfunctionremoteobject_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesfunctionremoteobject_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesfunctionremoteobject_fuzzer/pttypesfunctionremoteobject_fuzzer.cpp b/test/fuzztest/pttypesfunctionremoteobject_fuzzer/pttypesfunctionremoteobject_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..287b9cbb0499071d7ca0175d0ef523e6b7ae0702 --- /dev/null +++ b/test/fuzztest/pttypesfunctionremoteobject_fuzzer/pttypesfunctionremoteobject_fuzzer.cpp @@ -0,0 +1,45 @@ +/* + * 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 "pttypesfunctionremoteobject_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesFunctionRemoteObjectFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + Local exception = DebuggerApi::GetAndClearException(vm); + FunctionRemoteObject obj(vm, exception); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesFunctionRemoteObjectFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesfunctionremoteobject_fuzzer/pttypesfunctionremoteobject_fuzzer.h b/test/fuzztest/pttypesfunctionremoteobject_fuzzer/pttypesfunctionremoteobject_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..cd673c90f76ca02954180f6aac38dcd00ee36dfa --- /dev/null +++ b/test/fuzztest/pttypesfunctionremoteobject_fuzzer/pttypesfunctionremoteobject_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesfunctionremoteobject_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesgeneratorfunctionremoteobject_fuzzer/BUILD.gn b/test/fuzztest/pttypesgeneratorfunctionremoteobject_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..73e7c64381148fe26bf71f587a956dd621a4762d --- /dev/null +++ b/test/fuzztest/pttypesgeneratorfunctionremoteobject_fuzzer/BUILD.gn @@ -0,0 +1,42 @@ +# 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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesGeneratorFunctionRemoteObjectFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = "//arkcompiler/toolchain/test/fuzztest/pttypesgeneratorfunctionremoteobject_fuzzer" + + sources = [ "pttypesgeneratorfunctionremoteobject_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesGeneratorFunctionRemoteObjectFuzzTest" ] +} diff --git a/test/fuzztest/pttypesgeneratorfunctionremoteobject_fuzzer/corpus/init b/test/fuzztest/pttypesgeneratorfunctionremoteobject_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesgeneratorfunctionremoteobject_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesgeneratorfunctionremoteobject_fuzzer/project.xml b/test/fuzztest/pttypesgeneratorfunctionremoteobject_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesgeneratorfunctionremoteobject_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesgeneratorfunctionremoteobject_fuzzer/pttypesgeneratorfunctionremoteobject_fuzzer.cpp b/test/fuzztest/pttypesgeneratorfunctionremoteobject_fuzzer/pttypesgeneratorfunctionremoteobject_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9b37098bd072b5ee3dfc8257dd3da7e1030082d6 --- /dev/null +++ b/test/fuzztest/pttypesgeneratorfunctionremoteobject_fuzzer/pttypesgeneratorfunctionremoteobject_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 "pttypesgeneratorfunctionremoteobject_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesGeneratorFunctionRemoteObjectFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + GeneratorFunctionRemoteObject obj(vm, JSValueRef::Undefined(vm)); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesGeneratorFunctionRemoteObjectFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesgeneratorfunctionremoteobject_fuzzer/pttypesgeneratorfunctionremoteobject_fuzzer.h b/test/fuzztest/pttypesgeneratorfunctionremoteobject_fuzzer/pttypesgeneratorfunctionremoteobject_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..c28f5bc5eae1431d5f4a81e47b1d19f4e6509c79 --- /dev/null +++ b/test/fuzztest/pttypesgeneratorfunctionremoteobject_fuzzer/pttypesgeneratorfunctionremoteobject_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesgeneratorfunctionremoteobject_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesobjectremoteobject_fuzzer/BUILD.gn b/test/fuzztest/pttypesobjectremoteobject_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..32671cedb3fd286a294ec7a12785023cf1573b6e --- /dev/null +++ b/test/fuzztest/pttypesobjectremoteobject_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesObjectRemoteObjectFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/pttypesobjectremoteobject_fuzzer" + + sources = [ "pttypesobjectremoteobject_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesObjectRemoteObjectFuzzTest" ] +} diff --git a/test/fuzztest/pttypesobjectremoteobject_fuzzer/corpus/init b/test/fuzztest/pttypesobjectremoteobject_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesobjectremoteobject_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesobjectremoteobject_fuzzer/project.xml b/test/fuzztest/pttypesobjectremoteobject_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesobjectremoteobject_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesobjectremoteobject_fuzzer/pttypesobjectremoteobject_fuzzer.cpp b/test/fuzztest/pttypesobjectremoteobject_fuzzer/pttypesobjectremoteobject_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b713da6a0150325c126519c8dc28d5fb48c9264d --- /dev/null +++ b/test/fuzztest/pttypesobjectremoteobject_fuzzer/pttypesobjectremoteobject_fuzzer.cpp @@ -0,0 +1,47 @@ +/* + * 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 "pttypesobjectremoteobject_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesObjectRemoteObjectFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + ObjectRemoteObject obj(vm, StringRef::NewFromUtf8(vm, (const char*)data, size), + std::string((const char*)data, size)); + ObjectRemoteObject object(vm, StringRef::NewFromUtf8(vm, (const char*)data, size), + std::string((const char*)data, size), std::string((const char*)data, size)); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesObjectRemoteObjectFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesobjectremoteobject_fuzzer/pttypesobjectremoteobject_fuzzer.h b/test/fuzztest/pttypesobjectremoteobject_fuzzer/pttypesobjectremoteobject_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..583ad305643da4bf9b6a1fa4401937675afb9739 --- /dev/null +++ b/test/fuzztest/pttypesobjectremoteobject_fuzzer/pttypesobjectremoteobject_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesobjectremoteobject_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesprimitiveremoteobject_fuzzer/BUILD.gn b/test/fuzztest/pttypesprimitiveremoteobject_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0ab5b59841b633190c2ee36c5a0d9122f246800c --- /dev/null +++ b/test/fuzztest/pttypesprimitiveremoteobject_fuzzer/BUILD.gn @@ -0,0 +1,42 @@ +# 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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesPrimitiveRemoteObjectFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = "//arkcompiler/toolchain/test/fuzztest/pttypesprimitiveremoteobject_fuzzer" + + sources = [ "pttypesprimitiveremoteobject_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesPrimitiveRemoteObjectFuzzTest" ] +} diff --git a/test/fuzztest/pttypesprimitiveremoteobject_fuzzer/corpus/init b/test/fuzztest/pttypesprimitiveremoteobject_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesprimitiveremoteobject_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesprimitiveremoteobject_fuzzer/project.xml b/test/fuzztest/pttypesprimitiveremoteobject_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesprimitiveremoteobject_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesprimitiveremoteobject_fuzzer/pttypesprimitiveremoteobject_fuzzer.cpp b/test/fuzztest/pttypesprimitiveremoteobject_fuzzer/pttypesprimitiveremoteobject_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a3d2e19c656593c78beb409a7f2e1c7072527887 --- /dev/null +++ b/test/fuzztest/pttypesprimitiveremoteobject_fuzzer/pttypesprimitiveremoteobject_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 "pttypesprimitiveremoteobject_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesPrimitiveRemoteObjectFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + PrimitiveRemoteObject obj(vm, StringRef::NewFromUtf8(vm, (const char*)data, size)); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesPrimitiveRemoteObjectFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesprimitiveremoteobject_fuzzer/pttypesprimitiveremoteobject_fuzzer.h b/test/fuzztest/pttypesprimitiveremoteobject_fuzzer/pttypesprimitiveremoteobject_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..410426650e28dc215184bac9af3a9dda0c52e135 --- /dev/null +++ b/test/fuzztest/pttypesprimitiveremoteobject_fuzzer/pttypesprimitiveremoteobject_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesprimitiveremoteobject_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobject_fuzzer/BUILD.gn b/test/fuzztest/pttypesremoteobject_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..352f843e7ecc091a90e4f491d1d3fd3392b3a8d6 --- /dev/null +++ b/test/fuzztest/pttypesremoteobject_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesRemoteObjectFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/pttypesremoteobject_fuzzer" + + sources = [ "pttypesremoteobject_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesRemoteObjectFuzzTest" ] +} diff --git a/test/fuzztest/pttypesremoteobject_fuzzer/corpus/init b/test/fuzztest/pttypesremoteobject_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobject_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobject_fuzzer/project.xml b/test/fuzztest/pttypesremoteobject_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesremoteobject_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobject_fuzzer/pttypesremoteobject_fuzzer.cpp b/test/fuzztest/pttypesremoteobject_fuzzer/pttypesremoteobject_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9662e82343f5c5c0597d48fcc6050247eacf8987 --- /dev/null +++ b/test/fuzztest/pttypesremoteobject_fuzzer/pttypesremoteobject_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 "pttypesremoteobject_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesRemoteObjectFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + RemoteObject obj; + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesRemoteObjectFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesremoteobject_fuzzer/pttypesremoteobject_fuzzer.h b/test/fuzztest/pttypesremoteobject_fuzzer/pttypesremoteobject_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..8ef2e3f558bd0a5acd3b3c40141321da4fe535c1 --- /dev/null +++ b/test/fuzztest/pttypesremoteobject_fuzzer/pttypesremoteobject_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesremoteobject_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectdescription_fuzzer/BUILD.gn b/test/fuzztest/pttypesremoteobjectdescription_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..2dd58c2618c1374441a8d3304346b2ca19fb7af2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectdescription_fuzzer/BUILD.gn @@ -0,0 +1,42 @@ +# 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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesRemoteObjectDescriptionFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = "//arkcompiler/toolchain/test/fuzztest/pttypesremoteobjectdescription_fuzzer" + + sources = [ "pttypesremoteobjectdescription_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesRemoteObjectDescriptionFuzzTest" ] +} diff --git a/test/fuzztest/pttypesremoteobjectdescription_fuzzer/corpus/init b/test/fuzztest/pttypesremoteobjectdescription_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectdescription_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectdescription_fuzzer/project.xml b/test/fuzztest/pttypesremoteobjectdescription_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectdescription_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectdescription_fuzzer/pttypesremoteobjectdescription_fuzzer.cpp b/test/fuzztest/pttypesremoteobjectdescription_fuzzer/pttypesremoteobjectdescription_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e9540031a1f33c1d19601ecf2c96a4628792be9d --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectdescription_fuzzer/pttypesremoteobjectdescription_fuzzer.cpp @@ -0,0 +1,47 @@ +/* + * 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 "pttypesremoteobjectdescription_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesRemoteObjectDescriptionFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + RemoteObject obj; + obj.SetDescription(std::string((const char*)data, size)); + std::string des = obj.GetDescription(); + obj.HasDescription(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesRemoteObjectDescriptionFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesremoteobjectdescription_fuzzer/pttypesremoteobjectdescription_fuzzer.h b/test/fuzztest/pttypesremoteobjectdescription_fuzzer/pttypesremoteobjectdescription_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..65d77a2deb2aed3e19b35d9fe6b6ef7d0ab531b7 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectdescription_fuzzer/pttypesremoteobjectdescription_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesremoteobjectdescription_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectgetclassname_fuzzer/BUILD.gn b/test/fuzztest/pttypesremoteobjectgetclassname_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..fc4a574e71876b5d8df1a872163d613c99c6209c --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgetclassname_fuzzer/BUILD.gn @@ -0,0 +1,42 @@ +# 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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesRemoteObjectGetClassNameFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = "//arkcompiler/toolchain/test/fuzztest/pttypesremoteobjectgetclassname_fuzzer" + + sources = [ "pttypesremoteobjectgetclassname_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesRemoteObjectGetClassNameFuzzTest" ] +} diff --git a/test/fuzztest/pttypesremoteobjectgetclassname_fuzzer/corpus/init b/test/fuzztest/pttypesremoteobjectgetclassname_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgetclassname_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectgetclassname_fuzzer/project.xml b/test/fuzztest/pttypesremoteobjectgetclassname_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgetclassname_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectgetclassname_fuzzer/pttypesremoteobjectgetclassname_fuzzer.cpp b/test/fuzztest/pttypesremoteobjectgetclassname_fuzzer/pttypesremoteobjectgetclassname_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..79d5d46403c037f8bad988288eef61a426beb6e3 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgetclassname_fuzzer/pttypesremoteobjectgetclassname_fuzzer.cpp @@ -0,0 +1,46 @@ +/* + * 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 "pttypesremoteobjectgetclassname_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesRemoteObjectGetClassNameFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + RemoteObject obj; + obj.SetClassName(std::string((const char*)data, size)); + obj.GetClassName(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesRemoteObjectGetClassNameFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesremoteobjectgetclassname_fuzzer/pttypesremoteobjectgetclassname_fuzzer.h b/test/fuzztest/pttypesremoteobjectgetclassname_fuzzer/pttypesremoteobjectgetclassname_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..241909801155b28a451c3c4ec5af57042a942e6f --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgetclassname_fuzzer/pttypesremoteobjectgetclassname_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesremoteobjectgetclassname_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectgetsubtype_fuzzer/BUILD.gn b/test/fuzztest/pttypesremoteobjectgetsubtype_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b9a48473244e26db3bcf3b7a4ca665143ebfa83a --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgetsubtype_fuzzer/BUILD.gn @@ -0,0 +1,42 @@ +# 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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesRemoteObjectGetSubTypeFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = "//arkcompiler/toolchain/test/fuzztest/pttypesremoteobjectgetsubtype_fuzzer" + + sources = [ "pttypesremoteobjectgetsubtype_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesRemoteObjectGetSubTypeFuzzTest" ] +} diff --git a/test/fuzztest/pttypesremoteobjectgetsubtype_fuzzer/corpus/init b/test/fuzztest/pttypesremoteobjectgetsubtype_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgetsubtype_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectgetsubtype_fuzzer/project.xml b/test/fuzztest/pttypesremoteobjectgetsubtype_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgetsubtype_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectgetsubtype_fuzzer/pttypesremoteobjectgetsubtype_fuzzer.cpp b/test/fuzztest/pttypesremoteobjectgetsubtype_fuzzer/pttypesremoteobjectgetsubtype_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3ac620a772f0c5ce415f617c1b47a8c8160c22bd --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgetsubtype_fuzzer/pttypesremoteobjectgetsubtype_fuzzer.cpp @@ -0,0 +1,46 @@ +/* + * 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 "pttypesremoteobjectgetsubtype_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesRemoteObjectGetSubTypeFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + RemoteObject obj; + obj.SetSubType(std::string((const char*)data, size)); + std::string type = obj.GetSubType(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesRemoteObjectGetSubTypeFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesremoteobjectgetsubtype_fuzzer/pttypesremoteobjectgetsubtype_fuzzer.h b/test/fuzztest/pttypesremoteobjectgetsubtype_fuzzer/pttypesremoteobjectgetsubtype_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..db409ed0d2582dbd1092a9623b44b15ea732970f --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgetsubtype_fuzzer/pttypesremoteobjectgetsubtype_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesremoteobjectgetsubtype_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectgettype_fuzzer/BUILD.gn b/test/fuzztest/pttypesremoteobjectgettype_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1881707f258d01e20ad3553b1b057c3689f76f6e --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgettype_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesRemoteObjectGetTypeFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/pttypesremoteobjectgettype_fuzzer" + + sources = [ "pttypesremoteobjectgettype_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesRemoteObjectGetTypeFuzzTest" ] +} diff --git a/test/fuzztest/pttypesremoteobjectgettype_fuzzer/corpus/init b/test/fuzztest/pttypesremoteobjectgettype_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgettype_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectgettype_fuzzer/project.xml b/test/fuzztest/pttypesremoteobjectgettype_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgettype_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectgettype_fuzzer/pttypesremoteobjectgettype_fuzzer.cpp b/test/fuzztest/pttypesremoteobjectgettype_fuzzer/pttypesremoteobjectgettype_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c5f7d02d3b72ca3008e373e7e4fb2105ccc85a82 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgettype_fuzzer/pttypesremoteobjectgettype_fuzzer.cpp @@ -0,0 +1,45 @@ +/* + * 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 "pttypesremoteobjectgettype_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesRemoteObjectGetTypeFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + RemoteObject obj; + std::string type = obj.GetType(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesRemoteObjectGetTypeFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesremoteobjectgettype_fuzzer/pttypesremoteobjectgettype_fuzzer.h b/test/fuzztest/pttypesremoteobjectgettype_fuzzer/pttypesremoteobjectgettype_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..331bf907a1767ec5996971e9a76e028b88141fe1 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgettype_fuzzer/pttypesremoteobjectgettype_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesremoteobjectgettype_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectgetvalue_fuzzer/BUILD.gn b/test/fuzztest/pttypesremoteobjectgetvalue_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0ac9788313f03fa1d8098e44d778b6f59114d0d2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgetvalue_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesRemoteObjectGetValueFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/pttypesremoteobjectgetvalue_fuzzer" + + sources = [ "pttypesremoteobjectgetvalue_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesRemoteObjectGetValueFuzzTest" ] +} diff --git a/test/fuzztest/pttypesremoteobjectgetvalue_fuzzer/corpus/init b/test/fuzztest/pttypesremoteobjectgetvalue_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgetvalue_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectgetvalue_fuzzer/project.xml b/test/fuzztest/pttypesremoteobjectgetvalue_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgetvalue_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectgetvalue_fuzzer/pttypesremoteobjectgetvalue_fuzzer.cpp b/test/fuzztest/pttypesremoteobjectgetvalue_fuzzer/pttypesremoteobjectgetvalue_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..761a78d2a61558674a2a4994606eb1115075df7d --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgetvalue_fuzzer/pttypesremoteobjectgetvalue_fuzzer.cpp @@ -0,0 +1,49 @@ +/* + * 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 "pttypesremoteobjectgetvalue_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesRemoteObjectGetValueFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + RemoteObject obj; + Local val = JSValueRef::Undefined(vm); + obj.SetValue(val); + Local ref = obj.GetValue(); + ref.IsEmpty(); + obj.HasValue(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesRemoteObjectGetValueFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesremoteobjectgetvalue_fuzzer/pttypesremoteobjectgetvalue_fuzzer.h b/test/fuzztest/pttypesremoteobjectgetvalue_fuzzer/pttypesremoteobjectgetvalue_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..1ab4d41a747ae3370115bb69a49964d9389efebd --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectgetvalue_fuzzer/pttypesremoteobjectgetvalue_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesremoteobjectgetvalue_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjecthasclassname_fuzzer/BUILD.gn b/test/fuzztest/pttypesremoteobjecthasclassname_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..48f8875659b3652687b99053e7030e5d8051df70 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjecthasclassname_fuzzer/BUILD.gn @@ -0,0 +1,42 @@ +# 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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesRemoteObjectHasClassNameFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = "//arkcompiler/toolchain/test/fuzztest/pttypesremoteobjecthasclassname_fuzzer" + + sources = [ "pttypesremoteobjecthasclassname_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesRemoteObjectHasClassNameFuzzTest" ] +} diff --git a/test/fuzztest/pttypesremoteobjecthasclassname_fuzzer/corpus/init b/test/fuzztest/pttypesremoteobjecthasclassname_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjecthasclassname_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjecthasclassname_fuzzer/project.xml b/test/fuzztest/pttypesremoteobjecthasclassname_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjecthasclassname_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjecthasclassname_fuzzer/pttypesremoteobjecthasclassname_fuzzer.cpp b/test/fuzztest/pttypesremoteobjecthasclassname_fuzzer/pttypesremoteobjecthasclassname_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f560041e399c9f45255e71e9818acf1740b89d7a --- /dev/null +++ b/test/fuzztest/pttypesremoteobjecthasclassname_fuzzer/pttypesremoteobjecthasclassname_fuzzer.cpp @@ -0,0 +1,45 @@ +/* + * 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 "pttypesremoteobjecthasclassname_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesRemoteObjectHasClassNameFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + RemoteObject obj; + obj.HasClassName(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesRemoteObjectHasClassNameFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesremoteobjecthasclassname_fuzzer/pttypesremoteobjecthasclassname_fuzzer.h b/test/fuzztest/pttypesremoteobjecthasclassname_fuzzer/pttypesremoteobjecthasclassname_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..670a30ab107461532058d16fb42f2bafe1d6cb8e --- /dev/null +++ b/test/fuzztest/pttypesremoteobjecthasclassname_fuzzer/pttypesremoteobjecthasclassname_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesremoteobjecthasclassname_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjecthassubtype_fuzzer/BUILD.gn b/test/fuzztest/pttypesremoteobjecthassubtype_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..df06c5aad33a9003503925a88c0951755d867ee6 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjecthassubtype_fuzzer/BUILD.gn @@ -0,0 +1,42 @@ +# 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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesRemoteObjectHasSubTypeFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = "//arkcompiler/toolchain/test/fuzztest/pttypesremoteobjecthassubtype_fuzzer" + + sources = [ "pttypesremoteobjecthassubtype_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesRemoteObjectHasSubTypeFuzzTest" ] +} diff --git a/test/fuzztest/pttypesremoteobjecthassubtype_fuzzer/corpus/init b/test/fuzztest/pttypesremoteobjecthassubtype_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjecthassubtype_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjecthassubtype_fuzzer/project.xml b/test/fuzztest/pttypesremoteobjecthassubtype_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjecthassubtype_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjecthassubtype_fuzzer/pttypesremoteobjecthassubtype_fuzzer.cpp b/test/fuzztest/pttypesremoteobjecthassubtype_fuzzer/pttypesremoteobjecthassubtype_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d34ce6e569ef2c0ab76ac4ac99f3101de813c5ab --- /dev/null +++ b/test/fuzztest/pttypesremoteobjecthassubtype_fuzzer/pttypesremoteobjecthassubtype_fuzzer.cpp @@ -0,0 +1,45 @@ +/* + * 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 "pttypesremoteobjecthassubtype_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesRemoteObjectHasSubTypeFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + RemoteObject obj; + obj.HasSubType(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesRemoteObjectHasSubTypeFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesremoteobjecthassubtype_fuzzer/pttypesremoteobjecthassubtype_fuzzer.h b/test/fuzztest/pttypesremoteobjecthassubtype_fuzzer/pttypesremoteobjecthassubtype_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..5b2b8cec4c494cb20368beeded9b177d47d3bc85 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjecthassubtype_fuzzer/pttypesremoteobjecthassubtype_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesremoteobjecthassubtype_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectobjectid_fuzzer/BUILD.gn b/test/fuzztest/pttypesremoteobjectobjectid_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1ace860a63fcf66eb41331afb8e94a60b0ecf9df --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectobjectid_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesRemoteObjectObjectIdFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/pttypesremoteobjectobjectid_fuzzer" + + sources = [ "pttypesremoteobjectobjectid_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesRemoteObjectObjectIdFuzzTest" ] +} diff --git a/test/fuzztest/pttypesremoteobjectobjectid_fuzzer/corpus/init b/test/fuzztest/pttypesremoteobjectobjectid_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectobjectid_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectobjectid_fuzzer/project.xml b/test/fuzztest/pttypesremoteobjectobjectid_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectobjectid_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectobjectid_fuzzer/pttypesremoteobjectobjectid_fuzzer.cpp b/test/fuzztest/pttypesremoteobjectobjectid_fuzzer/pttypesremoteobjectobjectid_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..acc9b5df3a5b9c51ea194436aaffd568ace2189b --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectobjectid_fuzzer/pttypesremoteobjectobjectid_fuzzer.cpp @@ -0,0 +1,48 @@ +/* + * 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 "pttypesremoteobjectobjectid_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesRemoteObjectObjectIdFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + RemoteObject obj; + RemoteObjectId id = (RemoteObjectId)*data; + obj.SetObjectId(id); + id = obj.GetObjectId(); + obj.HasObjectId(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesRemoteObjectObjectIdFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesremoteobjectobjectid_fuzzer/pttypesremoteobjectobjectid_fuzzer.h b/test/fuzztest/pttypesremoteobjectobjectid_fuzzer/pttypesremoteobjectobjectid_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..963bc056fa4cdadc8f13f005023ad191746502d2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectobjectid_fuzzer/pttypesremoteobjectobjectid_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesremoteobjectobjectid_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectsetclassname_fuzzer/BUILD.gn b/test/fuzztest/pttypesremoteobjectsetclassname_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..da25a1d4aaf8681bd9825cf3fc0a38d6ba9f4cc0 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsetclassname_fuzzer/BUILD.gn @@ -0,0 +1,42 @@ +# 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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesRemoteObjectSetClassNameFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = "//arkcompiler/toolchain/test/fuzztest/pttypesremoteobjectsetclassname_fuzzer" + + sources = [ "pttypesremoteobjectsetclassname_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesRemoteObjectSetClassNameFuzzTest" ] +} diff --git a/test/fuzztest/pttypesremoteobjectsetclassname_fuzzer/corpus/init b/test/fuzztest/pttypesremoteobjectsetclassname_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsetclassname_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectsetclassname_fuzzer/project.xml b/test/fuzztest/pttypesremoteobjectsetclassname_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsetclassname_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectsetclassname_fuzzer/pttypesremoteobjectsetclassname_fuzzer.cpp b/test/fuzztest/pttypesremoteobjectsetclassname_fuzzer/pttypesremoteobjectsetclassname_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..04321ac6c0f66b33dcf25b49e8a4584834053fe6 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsetclassname_fuzzer/pttypesremoteobjectsetclassname_fuzzer.cpp @@ -0,0 +1,45 @@ +/* + * 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 "pttypesremoteobjectsetclassname_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesRemoteObjectSetClassNameFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + RemoteObject obj; + obj.SetClassName(std::string((const char*)data, size)); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesRemoteObjectSetClassNameFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesremoteobjectsetclassname_fuzzer/pttypesremoteobjectsetclassname_fuzzer.h b/test/fuzztest/pttypesremoteobjectsetclassname_fuzzer/pttypesremoteobjectsetclassname_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..0b17091e7168cecc7c415ba2b5eac3e5afe52c33 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsetclassname_fuzzer/pttypesremoteobjectsetclassname_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesremoteobjectsetclassname_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectsetsubtype_fuzzer/BUILD.gn b/test/fuzztest/pttypesremoteobjectsetsubtype_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c8c56abe6815b7ab954365ae41085dc0bbfc5e92 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsetsubtype_fuzzer/BUILD.gn @@ -0,0 +1,42 @@ +# 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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesRemoteObjectSetSubTypeFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = "//arkcompiler/toolchain/test/fuzztest/pttypesremoteobjectsetsubtype_fuzzer" + + sources = [ "pttypesremoteobjectsetsubtype_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesRemoteObjectSetSubTypeFuzzTest" ] +} diff --git a/test/fuzztest/pttypesremoteobjectsetsubtype_fuzzer/corpus/init b/test/fuzztest/pttypesremoteobjectsetsubtype_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsetsubtype_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectsetsubtype_fuzzer/project.xml b/test/fuzztest/pttypesremoteobjectsetsubtype_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsetsubtype_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectsetsubtype_fuzzer/pttypesremoteobjectsetsubtype_fuzzer.cpp b/test/fuzztest/pttypesremoteobjectsetsubtype_fuzzer/pttypesremoteobjectsetsubtype_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..10303309893161efde24c4f6912a44d687e01030 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsetsubtype_fuzzer/pttypesremoteobjectsetsubtype_fuzzer.cpp @@ -0,0 +1,45 @@ +/* + * 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 "pttypesremoteobjectsetsubtype_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesRemoteObjectSetSubTypeFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + RemoteObject obj; + obj.SetSubType(std::string((const char*)data, size)); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesRemoteObjectSetSubTypeFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesremoteobjectsetsubtype_fuzzer/pttypesremoteobjectsetsubtype_fuzzer.h b/test/fuzztest/pttypesremoteobjectsetsubtype_fuzzer/pttypesremoteobjectsetsubtype_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..ba7cfcb1f62cdb7dd0b377fc11db37959d9bb904 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsetsubtype_fuzzer/pttypesremoteobjectsetsubtype_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesremoteobjectsetsubtype_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectsettype_fuzzer/BUILD.gn b/test/fuzztest/pttypesremoteobjectsettype_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d8f465875b6c240d0d01c222621d8be10e3f10b2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsettype_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesRemoteObjectSetTypeFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/pttypesremoteobjectsettype_fuzzer" + + sources = [ "pttypesremoteobjectsettype_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesRemoteObjectSetTypeFuzzTest" ] +} diff --git a/test/fuzztest/pttypesremoteobjectsettype_fuzzer/corpus/init b/test/fuzztest/pttypesremoteobjectsettype_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsettype_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectsettype_fuzzer/project.xml b/test/fuzztest/pttypesremoteobjectsettype_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsettype_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectsettype_fuzzer/pttypesremoteobjectsettype_fuzzer.cpp b/test/fuzztest/pttypesremoteobjectsettype_fuzzer/pttypesremoteobjectsettype_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bf0fcbdbc9ab2e06c7b2097fe45ce642f732a4f6 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsettype_fuzzer/pttypesremoteobjectsettype_fuzzer.cpp @@ -0,0 +1,45 @@ +/* + * 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 "pttypesremoteobjectsettype_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesRemoteObjectSetTypeFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + RemoteObject obj; + obj.SetType(std::string((const char*)data, size)); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesRemoteObjectSetTypeFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesremoteobjectsettype_fuzzer/pttypesremoteobjectsettype_fuzzer.h b/test/fuzztest/pttypesremoteobjectsettype_fuzzer/pttypesremoteobjectsettype_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..ef47676686538b399474f1d46b576ca6589f2b03 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsettype_fuzzer/pttypesremoteobjectsettype_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesremoteobjectsettype_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectsetvalue_fuzzer/BUILD.gn b/test/fuzztest/pttypesremoteobjectsetvalue_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c6692999776c18544602f8c70add4a1c7e45352d --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsetvalue_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesRemoteObjectSetValueFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/pttypesremoteobjectsetvalue_fuzzer" + + sources = [ "pttypesremoteobjectsetvalue_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesRemoteObjectSetValueFuzzTest" ] +} diff --git a/test/fuzztest/pttypesremoteobjectsetvalue_fuzzer/corpus/init b/test/fuzztest/pttypesremoteobjectsetvalue_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsetvalue_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectsetvalue_fuzzer/project.xml b/test/fuzztest/pttypesremoteobjectsetvalue_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsetvalue_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectsetvalue_fuzzer/pttypesremoteobjectsetvalue_fuzzer.cpp b/test/fuzztest/pttypesremoteobjectsetvalue_fuzzer/pttypesremoteobjectsetvalue_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..95f67506b704f488f87828434d383ac608f620a6 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsetvalue_fuzzer/pttypesremoteobjectsetvalue_fuzzer.cpp @@ -0,0 +1,46 @@ +/* + * 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 "pttypesremoteobjectsetvalue_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesRemoteObjectSetValueFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + RemoteObject obj; + Local val = JSValueRef::Undefined(vm); + obj.SetValue(val); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesRemoteObjectSetValueFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesremoteobjectsetvalue_fuzzer/pttypesremoteobjectsetvalue_fuzzer.h b/test/fuzztest/pttypesremoteobjectsetvalue_fuzzer/pttypesremoteobjectsetvalue_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..297025bedd4134e57559870e3346825e7a52514e --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectsetvalue_fuzzer/pttypesremoteobjectsetvalue_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesremoteobjectsetvalue_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectunserializablevalue_fuzzer/BUILD.gn b/test/fuzztest/pttypesremoteobjectunserializablevalue_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d504b36a12724502dd53af37de51dc0ad3304c69 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectunserializablevalue_fuzzer/BUILD.gn @@ -0,0 +1,42 @@ +# 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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesRemoteObjectUnserializableValueFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = "//arkcompiler/toolchain/test/fuzztest/pttypesremoteobjectunserializablevalue_fuzzer" + + sources = [ "pttypesremoteobjectunserializablevalue_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesRemoteObjectUnserializableValueFuzzTest" ] +} diff --git a/test/fuzztest/pttypesremoteobjectunserializablevalue_fuzzer/corpus/init b/test/fuzztest/pttypesremoteobjectunserializablevalue_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectunserializablevalue_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectunserializablevalue_fuzzer/project.xml b/test/fuzztest/pttypesremoteobjectunserializablevalue_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectunserializablevalue_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesremoteobjectunserializablevalue_fuzzer/pttypesremoteobjectunserializablevalue_fuzzer.cpp b/test/fuzztest/pttypesremoteobjectunserializablevalue_fuzzer/pttypesremoteobjectunserializablevalue_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bdb58e7bdff00f60f6a2986b5ccd2a7901a3deb2 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectunserializablevalue_fuzzer/pttypesremoteobjectunserializablevalue_fuzzer.cpp @@ -0,0 +1,48 @@ +/* + * 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 "pttypesremoteobjectunserializablevalue_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesRemoteObjectUnserializableValueFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + RemoteObject obj; + UnserializableValue val((const char*)data, size); + obj.SetUnserializableValue(val); + obj.GetUnserializableValue(); + obj.HasUnserializableValue(); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesRemoteObjectUnserializableValueFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesremoteobjectunserializablevalue_fuzzer/pttypesremoteobjectunserializablevalue_fuzzer.h b/test/fuzztest/pttypesremoteobjectunserializablevalue_fuzzer/pttypesremoteobjectunserializablevalue_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..5492fb17f71ae16756ef0332bb1896952eefa970 --- /dev/null +++ b/test/fuzztest/pttypesremoteobjectunserializablevalue_fuzzer/pttypesremoteobjectunserializablevalue_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesremoteobjectunserializablevalue_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypesstringremoteobject_fuzzer/BUILD.gn b/test/fuzztest/pttypesstringremoteobject_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c52ea08bb630b3e13e571f2217210031259aaf20 --- /dev/null +++ b/test/fuzztest/pttypesstringremoteobject_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesStringRemoteObjectFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/pttypesstringremoteobject_fuzzer" + + sources = [ "pttypesstringremoteobject_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesStringRemoteObjectFuzzTest" ] +} diff --git a/test/fuzztest/pttypesstringremoteobject_fuzzer/corpus/init b/test/fuzztest/pttypesstringremoteobject_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypesstringremoteobject_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypesstringremoteobject_fuzzer/project.xml b/test/fuzztest/pttypesstringremoteobject_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypesstringremoteobject_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypesstringremoteobject_fuzzer/pttypesstringremoteobject_fuzzer.cpp b/test/fuzztest/pttypesstringremoteobject_fuzzer/pttypesstringremoteobject_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e2243648a17f47cfb992c399338d5cc27ec3df4e --- /dev/null +++ b/test/fuzztest/pttypesstringremoteobject_fuzzer/pttypesstringremoteobject_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 "pttypesstringremoteobject_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesStringRemoteObjectFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + StringRemoteObject obj(vm, StringRef::NewFromUtf8(vm, (const char*)data, size)); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesStringRemoteObjectFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypesstringremoteobject_fuzzer/pttypesstringremoteobject_fuzzer.h b/test/fuzztest/pttypesstringremoteobject_fuzzer/pttypesstringremoteobject_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..e0f2e310879fc2b472eb22396869d20ee76b577d --- /dev/null +++ b/test/fuzztest/pttypesstringremoteobject_fuzzer/pttypesstringremoteobject_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypesstringremoteobject_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/pttypessymbolremoteobject_fuzzer/BUILD.gn b/test/fuzztest/pttypessymbolremoteobject_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..560a24d51f9044f4858f3a764de021de452cfb5a --- /dev/null +++ b/test/fuzztest/pttypessymbolremoteobject_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/toolchain/test/test_helper.gni") +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##################################fuzztest##################################### +ohos_fuzztest("PtTypesSymbolRemoteObjectFuzzTest") { + module_out_path = "arkcompiler/toolchain" + + fuzz_config_file = + "//arkcompiler/toolchain/test/fuzztest/pttypessymbolremoteobject_fuzzer" + + sources = [ "pttypessymbolremoteobject_fuzzer.cpp" ] + + configs = [ "//arkcompiler/toolchain:toolchain_test_config" ] + + deps = [ + "//arkcompiler/ets_runtime:libark_jsruntime", + "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + sdk_libc_secshared_dep, + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":PtTypesSymbolRemoteObjectFuzzTest" ] +} diff --git a/test/fuzztest/pttypessymbolremoteobject_fuzzer/corpus/init b/test/fuzztest/pttypessymbolremoteobject_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..b9a20c8eb6a74b442cec3b244a433adbfa9414a2 --- /dev/null +++ b/test/fuzztest/pttypessymbolremoteobject_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/pttypessymbolremoteobject_fuzzer/project.xml b/test/fuzztest/pttypessymbolremoteobject_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7de9064465d473bb8e10fc88f0764eaad2d6112 --- /dev/null +++ b/test/fuzztest/pttypessymbolremoteobject_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/pttypessymbolremoteobject_fuzzer/pttypessymbolremoteobject_fuzzer.cpp b/test/fuzztest/pttypessymbolremoteobject_fuzzer/pttypessymbolremoteobject_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d64368c0ccc2074a43e8b719c96734f27604fea7 --- /dev/null +++ b/test/fuzztest/pttypessymbolremoteobject_fuzzer/pttypessymbolremoteobject_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 "pttypessymbolremoteobject_fuzzer.h" +#include "ecmascript/napi/include/jsnapi.h" +#include "tooling/base/pt_types.h" + +using namespace panda; +using namespace panda::ecmascript; +using namespace panda::ecmascript::tooling; + +namespace OHOS { + void PtTypesSymbolRemoteObjectFuzzTest(const uint8_t* data, size_t size) + { + RuntimeOption option; + option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + auto vm = JSNApi::CreateJSVM(option); + if (size <= 0 || data == NULL) { + return; + } + SymbolRemoteObject obj(vm, SymbolRef::New(vm, StringRef::NewFromUtf8(vm, (const char*)data, size))); + JSNApi::DestroyJSVM(vm); + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::PtTypesSymbolRemoteObjectFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/pttypessymbolremoteobject_fuzzer/pttypessymbolremoteobject_fuzzer.h b/test/fuzztest/pttypessymbolremoteobject_fuzzer/pttypessymbolremoteobject_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..f8a4373c1c629f19f1064504321111455eddbd13 --- /dev/null +++ b/test/fuzztest/pttypessymbolremoteobject_fuzzer/pttypessymbolremoteobject_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 PROTOCOLHANDLER_FUZZER_H +#define PROTOCOLHANDLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "pttypessymbolremoteobject_fuzzer" + +#endif \ No newline at end of file