From 554959125296d8966dde4edf4ca5f9795cabcbf1 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 27 Oct 2022 16:49:30 +0800 Subject: [PATCH 1/3] update fuzz Signed-off-by: wanderer-dl122 --- .../test/fuzztest/BUILD.gn | 4 + .../accessmanager_fuzzer.cpp | 11 ++- .../BUILD.gn | 62 ++++++++++++++ .../corpus/init | 16 ++++ .../dhmanagerfactory_fuzzer.cpp | 59 ++++++++++++++ .../dhmanagerfactory_fuzzer.h | 22 +++++ .../project.xml | 25 ++++++ .../enableedcompsdump_fuzzer/BUILD.gn | 62 ++++++++++++++ .../enableedcompsdump_fuzzer/corpus/init | 16 ++++ .../enableedcompsdump_fuzzer.cpp | 63 +++++++++++++++ .../enableedcompsdump_fuzzer.h | 22 +++++ .../enableedcompsdump_fuzzer/project.xml | 25 ++++++ .../test/fuzztest/publisher_fuzzer/BUILD.gn | 80 +++++++++++++++++++ .../fuzztest/publisher_fuzzer/corpus/init | 16 ++++ .../fuzztest/publisher_fuzzer/project.xml | 25 ++++++ .../publisher_fuzzer/publisher_fuzzer.cpp | 78 ++++++++++++++++++ .../publisher_fuzzer/publisher_fuzzer.h | 48 +++++++++++ .../fuzztest/publisheritem_fuzzer/BUILD.gn | 75 +++++++++++++++++ .../fuzztest/publisheritem_fuzzer/corpus/init | 16 ++++ .../fuzztest/publisheritem_fuzzer/project.xml | 25 ++++++ .../publisheritem_fuzzer.cpp | 80 +++++++++++++++++++ .../publisheritem_fuzzer.h | 47 +++++++++++ 22 files changed, 871 insertions(+), 6 deletions(-) create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/BUILD.gn create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/corpus/init create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/dhmanagerfactory_fuzzer.cpp create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/dhmanagerfactory_fuzzer.h create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/project.xml create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/BUILD.gn create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/corpus/init create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/enableedcompsdump_fuzzer.cpp create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/enableedcompsdump_fuzzer.h create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/project.xml create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/BUILD.gn create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/corpus/init create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/project.xml create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/publisher_fuzzer.cpp create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/publisher_fuzzer.h create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/BUILD.gn create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/corpus/init create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/project.xml create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/publisheritem_fuzzer.cpp create mode 100644 services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/publisheritem_fuzzer.h diff --git a/services/distributedhardwarefwkservice/test/fuzztest/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/BUILD.gn index 8de46bca..3d3d2cf4 100644 --- a/services/distributedhardwarefwkservice/test/fuzztest/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/fuzztest/BUILD.gn @@ -18,6 +18,10 @@ group("fuzztest") { "accessmanager_fuzzer:fuzztest", "componentloader_fuzzer:fuzztest", "componentmanager_fuzzer:fuzztest", + "distributedhardwaremanagerfactory_fuzzer:fuzztest", + "enableedcompsdump_fuzzer:fuzztest", + "publisher_fuzzer:fuzztest", + "publisheritem_fuzzer:fuzztest", "resourcemanager_fuzzer:fuzztest", "task_fuzzer:fuzztest", "versioninfomanager_fuzzer:fuzztest", diff --git a/services/distributedhardwarefwkservice/test/fuzztest/accessmanager_fuzzer/accessmanager_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/accessmanager_fuzzer/accessmanager_fuzzer.cpp index 68c73386..0053086a 100644 --- a/services/distributedhardwarefwkservice/test/fuzztest/accessmanager_fuzzer/accessmanager_fuzzer.cpp +++ b/services/distributedhardwarefwkservice/test/fuzztest/accessmanager_fuzzer/accessmanager_fuzzer.cpp @@ -29,21 +29,20 @@ namespace OHOS { namespace DistributedHardware { namespace { - constexpr uint16_t TEST_DEV_TYPE_PAD = 0x11; constexpr uint32_t SLEEP_TIME_US = 10 * 1000; } void AccessManagerFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size <= sizeof(DmDeviceInfo))) { return; } - std::string networkId(reinterpret_cast(data), size); - std::string uuid(reinterpret_cast(data), size); + + AccessManager::GetInstance()->Init(); + const DmDeviceInfo deviceInfo = *(reinterpret_cast(data)); + AccessManager::GetInstance()->OnDeviceReady(deviceInfo); - DistributedHardwareManagerFactory::GetInstance().SendOnLineEvent( - networkId, uuid, TEST_DEV_TYPE_PAD); usleep(SLEEP_TIME_US); } } diff --git a/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/BUILD.gn new file mode 100644 index 00000000..6c48870a --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/BUILD.gn @@ -0,0 +1,62 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_hardware_fwk/distributedhardwarefwk.gni") + +##############################fuzztest########################################## +ohos_fuzztest("DhManagerFactoryFuzzTest") { + module_out_path = "distributed_hardware_fwk/distributedhardwaremanagerfactory" + fuzz_config_file = "//foundation/distributedhardware/distributed_hardware_fwk/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer" + + include_dirs = [ + "//commonlibrary/c_utils/base/include", + "//utils/system/safwk/native/include", + "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp/include", + "//foundation/distributedhardware/device_manager/common/include", + "${utils_path}/include", + "${utils_path}/include/log", + "${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 = [ "//foundation/distributedhardware/distributed_hardware_fwk/services/distributedhardwarefwkservice:distributedhardwarefwksvr" ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"DhManagerFactoryFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ "init:libbegetutil" ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":DhManagerFactoryFuzzTest" ] +} +############################################################################### diff --git a/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/corpus/init b/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/corpus/init new file mode 100644 index 00000000..8eb5a7d6 --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * 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/distributedhardwaremanagerfactory_fuzzer/dhmanagerfactory_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/dhmanagerfactory_fuzzer.cpp new file mode 100644 index 00000000..4c00873f --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/dhmanagerfactory_fuzzer.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "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 { +namespace { + constexpr uint16_t TEST_DEV_TYPE_PAD = 0x11; + constexpr uint32_t SLEEP_TIME_US = 10 * 1000; +} + +void DhManagerFactoryFuzzTest(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); + + DistributedHardwareManagerFactory::GetInstance().SendOnLineEvent( + networkId, uuid, TEST_DEV_TYPE_PAD); + 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::DhManagerFactoryFuzzTest(data, size); + return 0; +} + diff --git a/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/dhmanagerfactory_fuzzer.h b/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/dhmanagerfactory_fuzzer.h new file mode 100644 index 00000000..d4ca1e17 --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/dhmanagerfactory_fuzzer.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef 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/distributedhardwaremanagerfactory_fuzzer/project.xml b/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/project.xml new file mode 100644 index 00000000..6e8ad2cf --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/BUILD.gn new file mode 100644 index 00000000..aaf219f3 --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/BUILD.gn @@ -0,0 +1,62 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_hardware_fwk/distributedhardwarefwk.gni") + +##############################fuzztest########################################## +ohos_fuzztest("EnableedCompsDumpFuzzTest") { + module_out_path = "distributed_hardware_fwk/enableedcompsdump" + fuzz_config_file = "//foundation/distributedhardware/distributed_hardware_fwk/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer" + + include_dirs = [ + "//commonlibrary/c_utils/base/include", + "//utils/system/safwk/native/include", + "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp/include", + "//foundation/distributedhardware/device_manager/common/include", + "${utils_path}/include", + "${utils_path}/include/log", + "${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 = [ "enableedcompsdump_fuzzer.cpp" ] + + deps = [ "//foundation/distributedhardware/distributed_hardware_fwk/services/distributedhardwarefwkservice:distributedhardwarefwksvr" ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"EnableedCompsDumpFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ "init:libbegetutil" ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":EnableedCompsDumpFuzzTest" ] +} +############################################################################### diff --git a/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/corpus/init b/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/corpus/init new file mode 100644 index 00000000..8eb5a7d6 --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * 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/enableedcompsdump_fuzzer/enableedcompsdump_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/enableedcompsdump_fuzzer.cpp new file mode 100644 index 00000000..830c0196 --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/enableedcompsdump_fuzzer.cpp @@ -0,0 +1,63 @@ +/* + * 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 "enableedcompsdump_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_MIC, + DHType::INPUT, DHType::A2D, DHType::GPS, DHType::HFP, DHType::VIRMODEM_SPEAKER + }; +} + +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/enableedcompsdump_fuzzer/enableedcompsdump_fuzzer.h b/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/enableedcompsdump_fuzzer.h new file mode 100644 index 00000000..7d6e0a89 --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/enableedcompsdump_fuzzer.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TEST_ENABLEEDCOMPSDUMP_FUZZER_H +#define TEST_ENABLEEDCOMPSDUMP_FUZZER_H + +#define FUZZ_PROJECT_NAME "enableedcompsdump_fuzzer" + +#endif + diff --git a/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/project.xml b/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/project.xml new file mode 100644 index 00000000..6e8ad2cf --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/BUILD.gn new file mode 100644 index 00000000..3461705f --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/BUILD.gn @@ -0,0 +1,80 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_hardware_fwk/distributedhardwarefwk.gni") + +##############################fuzztest########################################## +ohos_fuzztest("PublisherFuzzTest") { + module_out_path = "distributed_hardware_fwk/publisher" + fuzz_config_file = "//foundation/distributedhardware/distributed_hardware_fwk/services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer" + + include_dirs = [ + "//commonlibrary/c_utils/base/include", + "//utils/system/safwk/native/include", + "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp/include", + "//foundation/distributedhardware/device_manager/common/include", + "//utils/system/safwk/native/include", + "${utils_path}/include", + "${utils_path}/include/log", + "${common_path}/utils/include", + "${common_path}/log/include", + "${innerkits_path}/include", + "${innerkits_path}/include/ipc", + "${services_path}/distributedhardwarefwkservice/include", + "${services_path}/distributedhardwarefwkservice/include/utils", + "${services_path}/distributedhardwarefwkservice/include/publisher", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "publisher_fuzzer.cpp" ] + + deps = [ + "${innerkits_path}:libdhfwk_sdk", + "${utils_path}:distributedhardwareutils", + "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//foundation/distributedhardware/distributed_hardware_fwk/services/distributedhardwarefwkservice:distributedhardwarefwksvr", + "//foundation/systemabilitymgr/safwk/interfaces/innerkits/safwk:system_ability_fwk", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"PublisherFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "c_utils:utils", + "eventhandler:libeventhandler", + "init:libbegetutil", + "ipc:ipc_core", + "kv_store:distributeddata_inner", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":PublisherFuzzTest" ] +} +############################################################################### diff --git a/services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/corpus/init b/services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/corpus/init new file mode 100644 index 00000000..8eb5a7d6 --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * 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/publisher_fuzzer/project.xml b/services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/project.xml new file mode 100644 index 00000000..6e8ad2cf --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/publisher_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/publisher_fuzzer.cpp new file mode 100644 index 00000000..2d1c6e7c --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/publisher_fuzzer.cpp @@ -0,0 +1,78 @@ +/* + * 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 "publisher_fuzzer.h" + +#include +#include +#include +#include +#include +#include + +#include "distributed_hardware_errno.h" +#include "publisher.h" + +namespace OHOS { +namespace DistributedHardware { +namespace { + const uint32_t TOPIC_SIZE = 4; + const DHTopic topicFuzz[TOPIC_SIZE] = { + DHTopic::TOPIC_START_DSCREEN, DHTopic::TOPIC_SINK_PROJECT_WINDOW_INFO, + DHTopic::TOPIC_STOP_DSCREEN, DHTopic::TOPIC_DEV_OFFLINE + }; +} + +void MockPublisherListener::OnMessage(const DHTopic topic, const std::string &message) +{ + (void)topic; + (void)message; +} + +int32_t MockPublisherListener::OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) +{ + (void)code; + (void)data; + (void)reply; + (void)option; + return DH_FWK_SUCCESS; +} + +void PublisherListenerFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + DHTopic topic = topicFuzz[data[0] % TOPIC_SIZE]; + sptr listener = new MockPublisherListener(); + std::string message(reinterpret_cast(data), size); + + Publisher::GetInstance().RegisterListener(topic, listener); + Publisher::GetInstance().PublishMessage(topic, message); + Publisher::GetInstance().UnregisterListener(topic, listener); +} +} // namespace DistributedHardware +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::PublisherListenerFuzzTest(data, size); + return 0; +} + diff --git a/services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/publisher_fuzzer.h b/services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/publisher_fuzzer.h new file mode 100644 index 00000000..92e46232 --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/publisher_fuzzer/publisher_fuzzer.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TEST_PUBLISHER_FUZZER_H +#define TEST_PUBLISHER_FUZZER_H + +#define FUZZ_PROJECT_NAME "publisher_fuzzer" + +#include + +#include "iremote_stub.h" + +#include "ipublisher_listener.h" +#include "single_instance.h" + +namespace OHOS { +namespace DistributedHardware { + +#define REMOVE_NO_USE_CONSTRUCTOR(className) \ +private: \ + className(const className&) = delete; \ + className& operator= (const className&) = delete; \ + className(className&&) = delete; \ + className& operator= (className&&) = delete; \ + +class MockPublisherListener : public IRemoteStub { +public: + MockPublisherListener() = default; + virtual ~MockPublisherListener() = default; + void OnMessage(const DHTopic topic, const std::string &message) override; + int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif + diff --git a/services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/BUILD.gn new file mode 100644 index 00000000..76a64101 --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/BUILD.gn @@ -0,0 +1,75 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_hardware_fwk/distributedhardwarefwk.gni") + +##############################fuzztest########################################## +ohos_fuzztest("PublisherItemFuzzTest") { + module_out_path = "distributed_hardware_fwk/publisheritem" + fuzz_config_file = "//foundation/distributedhardware/distributed_hardware_fwk/services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer" + + include_dirs = [ + "//commonlibrary/c_utils/base/include", + "//utils/system/safwk/native/include", + "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp/include", + "//foundation/distributedhardware/device_manager/common/include", + "${utils_path}/include", + "${utils_path}/include/log", + "${common_path}/utils/include", + "${common_path}/log/include", + "${innerkits_path}/include", + "${innerkits_path}/include/ipc", + "${services_path}/distributedhardwarefwkservice/include", + "${services_path}/distributedhardwarefwkservice/include/publisher", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "publisheritem_fuzzer.cpp" ] + + deps = [ + "${innerkits_path}:libdhfwk_sdk", + "//foundation/distributedhardware/distributed_hardware_fwk/services/distributedhardwarefwkservice:distributedhardwarefwksvr", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"PublisherItemFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "c_utils:utils", + "eventhandler:libeventhandler", + "init:libbegetutil", + "ipc:ipc_core", + "kv_store:distributeddata_inner", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":PublisherItemFuzzTest" ] +} +############################################################################### diff --git a/services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/corpus/init b/services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/corpus/init new file mode 100644 index 00000000..8eb5a7d6 --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * 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/publisheritem_fuzzer/project.xml b/services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/project.xml new file mode 100644 index 00000000..6e8ad2cf --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/publisheritem_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/publisheritem_fuzzer.cpp new file mode 100644 index 00000000..43202754 --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/publisheritem_fuzzer.cpp @@ -0,0 +1,80 @@ +/* + * 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 "publisheritem_fuzzer.h" + +#include +#include +#include +#include +#include +#include + +#include "publisher_item.h" +#include "distributed_hardware_errno.h" + +namespace OHOS { +namespace DistributedHardware { +namespace { + const uint32_t TOPIC_SIZE = 4; + const DHTopic topicFuzz[TOPIC_SIZE] = { + DHTopic::TOPIC_START_DSCREEN, DHTopic::TOPIC_SINK_PROJECT_WINDOW_INFO, + DHTopic::TOPIC_STOP_DSCREEN, DHTopic::TOPIC_DEV_OFFLINE + }; +} + +void MockPublisherItemListener::OnMessage(const DHTopic topic, const std::string &message) +{ + (void)topic; + (void)message; +} + +int32_t MockPublisherItemListener::OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) +{ + (void)code; + (void)data; + (void)reply; + (void)option; + return DH_FWK_SUCCESS; +} + +void PublisherItemFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + DHTopic topic = topicFuzz[data[0] % TOPIC_SIZE]; + sptr listener = new MockPublisherItemListener(); + std::string message(reinterpret_cast(data), size); + + PublisherItem publisherItem(topic); + + publisherItem.AddListener(listener); + publisherItem.PublishMessage(message); + publisherItem.RemoveListener(listener); +} +} // namespace DistributedHardware +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::PublisherItemFuzzTest(data, size); + return 0; +} + diff --git a/services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/publisheritem_fuzzer.h b/services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/publisheritem_fuzzer.h new file mode 100644 index 00000000..cbfb552d --- /dev/null +++ b/services/distributedhardwarefwkservice/test/fuzztest/publisheritem_fuzzer/publisheritem_fuzzer.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TEST_PUBLISHER_ITEM_FUZZER_H +#define TEST_PUBLISHER_ITEM_FUZZER_H + +#define FUZZ_PROJECT_NAME "publisheritem_fuzzer" + +#include + +#include "iremote_stub.h" + +#include "ipublisher_listener.h" + +namespace OHOS { +namespace DistributedHardware { + +#define REMOVE_NO_USE_CONSTRUCTOR(className) \ +private: \ + className(const className&) = delete; \ + className& operator= (const className&) = delete; \ + className(className&&) = delete; \ + className& operator= (className&&) = delete; \ + +class MockPublisherItemListener : public IRemoteStub { +public: + MockPublisherItemListener() = default; + virtual ~MockPublisherItemListener() = default; + void OnMessage(const DHTopic topic, const std::string &message) override; + int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif + -- Gitee From fb401913eee2cee580f218805365bf63807ab760 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 27 Oct 2022 19:42:10 +0800 Subject: [PATCH 2/3] update fuzz test Signed-off-by: wanderer-dl122 --- .../test/fuzztest/BUILD.gn | 4 ++-- .../BUILD.gn | 4 ++-- .../corpus/init | 0 .../dhmanagerfactory_fuzzer.cpp | 0 .../dhmanagerfactory_fuzzer.h | 0 .../project.xml | 0 .../BUILD.gn | 10 +++++----- .../corpus/init | 0 .../enabledcompsdump_fuzzer.cpp} | 0 .../enabledcompsdump_fuzzer.h} | 0 .../project.xml | 0 11 files changed, 9 insertions(+), 9 deletions(-) rename services/distributedhardwarefwkservice/test/fuzztest/{distributedhardwaremanagerfactory_fuzzer => dhmanagerfactory_fuzzer}/BUILD.gn (94%) rename services/distributedhardwarefwkservice/test/fuzztest/{distributedhardwaremanagerfactory_fuzzer => dhmanagerfactory_fuzzer}/corpus/init (100%) rename services/distributedhardwarefwkservice/test/fuzztest/{distributedhardwaremanagerfactory_fuzzer => dhmanagerfactory_fuzzer}/dhmanagerfactory_fuzzer.cpp (100%) rename services/distributedhardwarefwkservice/test/fuzztest/{distributedhardwaremanagerfactory_fuzzer => dhmanagerfactory_fuzzer}/dhmanagerfactory_fuzzer.h (100%) rename services/distributedhardwarefwkservice/test/fuzztest/{distributedhardwaremanagerfactory_fuzzer => dhmanagerfactory_fuzzer}/project.xml (100%) rename services/distributedhardwarefwkservice/test/fuzztest/{enableedcompsdump_fuzzer => enabledcompsdump_fuzzer}/BUILD.gn (91%) rename services/distributedhardwarefwkservice/test/fuzztest/{enableedcompsdump_fuzzer => enabledcompsdump_fuzzer}/corpus/init (100%) rename services/distributedhardwarefwkservice/test/fuzztest/{enableedcompsdump_fuzzer/enableedcompsdump_fuzzer.cpp => enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.cpp} (100%) rename services/distributedhardwarefwkservice/test/fuzztest/{enableedcompsdump_fuzzer/enableedcompsdump_fuzzer.h => enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.h} (100%) rename services/distributedhardwarefwkservice/test/fuzztest/{enableedcompsdump_fuzzer => enabledcompsdump_fuzzer}/project.xml (100%) diff --git a/services/distributedhardwarefwkservice/test/fuzztest/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/BUILD.gn index 3d3d2cf4..454cf537 100644 --- a/services/distributedhardwarefwkservice/test/fuzztest/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/fuzztest/BUILD.gn @@ -18,8 +18,8 @@ group("fuzztest") { "accessmanager_fuzzer:fuzztest", "componentloader_fuzzer:fuzztest", "componentmanager_fuzzer:fuzztest", - "distributedhardwaremanagerfactory_fuzzer:fuzztest", - "enableedcompsdump_fuzzer:fuzztest", + "dhmanagerfactory_fuzzer:fuzztest", + "enabledcompsdump_fuzzer:fuzztest", "publisher_fuzzer:fuzztest", "publisheritem_fuzzer:fuzztest", "resourcemanager_fuzzer:fuzztest", diff --git a/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/BUILD.gn similarity index 94% rename from services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/BUILD.gn rename to services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/BUILD.gn index 6c48870a..001292fb 100644 --- a/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/BUILD.gn @@ -19,8 +19,8 @@ import( ##############################fuzztest########################################## ohos_fuzztest("DhManagerFactoryFuzzTest") { - module_out_path = "distributed_hardware_fwk/distributedhardwaremanagerfactory" - fuzz_config_file = "//foundation/distributedhardware/distributed_hardware_fwk/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer" + module_out_path = "distributed_hardware_fwk/dhmanagerfactory" + fuzz_config_file = "//foundation/distributedhardware/distributed_hardware_fwk/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer" include_dirs = [ "//commonlibrary/c_utils/base/include", diff --git a/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/corpus/init b/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/corpus/init similarity index 100% rename from services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/corpus/init rename to services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/corpus/init diff --git a/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/dhmanagerfactory_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/dhmanagerfactory_fuzzer.cpp similarity index 100% rename from services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/dhmanagerfactory_fuzzer.cpp rename to services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/dhmanagerfactory_fuzzer.cpp diff --git a/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/dhmanagerfactory_fuzzer.h b/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/dhmanagerfactory_fuzzer.h similarity index 100% rename from services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/dhmanagerfactory_fuzzer.h rename to services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/dhmanagerfactory_fuzzer.h diff --git a/services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/project.xml b/services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/project.xml similarity index 100% rename from services/distributedhardwarefwkservice/test/fuzztest/distributedhardwaremanagerfactory_fuzzer/project.xml rename to services/distributedhardwarefwkservice/test/fuzztest/dhmanagerfactory_fuzzer/project.xml diff --git a/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/BUILD.gn similarity index 91% rename from services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/BUILD.gn rename to services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/BUILD.gn index aaf219f3..d66696bb 100644 --- a/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/BUILD.gn @@ -18,9 +18,9 @@ import( "//foundation/distributedhardware/distributed_hardware_fwk/distributedhardwarefwk.gni") ##############################fuzztest########################################## -ohos_fuzztest("EnableedCompsDumpFuzzTest") { +ohos_fuzztest("EnabledCompsDumpFuzzTest") { module_out_path = "distributed_hardware_fwk/enableedcompsdump" - fuzz_config_file = "//foundation/distributedhardware/distributed_hardware_fwk/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer" + fuzz_config_file = "//foundation/distributedhardware/distributed_hardware_fwk/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer" include_dirs = [ "//commonlibrary/c_utils/base/include", @@ -40,13 +40,13 @@ ohos_fuzztest("EnableedCompsDumpFuzzTest") { "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "enableedcompsdump_fuzzer.cpp" ] + sources = [ "enabledcompsdump_fuzzer.cpp" ] deps = [ "//foundation/distributedhardware/distributed_hardware_fwk/services/distributedhardwarefwkservice:distributedhardwarefwksvr" ] defines = [ "HI_LOG_ENABLE", - "DH_LOG_TAG=\"EnableedCompsDumpFuzzTest\"", + "DH_LOG_TAG=\"EnabledCompsDumpFuzzTest\"", "LOG_DOMAIN=0xD004100", ] @@ -57,6 +57,6 @@ ohos_fuzztest("EnableedCompsDumpFuzzTest") { group("fuzztest") { testonly = true - deps = [ ":EnableedCompsDumpFuzzTest" ] + deps = [ ":EnabledCompsDumpFuzzTest" ] } ############################################################################### diff --git a/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/corpus/init b/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/corpus/init similarity index 100% rename from services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/corpus/init rename to services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/corpus/init diff --git a/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/enableedcompsdump_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.cpp similarity index 100% rename from services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/enableedcompsdump_fuzzer.cpp rename to services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.cpp diff --git a/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/enableedcompsdump_fuzzer.h b/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.h similarity index 100% rename from services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/enableedcompsdump_fuzzer.h rename to services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.h diff --git a/services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/project.xml b/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/project.xml similarity index 100% rename from services/distributedhardwarefwkservice/test/fuzztest/enableedcompsdump_fuzzer/project.xml rename to services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/project.xml -- Gitee From 9f0960aa8c3e0702cc49b672437c2e1cb5010a54 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 27 Oct 2022 20:15:35 +0800 Subject: [PATCH 3/3] update fuzz test Signed-off-by: wanderer-dl122 --- .../test/fuzztest/enabledcompsdump_fuzzer/BUILD.gn | 2 +- .../enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/BUILD.gn index d66696bb..3ea6a932 100644 --- a/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/BUILD.gn @@ -19,7 +19,7 @@ import( ##############################fuzztest########################################## ohos_fuzztest("EnabledCompsDumpFuzzTest") { - module_out_path = "distributed_hardware_fwk/enableedcompsdump" + module_out_path = "distributed_hardware_fwk/enabledcompsdump" fuzz_config_file = "//foundation/distributedhardware/distributed_hardware_fwk/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer" include_dirs = [ diff --git a/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.cpp index 830c0196..9d95ed1e 100644 --- a/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.cpp +++ b/services/distributedhardwarefwkservice/test/fuzztest/enabledcompsdump_fuzzer/enabledcompsdump_fuzzer.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "enableedcompsdump_fuzzer.h" +#include "enabledcompsdump_fuzzer.h" #include #include -- Gitee