diff --git a/state_manager/test/fuzztest/BUILD.gn b/state_manager/test/fuzztest/BUILD.gn index 5cc07d38951092321ff4e073e40c56e00756f844..8b9a74ceca93896ae94ddfc9ffdad293ea91569e 100644 --- a/state_manager/test/fuzztest/BUILD.gn +++ b/state_manager/test/fuzztest/BUILD.gn @@ -31,5 +31,6 @@ group("fuzztest") { "overridedisplayoffdelay_fuzzer:OverrideDisplayOffDelayFuzzTest", "registercallback_fuzzer:RegisterCallbackFuzzTest", "setbrightness_fuzzer:SetBrightnessFuzzTest", + "setcoordinated_fuzzer:SetCoordinatedFuzzTest", ] } diff --git a/state_manager/test/fuzztest/setcoordinated_fuzzer/BUILD.gn b/state_manager/test/fuzztest/setcoordinated_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..830f2e11ff70e4b6a32cf5aebbdf2300ab7a95d4 --- /dev/null +++ b/state_manager/test/fuzztest/setcoordinated_fuzzer/BUILD.gn @@ -0,0 +1,86 @@ +# 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. + +import("//build/test.gni") +import("../../../../displaymgr.gni") + +module_output_path = "display_manager/display_state_manager" + +##############################fuzztest########################################## +ohos_fuzztest("SetCoordinatedFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "${displaymgr_root_path}/test/fuzztest/setcoordinated_fuzzer" + + include_dirs = [ + "./", + "${displaymgr_root_path}/service/native/include", + "${displaymgr_root_path}/service/zidl/include", + "${displaymgr_inner_api}/native/include", + "../display_utils", + ] + + configs = [ + "${displaymgr_utils_path}:utils_config", + "${displaymgr_utils_path}:coverage_flags", + "${brightnessmgr_root_path}:brightness_manager_config", + ] + + deps = [ "${brightnessmgr_root_path}:brightness_manager" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "${displaymgr_root_path}/service/native/src/display_auto_brightness.cpp", + "${displaymgr_root_path}/service/native/src/display_param_helper.cpp", + "${displaymgr_root_path}/service/native/src/display_power_mgr_service.cpp", + "${displaymgr_root_path}/service/native/src/display_setting_helper.cpp", + "${displaymgr_root_path}/service/native/src/display_system_ability.cpp", + "${displaymgr_root_path}/service/native/src/gradual_animator.cpp", + "${displaymgr_root_path}/service/native/src/screen_action.cpp", + "${displaymgr_root_path}/service/native/src/screen_controller.cpp", + "${displaymgr_root_path}/service/zidl/src/display_power_callback_proxy.cpp", + "${displaymgr_root_path}/service/zidl/src/display_power_mgr_stub.cpp", + "../display_utils/display_fuzzer.cpp", + "./setcoordinated_fuzzer_test.cpp", + ] + + external_deps = [ "power_manager:power_permission" ] + external_deps += [ + "ability_runtime:ability_manager", + "c_utils:utils", + "data_share:datashare_consumer", + "display_manager:displaymgr", + "eventhandler:libeventhandler", + "ffrt:libffrt", + "hicollie:libhicollie", + "hilog:libhilog", + "hisysevent:libhisysevent", + "image_framework:image_native", + "ipc:ipc_core", + "power_manager:power_ffrt", + "power_manager:power_setting", + "power_manager:power_sysparam", + "power_manager:powermgr_client", + "safwk:system_ability_fwk", + "window_manager:libdm", + ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } +} diff --git a/state_manager/test/fuzztest/setcoordinated_fuzzer/corpus/init b/state_manager/test/fuzztest/setcoordinated_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..e7c3fecd8d4d4816e40088113a2316bb9eb2e13f --- /dev/null +++ b/state_manager/test/fuzztest/setcoordinated_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# 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/state_manager/test/fuzztest/setcoordinated_fuzzer/project.xml b/state_manager/test/fuzztest/setcoordinated_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..1244d8de8de2491c405021e29d3ff754b865f963 --- /dev/null +++ b/state_manager/test/fuzztest/setcoordinated_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 180 + + 4096 + + diff --git a/state_manager/test/fuzztest/setcoordinated_fuzzer/setcoordinated_fuzzer_test.cpp b/state_manager/test/fuzztest/setcoordinated_fuzzer/setcoordinated_fuzzer_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8876e04a03fe8f3b1e5194b32d36d89d2091f11a --- /dev/null +++ b/state_manager/test/fuzztest/setcoordinated_fuzzer/setcoordinated_fuzzer_test.cpp @@ -0,0 +1,36 @@ +/* + * 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. + */ + +/* This files contains faultlog fuzzer test modules. */ + +#define FUZZ_PROJECT_NAME "setcoordinated_fuzzer" + +#include "display_fuzzer.h" +#include "display_power_mgr_ipc_interface_code.h" + +using namespace OHOS::PowerMgr; + +namespace { +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + DisplayFuzzerTest g_serviceTest; + g_serviceTest.TestDisplayServiceStub( + static_cast(DisplayPowerMgrInterfaceCode::SET_COORDINATED), data, size); + return 0; +}