From e240e0e79565a6ab694a0992c3ed3853422334ed Mon Sep 17 00:00:00 2001 From: li-tiangang4 Date: Mon, 1 Sep 2025 16:59:47 +0800 Subject: [PATCH] =?UTF-8?q?FUZZ=E7=94=A8=E4=BE=8B=E8=A7=84=E8=8C=83?= =?UTF-8?q?=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-tiangang4 --- bundle.json | 1 - .../test/fuzztest/BUILD.gn | 11 +- .../fuzztest/componentloader_fuzzer/BUILD.gn | 67 ----- .../componentloader_fuzzer.cpp | 70 ----- .../componentloader_fuzzer.h | 21 -- .../componentloader_fuzzer/corpus/init | 16 -- .../componentloader_fuzzer/project.xml | 25 -- .../fuzztest/componentmanager_fuzzer/BUILD.gn | 72 ----- .../componentmanager_fuzzer.cpp | 114 -------- .../componentmanager_fuzzer.h | 21 -- .../componentmanager_fuzzer/corpus/init | 16 -- .../componentmanager_fuzzer/project.xml | 25 -- .../fuzztest/dhmanagerfactory_fuzzer/BUILD.gn | 67 ----- .../dhmanagerfactory_fuzzer/corpus/init | 16 -- .../dhmanagerfactory_fuzzer.cpp | 54 ---- .../dhmanagerfactory_fuzzer.h | 22 -- .../dhmanagerfactory_fuzzer/project.xml | 25 -- .../distributedfwkservices_fuzzer/BUILD.gn | 73 ------ .../distributedfwkservices_fuzzer/corpus/init | 16 -- .../distributedfwkservices_fuzzer.cpp | 245 ------------------ .../distributedfwkservices_fuzzer.h | 21 -- .../distributedfwkservices_fuzzer/project.xml | 25 -- .../fuzztest/enabledcompsdump_fuzzer/BUILD.gn | 67 ----- .../enabledcompsdump_fuzzer/corpus/init | 16 -- .../enabledcompsdump_fuzzer.cpp | 63 ----- .../enabledcompsdump_fuzzer.h | 22 -- .../enabledcompsdump_fuzzer/project.xml | 25 -- .../test/fuzztest/metainfomgr_fuzzer/BUILD.gn | 73 ------ .../fuzztest/metainfomgr_fuzzer/corpus/init | 16 -- .../metainfomgr_fuzzer/metainfomgr_fuzzer.cpp | 76 ------ .../metainfomgr_fuzzer/metainfomgr_fuzzer.h | 22 -- .../fuzztest/metainfomgr_fuzzer/project.xml | 25 -- .../fuzztest/resourcemanager_fuzzer/BUILD.gn | 68 ----- .../resourcemanager_fuzzer/corpus/init | 16 -- .../resourcemanager_fuzzer/project.xml | 25 -- .../resourcemanager_fuzzer.cpp | 78 ------ .../resourcemanager_fuzzer.h | 21 -- .../test/fuzztest/task_fuzzer/BUILD.gn | 67 ----- .../test/fuzztest/task_fuzzer/corpus/init | 16 -- .../test/fuzztest/task_fuzzer/project.xml | 25 -- .../test/fuzztest/task_fuzzer/task_fuzzer.cpp | 77 ------ .../test/fuzztest/task_fuzzer/task_fuzzer.h | 21 -- .../versioninfomanager_fuzzer/BUILD.gn | 67 ----- .../versioninfomanager_fuzzer/corpus/init | 16 -- .../versioninfomanager_fuzzer/project.xml | 25 -- .../versioninfomanager_fuzzer.cpp | 76 ------ .../versioninfomanager_fuzzer.h | 22 -- utils/test/fuzztest/BUILD.gn | 18 -- utils/test/fuzztest/utils_fuzzer/BUILD.gn | 50 ---- utils/test/fuzztest/utils_fuzzer/corpus/init | 16 -- utils/test/fuzztest/utils_fuzzer/project.xml | 25 -- .../fuzztest/utils_fuzzer/utils_fuzzer.cpp | 70 ----- .../test/fuzztest/utils_fuzzer/utils_fuzzer.h | 21 -- .../histreamer_ability_parser/BUILD.gn | 0 .../histreamer_ability_parser_test.cpp | 0 .../histreamer_ability_parser_test.h | 0 .../unittest/{common => }/utilstool/BUILD.gn | 0 .../utilstool/utils_tool_test.cpp | 0 .../{common => }/utilstool/utils_tool_test.h | 0 59 files changed, 1 insertion(+), 2247 deletions(-) delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/BUILD.gn delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/componentloader_fuzzer.cpp delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/componentloader_fuzzer.h delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/corpus/init delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/project.xml delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/BUILD.gn delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/componentmanager_fuzzer.cpp delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/componentmanager_fuzzer.h delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/corpus/init delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/project.xml delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/BUILD.gn delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/corpus/init delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/dhmanagerfactory_fuzzer.cpp delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/dhmanagerfactory_fuzzer.h delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/project.xml delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/BUILD.gn delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/corpus/init delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/distributedfwkservices_fuzzer.cpp delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/distributedfwkservices_fuzzer.h delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/project.xml delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/BUILD.gn delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/corpus/init delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.cpp delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.h delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/project.xml delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/BUILD.gn delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/corpus/init delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/metainfomgr_fuzzer.cpp delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/metainfomgr_fuzzer.h delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/project.xml delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/BUILD.gn delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/corpus/init delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/project.xml delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/resourcemanager_fuzzer.cpp delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/resourcemanager_fuzzer.h delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/BUILD.gn delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/corpus/init delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/project.xml delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/task_fuzzer.cpp delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/task_fuzzer.h delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/BUILD.gn delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/corpus/init delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/project.xml delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/versioninfomanager_fuzzer.cpp delete mode 100644 services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/versioninfomanager_fuzzer.h delete mode 100644 utils/test/fuzztest/BUILD.gn delete mode 100644 utils/test/fuzztest/utils_fuzzer/BUILD.gn delete mode 100644 utils/test/fuzztest/utils_fuzzer/corpus/init delete mode 100644 utils/test/fuzztest/utils_fuzzer/project.xml delete mode 100644 utils/test/fuzztest/utils_fuzzer/utils_fuzzer.cpp delete mode 100644 utils/test/fuzztest/utils_fuzzer/utils_fuzzer.h rename utils/test/unittest/{common => }/histreamer_ability_parser/BUILD.gn (100%) rename utils/test/unittest/{common => }/histreamer_ability_parser/histreamer_ability_parser_test.cpp (100%) rename utils/test/unittest/{common => }/histreamer_ability_parser/histreamer_ability_parser_test.h (100%) rename utils/test/unittest/{common => }/utilstool/BUILD.gn (100%) rename utils/test/unittest/{common => }/utilstool/utils_tool_test.cpp (100%) rename utils/test/unittest/{common => }/utilstool/utils_tool_test.h (100%) diff --git a/bundle.json b/bundle.json index 21414068..b4379cda 100644 --- a/bundle.json +++ b/bundle.json @@ -158,7 +158,6 @@ "//foundation/distributedhardware/distributed_hardware_fwk/utils/test/unittest:utils_test", "//foundation/distributedhardware/distributed_hardware_fwk/services/distributedhardwarefwkservice/test/unittest:test", "//foundation/distributedhardware/distributed_hardware_fwk/interfaces/inner_kits/test/unittest:kit_test", - "//foundation/distributedhardware/distributed_hardware_fwk/utils/test/fuzztest:fuzztest", "//foundation/distributedhardware/distributed_hardware_fwk/services/distributedhardwarefwkservice/test/fuzztest:fuzztest", "//foundation/distributedhardware/distributed_hardware_fwk/interfaces/inner_kits/test/fuzztest:fuzztest", "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/filters/test:filter_test", diff --git a/services/distributedhardwarefwkservice/test/fuzztest/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/BUILD.gn index c5982924..f3ee8d44 100644 --- a/services/distributedhardwarefwkservice/test/fuzztest/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/fuzztest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2024 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -20,18 +20,9 @@ group("fuzztest") { "capabilityinfomanager_fuzzer:fuzztest", "componentdisable_fuzzer:fuzztest", "componentenable_fuzzer:fuzztest", - "componentloader_fuzzer:fuzztest", - "componentmanager_fuzzer:fuzztest", "dhcommtool_fuzzer:fuzztest", - "dhmanagerfactory_fuzzer:fuzztest", "dhtransport_fuzzer:fuzztest", - "distributedfwkservices_fuzzer:fuzztest", - "enabledcompsdump_fuzzer:fuzztest", - "metainfomgr_fuzzer:fuzztest", "publisher_fuzzer:fuzztest", "publisheritem_fuzzer:fuzztest", - "resourcemanager_fuzzer:fuzztest", - "task_fuzzer:fuzztest", - "versioninfomanager_fuzzer:fuzztest", ] } diff --git a/services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/BUILD.gn deleted file mode 100644 index 51da25a7..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/BUILD.gn +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright (c) 2023-2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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/distributed_hardware_fwk/distributedhardwarefwk.gni") - -##############################fuzztest########################################## -ohos_fuzztest("ComponentLoaderFuzzTest") { - module_out_path = fuzz_test_output_path - fuzz_config_file = "${services_path}/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer" - - include_dirs = [ - "include", - "${utils_path}/include", - "${services_path}/distributedhardwarefwkservice/include", - "${services_path}/distributedhardwarefwkservice/include/versionmanager", - "${services_path}/distributedhardwarefwkservice/include/resourcemanager", - "${services_path}/distributedhardwarefwkservice/include/componentloader", - "${services_path}/distributedhardwarefwkservice/include/utils", - "${common_path}/utils/include", - "${common_path}/log/include", - ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "componentloader_fuzzer.cpp" ] - - deps = [ - "${services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"ComponentLoaderFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] - - external_deps = [ - "cJSON:cjson", - "eventhandler:libeventhandler", - "hilog:libhilog", - "samgr:samgr_proxy", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":ComponentLoaderFuzzTest" ] -} -############################################################################### diff --git a/services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/componentloader_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/componentloader_fuzzer.cpp deleted file mode 100644 index ba495a48..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/componentloader_fuzzer.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2022-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 "componentloader_fuzzer.h" - -#include -#include - -#include "component_loader.h" -#include "constants.h" -#include "distributed_hardware_errno.h" -#include "distributed_hardware_log.h" - -namespace OHOS { -namespace DistributedHardware { -namespace { -const uint32_t DH_TYPE_SIZE = 10; -const DHType dhTypeFuzz[DH_TYPE_SIZE] = { - DHType::CAMERA, DHType::AUDIO, DHType::SCREEN, DHType::VIRMODEM_AUDIO, - DHType::INPUT, DHType::A2D, DHType::GPS, DHType::HFP -}; -} - -void ComponentManagerFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - - ComponentLoader::GetInstance().Init(); - DHType dhType = dhTypeFuzz[data[0] % DH_TYPE_SIZE]; - - IHardwareHandler *hardwareHandlerPtr = nullptr; - ComponentLoader::GetInstance().GetHardwareHandler(dhType, hardwareHandlerPtr); - IDistributedHardwareSource *sourcePtr = nullptr; - ComponentLoader::GetInstance().GetSource(dhType, sourcePtr); - IDistributedHardwareSink *sinkPtr = nullptr; - ComponentLoader::GetInstance().GetSink(dhType, sinkPtr); - - ComponentLoader::GetInstance().ReleaseHardwareHandler(dhType); - ComponentLoader::GetInstance().ReleaseSource(dhType); - ComponentLoader::GetInstance().ReleaseSink(dhType); - - ComponentLoader::GetInstance().GetHardwareHandler(dhType); - ComponentLoader::GetInstance().GetSource(dhType); - ComponentLoader::GetInstance().GetSink(dhType); -} -} -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::ComponentManagerFuzzTest(data, size); - return 0; -} - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/componentloader_fuzzer.h b/services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/componentloader_fuzzer.h deleted file mode 100644 index 09c49fae..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/componentloader_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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_COMPONENTMANAGER_FUZZER_H -#define TEST_COMPONENTMANAGER_FUZZER_H - -#define FUZZ_PROJECT_NAME "componentloader_fuzzer" - -#endif diff --git a/services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/corpus/init b/services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/project.xml b/services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cf..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/BUILD.gn deleted file mode 100644 index e5e82900..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/BUILD.gn +++ /dev/null @@ -1,72 +0,0 @@ -# Copyright (c) 2023-2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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("../../../../../distributedhardwarefwk.gni") - -##############################fuzztest########################################## -ohos_fuzztest("ComponentManagerFuzzTest") { - module_out_path = fuzz_test_output_path - fuzz_config_file = "${services_path}/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer" - - include_dirs = [ - "${av_trans_path}/common/include", - "${innerkits_path}/include", - "${utils_path}/include", - "${services_path}/distributedhardwarefwkservice/include", - "${services_path}/distributedhardwarefwkservice/include/componentmanager", - "${services_path}/distributedhardwarefwkservice/include/lowlatency", - "${services_path}/distributedhardwarefwkservice/include/resourcemanager", - "${services_path}/distributedhardwarefwkservice/include/utils", - "${services_path}/distributedhardwarefwkservice/include/task", - "${services_path}/distributedhardwarefwkservice/include/transport", - "${common_path}/utils/include", - "${common_path}/log/include", - ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "componentmanager_fuzzer.cpp" ] - - deps = [ - "${services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", - ] - - external_deps = [ - "cJSON:cjson", - "c_utils:utils", - "dsoftbus:softbus_client", - "eventhandler:libeventhandler", - "hilog:libhilog", - "ipc:ipc_single", - "samgr:samgr_proxy", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"ComponentManagerFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":ComponentManagerFuzzTest" ] -} -############################################################################### diff --git a/services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/componentmanager_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/componentmanager_fuzzer.cpp deleted file mode 100644 index e473a524..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/componentmanager_fuzzer.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2022-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 "componentmanager_fuzzer.h" - -#include -#include -#include - -#include "component_disable.h" -#include "component_enable.h" -#include "component_manager.h" -#include "constants.h" -#include "distributed_hardware_errno.h" -#include "distributed_hardware_log.h" -#include "dh_data_sync_trigger_listener.h" -#include "dh_state_listener.h" -#include "event_handler.h" - -namespace OHOS { -namespace DistributedHardware { -namespace { - const uint32_t DH_TYPE_SIZE = 10; - const DHType dhTypeFuzz[DH_TYPE_SIZE] = { - DHType::CAMERA, DHType::AUDIO, DHType::SCREEN, DHType::VIRMODEM_AUDIO, - DHType::INPUT, DHType::A2D, DHType::GPS, DHType::HFP - }; -} -void ComponentManagerFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < sizeof(int32_t))) { - return; - } - - std::string networkId(reinterpret_cast(data), size); - std::string uuid(reinterpret_cast(data), size); - std::string dhId(reinterpret_cast(data), size); - DHType dhType = dhTypeFuzz[data[0] % DH_TYPE_SIZE]; - bool enableSource = false; - sptr sinkListener = nullptr; - sptr sourceListener = nullptr; - FuzzedDataProvider fdp(data, size); - int32_t callingUid = fdp.ConsumeIntegral(); - int32_t callingPid = fdp.ConsumeIntegral(); - DHDescriptor dhDescriptor { - .id = std::string(reinterpret_cast(data), size), - .dhType = dhType - }; - - ComponentManager::GetInstance().Init(); - ComponentManager::GetInstance().Enable(networkId, uuid, dhId, dhType); - ComponentManager::GetInstance().Disable(networkId, uuid, dhId, dhType); - ComponentManager::GetInstance().CheckDemandStart(uuid, dhType, enableSource); - ComponentManager::GetInstance().RegisterDHStatusListener(sinkListener, callingUid, callingPid); - ComponentManager::GetInstance().UnregisterDHStatusListener(sinkListener, callingUid, callingPid); - ComponentManager::GetInstance().RegisterDHStatusListener(networkId, sourceListener, callingUid, callingPid); - ComponentManager::GetInstance().UnregisterDHStatusListener(networkId, sourceListener, callingUid, callingPid); - ComponentManager::GetInstance().EnableSink(dhDescriptor, callingUid, callingPid); - ComponentManager::GetInstance().DisableSink(dhDescriptor, callingUid, callingPid); - ComponentManager::GetInstance().EnableSource(networkId, dhDescriptor, callingUid, callingPid); - ComponentManager::GetInstance().DisableSource(networkId, dhDescriptor, callingUid, callingPid); - ComponentManager::GetInstance().ForceDisableSink(dhDescriptor); - ComponentManager::GetInstance().ForceDisableSource(networkId, dhDescriptor); - ComponentManager::GetInstance().UnInit(); -} - -void OnDataSyncTriggerFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - - std::string networkId(reinterpret_cast(data), size); - DHDataSyncTriggerListener dhDataSyncTrigger; - dhDataSyncTrigger.OnDataSyncTrigger(networkId); -} - -void OnStateChangedFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - - std::string networkId(reinterpret_cast(data), size); - std::string dhId(reinterpret_cast(data), size); - BusinessState state = BusinessState::UNKNOWN; - DHStateListener dhData; - dhData.OnStateChanged(networkId, dhId, state); -} -} -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::ComponentManagerFuzzTest(data, size); - OHOS::DistributedHardware::OnDataSyncTriggerFuzzTest(data, size); - OHOS::DistributedHardware::OnStateChangedFuzzTest(data, size); - return 0; -} - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/componentmanager_fuzzer.h b/services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/componentmanager_fuzzer.h deleted file mode 100644 index bc780435..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/componentmanager_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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_COMPONENTMANAGER_FUZZER_H -#define TEST_COMPONENTMANAGER_FUZZER_H - -#define FUZZ_PROJECT_NAME "componentmanager_fuzzer" - -#endif diff --git a/services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/corpus/init b/services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/project.xml b/services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cf..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/BUILD.gn deleted file mode 100644 index 7e97ff80..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/BUILD.gn +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright (c) 2023-2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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/distributed_hardware_fwk/distributedhardwarefwk.gni") - -##############################fuzztest########################################## -ohos_fuzztest("DhManagerFactoryFuzzTest") { - module_out_path = fuzz_test_output_path - fuzz_config_file = "${services_path}/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer" - - include_dirs = [ - "${utils_path}/include", - "${common_path}/utils/include", - "${common_path}/log/include", - "${services_path}/distributedhardwarefwkservice/include", - "${services_path}/distributedhardwarefwkservice/include/accessmanager", - ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "dhmanagerfactory_fuzzer.cpp" ] - - deps = [ - "${services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"DhManagerFactoryFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] - - external_deps = [ - "c_utils:utils", - "device_manager:devicemanagersdk", - "eventhandler:libeventhandler", - "hilog:libhilog", - "init:libbegetutil", - "safwk:system_ability_fwk", - "samgr:samgr_proxy", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - - deps = [ ":DhManagerFactoryFuzzTest" ] -} -############################################################################### diff --git a/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/corpus/init b/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/dhmanagerfactory_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/dhmanagerfactory_fuzzer.cpp deleted file mode 100644 index b59a5097..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/dhmanagerfactory_fuzzer.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 "dhmanagerfactory_fuzzer.h" - -#include -#include -#include -#include -#include -#include - -#include "access_manager.h" -#include "distributed_hardware_errno.h" -#include "distributed_hardware_manager_factory.h" - -namespace OHOS { -namespace DistributedHardware { - -void DhManagerFactoryFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - - DHType dhType = DHType::CAMERA; - std::string str(reinterpret_cast(data), size); - std::unordered_map versionMap; - versionMap.insert(std::make_pair(dhType, str)); - DistributedHardwareManagerFactory::GetInstance().GetComponentVersion(versionMap); -} -} -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::DhManagerFactoryFuzzTest(data, size); - return 0; -} - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/dhmanagerfactory_fuzzer.h b/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/dhmanagerfactory_fuzzer.h deleted file mode 100644 index d4ca1e17..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/dhmanagerfactory_fuzzer.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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_DHMANAGER_FACTORY_FUZZER_H -#define TEST_DHMANAGER_FACTORY_FUZZER_H - -#define FUZZ_PROJECT_NAME "dhmanagerfactory_fuzzer" - -#endif - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/project.xml b/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cf..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/BUILD.gn deleted file mode 100644 index 3c6b2dc1..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/BUILD.gn +++ /dev/null @@ -1,73 +0,0 @@ -# Copyright (c) 2023-2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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("../../../../../distributedhardwarefwk.gni") - -##############################fuzztest########################################## -ohos_fuzztest("DistributedFwkServicesFuzzTest") { - module_out_path = fuzz_test_output_path - fuzz_config_file = "${services_path}/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer" - - include_dirs = [ - "${av_trans_path}/common/include", - "include", - "${utils_path}/include", - "${common_path}/utils/include", - "${common_path}/log/include", - "${services_path}/distributedhardwarefwkservice/include", - "${services_path}/distributedhardwarefwkservice/include/hidumphelper", - "${innerkits_path}/include", - "${innerkits_path}/include/ipc", - ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - "-Dprivate=public", - "-Dprotected=public", - ] - sources = [ "distributedfwkservices_fuzzer.cpp" ] - - deps = [ - "${services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"DistributedFwkServicesFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] - - external_deps = [ - "c_utils:utils", - "device_manager:devicemanagersdk", - "eventhandler:libeventhandler", - "hilog:libhilog", - "init:libbegetutil", - "ipc:ipc_single", - "safwk:system_ability_fwk", - "samgr:samgr_proxy", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - - deps = [ ":DistributedFwkServicesFuzzTest" ] -} -############################################################################### diff --git a/services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/corpus/init b/services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/corpus/init deleted file mode 100644 index 6198079a..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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. - */ - -FUZZ \ No newline at end of file diff --git a/services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/distributedfwkservices_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/distributedfwkservices_fuzzer.cpp deleted file mode 100644 index 5f3ab1bb..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/distributedfwkservices_fuzzer.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (c) 2024-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 "distributedfwkservices_fuzzer.h" - -#include -#include -#include -#include -#include -#include - -#include "distributed_hardware_errno.h" -#include "distributed_hardware_service.h" -#include "get_dh_descriptors_callback_stub.h" - -namespace OHOS { -namespace DistributedHardware { -namespace { - const int32_t SAID = 4801; - const uint32_t QUERY_LOCAL_SYS_SIZE = 6; - const QueryLocalSysSpecType SPEC_TYPE[QUERY_LOCAL_SYS_SIZE] = { - QueryLocalSysSpecType::MIN, QueryLocalSysSpecType::HISTREAMER_AUDIO_ENCODER, - QueryLocalSysSpecType::HISTREAMER_AUDIO_DECODER, QueryLocalSysSpecType::HISTREAMER_VIDEO_ENCODER, - QueryLocalSysSpecType::HISTREAMER_VIDEO_DECODER, QueryLocalSysSpecType::MAX - }; -} - -class MyFwkServicesFuzzTest : public IRemoteStub { -public: - virtual sptr AsObject() override - { - return nullptr; - } - void OnMessage(const DHTopic topic, const std::string& message) override - { - return; - } -}; - -class TestGetDistributedHardwareCallback : public GetDhDescriptorsCallbackStub { -public: - TestGetDistributedHardwareCallback() = default; - virtual ~TestGetDistributedHardwareCallback() = default; -protected: - void OnSuccess(const std::string &networkId, const std::vector &descriptors, - EnableStep enableStep) override - { - (void)networkId; - (void)descriptors; - (void)enableStep; - } - void OnError(const std::string &networkId, int32_t error) override - { - (void)networkId; - (void)error; - } -}; - -void FwkServicesQueryLocalSysSpecFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < sizeof(uint32_t))) { - return; - } - DistributedHardwareService service(SAID, true); - uint32_t sysSpec = *(reinterpret_cast(data)); - QueryLocalSysSpecType spec = SPEC_TYPE[sysSpec % QUERY_LOCAL_SYS_SIZE]; - - service.QueryLocalSysSpec(spec); -} - -void FwkServicesQueryDhSysSpecFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - DistributedHardwareService service(SAID, true); - std::string targetKey(reinterpret_cast(data), size); - std::string attrs(reinterpret_cast(data), size); - - service.QueryDhSysSpec(targetKey, attrs); -} - -void FwkServicesNotifySourceRemoteSinkStartedFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - DistributedHardwareService service(SAID, true); - std::string deviceId(reinterpret_cast(data), size); - - service.NotifySourceRemoteSinkStarted(deviceId); -} - -void FwkServicesPauseDistributedHardwareFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - DistributedHardwareService service(SAID, true); - DHType dhType = DHType::AUDIO; - std::string networkId(reinterpret_cast(data), size); - - service.PauseDistributedHardware(dhType, networkId); -} - -void FwkServicesResumeDistributedHardwareFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - DistributedHardwareService service(SAID, true); - DHType dhType = DHType::AUDIO; - std::string networkId(reinterpret_cast(data), size); - - service.ResumeDistributedHardware(dhType, networkId); -} - -void FwkServicesStopDistributedHardwareFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - DistributedHardwareService service(SAID, true); - DHType dhType = DHType::AUDIO; - std::string networkId(reinterpret_cast(data), size); - - service.StopDistributedHardware(dhType, networkId); -} - -void FwkServicesGetDistributedHardwareFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - DistributedHardwareService service(SAID, true); - std::string networkId(reinterpret_cast(data), size); - sptr callback(new TestGetDistributedHardwareCallback()); - EnableStep enableStep = EnableStep::ENABLE_SOURCE; - service.GetDistributedHardware(networkId, enableStep, callback); -} - -void FwkServicesRegisterDHStatusListenerFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - DistributedHardwareService service(SAID, true); - std::string networkId(reinterpret_cast(data), size); - sptr listener = nullptr; - - service.RegisterDHStatusListener(networkId, listener); -} - -void FwkServicesUnregisterDHStatusListenerFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - DistributedHardwareService service(SAID, true); - std::string networkId(reinterpret_cast(data), size); - sptr listener = nullptr; - - service.UnregisterDHStatusListener(networkId, listener); -} - -void FwkServicesEnableSinkFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - DistributedHardwareService service(SAID, true); - std::vector descriptors = { - { std::string(reinterpret_cast(data), size), DHType::AUDIO } - }; - - service.EnableSink(descriptors); -} - -void FwkServicesDisableSinkFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - DistributedHardwareService service(SAID, true); - std::vector descriptors = { - { std::string(reinterpret_cast(data), size), DHType::AUDIO } - }; - - service.DisableSink(descriptors); -} - -void FwkServicesEnableSourceFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - DistributedHardwareService service(SAID, true); - std::string networkId(reinterpret_cast(data), size); - std::vector descriptors = { - { std::string(reinterpret_cast(data), size), DHType::AUDIO } - }; - - service.EnableSource(networkId, descriptors); -} - -void FwkServicesDisableSourceFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - DistributedHardwareService service(SAID, true); - std::string networkId(reinterpret_cast(data), size); - std::vector descriptors = { - { std::string(reinterpret_cast(data), size), DHType::AUDIO } - }; - - service.DisableSource(networkId, descriptors); -} -} -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::FwkServicesQueryLocalSysSpecFuzzTest(data, size); - OHOS::DistributedHardware::FwkServicesQueryDhSysSpecFuzzTest(data, size); - OHOS::DistributedHardware::FwkServicesPauseDistributedHardwareFuzzTest(data, size); - OHOS::DistributedHardware::FwkServicesResumeDistributedHardwareFuzzTest(data, size); - OHOS::DistributedHardware::FwkServicesStopDistributedHardwareFuzzTest(data, size); - return 0; -} diff --git a/services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/distributedfwkservices_fuzzer.h b/services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/distributedfwkservices_fuzzer.h deleted file mode 100644 index 94b85300..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/distributedfwkservices_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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. - */ - -#ifndef DISTRIBUTEDFWKSERVICES_FUZZER_H -#define DISTRIBUTEDFWKSERVICES_FUZZER_H - -#define FUZZ_PROJECT_NAME "distributedfwkservices_fuzzer" - -#endif diff --git a/services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/project.xml b/services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/project.xml deleted file mode 100644 index 7133b2b9..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/distributedfwkservices_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/BUILD.gn deleted file mode 100644 index 7f1db7bc..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/BUILD.gn +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright (c) 2023-2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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/distributed_hardware_fwk/distributedhardwarefwk.gni") - -##############################fuzztest########################################## -ohos_fuzztest("EnabledCompsDumpFuzzTest") { - module_out_path = fuzz_test_output_path - fuzz_config_file = "${services_path}/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer" - - include_dirs = [ - "${utils_path}/include", - "${common_path}/utils/include", - "${common_path}/log/include", - "${services_path}/distributedhardwarefwkservice/include", - "${services_path}/distributedhardwarefwkservice/include/hidumphelper", - ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "enabledcompsdump_fuzzer.cpp" ] - - deps = [ - "${services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"EnabledCompsDumpFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] - - external_deps = [ - "c_utils:utils", - "device_manager:devicemanagersdk", - "eventhandler:libeventhandler", - "hilog:libhilog", - "init:libbegetutil", - "safwk:system_ability_fwk", - "samgr:samgr_proxy", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - - deps = [ ":EnabledCompsDumpFuzzTest" ] -} -############################################################################### diff --git a/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/corpus/init b/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.cpp deleted file mode 100644 index 34652c2c..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 "enabledcompsdump_fuzzer.h" - -#include -#include -#include -#include -#include -#include - -#include "distributed_hardware_errno.h" -#include "enabled_comps_dump.h" - -namespace OHOS { -namespace DistributedHardware { -namespace { - const uint32_t DH_TYPE_SIZE = 10; - const DHType dhTypeFuzz[DH_TYPE_SIZE] = { - DHType::CAMERA, DHType::AUDIO, DHType::SCREEN, DHType::VIRMODEM_AUDIO, - DHType::INPUT, DHType::A2D, DHType::GPS, DHType::HFP - }; -} - -void EnableedCompsDumpFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - - std::string networkId(reinterpret_cast(data), size); - std::string dhId(reinterpret_cast(data), size); - DHType dhType = dhTypeFuzz[data[0] % DH_TYPE_SIZE]; - - std::set compInfoSet {}; - EnabledCompsDump::GetInstance().DumpEnabledComp(networkId, dhType, dhId); - EnabledCompsDump::GetInstance().Dump(compInfoSet); - EnabledCompsDump::GetInstance().DumpDisabledComp(networkId, dhType, dhId); -} -} -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::EnableedCompsDumpFuzzTest(data, size); - return 0; -} - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.h b/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.h deleted file mode 100644 index 7d6e0a89..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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_ENABLEEDCOMPSDUMP_FUZZER_H -#define TEST_ENABLEEDCOMPSDUMP_FUZZER_H - -#define FUZZ_PROJECT_NAME "enableedcompsdump_fuzzer" - -#endif - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/project.xml b/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cf..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/BUILD.gn deleted file mode 100644 index 79d3f7c2..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/BUILD.gn +++ /dev/null @@ -1,73 +0,0 @@ -# Copyright (c) 2023-2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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("../../../../../distributedhardwarefwk.gni") - -##############################fuzztest########################################## -ohos_fuzztest("MetaInfoMgrFuzzTest") { - module_out_path = fuzz_test_output_path - fuzz_config_file = "${services_path}/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer" - - include_dirs = [ - "${utils_path}/include", - "${common_path}/utils/include", - "${common_path}/log/include", - "${services_path}/distributedhardwarefwkservice/include", - "${services_path}/distributedhardwarefwkservice/include/transport", - "${services_path}/distributedhardwarefwkservice/include/componentmanager", - "${services_path}/distributedhardwarefwkservice/include/localhardwaremanager", - "${services_path}/distributedhardwarefwkservice/include/utils", - "${services_path}/distributedhardwarefwkservice/include/resourcemanager", - ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - "-Dprivate = public", - ] - sources = [ "metainfomgr_fuzzer.cpp" ] - - deps = [ - "${services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"MetaInfoMgrFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] - - external_deps = [ - "cJSON:cjson", - "c_utils:utils", - "device_manager:devicemanagersdk", - "eventhandler:libeventhandler", - "hilog:libhilog", - "init:libbegetutil", - "kv_store:distributeddata_inner", - "safwk:system_ability_fwk", - "samgr:samgr_proxy", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - - deps = [ ":MetaInfoMgrFuzzTest" ] -} -############################################################################### diff --git a/services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/corpus/init b/services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/corpus/init deleted file mode 100644 index 6198079a..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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. - */ - -FUZZ \ No newline at end of file diff --git a/services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/metainfomgr_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/metainfomgr_fuzzer.cpp deleted file mode 100644 index c4f11d23..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/metainfomgr_fuzzer.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2024-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 "metainfomgr_fuzzer.h" - -#include -#include -#include -#include - -#include "meta_info_manager.h" -#include "meta_capability_info.h" - -namespace OHOS { -namespace DistributedHardware { -void SyncMetaInfoFromDBFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - std::string deviceId(reinterpret_cast(data), size); - MetaInfoManager::GetInstance()->Init(); - MetaInfoManager::GetInstance()->SyncMetaInfoFromDB(deviceId); -} - -void GetDataByKeyPrefixFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - std::string keyPrefix(reinterpret_cast(data), size); - MetaCapInfoMap metaCapMap; - MetaInfoManager::GetInstance()->GetDataByKeyPrefix(keyPrefix, metaCapMap); -} - -void GetMetaCapInfoFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - std::string deviceId(reinterpret_cast(data), size); - std::string udidHash(reinterpret_cast(data), size); - std::string dhId(reinterpret_cast(data), size); - uint16_t deviceType = 14; - std::shared_ptr metaCapPtr = std::make_shared( - dhId, deviceId, "devName_test", deviceType, DHType::CAMERA, "attrs_test", "subtype", udidHash, - CompVersion{ .sinkVersion = "1.0" }); - std::string key = deviceId + "###" + dhId; - MetaInfoManager::GetInstance()->globalMetaInfoMap_[key] = metaCapPtr; - MetaInfoManager::GetInstance()->GetMetaCapInfo(deviceId, dhId, metaCapPtr); -} -} -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::SyncMetaInfoFromDBFuzzTest(data, size); - OHOS::DistributedHardware::GetDataByKeyPrefixFuzzTest(data, size); - OHOS::DistributedHardware::GetMetaCapInfoFuzzTest(data, size); - return 0; -} - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/metainfomgr_fuzzer.h b/services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/metainfomgr_fuzzer.h deleted file mode 100644 index 3abd6160..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/metainfomgr_fuzzer.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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. - */ - -#ifndef TEST_META_INFO_MGR_FUZZER_H -#define TEST_META_INFO_MGR_FUZZER_H - -#define FUZZ_PROJECT_NAME "metainfomgr_fuzzer" - -#endif - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/project.xml b/services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/project.xml deleted file mode 100644 index 7133b2b9..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/metainfomgr_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/BUILD.gn deleted file mode 100644 index a274ba75..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/BUILD.gn +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright (c) 2023-2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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/distributed_hardware_fwk/distributedhardwarefwk.gni") - -##############################fuzztest########################################## -ohos_fuzztest("ResourceManagerFuzzTest") { - module_out_path = fuzz_test_output_path - fuzz_config_file = "${services_path}/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer" - - include_dirs = [ - "${utils_path}/include", - "${services_path}/distributedhardwarefwkservice/include", - "${services_path}/distributedhardwarefwkservice/include/resourcemanager", - "${services_path}/distributedhardwarefwkservice/include/utils", - "${common_path}/utils/include", - "${common_path}/log/include", - ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "resourcemanager_fuzzer.cpp" ] - - deps = [ - "${services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"ResourceManagerFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] - - external_deps = [ - "cJSON:cjson", - "c_utils:utils", - "eventhandler:libeventhandler", - "eventhandler:libeventhandler", - "hilog:libhilog", - "ipc:ipc_single", - "kv_store:distributeddata_inner", - "samgr:samgr_proxy", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":ResourceManagerFuzzTest" ] -} -############################################################################### diff --git a/services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/corpus/init b/services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/project.xml b/services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cf..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/resourcemanager_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/resourcemanager_fuzzer.cpp deleted file mode 100644 index 2776db93..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/resourcemanager_fuzzer.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 "resourcemanager_fuzzer.h" - -#include -#include -#include -#include - -#include "capability_info.h" -#include "capability_info_manager.h" -#include "dh_context.h" -#include "distributed_hardware_errno.h" -#include "distributed_hardware_log.h" - -namespace OHOS { -namespace DistributedHardware { -namespace { - const uint32_t DH_TYPE_SIZE = 10; - const DHType dhTypeFuzz[DH_TYPE_SIZE] = { - DHType::CAMERA, DHType::AUDIO, DHType::SCREEN, DHType::VIRMODEM_AUDIO, - DHType::INPUT, DHType::A2D, DHType::GPS, DHType::HFP - }; -} - -void ResourceManagerFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < sizeof(uint16_t))) { - return; - } - - std::string dhId(reinterpret_cast(data), size); - std::string devId(reinterpret_cast(data), size); - std::string devName(reinterpret_cast(data), size); - uint16_t devType = *(reinterpret_cast(data)); - DHType dhType = dhTypeFuzz[data[0] % DH_TYPE_SIZE]; - std::string dhAttrs(reinterpret_cast(data), size); - std::string dhSubtype(reinterpret_cast(data), size); - - std::shared_ptr capInfo = - std::make_shared(dhId, devId, devName, devType, dhType, dhAttrs, dhSubtype); - std::vector> resInfos; - resInfos.emplace_back(capInfo); - - CapabilityInfoManager::GetInstance()->AddCapability(resInfos); - - std::shared_ptr info; - CapabilityInfoManager::GetInstance()->GetCapability(capInfo->GetDeviceId(), capInfo->GetDHId(), info); - CapabilityInfoManager::GetInstance()->GetDataByKey(capInfo->GetKey(), info); - - CapabilityInfoMap capMap; - CapabilityInfoManager::GetInstance()->GetDataByKeyPrefix(capInfo->GetDeviceId(), capMap); - CapabilityInfoManager::GetInstance()->RemoveCapabilityInfoByKey(capInfo->GetKey()); -} -} -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::ResourceManagerFuzzTest(data, size); - return 0; -} - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/resourcemanager_fuzzer.h b/services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/resourcemanager_fuzzer.h deleted file mode 100644 index 5c73c777..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/resourcemanager_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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_RESOURCEMANAGER_FUZZER_H -#define TEST_RESOURCEMANAGER_FUZZER_H - -#define FUZZ_PROJECT_NAME "resourcemanager_fuzzer" - -#endif diff --git a/services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/BUILD.gn deleted file mode 100644 index 1fcb2be9..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/BUILD.gn +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright (c) 2023-2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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/distributed_hardware_fwk/distributedhardwarefwk.gni") - -##############################fuzztest########################################## -ohos_fuzztest("TaskFuzzTest") { - module_out_path = fuzz_test_output_path - fuzz_config_file = - "${services_path}/distributedhardwarefwkservice/test/fuzztest/task_fuzzer" - - include_dirs = [ - "include", - "${utils_path}/include", - "${services_path}/distributedhardwarefwkservice/include", - "${services_path}/distributedhardwarefwkservice/include/task", - "${services_path}/distributedhardwarefwkservice/include/utils", - "${common_path}/utils/include", - "${common_path}/log/include", - ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "task_fuzzer.cpp" ] - - deps = [ - "${services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", - ] - - external_deps = [ - "cJSON:cjson", - "c_utils:utils", - "eventhandler:libeventhandler", - "hilog:libhilog", - "samgr:samgr_proxy", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"TaskFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":TaskFuzzTest" ] -} -############################################################################### diff --git a/services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/corpus/init b/services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/project.xml b/services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cf..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/task_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/task_fuzzer.cpp deleted file mode 100644 index 6a869a59..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/task_fuzzer.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 "task_fuzzer.h" - -#include -#include - -#include "constants.h" -#include "distributed_hardware_errno.h" -#include "distributed_hardware_log.h" -#include "task_board.h" -#include "task_executor.h" -#include "task_factory.h" - -namespace OHOS { -namespace DistributedHardware { -namespace { - const uint32_t DH_TYPE_SIZE = 10; - const DHType dhTypeFuzz[DH_TYPE_SIZE] = { - DHType::CAMERA, DHType::AUDIO, DHType::SCREEN, DHType::VIRMODEM_AUDIO, - DHType::INPUT, DHType::A2D, DHType::GPS, DHType::HFP - }; - - const uint32_t TASK_TYPE_SIZE = 5; - const TaskType taskTypeFuzz[TASK_TYPE_SIZE] = { - TaskType::UNKNOWN, TaskType::ENABLE, TaskType::DISABLE, TaskType::ON_LINE, TaskType::OFF_LINE - }; -} - -void TaskFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - - std::string networkId(reinterpret_cast(data), size); - std::string uuid(reinterpret_cast(data), size); - std::string dhId(reinterpret_cast(data), size); - DHType dhType = dhTypeFuzz[data[0] % DH_TYPE_SIZE]; - - TaskParam taskParam = { - .networkId = networkId, - .uuid = uuid, - .dhId = dhId, - .dhType = dhType - }; - TaskType taskType = taskTypeFuzz[data[0] % TASK_TYPE_SIZE]; - - auto task = TaskFactory::GetInstance().CreateTask(taskType, taskParam, nullptr); - if (task != nullptr) { - TaskBoard::GetInstance().RemoveTask(task->GetId()); - } -} -} -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::TaskFuzzTest(data, size); - return 0; -} - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/task_fuzzer.h b/services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/task_fuzzer.h deleted file mode 100644 index bc780435..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/task_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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_COMPONENTMANAGER_FUZZER_H -#define TEST_COMPONENTMANAGER_FUZZER_H - -#define FUZZ_PROJECT_NAME "componentmanager_fuzzer" - -#endif diff --git a/services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/BUILD.gn deleted file mode 100644 index 815e0473..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/BUILD.gn +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright (c) 2023-2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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/distributed_hardware_fwk/distributedhardwarefwk.gni") - -##############################fuzztest########################################## -ohos_fuzztest("VersioninfoManagerFuzzTest") { - module_out_path = fuzz_test_output_path - fuzz_config_file = "${services_path}/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer" - - include_dirs = [ - "${utils_path}/include", - "${services_path}/distributedhardwarefwkservice/include", - "${services_path}/distributedhardwarefwkservice/include/resourcemanager", - "${services_path}/distributedhardwarefwkservice/include/utils", - "${common_path}/utils/include", - "${common_path}/log/include", - ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "versioninfomanager_fuzzer.cpp" ] - - deps = [ - "${services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"VersioninfoManagerFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] - - external_deps = [ - "cJSON:cjson", - "c_utils:utils", - "eventhandler:libeventhandler", - "hilog:libhilog", - "kv_store:distributeddata_inner", - "samgr:samgr_proxy", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - - deps = [ ":VersioninfoManagerFuzzTest" ] -} -############################################################################### diff --git a/services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/corpus/init b/services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/project.xml b/services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cf..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/versioninfomanager_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/versioninfomanager_fuzzer.cpp deleted file mode 100644 index 1d196d8f..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/versioninfomanager_fuzzer.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 "versioninfomanager_fuzzer.h" - -#include -#include -#include -#include -#include -#include - -#include "version_info_manager.h" -#include "distributed_hardware_errno.h" -#include "distributed_hardware_manager_factory.h" - -namespace OHOS { -namespace DistributedHardware { -namespace { - constexpr uint32_t SLEEP_TIME_US = 10 * 1000; - const uint32_t DH_TYPE_SIZE = 10; - const DHType dhTypeFuzz[DH_TYPE_SIZE] = { - DHType::CAMERA, DHType::AUDIO, DHType::SCREEN, DHType::VIRMODEM_AUDIO, - DHType::INPUT, DHType::A2D, DHType::GPS, DHType::HFP - }; -} - -void VersioninfoManagerFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - - VersionInfo versionInfo; - versionInfo.deviceId = std::string(reinterpret_cast(data), size); - versionInfo.dhVersion = std::string(reinterpret_cast(data), size); - - CompVersion compVer; - compVer.dhType = dhTypeFuzz[data[0] % DH_TYPE_SIZE]; - compVer.name = std::string(reinterpret_cast(data), size); - compVer.handlerVersion = std::string(reinterpret_cast(data), size); - compVer.sourceVersion = std::string(reinterpret_cast(data), size); - compVer.sinkVersion = std::string(reinterpret_cast(data), size); - versionInfo.compVersions.insert(std::pair(compVer.dhType, compVer)); - - VersionInfo info; - VersionInfoManager::GetInstance()->AddVersion(versionInfo); - VersionInfoManager::GetInstance()->GetVersionInfoByDeviceId(versionInfo.deviceId, info); - VersionInfoManager::GetInstance()->SyncVersionInfoFromDB(versionInfo.deviceId); - VersionInfoManager::GetInstance()->RemoveVersionInfoByDeviceId(versionInfo.deviceId); - - usleep(SLEEP_TIME_US); -} -} -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::VersioninfoManagerFuzzTest(data, size); - return 0; -} - diff --git a/services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/versioninfomanager_fuzzer.h b/services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/versioninfomanager_fuzzer.h deleted file mode 100644 index 241f550d..00000000 --- a/services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/versioninfomanager_fuzzer.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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_ACCESSMANAGER_FUZZER_H -#define TEST_ACCESSMANAGER_FUZZER_H - -#define FUZZ_PROJECT_NAME "versioninfomanager_fuzzer" - -#endif - diff --git a/utils/test/fuzztest/BUILD.gn b/utils/test/fuzztest/BUILD.gn deleted file mode 100644 index 9bc256c9..00000000 --- a/utils/test/fuzztest/BUILD.gn +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -group("fuzztest") { - testonly = true - - deps = [ "utils_fuzzer:fuzztest" ] -} diff --git a/utils/test/fuzztest/utils_fuzzer/BUILD.gn b/utils/test/fuzztest/utils_fuzzer/BUILD.gn deleted file mode 100644 index fe1485b6..00000000 --- a/utils/test/fuzztest/utils_fuzzer/BUILD.gn +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2021-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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import( - "//foundation/distributedhardware/distributed_hardware_fwk/distributedhardwarefwk.gni") - -##############################fuzztest########################################## -ohos_fuzztest("UtilsFuzzTest") { - module_out_path = fuzz_test_output_path - fuzz_config_file = "${utils_path}/test/fuzztest/utils_fuzzer" - - include_dirs = [ - "${utils_path}/include", - "${common_path}/utils/include", - ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "utils_fuzzer.cpp" ] - - deps = [ "${utils_path}:distributedhardwareutils" ] - - external_deps = [ - "cJSON:cjson", - "c_utils:utils", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":UtilsFuzzTest" ] -} -############################################################################### diff --git a/utils/test/fuzztest/utils_fuzzer/corpus/init b/utils/test/fuzztest/utils_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6..00000000 --- a/utils/test/fuzztest/utils_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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/utils/test/fuzztest/utils_fuzzer/project.xml b/utils/test/fuzztest/utils_fuzzer/project.xml deleted file mode 100644 index 85e7ef2c..00000000 --- a/utils/test/fuzztest/utils_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/utils/test/fuzztest/utils_fuzzer/utils_fuzzer.cpp b/utils/test/fuzztest/utils_fuzzer/utils_fuzzer.cpp deleted file mode 100644 index 29faf05e..00000000 --- a/utils/test/fuzztest/utils_fuzzer/utils_fuzzer.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "utils_fuzzer.h" - -#include -#include -#include - -#include "anonymous_string.h" -#include "dh_utils_tool.h" - -namespace OHOS { -namespace DistributedHardware { -void GetAnonyStringTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - - std::string str(reinterpret_cast(data), size); - GetAnonyString(str); -} - -void GetAnonyInt32Test(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < sizeof(int32_t))) { - return; - } - - int32_t i = *(reinterpret_cast(data)); - GetAnonyInt32(i); -} - -void UtilsToolTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - - std::string networkId(reinterpret_cast(data), size); - std::string uuid(reinterpret_cast(data), size); - GetUUIDByDm(networkId); - GetDeviceIdByUUID(uuid); -} -} -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::GetAnonyStringTest(data, size); - OHOS::DistributedHardware::GetAnonyInt32Test(data, size); - OHOS::DistributedHardware::UtilsToolTest(data, size); - return 0; -} - diff --git a/utils/test/fuzztest/utils_fuzzer/utils_fuzzer.h b/utils/test/fuzztest/utils_fuzzer/utils_fuzzer.h deleted file mode 100644 index 99c304c0..00000000 --- a/utils/test/fuzztest/utils_fuzzer/utils_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TEST_UTILS_FUZZER_H -#define TEST_UTILS_FUZZER_H - -#define FUZZ_PROJECT_NAME "utils_fuzzer" - -#endif diff --git a/utils/test/unittest/common/histreamer_ability_parser/BUILD.gn b/utils/test/unittest/histreamer_ability_parser/BUILD.gn similarity index 100% rename from utils/test/unittest/common/histreamer_ability_parser/BUILD.gn rename to utils/test/unittest/histreamer_ability_parser/BUILD.gn diff --git a/utils/test/unittest/common/histreamer_ability_parser/histreamer_ability_parser_test.cpp b/utils/test/unittest/histreamer_ability_parser/histreamer_ability_parser_test.cpp similarity index 100% rename from utils/test/unittest/common/histreamer_ability_parser/histreamer_ability_parser_test.cpp rename to utils/test/unittest/histreamer_ability_parser/histreamer_ability_parser_test.cpp diff --git a/utils/test/unittest/common/histreamer_ability_parser/histreamer_ability_parser_test.h b/utils/test/unittest/histreamer_ability_parser/histreamer_ability_parser_test.h similarity index 100% rename from utils/test/unittest/common/histreamer_ability_parser/histreamer_ability_parser_test.h rename to utils/test/unittest/histreamer_ability_parser/histreamer_ability_parser_test.h diff --git a/utils/test/unittest/common/utilstool/BUILD.gn b/utils/test/unittest/utilstool/BUILD.gn similarity index 100% rename from utils/test/unittest/common/utilstool/BUILD.gn rename to utils/test/unittest/utilstool/BUILD.gn diff --git a/utils/test/unittest/common/utilstool/utils_tool_test.cpp b/utils/test/unittest/utilstool/utils_tool_test.cpp similarity index 100% rename from utils/test/unittest/common/utilstool/utils_tool_test.cpp rename to utils/test/unittest/utilstool/utils_tool_test.cpp diff --git a/utils/test/unittest/common/utilstool/utils_tool_test.h b/utils/test/unittest/utilstool/utils_tool_test.h similarity index 100% rename from utils/test/unittest/common/utilstool/utils_tool_test.h rename to utils/test/unittest/utilstool/utils_tool_test.h -- Gitee