diff --git a/state_manager/test/fuzztest/BUILD.gn b/state_manager/test/fuzztest/BUILD.gn index 8b9a74ceca93896ae94ddfc9ffdad293ea91569e..836c737a6bb893fef26c13f76e4846a08ffb25c5 100644 --- a/state_manager/test/fuzztest/BUILD.gn +++ b/state_manager/test/fuzztest/BUILD.gn @@ -32,5 +32,7 @@ group("fuzztest") { "registercallback_fuzzer:RegisterCallbackFuzzTest", "setbrightness_fuzzer:SetBrightnessFuzzTest", "setcoordinated_fuzzer:SetCoordinatedFuzzTest", + "setlightbrightnessthreshold_fuzzer:SetLightBrightnessThresholdFuzzTest", + "setmaxbrightness_fuzzer:SetMaxBrightnessFuzzTest", ] } diff --git a/state_manager/test/fuzztest/setlightbrightnessthreshold_fuzzer/BUILD.gn b/state_manager/test/fuzztest/setlightbrightnessthreshold_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b50529657a35bccaaebbee6f0222b71f55723d38 --- /dev/null +++ b/state_manager/test/fuzztest/setlightbrightnessthreshold_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("SetLightBrightnessThresholdFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "${displaymgr_root_path}/test/fuzztest/setlightbrightnessthreshold_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", + "./setlightbrightnessthreshold_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/setlightbrightnessthreshold_fuzzer/corpus/init b/state_manager/test/fuzztest/setlightbrightnessthreshold_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..e7c3fecd8d4d4816e40088113a2316bb9eb2e13f --- /dev/null +++ b/state_manager/test/fuzztest/setlightbrightnessthreshold_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/setlightbrightnessthreshold_fuzzer/project.xml b/state_manager/test/fuzztest/setlightbrightnessthreshold_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..1244d8de8de2491c405021e29d3ff754b865f963 --- /dev/null +++ b/state_manager/test/fuzztest/setlightbrightnessthreshold_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 180 + + 4096 + + diff --git a/state_manager/test/fuzztest/setlightbrightnessthreshold_fuzzer/setlightbrightnessthreshold_fuzzer_test.cpp b/state_manager/test/fuzztest/setlightbrightnessthreshold_fuzzer/setlightbrightnessthreshold_fuzzer_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2e87c7c4af6f244948967602f195b155fe8ba48a --- /dev/null +++ b/state_manager/test/fuzztest/setlightbrightnessthreshold_fuzzer/setlightbrightnessthreshold_fuzzer_test.cpp @@ -0,0 +1,38 @@ +/* + * 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 "setlightbrightnessthreshold_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_MAX_BRIGHTNESS), data, size); + g_serviceTest.TestDisplayServiceStub( + static_cast(DisplayPowerMgrInterfaceCode::SET_MAX_BRIGHTNESS_NIT), data, size); + return 0; +} diff --git a/state_manager/test/fuzztest/setmaxbrightness_fuzzer/BUILD.gn b/state_manager/test/fuzztest/setmaxbrightness_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..37a0134bdb92d45e26ffa45af11a73b2177d3e88 --- /dev/null +++ b/state_manager/test/fuzztest/setmaxbrightness_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("SetMaxBrightnessFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "${displaymgr_root_path}/test/fuzztest/setmaxbrightness_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", + "./setmaxbrightness_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/setmaxbrightness_fuzzer/corpus/init b/state_manager/test/fuzztest/setmaxbrightness_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..e7c3fecd8d4d4816e40088113a2316bb9eb2e13f --- /dev/null +++ b/state_manager/test/fuzztest/setmaxbrightness_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/setmaxbrightness_fuzzer/project.xml b/state_manager/test/fuzztest/setmaxbrightness_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..1244d8de8de2491c405021e29d3ff754b865f963 --- /dev/null +++ b/state_manager/test/fuzztest/setmaxbrightness_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 180 + + 4096 + + diff --git a/state_manager/test/fuzztest/setmaxbrightness_fuzzer/setmaxbrightness_fuzzer_test.cpp b/state_manager/test/fuzztest/setmaxbrightness_fuzzer/setmaxbrightness_fuzzer_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..71c70c465c19ed880967358a6c82513fb7bda310 --- /dev/null +++ b/state_manager/test/fuzztest/setmaxbrightness_fuzzer/setmaxbrightness_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 "setmaxbrightness_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_APS_LIGHT_AND_BRIGHTNESS_THRESOLD), data, size); + return 0; +}