From 98b8cd2296b319eeb7c2c6d945a933fdcfe8240b Mon Sep 17 00:00:00 2001 From: wangchaole Date: Sun, 24 Apr 2022 17:12:31 +0800 Subject: [PATCH 1/7] add fuzztest Signed-off-by: wangchaole --- bundle.json | 3 +- .../native_cpp/test/fuzztest/BUILD.gn | 24 ++++++ .../dcamerasinkhandleripc_fuzzer/BUILD.gn | 79 +++++++++++++++++++ .../dcamerasinkhandleripc_fuzzer/corpus/init | 14 ++++ .../dcamera_sink_handler_ipc_fuzzer.cpp | 55 +++++++++++++ .../dcamera_sink_handler_ipc_fuzzer.h | 21 +++++ .../dcamerasinkhandleripc_fuzzer/project.xml | 25 ++++++ .../dcamerasinkloadcallback_fuzzer/BUILD.gn | 73 +++++++++++++++++ .../corpus/init | 14 ++++ .../dcamera_sink_load_callback_fuzzer.cpp | 56 +++++++++++++ .../dcamera_sink_load_callback_fuzzer.h | 22 ++++++ .../project.xml | 25 ++++++ .../fuzztest/dcamerasinkproxy_fuzzer/BUILD.gn | 71 +++++++++++++++++ .../dcamerasinkproxy_fuzzer/corpus/init | 14 ++++ .../dcamera_sink_proxy_fuzzer.cpp | 65 +++++++++++++++ .../dcamera_sink_proxy_fuzzer.h | 21 +++++ .../dcamerasinkproxy_fuzzer/project.xml | 25 ++++++ .../dcamerasourcehandleripc_fuzzer/BUILD.gn | 78 ++++++++++++++++++ .../corpus/init | 14 ++++ .../dcamera_source_handler_ipc_fuzzer.cpp | 53 +++++++++++++ .../dcamera_source_handler_ipc_fuzzer.h | 21 +++++ .../project.xml | 25 ++++++ .../dcamerasourceloadcallback_fuzzer/BUILD.gn | 74 +++++++++++++++++ .../corpus/init | 1 + .../dcamera_source_load_callback_fuzzer.cpp | 52 ++++++++++++ .../dcamera_source_load_callback_fuzzer.h | 24 ++++++ .../project.xml | 25 ++++++ 27 files changed, 973 insertions(+), 1 deletion(-) create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/BUILD.gn create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/corpus/init create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/dcamera_sink_handler_ipc_fuzzer.cpp create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/dcamera_sink_handler_ipc_fuzzer.h create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/project.xml create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/BUILD.gn create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/corpus/init create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/dcamera_sink_load_callback_fuzzer.cpp create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/dcamera_sink_load_callback_fuzzer.h create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/project.xml create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/BUILD.gn create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/corpus/init create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/dcamera_sink_proxy_fuzzer.cpp create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/dcamera_sink_proxy_fuzzer.h create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/project.xml create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/BUILD.gn create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/corpus/init create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/dcamera_source_handler_ipc_fuzzer.cpp create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/dcamera_source_handler_ipc_fuzzer.h create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/project.xml create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/BUILD.gn create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/corpus/init create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/dcamera_source_load_callback_fuzzer.cpp create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/dcamera_source_load_callback_fuzzer.h create mode 100644 interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/project.xml diff --git a/bundle.json b/bundle.json index 1450c5d7..88b29c98 100644 --- a/bundle.json +++ b/bundle.json @@ -90,7 +90,8 @@ "//foundation/distributedhardware/distributedcamera/services/cameraservice/cameraoperator/handler/test/unittest:camera_handler_test", "//foundation/distributedhardware/distributedcamera/services/cameraservice/sinkservice/test/unittest:sink_service_test", "//foundation/distributedhardware/distributedcamera/services/cameraservice/sourceservice/test/unittest:source_service_test", - "//foundation/distributedhardware/distributedcamera/services/cameraservice/base/test/unittest:services_base_test" + "//foundation/distributedhardware/distributedcamera/services/cameraservice/base/test/unittest:services_base_test", + "//foundation/distributedhardware/distributedcamera/interfaces/inner_kits/native_cpp/test/fuzztest:fuzztest" ] } } diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn new file mode 100644 index 00000000..e077d859 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn @@ -0,0 +1,24 @@ +# 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. + +group("fuzztest") { + testonly = true + + deps = [ + "dcamerasinkhandleripc_fuzzer:fuzztest", + "dcamerasinkloadcallback_fuzzer:fuzztest", + "dcamerasinkproxy_fuzzer:fuzztest", + "dcamerasourcehandleripc_fuzzer:fuzztest", + "dcamerasourceloadcallback_fuzzer:fuzztest", + ] +} \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/BUILD.gn new file mode 100644 index 00000000..a69e5202 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/BUILD.gn @@ -0,0 +1,79 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributedcamera/distributedcamera.gni") +##############################fuzztest########################################## +ohos_fuzztest("DCameraSinkHandlerIpcFuzzTest") { + module_out_path = "distributed_camera/dcamerasinkhandleripc" + + fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer" + + include_dirs = [ + "//utils/native/base/include", + "//utils/system/safwk/native/include", + "${fwk_utils_path}/include/log", + "${fwk_utils_path}/include", + "${fwk_common_path}/log/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "${common_path}/include", + "${innerkits_path}/native_cpp/camera_sink/include", + "//foundation/distributedhardware/distributedcamera/common/include/constants", + "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "dcamera_sink_handler_ipc_fuzzer.cpp", + ] + + deps = [ + "${fwk_utils_path}:distributedhardwareutils", + "${innerkits_path}/native_cpp/camera_sink:distributed_camera_sink_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"DCameraSinkHandlerIpcFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] + +} +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":DCameraSinkHandlerIpcFuzzTest" ] + +} +############################################################################### \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/corpus/init new file mode 100644 index 00000000..bc977bd9 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/dcamera_sink_handler_ipc_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/dcamera_sink_handler_ipc_fuzzer.cpp new file mode 100644 index 00000000..e7c4a52e --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/dcamera_sink_handler_ipc_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * 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. + */ + +#include "dcamera_sink_handler_ipc_fuzzer.h" + +#include +#include + +#include "distributed_camera_constants.h" +#include "dcamera_sink_handler.h" +#include "dcamera_sink_handler_ipc.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +namespace OHOS { +namespace DistributedHardware { +void DCameraSinkHandlerIpcFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); + wptr remote (remoteObject); + + DCameraSinkHandlerIpc::GetInstance().Init(); + DCameraSinkHandlerIpc::GetInstance().GetSinkLocalDHMS(); + DCameraSinkHandlerIpc::GetInstance().OnSinkLocalDmsDied(remote); + DCameraSinkHandlerIpc::GetInstance().UnInit(); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::DCameraSinkHandlerIpcFuzzTest(data, size); + return 0; +} + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/dcamera_sink_handler_ipc_fuzzer.h b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/dcamera_sink_handler_ipc_fuzzer.h new file mode 100644 index 00000000..0e64ca3c --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/dcamera_sink_handler_ipc_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 DCAMERA_SINK_HANDLER_IPC_FUZZER_H +#define DCAMERA_SINK_HANDLER_IPC_FUZZER_H + +#define FUZZ_PROJECT_NAME "dcamera_sink_handler_ipc_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/project.xml new file mode 100644 index 00000000..85e7ef2c --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/BUILD.gn new file mode 100644 index 00000000..06bdb704 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/BUILD.gn @@ -0,0 +1,73 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributedcamera/distributedcamera.gni") +##############################fuzztest########################################## +ohos_fuzztest("DCameraSinkLoadCallbackFuzzTest") { + module_out_path = "distributed_camera/dcamerasinkloadcallback" + + fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer" + + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "${common_path}/include", + "${innerkits_path}/native_cpp/camera_sink/include", + "//foundation/distributedhardware/distributedcamera/common/include/constants", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "dcamera_sink_load_callback_fuzzer.cpp", + ] + + deps = [ + "${fwk_utils_path}:distributedhardwareutils", + "${innerkits_path}/native_cpp/camera_sink:distributed_camera_sink_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"DCameraSinkLoadCallbackFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] +} +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":DCameraSinkLoadCallbackFuzzTest" ] + +} +############################################################################### diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/corpus/init new file mode 100644 index 00000000..bc977bd9 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/dcamera_sink_load_callback_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/dcamera_sink_load_callback_fuzzer.cpp new file mode 100644 index 00000000..e7153623 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/dcamera_sink_load_callback_fuzzer.cpp @@ -0,0 +1,56 @@ +/* + * 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. + */ + +#include "dcamera_sink_load_callback_fuzzer.h" + +#include +#include + +#include "dcamera_sink_load_callback.h" +#include "dcamera_sink_handler.h" +#include "distributed_camera_constants.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +namespace OHOS { +namespace DistributedHardware { +void DCameraSinkLoadCallbackFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (sizeof(int32_t) <= 0)) { + return; + } + int32_t systemAbilityId = *(reinterpret_cast(data)); + std::string params(reinterpret_cast(data), size); + std::shared_ptr callback = std::make_shared(params); + + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); + + callback->OnLoadSystemAbilitySuccess(systemAbilityId, remoteObject); + callback->OnLoadSystemAbilityFail(systemAbilityId); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::DCameraSinkLoadCallbackFuzzTest(data, size); + return 0; +} + + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/dcamera_sink_load_callback_fuzzer.h b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/dcamera_sink_load_callback_fuzzer.h new file mode 100644 index 00000000..d79eee8d --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/dcamera_sink_load_callback_fuzzer.h @@ -0,0 +1,22 @@ +/* + * 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 DCAMERA_SINK_LOAD_CALLBACK_FUZZER_H +#define DCAMERA_SINK_LOAD_CALLBACK_FUZZER_H + +#define FUZZ_PROJECT_NAME "dcamera_sink_load_callback_fuzzer" + +#endif + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/project.xml new file mode 100644 index 00000000..85e7ef2c --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/BUILD.gn new file mode 100644 index 00000000..74847d3f --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/BUILD.gn @@ -0,0 +1,71 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributedcamera/distributedcamera.gni") +##############################fuzztest########################################## +ohos_fuzztest("DCameraSinkProxyFuzzTest") { + module_out_path = "distributed_camera/dcamerasinkproxy" + + fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer" + +include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "${common_path}/include", + "${innerkits_path}/native_cpp/camera_sink/include", + "//foundation/distributedhardware/distributedcamera/common/include/constants", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "dcamera_sink_proxy_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_camera_utils", + "${innerkits_path}/native_cpp/camera_sink:distributed_camera_sink_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"DCameraSinkProxyFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":DCameraSinkProxyFuzzTest" ] +} +############################################################################### \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/corpus/init new file mode 100644 index 00000000..bc977bd9 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/dcamera_sink_proxy_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/dcamera_sink_proxy_fuzzer.cpp new file mode 100644 index 00000000..4e4a8d13 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/dcamera_sink_proxy_fuzzer.cpp @@ -0,0 +1,65 @@ +/* + * 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. + */ + +#include "dcamera_sink_proxy_fuzzer.h" + +#include "distributed_camera_constants.h" +#include "distributed_camera_sink_proxy.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +namespace OHOS { +namespace DistributedHardware { +void DCameraSinkProxyFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string param(reinterpret_cast(data), size); + std::string dhId(reinterpret_cast(data), size); + std::string params(reinterpret_cast(data), size); + std::string devId(reinterpret_cast(data), size); + std::string channelInfo(reinterpret_cast(data), size); + std::string cameraInfo(reinterpret_cast(data), size); + std::string openInfo(reinterpret_cast(data), size); + + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); + std::shared_ptr dCSinkProxy = + std::make_shared(remoteObject); + + dCSinkProxy->InitSink(param); + dCSinkProxy->SubscribeLocalHardware(dhId, params); + dCSinkProxy->ChannelNeg(dhId, channelInfo); + dCSinkProxy->GetCameraInfo(dhId, cameraInfo); + dCSinkProxy->OpenChannel(dhId, openInfo); + dCSinkProxy->CloseChannel(dhId); + dCSinkProxy->UnsubscribeLocalHardware(dhId); + dCSinkProxy->StopCapture(dhId); + dCSinkProxy->ReleaseSink(); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::DCameraSinkProxyFuzzTest(data, size); + return 0; +} + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/dcamera_sink_proxy_fuzzer.h b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/dcamera_sink_proxy_fuzzer.h new file mode 100644 index 00000000..2b956a3f --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/dcamera_sink_proxy_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 DCAMERA_SINK_PROXY_FUZZER_H +#define DCAMERA_SINK_PROXY_FUZZER_H + +#define FUZZ_PROJECT_NAME "dcamera_sink_proxy_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/project.xml new file mode 100644 index 00000000..85e7ef2c --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/BUILD.gn new file mode 100644 index 00000000..624f07eb --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/BUILD.gn @@ -0,0 +1,78 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributedcamera/distributedcamera.gni") +##############################fuzztest########################################## +ohos_fuzztest("DCameraSourceHandlerIpcFuzzTest") { + module_out_path = "distributed_camera/dcamerasourcehandleripc" + + fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer" + + include_dirs = [ + "//utils/system/safwk/native/include", + "${innerkits_path}/native_cpp/camera_source/include/callback", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "${common_path}/include", + "${innerkits_path}/native_cpp/camera_source/include", + "${innerkits_path}/native_cpp/camera_source/include/callback", + "//foundation/distributedhardware/distributedcamera/common/include/constants", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include/componentmanager", + "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "dcamera_source_handler_ipc_fuzzer.cpp", + ] + + deps = [ + "${fwk_utils_path}:distributedhardwareutils", + "${innerkits_path}/native_cpp/camera_source:distributed_camera_source_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"DCameraSourceHandlerIpcFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] + +} +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":DCameraSourceHandlerIpcFuzzTest" ] + +} +############################################################################### \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/corpus/init new file mode 100644 index 00000000..bc977bd9 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/dcamera_source_handler_ipc_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/dcamera_source_handler_ipc_fuzzer.cpp new file mode 100644 index 00000000..2e02d2e8 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/dcamera_source_handler_ipc_fuzzer.cpp @@ -0,0 +1,53 @@ +/* + * 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. + */ + +#include "dcamera_source_handler_ipc_fuzzer.h" + +#include +#include +#include "distributed_camera_constants.h" +#include "dcamera_source_handler.h" +#include "dcamera_source_handler_ipc.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +namespace OHOS { +namespace DistributedHardware { +void DCameraSourceHandlerIpcFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID); + wptr remote (remoteObject); + + DCameraSourceHandlerIpc::GetInstance().Init(); + DCameraSourceHandlerIpc::GetInstance().GetSourceLocalDHMS(); + DCameraSourceHandlerIpc::GetInstance().OnSourceLocalDmsDied(remote); + DCameraSourceHandlerIpc::GetInstance().UnInit(); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::DCameraSourceHandlerIpcFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/dcamera_source_handler_ipc_fuzzer.h b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/dcamera_source_handler_ipc_fuzzer.h new file mode 100644 index 00000000..6bc5b694 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/dcamera_source_handler_ipc_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 DCAMERA_SOURCE_HANDLER_IPC_FUZZER_H +#define DCAMERA_SOURCE_HANDLER_IPC_FUZZER_H + +#define FUZZ_PROJECT_NAME "dcamera_source_handler_ipc_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/project.xml new file mode 100644 index 00000000..85e7ef2c --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/BUILD.gn new file mode 100644 index 00000000..e5cf5eaa --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/BUILD.gn @@ -0,0 +1,74 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributedcamera/distributedcamera.gni") +##############################fuzztest########################################## +ohos_fuzztest("DCameraSourceLoadCallbackFuzzTest") { + module_out_path = "distributed_camera/dcamerasourceloadcallback" + + fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer" + + include_dirs = [ + "//utils/system/safwk/native/include", + "${innerkits_path}/native_cpp/camera_source/include/callback", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "${common_path}/include", + "${innerkits_path}/native_cpp/camera_source/include", + "//foundation/distributedhardware/distributedcamera/common/include/constants", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "dcamera_source_load_callback_fuzzer.cpp", + ] + + deps = [ + "${fwk_utils_path}:distributedhardwareutils", + "${innerkits_path}/native_cpp/camera_source:distributed_camera_source_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"DCameraSourceLoadCallbackFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] +} +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":DCameraSourceLoadCallbackFuzzTest" ] + +} +############################################################################### diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/corpus/init new file mode 100644 index 00000000..6b7212c8 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/corpus/init @@ -0,0 +1 @@ +FUZZ \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/dcamera_source_load_callback_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/dcamera_source_load_callback_fuzzer.cpp new file mode 100644 index 00000000..086dbd51 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/dcamera_source_load_callback_fuzzer.cpp @@ -0,0 +1,52 @@ +/* + * 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. + */ + +#include "dcamera_source_load_callback_fuzzer.h" + +#include "dcamera_source_load_callback.h" +#include "dcamera_source_handler.h" +#include "distributed_camera_constants.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +namespace OHOS { +namespace DistributedHardware { +void DCameraSourceLoadCallbackFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (sizeof(int32_t) <= 0)) { + return; + } + int32_t systemAbilityId = *(reinterpret_cast(data)); + std::string params(reinterpret_cast(data), size); + std::shared_ptr callback = std::make_shared(params); + + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID); + + callback->OnLoadSystemAbilitySuccess(systemAbilityId, remoteObject); + callback->OnLoadSystemAbilityFail(systemAbilityId); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::DCameraSourceLoadCallbackFuzzTest(data, size); + return 0; +} + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/dcamera_source_load_callback_fuzzer.h b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/dcamera_source_load_callback_fuzzer.h new file mode 100644 index 00000000..d2366863 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/dcamera_source_load_callback_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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. + */ + +#include +#include +#include +#include +#include +#include + +#define FUZZ_PROJECT_NAME "dcamera_source_load_callback_fuzzer" + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/project.xml new file mode 100644 index 00000000..85e7ef2c --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + -- Gitee From d973c39964b1b4d3a7c0864e75fa6f9252e571b2 Mon Sep 17 00:00:00 2001 From: wangchaole Date: Sun, 24 Apr 2022 18:27:00 +0800 Subject: [PATCH 2/7] add fuzztest Signed-off-by: wangchaole --- .../dcamerasinkhandleripc_fuzzer/BUILD.gn | 15 +++++++-------- .../dcamera_sink_handler_ipc_fuzzer.cpp | 6 +++--- .../dcamerasinkhandleripc_fuzzer/project.xml | 2 +- .../dcamerasinkloadcallback_fuzzer/BUILD.gn | 7 +++---- .../dcamera_sink_load_callback_fuzzer.cpp | 10 ++++------ .../dcamerasinkloadcallback_fuzzer/project.xml | 2 +- .../fuzztest/dcamerasinkproxy_fuzzer/BUILD.gn | 8 +++++--- .../dcamera_sink_proxy_fuzzer.cpp | 5 ++++- .../fuzztest/dcamerasinkproxy_fuzzer/project.xml | 2 +- .../dcamerasourcehandleripc_fuzzer/BUILD.gn | 10 ++++------ .../dcamera_source_handler_ipc_fuzzer.cpp | 7 ++++--- .../dcamerasourcehandleripc_fuzzer/project.xml | 2 +- .../dcamerasourceloadcallback_fuzzer/BUILD.gn | 7 +++---- .../dcamera_source_load_callback_fuzzer.cpp | 5 ++++- .../dcamera_source_load_callback_fuzzer.h | 11 ++++------- .../dcamerasourceloadcallback_fuzzer/project.xml | 2 +- 16 files changed, 50 insertions(+), 51 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/BUILD.gn index a69e5202..e016abda 100644 --- a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/BUILD.gn @@ -16,11 +16,13 @@ import("//build/config/features.gni") import("//build/test.gni") import( "//foundation/distributedhardware/distributedcamera/distributedcamera.gni") + ##############################fuzztest########################################## ohos_fuzztest("DCameraSinkHandlerIpcFuzzTest") { module_out_path = "distributed_camera/dcamerasinkhandleripc" - fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer" + fuzz_config_file = + "${innerkits_path}/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer" include_dirs = [ "//utils/native/base/include", @@ -46,10 +48,8 @@ ohos_fuzztest("DCameraSinkHandlerIpcFuzzTest") { "-fno-omit-frame-pointer", ] - sources = [ - "dcamera_sink_handler_ipc_fuzzer.cpp", - ] - + sources = [ "dcamera_sink_handler_ipc_fuzzer.cpp" ] + deps = [ "${fwk_utils_path}:distributedhardwareutils", "${innerkits_path}/native_cpp/camera_sink:distributed_camera_sink_sdk", @@ -68,12 +68,11 @@ ohos_fuzztest("DCameraSinkHandlerIpcFuzzTest") { "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", ] - } + ############################################################################### group("fuzztest") { testonly = true deps = [ ":DCameraSinkHandlerIpcFuzzTest" ] - } -############################################################################### \ No newline at end of file +############################################################################### diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/dcamera_sink_handler_ipc_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/dcamera_sink_handler_ipc_fuzzer.cpp index e7c4a52e..27dd8746 100644 --- a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/dcamera_sink_handler_ipc_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/dcamera_sink_handler_ipc_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -15,8 +15,8 @@ #include "dcamera_sink_handler_ipc_fuzzer.h" -#include -#include +#include +#include #include "distributed_camera_constants.h" #include "dcamera_sink_handler.h" diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/project.xml index 85e7ef2c..6e8ad2cf 100644 --- a/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/project.xml +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer/project.xml @@ -1,5 +1,5 @@ -