From 0e8dd2b57ca6a8aef3b021b2093befd94addfb98 Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Fri, 22 Apr 2022 15:33:26 +0800 Subject: [PATCH 01/12] add screen fuzz test Signed-off-by: qinlong0101 --- bundle.json | 7 +- .../dscreensinkhandler_fuzzer/BUILD.gn | 2 +- .../fuzztest/dscreensinkproxy_fuzzer/BUILD.gn | 2 +- .../dscreensourcehandler_fuzzer/BUILD.gn | 2 +- .../fuzztest/dscreenhandler_fuzzer/BUILD.gn | 2 +- services/screenservice/test/fuzztest/BUILD.gn | 20 ++++ .../test/fuzztest/sinkservice_fuzzer/BUILD.gn | 95 +++++++++++++++++++ .../fuzztest/sinkservice_fuzzer/corpus/init | 14 +++ .../fuzztest/sinkservice_fuzzer/project.xml | 25 +++++ .../sink_service_fuzzer.cpp | 58 +++++++++++ .../sinkservice_fuzzer/sink_service_fuzzer.h | 21 ++++ .../screentransport/test/fuzztest/BUILD.gn | 22 +++++ .../screendatachannel_fuzzer/BUILD.gn | 84 ++++++++++++++++ .../screendatachannel_fuzzer/corpus/init | 14 +++ .../screendatachannel_fuzzer/project.xml | 25 +++++ .../screen_data_channel_fuzzer.cpp | 55 +++++++++++ .../screen_data_channel_fuzzer.h | 21 ++++ .../screensourceprocessor_fuzzer/BUILD.gn | 84 ++++++++++++++++ .../screensourceprocessor_fuzzer/corpus/init | 14 +++ .../screensourceprocessor_fuzzer/project.xml | 25 +++++ .../screen_source_processor_fuzzer.cpp | 59 ++++++++++++ .../screen_source_processor_fuzzer.h | 21 ++++ .../screensourcetrans_fuzzer/BUILD.gn | 95 +++++++++++++++++++ .../screensourcetrans_fuzzer/corpus/init | 14 +++ .../screensourcetrans_fuzzer/project.xml | 25 +++++ .../screen_source_trans_fuzzer.cpp | 68 +++++++++++++ .../screen_source_trans_fuzzer.h | 21 ++++ .../softbusadapter/test/fuzztest/BUILD.gn | 20 ++++ .../fuzztest/softbusadapter_fuzzer/BUILD.gn | 83 ++++++++++++++++ .../softbusadapter_fuzzer/corpus/init | 14 +++ .../softbusadapter_fuzzer/project.xml | 25 +++++ .../softbus_adapter_fuzzer.cpp | 75 +++++++++++++++ .../softbus_adapter_fuzzer.h | 21 ++++ 33 files changed, 1127 insertions(+), 6 deletions(-) create mode 100644 services/screenservice/test/fuzztest/BUILD.gn create mode 100644 services/screenservice/test/fuzztest/sinkservice_fuzzer/BUILD.gn create mode 100644 services/screenservice/test/fuzztest/sinkservice_fuzzer/corpus/init create mode 100644 services/screenservice/test/fuzztest/sinkservice_fuzzer/project.xml create mode 100644 services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.cpp create mode 100644 services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.h create mode 100644 services/screentransport/test/fuzztest/BUILD.gn create mode 100644 services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn create mode 100644 services/screentransport/test/fuzztest/screendatachannel_fuzzer/corpus/init create mode 100644 services/screentransport/test/fuzztest/screendatachannel_fuzzer/project.xml create mode 100644 services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.cpp create mode 100644 services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.h create mode 100644 services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn create mode 100644 services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/corpus/init create mode 100644 services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/project.xml create mode 100644 services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.cpp create mode 100644 services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.h create mode 100644 services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn create mode 100644 services/screentransport/test/fuzztest/screensourcetrans_fuzzer/corpus/init create mode 100644 services/screentransport/test/fuzztest/screensourcetrans_fuzzer/project.xml create mode 100644 services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.cpp create mode 100644 services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.h create mode 100644 services/softbusadapter/test/fuzztest/BUILD.gn create mode 100644 services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn create mode 100644 services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/corpus/init create mode 100644 services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/project.xml create mode 100644 services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.cpp create mode 100644 services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.h diff --git a/bundle.json b/bundle.json index 3250cc91..4af063fd 100644 --- a/bundle.json +++ b/bundle.json @@ -81,8 +81,11 @@ "//foundation/distributedhardware/distributedscreen/services/softbusadapter/test/unittest:SoftBusAdapterTest", "//foundation/distributedhardware/distributedscreen/services/common/test/unittest:service_common_test", "//foundation/distributedhardware/distributedscreen/screenhandler/test/fuzztest:fuzztest", - "//foundation/distributedhardware/distributedscreen/interfaces/innerkits/native_cpp/test/fuzztest:fuzztest" + "//foundation/distributedhardware/distributedscreen/interfaces/innerkits/native_cpp/test/fuzztest:fuzztest", + "//foundation/distributedhardware/distributedscreen/services/softbusadapter/test/fuzztest:fuzztest", + "//foundation/distributedhardware/distributedscreen/services/screenservice/test/fuzztest:fuzztest", + "//foundation/distributedhardware/distributedscreen/services/screentransport/test/fuzztest:fuzztest" ] } } -} +} \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/BUILD.gn index 0d665773..7a1b57f8 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/BUILD.gn @@ -19,7 +19,7 @@ import( ##############################fuzztest########################################## ohos_fuzztest("DscreenSinkHandlerFuzzTest") { - module_out_path = "distributed_screen/dscreensinkhandler_fuzzer" + module_out_path = "distributed_screen/dscreensinkhandler" fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer" diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/BUILD.gn index 3c605425..43962755 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/BUILD.gn @@ -19,7 +19,7 @@ import( ##############################fuzztest########################################## ohos_fuzztest("DscreenSinkProxyFuzzTest") { - module_out_path = "distributed_screen/dscreensinkproxy_fuzzer" + module_out_path = "distributed_screen/dscreensinkproxy" fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer" diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/BUILD.gn index 12514222..7567f729 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/BUILD.gn @@ -19,7 +19,7 @@ import( ##############################fuzztest########################################## ohos_fuzztest("DscreenSourceHandlerFuzzTest") { - module_out_path = "distributed_screen/dscreensourcehandler_fuzzer" + module_out_path = "distributed_screen/dscreensourcehandler" fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer" diff --git a/screenhandler/test/fuzztest/dscreenhandler_fuzzer/BUILD.gn b/screenhandler/test/fuzztest/dscreenhandler_fuzzer/BUILD.gn index a97ffede..c003bc19 100644 --- a/screenhandler/test/fuzztest/dscreenhandler_fuzzer/BUILD.gn +++ b/screenhandler/test/fuzztest/dscreenhandler_fuzzer/BUILD.gn @@ -19,7 +19,7 @@ import( ##############################fuzztest########################################## ohos_fuzztest("DscreenHandlerFuzzTest") { - module_out_path = "distributed_screen/dscreenhandler_fuzzer" + module_out_path = "distributed_screen/dscreenhandler" fuzz_config_file = "${distributedscreen_path}/screenhandler/test/fuzztest/dscreenhandler_fuzzer" diff --git a/services/screenservice/test/fuzztest/BUILD.gn b/services/screenservice/test/fuzztest/BUILD.gn new file mode 100644 index 00000000..680a37a0 --- /dev/null +++ b/services/screenservice/test/fuzztest/BUILD.gn @@ -0,0 +1,20 @@ +# 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 = [ + "sinkservice_fuzzer:fuzztest" + ] +} \ No newline at end of file diff --git a/services/screenservice/test/fuzztest/sinkservice_fuzzer/BUILD.gn b/services/screenservice/test/fuzztest/sinkservice_fuzzer/BUILD.gn new file mode 100644 index 00000000..4a6cbcee --- /dev/null +++ b/services/screenservice/test/fuzztest/sinkservice_fuzzer/BUILD.gn @@ -0,0 +1,95 @@ +# 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("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("SinkServiceFuzzTest") { + module_out_path = "distributed_screen/sinkservice" + + fuzz_config_file = "${services_path}/screenservice/test/fuzztest/sinkservice_fuzzer" + + include_dirs = [ + "//third_party/json/include", + "//utils/native/base/include", + "//utils/system/safwk/native/include", + "//foundation/graphic/standard/interfaces/innerkits/surface", + "${windowmanager_path}/interfaces/innerkits/dm", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "./dscreenservice/include", + "./screenregionmgr/include", + "${interfaces_path}/innerkits/native_cpp/screen_sink/include", + "${interfaces_path}/innerkits/native_cpp/screen_sink/include/callback", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${common_path}/include", + "${services_path}/common/utils/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/screen_channel/include", + "${services_path}/screentransport/screensinktrans/include", + "${services_path}/screentransport/screensinkprocessor/include", + "${services_path}/screentransport/screensinkprocessor/decoder/include", + "${services_path}/screenclient/include", + "${services_path}/screenservice/sinkservice/dscreenservice/include", + "${services_path}/screenservice/sinkservice/screenregionmgr/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "sink_service_fuzzer.cpp", + ] + + deps = [ + "//utils/native/base:utils", + "${common_path}:distributed_screen_utils", + "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", + "${services_path}/screenclient:distributed_screen_client", + "//foundation/graphic/standard/frameworks/surface:surface", + "//foundation/distributedhardware/distributedscreen/services/screenservice/sinkservice:distributed_screen_sink", + "${windowmanager_path}/dm:libdm", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SinkServiceFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + "multimedia_media_standard:media_client", + ] + +} +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":SinkServiceFuzzTest" ] +} +############################################################################### diff --git a/services/screenservice/test/fuzztest/sinkservice_fuzzer/corpus/init b/services/screenservice/test/fuzztest/sinkservice_fuzzer/corpus/init new file mode 100644 index 00000000..bc977bd9 --- /dev/null +++ b/services/screenservice/test/fuzztest/sinkservice_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/services/screenservice/test/fuzztest/sinkservice_fuzzer/project.xml b/services/screenservice/test/fuzztest/sinkservice_fuzzer/project.xml new file mode 100644 index 00000000..6e8ad2cf --- /dev/null +++ b/services/screenservice/test/fuzztest/sinkservice_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.cpp b/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.cpp new file mode 100644 index 00000000..64d26307 --- /dev/null +++ b/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.cpp @@ -0,0 +1,58 @@ +/* + * 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 "sink_service_fuzzer.h" + +#include +#include +#include + +#include "dscreen_sink_service.h" + +namespace OHOS { +namespace DistributedHardware { +void SinkServiceFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= sizeof(int32_t))) { + return; + } + + int32_t saId = *(reinterpret_cast(data)); + bool runOnCreate = true; + std::shared_ptr sinkService = std::make_shared(saId, runOnCreate); + std::string params(reinterpret_cast(data), size); + std::string dhId(reinterpret_cast(data), size); + std::string param(reinterpret_cast(data), size); + std::string devId(reinterpret_cast(data), size); + int32_t eventCode = *(reinterpret_cast(data)); + std::string eventContent(reinterpret_cast(data), size); + + sinkService->DScreenNotify(devId, eventCode, eventContent); + sinkService->InitSink(params); + sinkService->SubscribeLocalHardware(dhId, param); + sinkService->UnsubscribeLocalHardware(dhId); + sinkService->ReleaseSink(); + +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SinkServiceFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.h b/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.h new file mode 100644 index 00000000..3f40dfac --- /dev/null +++ b/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_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 SINK_SERVICE_FUZZER_H +#define SINK_SERVICE_FUZZER_H + +#define FUZZ_PROJECT_NAME "sink_service_fuzzer" + +#endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/BUILD.gn b/services/screentransport/test/fuzztest/BUILD.gn new file mode 100644 index 00000000..025ffa11 --- /dev/null +++ b/services/screentransport/test/fuzztest/BUILD.gn @@ -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. + +group("fuzztest") { + testonly = true + + deps = [ + "screendatachannel_fuzzer:fuzztest", + "screensourceprocessor_fuzzer:fuzztest", + "screensourcetrans_fuzzer:fuzztest" + ] +} \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn new file mode 100644 index 00000000..6ce4f8a6 --- /dev/null +++ b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn @@ -0,0 +1,84 @@ +# 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("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ScreenDataChannelFuzzTest") { + module_out_path = "distributed_screen/screendatachannel" + + fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screendatachannel_fuzzer" + + include_dirs = [ + "//third_party/json/include", + "//foundation/graphic/standard/interfaces/innerkits/surface", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "./include", + "${services_path}/screentransport/test/unittest/screentranstestutils/include", + "${common_path}/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/include", + "${services_path}/screentransport/screensinkprocessor/include", + "${services_path}/screentransport/screensinktrans/include", + "${services_path}/screentransport/screensourcetrans/include", + "${services_path}/screentransport/screendatachannel/include", + "${services_path}/screentransport/screensourceprocessor/include", + "${services_path}/screentransport/screensourceprocessor/encoder/include", + "${services_path}/softbusadapter/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "screen_data_channel_fuzzer.cpp", + ] + + deps = [ + "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", + "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", + "${fwk_utils_path}:distributedhardwareutils", + "//foundation/graphic/standard/frameworks/surface:surface", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"ScreenDataChannelFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "dsoftbus_standard:softbus_client", + "hiviewdfx_hilog_native:libhilog", + "multimedia_media_standard:media_client", + ] +} +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ScreenDataChannelFuzzTest" ] +} +############################################################################### \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/corpus/init b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/corpus/init new file mode 100644 index 00000000..bc977bd9 --- /dev/null +++ b/services/screentransport/test/fuzztest/screendatachannel_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/services/screentransport/test/fuzztest/screendatachannel_fuzzer/project.xml b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/project.xml new file mode 100644 index 00000000..27c26d11 --- /dev/null +++ b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.cpp b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.cpp new file mode 100644 index 00000000..46058019 --- /dev/null +++ b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "screen_data_channel_fuzzer.h" + +#include +#include + +#include "screen_data_channel_impl.h" +#include "screen_sink_trans.h" +#include "screen_source_trans.h" + +namespace OHOS { +namespace DistributedHardware { +void ScreenDataChannelFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + + std::string peerDevId(reinterpret_cast(data), size); + std::shared_ptr screenDataChannelImpl = std::make_shared(peerDevId); + std::shared_ptr listener = std::make_shared(); + size_t capacity = size; + std::shared_ptr screenData = std::make_shared(capacity); + + screenDataChannelImpl->CreateSession(listener); + screenDataChannelImpl->OpenSession(); + screenDataChannelImpl->SendData(screenData); + screenDataChannelImpl->CloseSession(); + screenDataChannelImpl->ReleaseSession(); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::ScreenDataChannelFuzzTest(data, size); + + return 0; +} \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.h b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.h new file mode 100644 index 00000000..73d19ac7 --- /dev/null +++ b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_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 SCREEN_DATA_CHANNEL_FUZZER_H +#define SCREEN_DATA_CHANNEL_FUZZER_H + +#define FUZZ_PROJECT_NAME "screen_data_channel_fuzzer" + +#endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn new file mode 100644 index 00000000..055e8fb5 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn @@ -0,0 +1,84 @@ +# 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("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ScreenSourceProcessorFuzzTest") { + module_out_path = "distributed_screen/screensourceprocessor" + + fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensourceprocessor_fuzzer" + + include_dirs = [ + "//third_party/json/include", + "//foundation/graphic/standard/interfaces/innerkits/surface", + "${fwk_common_path}/utils/include", + "${fwk_utils_path}/include/", + ] + + include_dirs += [ + "./include", + "${services_path}/screentransport/test/unittest/screentranstestutils/include", + "${common_path}/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/include", + "${services_path}/screentransport/test/unittest/screensourcetrans", + "${services_path}/screentransport/screensourcetrans/include", + "${services_path}/screentransport/screendatachannel/include", + "${services_path}/screentransport/screensourceprocessor/include", + "${services_path}/screentransport/screensourceprocessor/encoder/include", + "${services_path}/softbusadapter/include", + "${services_path}/screentransport/test/unittest/screensourceprocessor/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "screen_source_processor_fuzzer.cpp", + ] + + deps = [ + "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", + "${fwk_utils_path}:distributedhardwareutils", + "//foundation/graphic/standard/frameworks/surface:surface", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"ScreenSourceProcessorFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "dsoftbus_standard:softbus_client", + "hiviewdfx_hilog_native:libhilog", + "multimedia_media_standard:media_client", + ] +} +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ScreenSourceProcessorFuzzTest" ] +} +############################################################################### diff --git a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/corpus/init b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/corpus/init new file mode 100644 index 00000000..bc977bd9 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor_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/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/project.xml b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/project.xml new file mode 100644 index 00000000..6e8ad2cf --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.cpp b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.cpp new file mode 100644 index 00000000..688a95e1 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.cpp @@ -0,0 +1,59 @@ +/* + * 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 "screen_source_processor_fuzzer.h" + +#include +#include + +#include "image_source_processor.h" +#include "screen_source_trans.h" + +namespace OHOS { +namespace DistributedHardware { +void ScreenSourceProcessorFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(uint32_t))) { + return; + } + + std::shared_ptr imageSourceProcessor = std::make_shared(); + std::shared_ptr param = std::make_shared(); + uint32_t screenWidth = *(reinterpret_cast(data)); + uint32_t screenHeight = *(reinterpret_cast(data)); + uint32_t videoWidth = *(reinterpret_cast(data)); + uint32_t videoHeight = *(reinterpret_cast(data)); + param->SetScreenWidth(screenWidth); + param->SetScreenHeight(screenHeight); + param->SetVideoWidth(videoWidth); + param->SetScreenHeight(videoHeight); + std::shared_ptr listener = std::make_shared(); + + imageSourceProcessor->ConfigureImageProcessor(*param, *param, listener); + imageSourceProcessor->GetImageSurface(); + imageSourceProcessor->StartImageProcessor(); + imageSourceProcessor->StopImageProcessor(); + imageSourceProcessor->ReleaseImageProcessor(); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::ScreenSourceProcessorFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.h b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.h new file mode 100644 index 00000000..36cfae08 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_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 SCREEN_SOURCE_PROCESSOR_FUZZER_H +#define SCREEN_SOURCE_PROCESSOR_FUZZER_H + +#define FUZZ_PROJECT_NAME "screen_source_processor_fuzzer" + +#endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn new file mode 100644 index 00000000..ff1a4ab4 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn @@ -0,0 +1,95 @@ +# 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("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ScreenSourceTransFuzzTest") { + module_out_path = "distributed_screen/screensourcetrans" + + fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensourcetrans_fuzzer" + + include_dirs = [ + "//third_party/json/include", + "//foundation/graphic/standard/interfaces/innerkits/surface", + "${windowmanager_path}/interfaces/innerkits/dm", + "${fwk_common_path}/log/include", + "${fwk_common_path}/utils/include", + "${fwk_utils_path}/include/", + "${fwk_utils_path}/include/log", + ] + + include_dirs += [ + "./include", + "${services_path}/screentransport/test/unittest/screentranstestutils/include", + "${common_path}/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/include", + "${services_path}/screentransport/screensinktrans/include", + "${services_path}/screentransport/screensinkprocessor/include", + "${services_path}/screentransport/test/unittest/screensourcetrans/include", + "${services_path}/screentransport/screensourcetrans/include", + "${services_path}/screentransport/screendatachannel/include", + "${services_path}/screentransport/screensourceprocessor/include", + "${services_path}/screentransport/screensourceprocessor/encoder/include", + "${services_path}/softbusadapter/include", + "${services_path}/screenservice/sourceservice/dscreenmgr/include", + "//foundation/graphic/standard/rosen/modules/render_service_base/include", + "${interfaces_path}/innerkits/native_cpp/screen_sink/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "screen_source_trans_fuzzer.cpp", + ] + + deps = [ + "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", + "${services_path}/screenservice/sourceservice:distributed_screen_source", + "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", + "${windowmanager_path}/dm:libdm", + "${fwk_utils_path}:distributedhardwareutils", + "//foundation/graphic/standard/frameworks/surface:surface", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"ScreenSourceTransFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "dsoftbus_standard:softbus_client", + "hiviewdfx_hilog_native:libhilog", + "multimedia_media_standard:media_client", + ] +} +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ScreenSourceTransFuzzTest" ] +} +############################################################################### diff --git a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/corpus/init b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/corpus/init new file mode 100644 index 00000000..bc977bd9 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourcetrans_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/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/project.xml b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/project.xml new file mode 100644 index 00000000..6e8ad2cf --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.cpp b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.cpp new file mode 100644 index 00000000..696740a9 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.cpp @@ -0,0 +1,68 @@ +/* + * 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 "screen_source_trans_fuzzer.h" + +#include +#include + +#include "dscreen.h" +#include "dscreen_errcode.h" +#include "dscreen_manager.h" +#include "screen_source_trans.h" +#include "video_param.h" +#include "screentrans_test_utils.h" + +namespace OHOS { +namespace DistributedHardware { +void ScreenSourceTransFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(uint32_t))) { + return; + } + + std::shared_ptr screenSourceTrans = std::make_shared(); + std::shared_ptr param = std::make_shared(); + uint32_t screenWidth = *(reinterpret_cast(data)); + uint32_t screenHeight = *(reinterpret_cast(data)); + uint32_t videoWidth = *(reinterpret_cast(data)); + uint32_t videoHeight = *(reinterpret_cast(data)); + param->SetScreenWidth(screenWidth); + param->SetScreenHeight(screenHeight); + param->SetVideoWidth(videoWidth); + param->SetScreenHeight(videoHeight); + std::string peerDevId(reinterpret_cast(data), size); + std::string devId(reinterpret_cast(data), size); + std::string dhId(reinterpret_cast(data), size); + std::shared_ptr dScreenCallback = std::make_shared(); + std::shared_ptr callBack = std::make_shared(devId, dhId, dScreenCallback); + + screenSourceTrans->SetUp(*param, *param, peerDevId); + screenSourceTrans->GetImageSurface(); + screenSourceTrans->Start(); + screenSourceTrans->RegisterStateCallback(callBack); + screenSourceTrans->Stop(); + screenSourceTrans->Release(); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::ScreenSourceTransFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.h b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.h new file mode 100644 index 00000000..c5e54307 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_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 SCREEN_SOURCE_TRANS_FUZZER_H +#define SCREEN_SOURCE_TRANS_FUZZER_H + +#define FUZZ_PROJECT_NAME "screen_source_trans_fuzzer" + +#endif \ No newline at end of file diff --git a/services/softbusadapter/test/fuzztest/BUILD.gn b/services/softbusadapter/test/fuzztest/BUILD.gn new file mode 100644 index 00000000..78d973ac --- /dev/null +++ b/services/softbusadapter/test/fuzztest/BUILD.gn @@ -0,0 +1,20 @@ +# 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 = [ + "softbusadapter_fuzzer:fuzztest" + ] +} \ No newline at end of file diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn new file mode 100644 index 00000000..f80355f7 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn @@ -0,0 +1,83 @@ +# 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("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("SoftbusAdapterFuzzTest") { + module_out_path = "distributed_screen/softbusadapter" + + fuzz_config_file = "${services_path}/softbusadapter/test/fuzztest/softbusadapter_fuzzer" + + include_dirs = [ + "//third_party/json/include", + "//foundation/graphic/standard/interfaces/innerkits/surface", + "${fwk_common_path}/utils/include", + "${fwk_utils_path}/include/", + ] + + include_dirs += [ + "./include", + "${common_path}/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/include", + "${services_path}/screentransport/test/unittest/screensourcetrans/include", + "${services_path}/screentransport/screensourcetrans/include", + "${services_path}/screentransport/screendatachannel/include", + "${services_path}/screentransport/screensourceprocessor/include", + "${services_path}/screentransport/screensourceprocessor/encoder/include", + "${services_path}/softbusadapter/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer" + ] + + sources = [ + "softbus_adapter_fuzzer.cpp", + ] + + deps = [ + "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", + "${fwk_utils_path}:distributedhardwareutils", + "//foundation/graphic/standard/frameworks/surface:surface", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SoftbusAdapterFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "dsoftbus_standard:softbus_client", + "hiviewdfx_hilog_native:libhilog", + "multimedia_media_standard:media_client", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true +deps = [ ":SoftbusAdapterFuzzTest" ] +} +############################################################################### diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/corpus/init b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/corpus/init new file mode 100644 index 00000000..bc977bd9 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusadapter_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/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/project.xml b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/project.xml new file mode 100644 index 00000000..6e8ad2cf --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.cpp b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.cpp new file mode 100644 index 00000000..f09fec6f --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.cpp @@ -0,0 +1,75 @@ +/* + * 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 "softbus_adapter_fuzzer.h" + +#include +#include +#include + +#include "isoftbus_listener.h" +#include "screen_data_channel_impl.h" +#include "softbus_adapter.h" + +namespace OHOS { +namespace DistributedHardware { +void SoftbusAdapterFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + std::string pkgname(reinterpret_cast(data), size); + std::string sessionName(reinterpret_cast(data), size); + std::string peerDevId(reinterpret_cast(data), size); + std::string mySessionName(reinterpret_cast(data), size); + std::string peerSessionName(reinterpret_cast(data), size); + int32_t sessionId = *(reinterpret_cast(data)); + void *data1 = const_cast(data); + int32_t dataLen = (int32_t)size; + StreamData streamdata = {reinterpret_cast(const_cast(data)), (int)size}; + StreamData ext = {0}; + StreamFrameInfo frameInfo = {0}; + std::shared_ptr listener = std::make_shared(peerDevId); + int32_t result = *(reinterpret_cast(data)); + unsigned int datalength = (unsigned int)size; + int eventId = *(reinterpret_cast(data)); + int tvCount = *(reinterpret_cast(data)); + QosTv tvList; //??? + + SoftbusAdapter::GetInstance().CreateSoftbusSessionServer(pkgname, sessionName, peerDevId); + SoftbusAdapter::GetInstance().RemoveSoftbusSessionServer(pkgname, sessionName, peerDevId); + SoftbusAdapter::GetInstance().OpenSoftbusSession(mySessionName, peerSessionName, peerDevId); + SoftbusAdapter::GetInstance().CloseSoftbusSession(sessionId); + SoftbusAdapter::GetInstance().SendSoftbusBytes(sessionId, data1, dataLen); + SoftbusAdapter::GetInstance().SendSoftbusStream(sessionId, &streamdata, &ext, &frameInfo); + SoftbusAdapter::GetInstance().RegisterSoftbusListener(listener, sessionName, peerDevId); + SoftbusAdapter::GetInstance().UnRegisterSoftbusListener(sessionName, peerDevId); + SoftbusAdapter::GetInstance().OnSoftbusSessionOpened(sessionId, result); + SoftbusAdapter::GetInstance().OnSoftbusSessionClosed(sessionId); + SoftbusAdapter::GetInstance().OnBytesReceived(sessionId, data1, dataLen); + SoftbusAdapter::GetInstance().OnStreamReceived(sessionId, &streamdata, &ext, &frameInfo); + SoftbusAdapter::GetInstance().OnMessageReceived(sessionId, data1, datalength); + SoftbusAdapter::GetInstance().OnQosEvent(sessionId, eventId, tvCount, &tvList); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SoftbusAdapterFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.h b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.h new file mode 100644 index 00000000..f8959fec --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_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 TEST_SOFTBUS_ADAPTER_FUZZER_H +#define TEST_SOFTBUS_ADAPTER_FUZZER_H + +#define FUZZ_PROJECT_NAME "test_softbus_adapter_fuzzer" + +#endif \ No newline at end of file -- Gitee From 1d32331127a1d1fc75f2910a36d9f3becc1d9419 Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Fri, 22 Apr 2022 16:15:39 +0800 Subject: [PATCH 02/12] add screen fuzz test Signed-off-by: qinlong0101 --- services/screenservice/test/fuzztest/BUILD.gn | 2 +- .../sinkservice_fuzzer/sink_service_fuzzer.cpp | 1 - .../softbus_adapter_fuzzer.cpp | 17 +++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/services/screenservice/test/fuzztest/BUILD.gn b/services/screenservice/test/fuzztest/BUILD.gn index 680a37a0..db06f70a 100644 --- a/services/screenservice/test/fuzztest/BUILD.gn +++ b/services/screenservice/test/fuzztest/BUILD.gn @@ -17,4 +17,4 @@ group("fuzztest") { deps = [ "sinkservice_fuzzer:fuzztest" ] -} \ No newline at end of file +} diff --git a/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.cpp b/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.cpp index 64d26307..f1988636 100644 --- a/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.cpp +++ b/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.cpp @@ -44,7 +44,6 @@ void SinkServiceFuzzTest(const uint8_t* data, size_t size) sinkService->SubscribeLocalHardware(dhId, param); sinkService->UnsubscribeLocalHardware(dhId); sinkService->ReleaseSink(); - } } } diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.cpp b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.cpp index f09fec6f..2a6345f5 100644 --- a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.cpp +++ b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.cpp @@ -30,37 +30,38 @@ void SoftbusAdapterFuzzTest(const uint8_t* data, size_t size) if ((data == nullptr) || (size < sizeof(int32_t))) { return; } + std::string pkgname(reinterpret_cast(data), size); std::string sessionName(reinterpret_cast(data), size); std::string peerDevId(reinterpret_cast(data), size); std::string mySessionName(reinterpret_cast(data), size); std::string peerSessionName(reinterpret_cast(data), size); int32_t sessionId = *(reinterpret_cast(data)); - void *data1 = const_cast(data); - int32_t dataLen = (int32_t)size; - StreamData streamdata = {reinterpret_cast(const_cast(data)), (int)size}; + void *datapointer = const_cast(data); + int32_t dataLen = static_cast(size); + StreamData streamdata = {reinterpret_cast(const_cast(data)), static_cast(size)}; StreamData ext = {0}; StreamFrameInfo frameInfo = {0}; std::shared_ptr listener = std::make_shared(peerDevId); int32_t result = *(reinterpret_cast(data)); - unsigned int datalength = (unsigned int)size; + unsigned int datalength = static_cast(size); int eventId = *(reinterpret_cast(data)); int tvCount = *(reinterpret_cast(data)); - QosTv tvList; //??? + QosTv tvList; SoftbusAdapter::GetInstance().CreateSoftbusSessionServer(pkgname, sessionName, peerDevId); SoftbusAdapter::GetInstance().RemoveSoftbusSessionServer(pkgname, sessionName, peerDevId); SoftbusAdapter::GetInstance().OpenSoftbusSession(mySessionName, peerSessionName, peerDevId); SoftbusAdapter::GetInstance().CloseSoftbusSession(sessionId); - SoftbusAdapter::GetInstance().SendSoftbusBytes(sessionId, data1, dataLen); + SoftbusAdapter::GetInstance().SendSoftbusBytes(sessionId, datapointer, dataLen); SoftbusAdapter::GetInstance().SendSoftbusStream(sessionId, &streamdata, &ext, &frameInfo); SoftbusAdapter::GetInstance().RegisterSoftbusListener(listener, sessionName, peerDevId); SoftbusAdapter::GetInstance().UnRegisterSoftbusListener(sessionName, peerDevId); SoftbusAdapter::GetInstance().OnSoftbusSessionOpened(sessionId, result); SoftbusAdapter::GetInstance().OnSoftbusSessionClosed(sessionId); - SoftbusAdapter::GetInstance().OnBytesReceived(sessionId, data1, dataLen); + SoftbusAdapter::GetInstance().OnBytesReceived(sessionId, datapointer, dataLen); SoftbusAdapter::GetInstance().OnStreamReceived(sessionId, &streamdata, &ext, &frameInfo); - SoftbusAdapter::GetInstance().OnMessageReceived(sessionId, data1, datalength); + SoftbusAdapter::GetInstance().OnMessageReceived(sessionId, datapointer, datalength); SoftbusAdapter::GetInstance().OnQosEvent(sessionId, eventId, tvCount, &tvList); } } -- Gitee From 598ef309ab4ae29b7a228fbabd8db2aeee5359d8 Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Fri, 22 Apr 2022 16:38:17 +0800 Subject: [PATCH 03/12] add screen fuzz test Signed-off-by: qinlong0101 --- services/screenservice/test/fuzztest/BUILD.gn | 2 +- services/screentransport/test/fuzztest/BUILD.gn | 2 +- .../screensourcetrans_fuzzer/screen_source_trans_fuzzer.cpp | 2 +- services/softbusadapter/test/fuzztest/BUILD.gn | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/services/screenservice/test/fuzztest/BUILD.gn b/services/screenservice/test/fuzztest/BUILD.gn index db06f70a..60635be7 100644 --- a/services/screenservice/test/fuzztest/BUILD.gn +++ b/services/screenservice/test/fuzztest/BUILD.gn @@ -15,6 +15,6 @@ group("fuzztest") { testonly = true deps = [ - "sinkservice_fuzzer:fuzztest" + "sinkservice_fuzzer:fuzztest", ] } diff --git a/services/screentransport/test/fuzztest/BUILD.gn b/services/screentransport/test/fuzztest/BUILD.gn index 025ffa11..82e2a92c 100644 --- a/services/screentransport/test/fuzztest/BUILD.gn +++ b/services/screentransport/test/fuzztest/BUILD.gn @@ -17,6 +17,6 @@ group("fuzztest") { deps = [ "screendatachannel_fuzzer:fuzztest", "screensourceprocessor_fuzzer:fuzztest", - "screensourcetrans_fuzzer:fuzztest" + "screensourcetrans_fuzzer:fuzztest", ] } \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.cpp b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.cpp index 696740a9..50c6bea8 100644 --- a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.cpp +++ b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.cpp @@ -52,7 +52,7 @@ void ScreenSourceTransFuzzTest(const uint8_t* data, size_t size) screenSourceTrans->SetUp(*param, *param, peerDevId); screenSourceTrans->GetImageSurface(); screenSourceTrans->Start(); - screenSourceTrans->RegisterStateCallback(callBack); + screenSourceTrans->RegisterStateCallback(callBack); screenSourceTrans->Stop(); screenSourceTrans->Release(); } diff --git a/services/softbusadapter/test/fuzztest/BUILD.gn b/services/softbusadapter/test/fuzztest/BUILD.gn index 78d973ac..41ae0ccd 100644 --- a/services/softbusadapter/test/fuzztest/BUILD.gn +++ b/services/softbusadapter/test/fuzztest/BUILD.gn @@ -15,6 +15,6 @@ group("fuzztest") { testonly = true deps = [ - "softbusadapter_fuzzer:fuzztest" + "softbusadapter_fuzzer:fuzztest", ] } \ No newline at end of file -- Gitee From 437e160f5fcb5e6467d50c32bb2ec953e3655ccb Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Fri, 22 Apr 2022 17:08:40 +0800 Subject: [PATCH 04/12] add screen fuzz test Signed-off-by: qinlong0101 --- services/screenservice/test/fuzztest/BUILD.gn | 4 +--- services/softbusadapter/test/fuzztest/BUILD.gn | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/services/screenservice/test/fuzztest/BUILD.gn b/services/screenservice/test/fuzztest/BUILD.gn index 60635be7..a63f7a6f 100644 --- a/services/screenservice/test/fuzztest/BUILD.gn +++ b/services/screenservice/test/fuzztest/BUILD.gn @@ -14,7 +14,5 @@ group("fuzztest") { testonly = true - deps = [ - "sinkservice_fuzzer:fuzztest", - ] + deps = [ "sinkservice_fuzzer:fuzztest" ] } diff --git a/services/softbusadapter/test/fuzztest/BUILD.gn b/services/softbusadapter/test/fuzztest/BUILD.gn index 41ae0ccd..dceae266 100644 --- a/services/softbusadapter/test/fuzztest/BUILD.gn +++ b/services/softbusadapter/test/fuzztest/BUILD.gn @@ -14,7 +14,5 @@ group("fuzztest") { testonly = true - deps = [ - "softbusadapter_fuzzer:fuzztest", - ] + deps = [ "softbusadapter_fuzzer:fuzztest" ] } \ No newline at end of file -- Gitee From 530a336a12543d5883b7d5f593c39ed90e26a3e3 Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Fri, 22 Apr 2022 17:44:59 +0800 Subject: [PATCH 05/12] add screen fuzz test Signed-off-by: qinlong0101 --- services/screenservice/test/fuzztest/BUILD.gn | 2 +- .../test/fuzztest/sinkservice_fuzzer/BUILD.gn | 83 +++++++++---------- 2 files changed, 42 insertions(+), 43 deletions(-) diff --git a/services/screenservice/test/fuzztest/BUILD.gn b/services/screenservice/test/fuzztest/BUILD.gn index a63f7a6f..beae3f41 100644 --- a/services/screenservice/test/fuzztest/BUILD.gn +++ b/services/screenservice/test/fuzztest/BUILD.gn @@ -15,4 +15,4 @@ group("fuzztest") { testonly = true deps = [ "sinkservice_fuzzer:fuzztest" ] -} +} \ No newline at end of file diff --git a/services/screenservice/test/fuzztest/sinkservice_fuzzer/BUILD.gn b/services/screenservice/test/fuzztest/sinkservice_fuzzer/BUILD.gn index 4a6cbcee..581a9fc5 100644 --- a/services/screenservice/test/fuzztest/sinkservice_fuzzer/BUILD.gn +++ b/services/screenservice/test/fuzztest/sinkservice_fuzzer/BUILD.gn @@ -21,34 +21,35 @@ import( ohos_fuzztest("SinkServiceFuzzTest") { module_out_path = "distributed_screen/sinkservice" - fuzz_config_file = "${services_path}/screenservice/test/fuzztest/sinkservice_fuzzer" + fuzz_config_file = + "${services_path}/screenservice/test/fuzztest/sinkservice_fuzzer" include_dirs = [ - "//third_party/json/include", - "//utils/native/base/include", - "//utils/system/safwk/native/include", - "//foundation/graphic/standard/interfaces/innerkits/surface", - "${windowmanager_path}/interfaces/innerkits/dm", - "${fwk_common_path}/utils/include", + "//third_party/json/include", + "//utils/native/base/include", + "//utils/system/safwk/native/include", + "//foundation/graphic/standard/interfaces/innerkits/surface", + "${windowmanager_path}/interfaces/innerkits/dm", + "${fwk_common_path}/utils/include", ] include_dirs += [ - "./dscreenservice/include", - "./screenregionmgr/include", - "${interfaces_path}/innerkits/native_cpp/screen_sink/include", - "${interfaces_path}/innerkits/native_cpp/screen_sink/include/callback", - "${interfaces_path}/innerkits/native_cpp/screen_source/include", - "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", - "${common_path}/include", - "${services_path}/common/utils/include", - "${services_path}/common/databuffer/include", - "${services_path}/common/screen_channel/include", - "${services_path}/screentransport/screensinktrans/include", - "${services_path}/screentransport/screensinkprocessor/include", - "${services_path}/screentransport/screensinkprocessor/decoder/include", - "${services_path}/screenclient/include", - "${services_path}/screenservice/sinkservice/dscreenservice/include", - "${services_path}/screenservice/sinkservice/screenregionmgr/include", + "./dscreenservice/include", + "./screenregionmgr/include", + "${interfaces_path}/innerkits/native_cpp/screen_sink/include", + "${interfaces_path}/innerkits/native_cpp/screen_sink/include/callback", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${common_path}/include", + "${services_path}/common/utils/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/screen_channel/include", + "${services_path}/screentransport/screensinktrans/include", + "${services_path}/screentransport/screensinkprocessor/include", + "${services_path}/screentransport/screensinkprocessor/decoder/include", + "${services_path}/screenclient/include", + "${services_path}/screenservice/sinkservice/dscreenservice/include", + "${services_path}/screenservice/sinkservice/screenregionmgr/include", ] cflags = [ @@ -58,35 +59,33 @@ ohos_fuzztest("SinkServiceFuzzTest") { "-fno-omit-frame-pointer", ] - sources = [ - "sink_service_fuzzer.cpp", - ] + sources = [ "sink_service_fuzzer.cpp" ] deps = [ - "//utils/native/base:utils", - "${common_path}:distributed_screen_utils", - "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", - "${services_path}/screenclient:distributed_screen_client", - "//foundation/graphic/standard/frameworks/surface:surface", - "//foundation/distributedhardware/distributedscreen/services/screenservice/sinkservice:distributed_screen_sink", - "${windowmanager_path}/dm:libdm", + "${common_path}:distributed_screen_utils", + "${services_path}/screenclient:distributed_screen_client", + "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", + "${windowmanager_path}/dm:libdm", + "//foundation/distributedhardware/distributedscreen/services/screenservice/sinkservice:distributed_screen_sink", + "//foundation/graphic/standard/frameworks/surface:surface", + "//utils/native/base:utils", ] defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"SinkServiceFuzzTest\"", - "LOG_DOMAIN=0xD004100", + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SinkServiceFuzzTest\"", + "LOG_DOMAIN=0xD004100", ] external_deps = [ - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", - "multimedia_media_standard:media_client", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "multimedia_media_standard:media_client", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", ] - } + ############################################################################### group("fuzztest") { testonly = true -- Gitee From 732f75f460c09b6e527399b2b9bf07b3a95a530c Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Fri, 22 Apr 2022 18:01:03 +0800 Subject: [PATCH 06/12] add screen fuzz test Signed-off-by: qinlong0101 --- services/screenservice/test/fuzztest/BUILD.gn | 2 +- .../test/fuzztest/screendatachannel_fuzzer/BUILD.gn | 5 +---- .../test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn | 5 +---- .../test/fuzztest/screensourcetrans_fuzzer/BUILD.gn | 5 +---- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/services/screenservice/test/fuzztest/BUILD.gn b/services/screenservice/test/fuzztest/BUILD.gn index beae3f41..a63f7a6f 100644 --- a/services/screenservice/test/fuzztest/BUILD.gn +++ b/services/screenservice/test/fuzztest/BUILD.gn @@ -15,4 +15,4 @@ group("fuzztest") { testonly = true deps = [ "sinkservice_fuzzer:fuzztest" ] -} \ No newline at end of file +} diff --git a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn index 6ce4f8a6..d12a0bae 100644 --- a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn +++ b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn @@ -16,7 +16,6 @@ import("//build/config/features.gni") import("//build/test.gni") import( "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") - ##############################fuzztest########################################## ohos_fuzztest("ScreenDataChannelFuzzTest") { module_out_path = "distributed_screen/screendatachannel" @@ -52,9 +51,7 @@ ohos_fuzztest("ScreenDataChannelFuzzTest") { "-fno-omit-frame-pointer", ] - sources = [ - "screen_data_channel_fuzzer.cpp", - ] + sources = [ "screen_data_channel_fuzzer.cpp" ] deps = [ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", diff --git a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn index 055e8fb5..48fc3fe6 100644 --- a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn +++ b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn @@ -16,7 +16,6 @@ import("//build/config/features.gni") import("//build/test.gni") import( "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") - ##############################fuzztest########################################## ohos_fuzztest("ScreenSourceProcessorFuzzTest") { module_out_path = "distributed_screen/screensourceprocessor" @@ -53,9 +52,7 @@ ohos_fuzztest("ScreenSourceProcessorFuzzTest") { "-fno-omit-frame-pointer", ] - sources = [ - "screen_source_processor_fuzzer.cpp", - ] + sources = [ "screen_source_processor_fuzzer.cpp" ] deps = [ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", diff --git a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn index ff1a4ab4..14415474 100644 --- a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn +++ b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn @@ -16,7 +16,6 @@ import("//build/config/features.gni") import("//build/test.gni") import( "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") - ##############################fuzztest########################################## ohos_fuzztest("ScreenSourceTransFuzzTest") { module_out_path = "distributed_screen/screensourcetrans" @@ -61,9 +60,7 @@ ohos_fuzztest("ScreenSourceTransFuzzTest") { "-fno-omit-frame-pointer", ] - sources = [ - "screen_source_trans_fuzzer.cpp", - ] + sources = [ "screen_source_trans_fuzzer.cpp" ] deps = [ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", -- Gitee From cbc8008cfb2c9bc6b397190538ede26b373e19c3 Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Fri, 22 Apr 2022 18:14:45 +0800 Subject: [PATCH 07/12] add screen fuzz test Signed-off-by: qinlong0101 --- bundle.json | 6 +++--- services/screentransport/test/fuzztest/BUILD.gn | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bundle.json b/bundle.json index 4af063fd..fcd77c3f 100644 --- a/bundle.json +++ b/bundle.json @@ -82,9 +82,9 @@ "//foundation/distributedhardware/distributedscreen/services/common/test/unittest:service_common_test", "//foundation/distributedhardware/distributedscreen/screenhandler/test/fuzztest:fuzztest", "//foundation/distributedhardware/distributedscreen/interfaces/innerkits/native_cpp/test/fuzztest:fuzztest", - "//foundation/distributedhardware/distributedscreen/services/softbusadapter/test/fuzztest:fuzztest", - "//foundation/distributedhardware/distributedscreen/services/screenservice/test/fuzztest:fuzztest", - "//foundation/distributedhardware/distributedscreen/services/screentransport/test/fuzztest:fuzztest" + "//foundation/distributedhardware/distributedscreen/services/softbusadapter/test/fuzztest:fuzztest", + "//foundation/distributedhardware/distributedscreen/services/screenservice/test/fuzztest:fuzztest", + "//foundation/distributedhardware/distributedscreen/services/screentransport/test/fuzztest:fuzztest" ] } } diff --git a/services/screentransport/test/fuzztest/BUILD.gn b/services/screentransport/test/fuzztest/BUILD.gn index 82e2a92c..02b6da6b 100644 --- a/services/screentransport/test/fuzztest/BUILD.gn +++ b/services/screentransport/test/fuzztest/BUILD.gn @@ -19,4 +19,4 @@ group("fuzztest") { "screensourceprocessor_fuzzer:fuzztest", "screensourcetrans_fuzzer:fuzztest", ] -} \ No newline at end of file +} -- Gitee From f4f31eca0a1dbc335ea6f72eb50a91e7c3b23462 Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Sun, 24 Apr 2022 09:10:12 +0800 Subject: [PATCH 08/12] add screen fuzz test Signed-off-by: qinlong0101 --- .../test/fuzztest/screendatachannel_fuzzer/BUILD.gn | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn index d12a0bae..7895eec6 100644 --- a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn +++ b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn @@ -16,11 +16,13 @@ import("//build/config/features.gni") import("//build/test.gni") import( "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") + ##############################fuzztest########################################## ohos_fuzztest("ScreenDataChannelFuzzTest") { module_out_path = "distributed_screen/screendatachannel" - fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screendatachannel_fuzzer" + fuzz_config_file = + "${services_path}/screentransport/test/fuzztest/screendatachannel_fuzzer" include_dirs = [ "//third_party/json/include", @@ -54,9 +56,9 @@ ohos_fuzztest("ScreenDataChannelFuzzTest") { sources = [ "screen_data_channel_fuzzer.cpp" ] deps = [ - "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", - "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", "${fwk_utils_path}:distributedhardwareutils", + "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", + "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", "//foundation/graphic/standard/frameworks/surface:surface", "//utils/native/base:utils", ] @@ -73,9 +75,10 @@ ohos_fuzztest("ScreenDataChannelFuzzTest") { "multimedia_media_standard:media_client", ] } + ############################################################################### group("fuzztest") { testonly = true deps = [ ":ScreenDataChannelFuzzTest" ] } -############################################################################### \ No newline at end of file +############################################################################### -- Gitee From 84d3f9aea8597309db3b817efd1d693a7ed4f7fd Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Sun, 24 Apr 2022 09:29:10 +0800 Subject: [PATCH 09/12] add screen fuzz test Signed-off-by: qinlong0101 --- .../test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn | 4 +++- .../test/fuzztest/screensourcetrans_fuzzer/BUILD.gn | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn index 48fc3fe6..979a7ea0 100644 --- a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn +++ b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn @@ -16,6 +16,7 @@ import("//build/config/features.gni") import("//build/test.gni") import( "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") + ##############################fuzztest########################################## ohos_fuzztest("ScreenSourceProcessorFuzzTest") { module_out_path = "distributed_screen/screensourceprocessor" @@ -55,8 +56,8 @@ ohos_fuzztest("ScreenSourceProcessorFuzzTest") { sources = [ "screen_source_processor_fuzzer.cpp" ] deps = [ - "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", "${fwk_utils_path}:distributedhardwareutils", + "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", "//foundation/graphic/standard/frameworks/surface:surface", "//utils/native/base:utils", ] @@ -73,6 +74,7 @@ ohos_fuzztest("ScreenSourceProcessorFuzzTest") { "multimedia_media_standard:media_client", ] } + ############################################################################### group("fuzztest") { testonly = true diff --git a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn index 14415474..9e412523 100644 --- a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn +++ b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn @@ -16,6 +16,7 @@ import("//build/config/features.gni") import("//build/test.gni") import( "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") + ##############################fuzztest########################################## ohos_fuzztest("ScreenSourceTransFuzzTest") { module_out_path = "distributed_screen/screensourcetrans" -- Gitee From e3a8dab88d3d4a790ae684253296d8524b4f4f7e Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Sun, 24 Apr 2022 09:39:30 +0800 Subject: [PATCH 10/12] add screen fuzz test Signed-off-by: qinlong0101 --- .../fuzztest/screensourcetrans_fuzzer/BUILD.gn | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn index 9e412523..bee0caa7 100644 --- a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn +++ b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn @@ -16,14 +16,15 @@ import("//build/config/features.gni") import("//build/test.gni") import( "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") - + ##############################fuzztest########################################## ohos_fuzztest("ScreenSourceTransFuzzTest") { module_out_path = "distributed_screen/screensourcetrans" - fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensourcetrans_fuzzer" + fuzz_config_file = + "${services_path}/screentransport/test/fuzztest/screensourcetrans_fuzzer" - include_dirs = [ + include_dirs = [ "//third_party/json/include", "//foundation/graphic/standard/interfaces/innerkits/surface", "${windowmanager_path}/interfaces/innerkits/dm", @@ -64,11 +65,11 @@ ohos_fuzztest("ScreenSourceTransFuzzTest") { sources = [ "screen_source_trans_fuzzer.cpp" ] deps = [ - "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", - "${services_path}/screenservice/sourceservice:distributed_screen_source", + "${fwk_utils_path}:distributedhardwareutils", "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", + "${services_path}/screenservice/sourceservice:distributed_screen_source", + "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", "${windowmanager_path}/dm:libdm", - "${fwk_utils_path}:distributedhardwareutils", "//foundation/graphic/standard/frameworks/surface:surface", "//utils/native/base:utils", ] @@ -85,6 +86,7 @@ ohos_fuzztest("ScreenSourceTransFuzzTest") { "multimedia_media_standard:media_client", ] } + ############################################################################### group("fuzztest") { testonly = true -- Gitee From 241e2bbe41615305443a23208335c4aadcc05901 Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Sun, 24 Apr 2022 09:55:49 +0800 Subject: [PATCH 11/12] add screen fuzz test Signed-off-by: qinlong0101 --- services/softbusadapter/test/fuzztest/BUILD.gn | 2 +- .../test/fuzztest/softbusadapter_fuzzer/BUILD.gn | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/services/softbusadapter/test/fuzztest/BUILD.gn b/services/softbusadapter/test/fuzztest/BUILD.gn index dceae266..598cc3f3 100644 --- a/services/softbusadapter/test/fuzztest/BUILD.gn +++ b/services/softbusadapter/test/fuzztest/BUILD.gn @@ -15,4 +15,4 @@ group("fuzztest") { testonly = true deps = [ "softbusadapter_fuzzer:fuzztest" ] -} \ No newline at end of file +} diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn index f80355f7..77a288ee 100644 --- a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn +++ b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn @@ -21,7 +21,8 @@ import( ohos_fuzztest("SoftbusAdapterFuzzTest") { module_out_path = "distributed_screen/softbusadapter" - fuzz_config_file = "${services_path}/softbusadapter/test/fuzztest/softbusadapter_fuzzer" + fuzz_config_file = + "${services_path}/softbusadapter/test/fuzztest/softbusadapter_fuzzer" include_dirs = [ "//third_party/json/include", @@ -63,9 +64,9 @@ ohos_fuzztest("SoftbusAdapterFuzzTest") { ] defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"SoftbusAdapterFuzzTest\"", - "LOG_DOMAIN=0xD004100", + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SoftbusAdapterFuzzTest\"", + "LOG_DOMAIN=0xD004100", ] external_deps = [ @@ -78,6 +79,6 @@ ohos_fuzztest("SoftbusAdapterFuzzTest") { ############################################################################### group("fuzztest") { testonly = true -deps = [ ":SoftbusAdapterFuzzTest" ] + deps = [ ":SoftbusAdapterFuzzTest" ] } ############################################################################### -- Gitee From 65f81bd46f935b4b6ab9c7d90c7d4258307e4a0b Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Sun, 24 Apr 2022 10:31:34 +0800 Subject: [PATCH 12/12] add screen fuzz test Signed-off-by: qinlong0101 --- .../test/fuzztest/softbusadapter_fuzzer/BUILD.gn | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn index 77a288ee..016636e8 100644 --- a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn +++ b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn @@ -21,7 +21,7 @@ import( ohos_fuzztest("SoftbusAdapterFuzzTest") { module_out_path = "distributed_screen/softbusadapter" - fuzz_config_file = + fuzz_config_file = "${services_path}/softbusadapter/test/fuzztest/softbusadapter_fuzzer" include_dirs = [ @@ -49,16 +49,14 @@ ohos_fuzztest("SoftbusAdapterFuzzTest") { "-g", "-O0", "-Wno-unused-variable", - "-fno-omit-frame-pointer" + "-fno-omit-frame-pointer", ] - sources = [ - "softbus_adapter_fuzzer.cpp", - ] + sources = [ "softbus_adapter_fuzzer.cpp" ] deps = [ - "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", "${fwk_utils_path}:distributedhardwareutils", + "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", "//foundation/graphic/standard/frameworks/surface:surface", "//utils/native/base:utils", ] -- Gitee