From 0dd4489a0530c0bffd61e4403419466f3918549e Mon Sep 17 00:00:00 2001 From: pwx1285814 Date: Sat, 17 Aug 2024 14:03:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85fuzz=E7=94=A8=E4=BE=8B,?= =?UTF-8?q?=E4=BF=AE=E6=94=B9googletest=E4=B8=BA=E9=9D=9E=E7=BB=9D?= =?UTF-8?q?=E5=AF=B9=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: pwx1285814 --- bundle.json | 7 +-- .../initsink_fuzzer.cpp | 5 +++ .../proxyinitsink_fuzzer/initsink_fuzzer.cpp | 1 + .../initsource_fuzzer.cpp | 1 + .../test/unittest/screensinktest/BUILD.gn | 8 ++-- .../test/unittest/screensourcetest/BUILD.gn | 8 ++-- .../test/unittest/screenhandler/BUILD.gn | 9 ++-- .../common/test/unittest/databuffer/BUILD.gn | 12 ++--- services/common/test/unittest/utils/BUILD.gn | 9 ++-- services/screenclient/test/unittest/BUILD.gn | 4 +- .../dscreenmanager_fuzzer.cpp | 22 +-------- .../sinkservice/dscreenservice/BUILD.gn | 4 +- .../sinkservice/screenregionmgr/BUILD.gn | 4 +- .../sourceservice/dscreenmgr/BUILD.gn | 4 +- .../sourceservice/dscreenservice/BUILD.gn | 4 +- .../test/unittest/screendatachannel/BUILD.gn | 8 ++-- .../unittest/screensinkprocessor/BUILD.gn | 8 ++-- .../test/unittest/screensinktrans/BUILD.gn | 8 ++-- .../unittest/screensourceprocessor/BUILD.gn | 8 ++-- .../test/unittest/screensourcetrans/BUILD.gn | 8 ++-- .../unittest/screentranstestutils/BUILD.gn | 4 +- .../fuzztest/softbusadapter_fuzzer/BUILD.gn | 10 +++-- .../softbusadapter_fuzzer/mock_socket.cpp | 45 +++++++++++++++++++ .../softbusadapter/test/unittest/BUILD.gn | 8 ++-- 24 files changed, 115 insertions(+), 94 deletions(-) create mode 100644 services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/mock_socket.cpp diff --git a/bundle.json b/bundle.json index d60cc459..ede16417 100644 --- a/bundle.json +++ b/bundle.json @@ -47,10 +47,11 @@ "c_utils", "window_manager", "distributed_hardware_fwk", - "libjpeg-turbo", - "json" + "libjpeg-turbo" ], - "third_party": [] + "third_party": [ + "googletest" + ] }, "build": { "sub_component": [ diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerinitsink_fuzzer/initsink_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerinitsink_fuzzer/initsink_fuzzer.cpp index e6a5e6fc..ece8a40a 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerinitsink_fuzzer/initsink_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerinitsink_fuzzer/initsink_fuzzer.cpp @@ -29,8 +29,13 @@ void InitSinkFuzzTest(const uint8_t* data, size_t size) } std::string params(reinterpret_cast(data), size); + std::string networkId(reinterpret_cast(data), size); DScreenSinkHandler::GetInstance().InitSink(params); + DScreenSinkHandler::GetInstance().PauseDistributedHardware(networkId); + DScreenSinkHandler::GetInstance().ResumeDistributedHardware(networkId); + DScreenSinkHandler::GetInstance().StopDistributedHardware(networkId); + DScreenSinkHandler::GetInstance().ReleaseSink(); } } // namespace DistributedHardware } // namespace OHOS diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyinitsink_fuzzer/initsink_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyinitsink_fuzzer/initsink_fuzzer.cpp index 33937b93..819d9352 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyinitsink_fuzzer/initsink_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyinitsink_fuzzer/initsink_fuzzer.cpp @@ -47,6 +47,7 @@ void InitSinkFuzzTest(const uint8_t* data, size_t size) std::shared_ptr dscreenSinkProxy = std::make_shared(remoteObject); dscreenSinkProxy->InitSink(params); + dscreenSinkProxy->ReleaseSink(); } } // namespace DistributedHardware } // namespace OHOS diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/initsource_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/initsource_fuzzer.cpp index 2d40347a..bfa212bf 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/initsource_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/initsource_fuzzer.cpp @@ -31,6 +31,7 @@ void InitSourceFuzzTest(const uint8_t* data, size_t size) std::string params(reinterpret_cast(data), size); DScreenSourceHandler::GetInstance().InitSource(params); + DScreenSourceHandler::GetInstance().ReleaseSource(); } } // namespace DistributedHardware } // namespace OHOS diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn b/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn index 56a525ca..4752e7e6 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn @@ -48,15 +48,13 @@ ohos_unittest("ScreenSinkTest") { "${common_path}/test/unittest/resource:dscreen_unittest_public_config", ] - deps = [ - "${interfaces_path}/innerkits/native_cpp/screen_sink:distributed_screen_sink_sdk", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] + deps = [ "${interfaces_path}/innerkits/native_cpp/screen_sink:distributed_screen_sink_sdk" ] external_deps = [ "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", + "googletest:gmock", + "googletest:gtest_main", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn index 331104b7..582577ba 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn @@ -52,15 +52,13 @@ ohos_unittest("ScreenSourceTest") { "${common_path}/test/unittest/resource:dscreen_unittest_public_config", ] - deps = [ - "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] + deps = [ "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk" ] external_deps = [ "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", + "googletest:gmock", + "googletest:gtest_main", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/screenhandler/test/unittest/screenhandler/BUILD.gn b/screenhandler/test/unittest/screenhandler/BUILD.gn index 6fc2f86b..1d6d96d8 100644 --- a/screenhandler/test/unittest/screenhandler/BUILD.gn +++ b/screenhandler/test/unittest/screenhandler/BUILD.gn @@ -42,16 +42,15 @@ ohos_unittest("DscreenHandlerTest") { "${common_path}/test/unittest/resource:dscreen_unittest_public_config", ] - deps = [ - "${distributedscreen_path}/screenhandler:distributed_screen_handler", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] + deps = + [ "${distributedscreen_path}/screenhandler:distributed_screen_handler" ] external_deps = [ "av_codec:av_codec_client", "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", + "googletest:gmock", + "googletest:gtest_main", "graphic_2d:libgraphic_utils", "graphic_surface:surface", "hilog:libhilog", diff --git a/services/common/test/unittest/databuffer/BUILD.gn b/services/common/test/unittest/databuffer/BUILD.gn index 63275332..6b962131 100644 --- a/services/common/test/unittest/databuffer/BUILD.gn +++ b/services/common/test/unittest/databuffer/BUILD.gn @@ -46,13 +46,13 @@ ohos_unittest("DataBufferTest") { "${common_path}/test/unittest/resource:dscreen_unittest_public_config", ] - deps = [ - "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] + deps = [ "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans" ] - external_deps = [ "distributed_hardware_fwk:distributedhardwareutils" ] + external_deps = [ + "distributed_hardware_fwk:distributedhardwareutils", + "googletest:gmock", + "googletest:gtest_main", + ] } group("data_buffer_test") { diff --git a/services/common/test/unittest/utils/BUILD.gn b/services/common/test/unittest/utils/BUILD.gn index 58f2bbfc..8ff1370f 100644 --- a/services/common/test/unittest/utils/BUILD.gn +++ b/services/common/test/unittest/utils/BUILD.gn @@ -49,16 +49,15 @@ ohos_unittest("UtilsTest") { "${common_path}/test/unittest/resource:dscreen_unittest_public_config", ] - deps = [ - "${services_path}/screenservice/sinkservice:distributed_screen_sink", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] + deps = + [ "${services_path}/screenservice/sinkservice:distributed_screen_sink" ] external_deps = [ "distributed_hardware_fwk:distributed_av_sender", "distributed_hardware_fwk:distributedhardwareutils", "distributed_hardware_fwk:libdhfwk_sdk", + "googletest:gmock", + "googletest:gtest_main", ] } diff --git a/services/screenclient/test/unittest/BUILD.gn b/services/screenclient/test/unittest/BUILD.gn index 0e19567d..057379e3 100644 --- a/services/screenclient/test/unittest/BUILD.gn +++ b/services/screenclient/test/unittest/BUILD.gn @@ -48,13 +48,13 @@ ohos_unittest("ScreenClientTest") { deps = [ "${common_path}:distributed_screen_utils", "${distributedscreen_path}/services/screenclient:distributed_screen_client", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", ] external_deps = [ "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", + "googletest:gmock", + "googletest:gtest_main", "graphic_2d:librender_service_client", "graphic_surface:surface", "input:libmmi-client", diff --git a/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/dscreenmanager_fuzzer/dscreenmanager_fuzzer.cpp b/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/dscreenmanager_fuzzer/dscreenmanager_fuzzer.cpp index eab2ca77..d7380b32 100644 --- a/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/dscreenmanager_fuzzer/dscreenmanager_fuzzer.cpp +++ b/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/dscreenmanager_fuzzer/dscreenmanager_fuzzer.cpp @@ -44,8 +44,8 @@ void HandleScreenChangeFuzzTest(const uint8_t* data, size_t size) uint32_t eventValue = *(reinterpret_cast(data)) % 3; if ((eventValue != static_cast(Rosen::ScreenGroupChangeEvent::ADD_TO_GROUP)) || - (eventValue != static_cast(Rosen::ScreenGroupChangeEvent::ADD_TO_GROUP)) || - (eventValue != static_cast(Rosen::ScreenGroupChangeEvent::ADD_TO_GROUP))) { + (eventValue != static_cast(Rosen::ScreenGroupChangeEvent::REMOVE_FROM_GROUP)) || + (eventValue != static_cast(Rosen::ScreenGroupChangeEvent::CHANGE_GROUP))) { return; } @@ -106,23 +106,6 @@ void DScreenManagerOnUnregResultFuzzTest(const uint8_t* data, size_t size) dscreenManager->OnUnregResult(dScreen, reqId, status, dataStr); } -void EnableDistributedScreenFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - - std::string str(reinterpret_cast(data), size); - std::string devId(reinterpret_cast(data), size); - std::string dhId(reinterpret_cast(data), size); - std::string reqId(reinterpret_cast(data), size); - EnableParam param = {str, str, str, str}; - - std::shared_ptr dscreenManager = std::make_shared(); - dscreenManager->EnableDistributedScreen(devId, dhId, param, reqId); - dscreenManager->DisableDistributedScreen(devId, dhId, reqId); -} - void NotifyRemoteScreenServiceFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size < sizeof(int32_t))) { @@ -163,7 +146,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::DistributedHardware::V1_0::AddToGroupFuzzTest(data, size); OHOS::DistributedHardware::V1_0::DScreenCallbackOnRegResultFuzzTest(data, size); OHOS::DistributedHardware::V1_0::DScreenManagerOnUnregResultFuzzTest(data, size); - OHOS::DistributedHardware::V1_0::EnableDistributedScreenFuzzTest(data, size); OHOS::DistributedHardware::V1_0::NotifyRemoteScreenServiceFuzzTest(data, size); OHOS::DistributedHardware::V1_0::HandleNotifySetUpResultFuzzTest(data, size); return 0; diff --git a/services/screenservice/test/unittest/sinkservice/dscreenservice/BUILD.gn b/services/screenservice/test/unittest/sinkservice/dscreenservice/BUILD.gn index f29179a5..16472d9f 100644 --- a/services/screenservice/test/unittest/sinkservice/dscreenservice/BUILD.gn +++ b/services/screenservice/test/unittest/sinkservice/dscreenservice/BUILD.gn @@ -47,12 +47,12 @@ ohos_unittest("DScreenSinkStubTest") { deps = [ "${interfaces_path}/innerkits/native_cpp/screen_sink:distributed_screen_sink_sdk", "${services_path}/screenservice/sinkservice:distributed_screen_sink", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", ] external_deps = [ "c_utils:utils", + "googletest:gmock", + "googletest:gtest_main", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/services/screenservice/test/unittest/sinkservice/screenregionmgr/BUILD.gn b/services/screenservice/test/unittest/sinkservice/screenregionmgr/BUILD.gn index 8ea8bd57..f9560735 100644 --- a/services/screenservice/test/unittest/sinkservice/screenregionmgr/BUILD.gn +++ b/services/screenservice/test/unittest/sinkservice/screenregionmgr/BUILD.gn @@ -67,8 +67,6 @@ ohos_unittest("DscreenRegionMgrTest") { "${services_path}/screenservice/sinkservice:distributed_screen_sink", "${services_path}/screenservice/sourceservice:distributed_screen_source", "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", ] external_deps = [ @@ -78,6 +76,8 @@ ohos_unittest("DscreenRegionMgrTest") { "distributed_hardware_fwk:distributed_av_receiver", "distributed_hardware_fwk:distributedhardwareutils", "distributed_hardware_fwk:libdhfwk_sdk", + "googletest:gmock", + "googletest:gtest_main", "graphic_2d:libcomposer", "graphic_2d:libgraphic_utils", "graphic_2d:librender_service_client", diff --git a/services/screenservice/test/unittest/sourceservice/dscreenmgr/BUILD.gn b/services/screenservice/test/unittest/sourceservice/dscreenmgr/BUILD.gn index 3d20b361..a9dcd9bf 100644 --- a/services/screenservice/test/unittest/sourceservice/dscreenmgr/BUILD.gn +++ b/services/screenservice/test/unittest/sourceservice/dscreenmgr/BUILD.gn @@ -68,8 +68,6 @@ ohos_unittest("DscreenMgrTest") { "${distributedscreen_path}/common:distributed_screen_utils", "${services_path}/screenservice/sourceservice:distributed_screen_source", "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", ] external_deps = [ @@ -83,6 +81,8 @@ ohos_unittest("DscreenMgrTest") { "distributed_hardware_fwk:distributedhardwareutils", "distributed_hardware_fwk:libdhfwk_sdk", "dsoftbus:softbus_client", + "googletest:gmock", + "googletest:gtest_main", "graphic_2d:libcomposer", "graphic_2d:librender_service_client", "graphic_surface:surface", diff --git a/services/screenservice/test/unittest/sourceservice/dscreenservice/BUILD.gn b/services/screenservice/test/unittest/sourceservice/dscreenservice/BUILD.gn index fffb46fb..6c79e0f3 100644 --- a/services/screenservice/test/unittest/sourceservice/dscreenservice/BUILD.gn +++ b/services/screenservice/test/unittest/sourceservice/dscreenservice/BUILD.gn @@ -52,13 +52,13 @@ ohos_unittest("DScreenSourceStubTest") { deps = [ "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", "${services_path}/screenservice/sourceservice:distributed_screen_source", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", ] external_deps = [ "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", + "googletest:gmock", + "googletest:gtest_main", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/services/screentransport/test/unittest/screendatachannel/BUILD.gn b/services/screentransport/test/unittest/screendatachannel/BUILD.gn index 2d1f4b3b..05329a4d 100644 --- a/services/screentransport/test/unittest/screendatachannel/BUILD.gn +++ b/services/screentransport/test/unittest/screendatachannel/BUILD.gn @@ -52,11 +52,7 @@ ohos_unittest("DataChannelTest") { "${common_path}/test/unittest/resource:dscreen_unittest_public_config", ] - deps = [ - "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] + deps = [ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans" ] external_deps = [ "access_token:libaccesstoken_sdk", @@ -65,6 +61,8 @@ ohos_unittest("DataChannelTest") { "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", "dsoftbus:softbus_client", + "googletest:gmock", + "googletest:gtest_main", "hilog:libhilog", ] diff --git a/services/screentransport/test/unittest/screensinkprocessor/BUILD.gn b/services/screentransport/test/unittest/screensinkprocessor/BUILD.gn index a46b88b2..5b85c35e 100644 --- a/services/screentransport/test/unittest/screensinkprocessor/BUILD.gn +++ b/services/screentransport/test/unittest/screensinkprocessor/BUILD.gn @@ -58,16 +58,14 @@ ohos_unittest("SinkProcessorTest") { "${common_path}/test/unittest/resource:dscreen_unittest_public_config", ] - deps = [ - "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] + deps = [ "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans" ] external_deps = [ "av_codec:av_codec_client", "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", + "googletest:gmock", + "googletest:gtest_main", "graphic_surface:surface", "hilog:libhilog", "media_foundation:media_foundation", diff --git a/services/screentransport/test/unittest/screensinktrans/BUILD.gn b/services/screentransport/test/unittest/screensinktrans/BUILD.gn index 6b4550dc..cf17a523 100644 --- a/services/screentransport/test/unittest/screensinktrans/BUILD.gn +++ b/services/screentransport/test/unittest/screensinktrans/BUILD.gn @@ -55,17 +55,15 @@ ohos_unittest("SinkTransTest") { "${common_path}/test/unittest/resource:dscreen_unittest_public_config", ] - deps = [ - "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] + deps = [ "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans" ] external_deps = [ "av_codec:av_codec_client", "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", "dsoftbus:softbus_client", + "googletest:gmock", + "googletest:gtest_main", "graphic_surface:surface", "hilog:libhilog", "media_foundation:media_foundation", diff --git a/services/screentransport/test/unittest/screensourceprocessor/BUILD.gn b/services/screentransport/test/unittest/screensourceprocessor/BUILD.gn index d10b49cd..f54d1338 100644 --- a/services/screentransport/test/unittest/screensourceprocessor/BUILD.gn +++ b/services/screentransport/test/unittest/screensourceprocessor/BUILD.gn @@ -55,16 +55,14 @@ ohos_unittest("SourceProcessorTest") { "${common_path}/test/unittest/resource:dscreen_unittest_public_config", ] - deps = [ - "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] + deps = [ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans" ] external_deps = [ "av_codec:av_codec_client", "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", + "googletest:gmock", + "googletest:gtest_main", "graphic_surface:surface", "graphic_surface:sync_fence", "ipc:ipc_core", diff --git a/services/screentransport/test/unittest/screensourcetrans/BUILD.gn b/services/screentransport/test/unittest/screensourcetrans/BUILD.gn index cf33b5ea..58997697 100644 --- a/services/screentransport/test/unittest/screensourcetrans/BUILD.gn +++ b/services/screentransport/test/unittest/screensourcetrans/BUILD.gn @@ -55,11 +55,7 @@ ohos_unittest("SourceTransTest") { "${common_path}/test/unittest/resource:dscreen_unittest_public_config", ] - deps = [ - "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] + deps = [ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans" ] external_deps = [ "access_token:libaccesstoken_sdk", @@ -69,6 +65,8 @@ ohos_unittest("SourceTransTest") { "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", "dsoftbus:softbus_client", + "googletest:gmock", + "googletest:gtest_main", "graphic_2d:libgraphic_utils", "graphic_surface:surface", "graphic_surface:sync_fence", diff --git a/services/screentransport/test/unittest/screentranstestutils/BUILD.gn b/services/screentransport/test/unittest/screentranstestutils/BUILD.gn index 36c8da89..62261137 100644 --- a/services/screentransport/test/unittest/screentranstestutils/BUILD.gn +++ b/services/screentransport/test/unittest/screentranstestutils/BUILD.gn @@ -59,14 +59,14 @@ ohos_unittest("ScreenCallbackTest") { deps = [ "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", ] external_deps = [ "av_codec:av_codec_client", "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", + "googletest:gmock", + "googletest:gtest_main", "graphic_2d:libgraphic_utils", "graphic_surface:surface", "graphic_surface:sync_fence", diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn index e2bf14e4..c1c6d526 100644 --- a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn +++ b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn @@ -25,17 +25,21 @@ ohos_fuzztest("SoftbusAdapterFuzzTest") { configs = [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] - sources = [ "softbusadapter_fuzzer.cpp" ] + sources = [ + "mock_socket.cpp", + "softbusadapter_fuzzer.cpp", + ] include_dirs = [ "${common_path}/include", + "${interfaces_path}/innerkits/native_cpp/test/include", "${services_path}/common/databuffer/include", "${services_path}/common/screen_channel/include", "${services_path}/common/utils/include", - "${services_path}/screentransport/screensourcetrans/include", "${services_path}/screentransport/screendatachannel/include", - "${services_path}/screentransport/screensourceprocessor/include", "${services_path}/screentransport/screensourceprocessor/encoder/include", + "${services_path}/screentransport/screensourceprocessor/include", + "${services_path}/screentransport/screensourcetrans/include", "${services_path}/softbusadapter/include", ] diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/mock_socket.cpp b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/mock_socket.cpp new file mode 100644 index 00000000..8b7de21f --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/mock_socket.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 "socket.h" + +constexpr int32_t DH_SUCCESS = 0; + +int Socket(SocketInfo info) +{ + return DH_SUCCESS; +} + +int Listen(int32_t socket, const QosTV qos[], uint32_t qosCount, const ISocketListener *listener) +{ + return DH_SUCCESS; +} + +int Bind(int32_t socket, const QosTV qos[], uint32_t qosCount, const ISocketListener *listener) +{ + return DH_SUCCESS; +} + +void Shutdown(int32_t socket) {} + +int SendBytes(int32_t socket, const void *data, uint32_t len) +{ + return DH_SUCCESS; +} + +int SendStream(int32_t socket, const StreamData *data, const StreamData *ext, const StreamFrameInfo *param) +{ + return DH_SUCCESS; +} diff --git a/services/softbusadapter/test/unittest/BUILD.gn b/services/softbusadapter/test/unittest/BUILD.gn index 02a5fdc2..32aa4c74 100644 --- a/services/softbusadapter/test/unittest/BUILD.gn +++ b/services/softbusadapter/test/unittest/BUILD.gn @@ -50,11 +50,7 @@ ohos_unittest("SoftBusAdapterTest") { "${common_path}/test/unittest/resource:dscreen_unittest_public_config", ] - deps = [ - "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] + deps = [ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans" ] external_deps = [ "access_token:libaccesstoken_sdk", @@ -63,6 +59,8 @@ ohos_unittest("SoftBusAdapterTest") { "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", "dsoftbus:softbus_client", + "googletest:gmock", + "googletest:gtest_main", ] } -- Gitee