test: fuzz use cases split into separate interfaces

Signed-off-by: ShiJie <shijie20@huawei.com>
Change-Id: I1e2b908bcc675bb9047cc5f6c0307b740feab6b1
This commit is contained in:
ShiJie 2023-08-28 14:18:55 +08:00
parent f3ba895240
commit 003ef29d5c
105 changed files with 3548 additions and 366 deletions

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-2023 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
@ -26,7 +26,7 @@ group("systemtest") {
group("fuzztest") {
testonly = true
deps = [ "fuzztest/power_fuzzer:fuzztest" ]
deps = [ "fuzztest:fuzztest" ]
}
group("unittest") {

49
test/fuzztest/BUILD.gn Normal file
View File

@ -0,0 +1,49 @@
# Copyright (c) 2023 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/config/features.gni")
import("//build/test.gni")
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
"asyncshutdowncallback_fuzzer:AsyncShutdownCallbackFuzzTest",
"createrunninglock_fuzzer:CreateRunningLockFuzzTest",
"forcesuspenddevice_fuzzer:ForceSuspendDeviceFuzzTest",
"getsetdevicemode_fuzzer:GetSetDeviceModeFuzzTest",
"getstate_fuzzer:GetStateFuzzTest",
"isrunninglocktypesupported_fuzzer:IsRunningLockTypeSupportedFuzzTest",
"isscreenon_fuzzer:IsScreenOnFuzzTest",
"isstandby_fuzzer:IsStandbyFuzzTest",
"lockunlockisused_fuzzer:LockUnLockIsUsedFuzzTest",
"overridescreenofftime_fuzzer:OverrideScreenOffTimeFuzzTest",
"powermodecallback_fuzzer:PowerModeCallbackFuzzTest",
"powerstatecallback_fuzzer:PowerStateCallbackFuzzTest",
"proxyrunninglock_fuzzer:ProxyRunningLocksFuzzTest",
"proxyrunninglocks_fuzzer:ProxyRunningLockFuzzTest",
"rebootdevice_fuzzer:RebootDeviceFuzzTest",
"refreshactivity_fuzzer:RefreshActivityFuzzTest",
"releaserunninglock_fuzzer:ReleaseRunningLockFuzzTest",
"resetrunninglocks_fuzzer:ResetRunningLocksFuzzTest",
"setdisplaysuspend_fuzzer:SetDisplaySuspendFuzzTest",
"shelldump_fuzzer:ShellDumpFuzzTest",
"shutdowndevice_fuzzer:ShutDownDeviceFuzzTest",
"suspenddevice_fuzzer:SuspendDeviceFuzzTest",
"syncshutdowncallback_fuzzer:SyncShutdownCallbackFuzzTest",
"takeovershutdowncallback_fuzzer:TakeOverShutdownCallbackFuzzTest",
"wakeupdevice_fuzzer:WakeupDeviceFuzzTest",
]
}

View File

@ -0,0 +1,64 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("AsyncShutdownCallbackFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${powermgr_root_path}/test/fuzztest/asyncshutdowncallback_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./asyncshutdowncallback_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2023 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 "asyncshutdowncallback_fuzzer"
#include "power_fuzzer.h"
#include "shutdown/shutdown_client_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(
static_cast<uint32_t>(ShutdownClientInterfaceCode::CMD_REG_ASYNC_SHUTDOWN_CALLBACK), data, size);
g_serviceTest.TestPowerServiceStub(
static_cast<uint32_t>(ShutdownClientInterfaceCode::CMD_UNREG_ASYNC_SHUTDOWN_CALLBACK), data, size);
return 0;
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Copyright (c) 2023 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

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
<!-- Copyright (c) 2023 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.
@ -18,7 +18,7 @@
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>

View File

@ -0,0 +1,64 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("CreateRunningLockFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${powermgr_root_path}/test/fuzztest/createrunninglock_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./createrunninglock_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 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 "createrunninglock_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::CREATE_RUNNINGLOCK), data, size);
return 0;
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,64 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("ForceSuspendDeviceFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${powermgr_root_path}/test/fuzztest/forcesuspenddevice_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./forcesuspenddevice_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 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 "forcesuspenddevice_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::FORCE_DEVICE_SUSPEND), data, size);
return 0;
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,64 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("GetSetDeviceModeFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${powermgr_root_path}/test/fuzztest/getsetdevicemode_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./getsetdevicemode_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 2023 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 "getsetdevicemode_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::SETMODE_DEVICE), data, size);
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::GETMODE_DEVICE), data, size);
return 0;
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,63 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("GetStateFuzzTest") {
module_out_path = module_output_path
fuzz_config_file = "${powermgr_root_path}/test/fuzztest/getstate_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./getstate_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 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 "getstate_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::GET_STATE), data, size);
return 0;
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,64 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("IsRunningLockTypeSupportedFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${powermgr_root_path}/test/fuzztest/isrunninglocktypesupported_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./isrunninglocktypesupported_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 2023 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 "isrunninglocktypesupported_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(
static_cast<uint32_t>(PowerMgrInterfaceCode::IS_RUNNINGLOCK_TYPE_SUPPORTED), data, size);
return 0;
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,63 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("IsScreenOnFuzzTest") {
module_out_path = module_output_path
fuzz_config_file = "${powermgr_root_path}/test/fuzztest/isscreenon_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./isscreenon_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 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 "isscreenon_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::IS_SCREEN_ON), data, size);
return 0;
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,63 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("IsStandbyFuzzTest") {
module_out_path = module_output_path
fuzz_config_file = "${powermgr_root_path}/test/fuzztest/isstandby_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./isstandby_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 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 "isstandby_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::IS_STANDBY), data, size);
return 0;
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,64 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("LockUnLockIsUsedFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${powermgr_root_path}/test/fuzztest/lockunlockisused_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./lockunlockisused_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2023 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 "lockunlockisused_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::RUNNINGLOCK_LOCK), data, size);
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::RUNNINGLOCK_UNLOCK), data, size);
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::RUNNINGLOCK_ISUSED), data, size);
return 0;
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,64 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("OverrideScreenOffTimeFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${powermgr_root_path}/test/fuzztest/overridescreenofftime_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./overridescreenofftime_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2023 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 "overridescreenofftime_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(
static_cast<uint32_t>(PowerMgrInterfaceCode::OVERRIDE_DISPLAY_OFF_TIME), data, size);
g_serviceTest.TestPowerServiceStub(
static_cast<uint32_t>(PowerMgrInterfaceCode::RESTORE_DISPLAY_OFF_TIME), data, size);
return 0;
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -1,339 +0,0 @@
/*
* Copyright (c) 2022-2023 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. */
#include "power_fuzzer.h"
#include <cstddef>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <random>
#include "actions/idevice_power_action.h"
#include "actions/idevice_state_action.h"
#include "message_parcel.h"
#include "power_mgr_client.h"
#include "power_mgr_service.h"
#include "power_state_machine_info.h"
#include "shutdown/shutdown_client.h"
#include "running_lock_action.h"
#include "securec.h"
using namespace OHOS;
using namespace OHOS::PowerMgr;
using namespace std;
namespace OHOS {
namespace PowerMgr {
class FuzzPowerAction : public IDevicePowerAction {
public:
FuzzPowerAction() = default;
virtual ~FuzzPowerAction() = default;
virtual void Reboot([[maybe_unused]] const std::string& reason) {};
virtual void Shutdown([[maybe_unused]] const std::string& reason) {};
};
class FuzzStateAction : public IDeviceStateAction {
public:
FuzzStateAction() = default;
virtual ~FuzzStateAction() = default;
virtual void Suspend([[maybe_unused]] int64_t callTimeMs, [[maybe_unused]] SuspendDeviceType type,
[[maybe_unused]] uint32_t flags) {};
virtual void ForceSuspend() {};
virtual void Wakeup([[maybe_unused]] int64_t callTimeMs, [[maybe_unused]] WakeupDeviceType type,
[[maybe_unused]] const std::string& details, [[maybe_unused]] const std::string& pkgName) {};
virtual void RefreshActivity([[maybe_unused]] int64_t callTimeMs, [[maybe_unused]] UserActivityType type,
[[maybe_unused]] uint32_t flags) {};
virtual DisplayState GetDisplayState()
{
return DisplayState::DISPLAY_OFF;
};
virtual uint32_t SetDisplayState([[maybe_unused]] DisplayState state,
[[maybe_unused]] StateChangeReason reason = StateChangeReason::STATE_CHANGE_REASON_UNKNOWN)
{
return 0;
}
virtual uint32_t GoToSleep([[maybe_unused]] const std::function<void()> onSuspend,
[[maybe_unused]] const std::function<void()> onWakeup, [[maybe_unused]] bool force)
{
return 0;
}
virtual void RegisterCallback([[maybe_unused]] std::function<void(uint32_t)>& callback) {};
};
} // namespace PowerMgr
} // namespace OHOS
namespace {
auto& g_powerMgrClient = PowerMgrClient::GetInstance();
auto& g_shutdownClient = ShutdownClient::GetInstance();
sptr<PowerMgrService> g_service = nullptr;
const int32_t REWIND_READ_DATA = 0;
} // namespace
static int32_t GetInt32(const uint8_t* data, size_t size)
{
int32_t value = 0;
if (size < sizeof(value)) {
return value;
}
if (memcpy_s(&value, sizeof(value), data, sizeof(value)) != EOK) {
return value;
}
return value;
}
static void SuspendDevice(const uint8_t* data, size_t size)
{
int32_t reason = GetInt32(data, size);
g_powerMgrClient.SuspendDevice(static_cast<SuspendDeviceType>(reason), static_cast<bool>(reason));
}
static void WakeupDevice(const uint8_t* data, size_t size)
{
if (data == nullptr || size == 0) {
return;
}
int32_t reason = GetInt32(data, size);
std::string detail(reinterpret_cast<const char*>(data), size);
g_powerMgrClient.WakeupDevice(static_cast<WakeupDeviceType>(reason), detail);
}
static void RefreshActivity(const uint8_t* data, size_t size)
{
int32_t type = GetInt32(data, size);
g_powerMgrClient.RefreshActivity(static_cast<UserActivityType>(type));
}
static void IsScreenOn([[maybe_unused]] const uint8_t* data, [[maybe_unused]] size_t size)
{
g_powerMgrClient.IsScreenOn();
}
static void GetState([[maybe_unused]] const uint8_t* data, [[maybe_unused]] size_t size)
{
g_powerMgrClient.GetState();
}
static void SetDeviceMode(const uint8_t* data, size_t size)
{
int32_t mode = GetInt32(data, size);
g_powerMgrClient.SetDeviceMode(static_cast<PowerMode>(mode));
}
static void GetDeviceMode([[maybe_unused]] const uint8_t* data, [[maybe_unused]] size_t size)
{
g_powerMgrClient.GetDeviceMode();
}
static void CreateRunningLock(const uint8_t* data, size_t size)
{
if (data == nullptr || size == 0) {
return;
}
int32_t type = GetInt32(data, size);
std::string name(reinterpret_cast<const char*>(data), size);
g_powerMgrClient.CreateRunningLock(name, static_cast<RunningLockType>(type));
}
static void RegisterPowerStateCallback(const uint8_t* data, size_t size)
{
OHOS::sptr<IPowerStateCallback> callback;
if ((memcpy_s(callback, sizeof(callback), data, sizeof(callback))) != EOK) {
return;
}
g_powerMgrClient.RegisterPowerStateCallback(callback);
g_powerMgrClient.UnRegisterPowerStateCallback(callback);
}
static void RegisterPowerModeCallback(const uint8_t* data, size_t size)
{
OHOS::sptr<IPowerModeCallback> callback;
if ((memcpy_s(callback, sizeof(callback), data, sizeof(callback))) != EOK) {
return;
}
g_powerMgrClient.RegisterPowerModeCallback(callback);
g_powerMgrClient.UnRegisterPowerModeCallback(callback);
}
static void ProxyRunningLock(const uint8_t* data, size_t size)
{
int32_t type = GetInt32(data, size);
bool isProxied = static_cast<bool>(type);
pid_t pid = static_cast<pid_t>(type);
pid_t uid = static_cast<pid_t>(type);
g_powerMgrClient.ProxyRunningLock(isProxied, pid, uid);
}
static void Lock(const uint8_t* data, size_t size)
{
if (data == nullptr || size == 0) {
return;
}
int32_t type = GetInt32(data, size);
std::string name(reinterpret_cast<const char*>(data), size);
auto fuzzLock = g_powerMgrClient.CreateRunningLock(name, static_cast<RunningLockType>(type));
if (fuzzLock == nullptr) {
return;
}
int32_t timeout = GetInt32(data, size);
fuzzLock->Lock(timeout);
}
static void UnLock(const uint8_t* data, size_t size)
{
if (data == nullptr || size == 0) {
return;
}
int32_t type = GetInt32(data, size);
std::string name(reinterpret_cast<const char*>(data), size);
auto fuzzLock = g_powerMgrClient.CreateRunningLock(name, static_cast<RunningLockType>(type));
if (fuzzLock == nullptr) {
return;
}
fuzzLock->UnLock();
}
static void OverrideScreenOffTime(const uint8_t* data, size_t size)
{
int32_t timeout = GetInt32(data, size);
g_powerMgrClient.OverrideScreenOffTime(timeout);
}
static void RestoreScreenOffTime([[maybe_unused]] const uint8_t* data, [[maybe_unused]] size_t size)
{
g_powerMgrClient.RestoreScreenOffTime();
}
static void IsRunningLockTypeSupported(const uint8_t* data, size_t size)
{
int32_t type = GetInt32(data, size);
g_powerMgrClient.IsRunningLockTypeSupported(static_cast<RunningLockType>(type));
}
static void SetDisplaySuspend(const uint8_t* data, size_t size)
{
int32_t suspend = GetInt32(data, size);
g_powerMgrClient.SetDisplaySuspend(static_cast<bool>(suspend));
}
static void TestPowerServiceStub(const uint8_t* data, size_t size)
{
uint32_t code;
if (size < sizeof(code)) {
return;
}
if (memcpy_s(&code, sizeof(code), data, sizeof(code)) != EOK) {
return;
}
MessageParcel datas;
datas.WriteInterfaceToken(PowerMgrService::GetDescriptor());
datas.WriteBuffer(data, size);
datas.RewindRead(REWIND_READ_DATA);
MessageParcel reply;
MessageOption option;
if (g_service == nullptr) {
g_service = DelayedSpSingleton<PowerMgrService>::GetInstance();
g_service->OnStart();
auto powerAction = new FuzzPowerAction();
auto powerState = new FuzzStateAction();
auto shutdownState = new FuzzStateAction();
auto lockAction = new RunningLockAction();
g_service->EnableMock(powerState, shutdownState, powerAction, lockAction);
}
g_service->OnRemoteRequest(code, datas, reply, option);
}
static void RegisterAsyncShutdownCallback(const uint8_t* data, size_t size)
{
OHOS::sptr<IAsyncShutdownCallback> callback;
if ((memcpy_s(callback, sizeof(callback), data, sizeof(callback))) != EOK) {
return;
}
int32_t type = GetInt32(data, size);
ShutdownPriority priority = static_cast<ShutdownPriority>(type);
g_shutdownClient.RegisterShutdownCallback(callback, priority);
g_shutdownClient.UnRegisterShutdownCallback(callback);
}
static void RegisterSyncShutdownCallback(const uint8_t* data, size_t size)
{
OHOS::sptr<ISyncShutdownCallback> callback;
if ((memcpy_s(callback, sizeof(callback), data, sizeof(callback))) != EOK) {
return;
}
int32_t type = GetInt32(data, size);
ShutdownPriority priority = static_cast<ShutdownPriority>(type);
g_shutdownClient.RegisterShutdownCallback(callback, priority);
g_shutdownClient.UnRegisterShutdownCallback(callback);
}
static void RegisterTakeOverShutdownCallback(const uint8_t* data, size_t size)
{
OHOS::sptr<ITakeOverShutdownCallback> callback;
if ((memcpy_s(callback, sizeof(callback), data, sizeof(callback))) != EOK) {
return;
}
int32_t type = GetInt32(data, size);
ShutdownPriority priority = static_cast<ShutdownPriority>(type);
g_shutdownClient.RegisterShutdownCallback(callback, priority);
g_shutdownClient.UnRegisterShutdownCallback(callback);
}
static std::vector<std::function<void(const uint8_t*, size_t)>> fuzzFunc = {
&SuspendDevice,
&WakeupDevice,
&RefreshActivity,
&IsScreenOn,
&GetState,
&SetDeviceMode,
&GetDeviceMode,
&CreateRunningLock,
&RegisterPowerStateCallback,
&RegisterPowerModeCallback,
&ProxyRunningLock,
&Lock,
&UnLock,
&OverrideScreenOffTime,
&RestoreScreenOffTime,
&IsRunningLockTypeSupported,
&SetDisplaySuspend,
&RegisterAsyncShutdownCallback,
&RegisterSyncShutdownCallback,
&RegisterTakeOverShutdownCallback
};
namespace OHOS {
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
{
std::random_device rd;
std::default_random_engine engine(rd());
std::uniform_int_distribution<int32_t> randomNum(0, fuzzFunc.size() - 1);
int32_t number = randomNum(engine);
fuzzFunc[number](data, size);
TestPowerServiceStub(data, size);
return true;
}
} // namespace OHOS
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::DoSomethingInterestingWithMyAPI(data, size);
return 0;
}

View File

@ -0,0 +1,106 @@
/*
* Copyright (c) 2023 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. */
#include "power_fuzzer.h"
#include <cstddef>
#include <cstdlib>
#include "actions/idevice_power_action.h"
#include "actions/idevice_state_action.h"
#include "message_parcel.h"
#include "running_lock_action.h"
#include "securec.h"
#include "shutdown/shutdown_client.h"
using namespace OHOS;
using namespace OHOS::PowerMgr;
using namespace std;
namespace OHOS {
namespace PowerMgr {
class FuzzPowerAction : public IDevicePowerAction {
public:
FuzzPowerAction() = default;
virtual ~FuzzPowerAction() = default;
virtual void Reboot([[maybe_unused]] const std::string& reason) {};
virtual void Shutdown([[maybe_unused]] const std::string& reason) {};
};
class FuzzStateAction : public IDeviceStateAction {
public:
FuzzStateAction() = default;
virtual ~FuzzStateAction() = default;
virtual void Suspend([[maybe_unused]] int64_t callTimeMs, [[maybe_unused]] SuspendDeviceType type,
[[maybe_unused]] uint32_t flags) {};
virtual void ForceSuspend() {};
virtual void Wakeup([[maybe_unused]] int64_t callTimeMs, [[maybe_unused]] WakeupDeviceType type,
[[maybe_unused]] const std::string& details, [[maybe_unused]] const std::string& pkgName) {};
virtual void RefreshActivity([[maybe_unused]] int64_t callTimeMs, [[maybe_unused]] UserActivityType type,
[[maybe_unused]] uint32_t flags) {};
virtual DisplayState GetDisplayState()
{
return DisplayState::DISPLAY_OFF;
};
virtual uint32_t SetDisplayState([[maybe_unused]] DisplayState state,
[[maybe_unused]] StateChangeReason reason = StateChangeReason::STATE_CHANGE_REASON_UNKNOWN)
{
return 0;
}
virtual uint32_t GoToSleep([[maybe_unused]] const std::function<void()> onSuspend,
[[maybe_unused]] const std::function<void()> onWakeup, [[maybe_unused]] bool force)
{
return 0;
}
virtual void RegisterCallback([[maybe_unused]] std::function<void(uint32_t)>& callback) {};
};
} // namespace PowerMgr
} // namespace OHOS
namespace {
const int32_t REWIND_READ_DATA = 0;
} // namespace
PowerFuzzerTest::PowerFuzzerTest()
{
service_ = DelayedSpSingleton<PowerMgrService>::GetInstance();
service_->OnStart();
auto powerAction = new FuzzPowerAction();
auto powerState = new FuzzStateAction();
auto shutdownState = new FuzzStateAction();
auto lockAction = new RunningLockAction();
service_->EnableMock(powerState, shutdownState, powerAction, lockAction);
}
PowerFuzzerTest::~PowerFuzzerTest()
{
if (service_ != nullptr) {
service_->OnStop();
}
service_ = nullptr;
}
void PowerFuzzerTest::TestPowerServiceStub(const uint32_t code, const uint8_t* data, size_t size)
{
MessageParcel datas;
datas.WriteInterfaceToken(PowerMgrService::GetDescriptor());
datas.WriteBuffer(data, size);
datas.RewindRead(REWIND_READ_DATA);
MessageParcel reply;
MessageOption option;
service_->OnRemoteRequest(code, datas, reply, option);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Copyright (c) 2023 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
@ -18,6 +18,16 @@
#ifndef POWER_FUZZER_TEST_H
#define POWER_FUZZER_TEST_H
#define FUZZ_PROJECT_NAME "power_fuzzer"
#include "power_mgr_service.h"
class PowerFuzzerTest {
public:
PowerFuzzerTest();
~PowerFuzzerTest();
void TestPowerServiceStub(const uint32_t code, const uint8_t* data, size_t size);
private:
OHOS::sptr<OHOS::PowerMgr::PowerMgrService> service_ {nullptr};
};
#endif

View File

@ -0,0 +1,64 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("PowerModeCallbackFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${powermgr_root_path}/test/fuzztest/powermodecallback_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./powermodecallback_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2023 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 "powermodecallback_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(
static_cast<uint32_t>(PowerMgrInterfaceCode::REG_POWER_MODE_CALLBACK), data, size);
g_serviceTest.TestPowerServiceStub(
static_cast<uint32_t>(PowerMgrInterfaceCode::UNREG_POWER_MODE_CALLBACK), data, size);
return 0;
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,64 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("PowerStateCallbackFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${powermgr_root_path}/test/fuzztest/powerstatecallback_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./powerstatecallback_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2023 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 "powerstatecallback_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(
static_cast<uint32_t>(PowerMgrInterfaceCode::REG_POWER_STATE_CALLBACK), data, size);
g_serviceTest.TestPowerServiceStub(
static_cast<uint32_t>(PowerMgrInterfaceCode::UNREG_POWER_STATE_CALLBACK), data, size);
return 0;
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,64 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("ProxyRunningLocksFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${powermgr_root_path}/test/fuzztest/proxyrunninglock_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./proxyrunninglock_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 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 "proxyrunninglock_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::PROXY_RUNNINGLOCK), data, size);
return 0;
}

View File

@ -0,0 +1,64 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("ProxyRunningLockFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${powermgr_root_path}/test/fuzztest/proxyrunninglocks_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./proxyrunninglocks_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 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 "proxyrunninglocks_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::PROXY_RUNNINGLOCKS), data, size);
return 0;
}

View File

@ -0,0 +1,63 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("RebootDeviceFuzzTest") {
module_out_path = module_output_path
fuzz_config_file = "${powermgr_root_path}/test/fuzztest/rebootdevice_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./rebootdevice_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2023 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 "rebootdevice_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::REBOOT_DEVICE), data, size);
g_serviceTest.TestPowerServiceStub(
static_cast<uint32_t>(PowerMgrInterfaceCode::REBOOT_DEVICE_FOR_DEPRECATED), data, size);
return 0;
}

View File

@ -0,0 +1,64 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("RefreshActivityFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${powermgr_root_path}/test/fuzztest/refreshactivity_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./refreshactivity_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 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 "refreshactivity_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::REFRESH_ACTIVITY), data, size);
return 0;
}

View File

@ -0,0 +1,64 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("ReleaseRunningLockFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${powermgr_root_path}/test/fuzztest/releaserunninglock_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./releaserunninglock_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 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 "releaserunninglock_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::RELEASE_RUNNINGLOCK), data, size);
return 0;
}

View File

@ -0,0 +1,64 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("ResetRunningLocksFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${powermgr_root_path}/test/fuzztest/resetrunninglocks_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./resetrunninglocks_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 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 "resetrunninglocks_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::RESET_RUNNINGLOCKS), data, size);
return 0;
}

View File

@ -0,0 +1,64 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("SetDisplaySuspendFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${powermgr_root_path}/test/fuzztest/setdisplaysuspend_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./setdisplaysuspend_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 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 "setdisplaysuspend_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::SET_DISPLAY_SUSPEND), data, size);
return 0;
}

View File

@ -0,0 +1,63 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("ShellDumpFuzzTest") {
module_out_path = module_output_path
fuzz_config_file = "${powermgr_root_path}/test/fuzztest/shelldump_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./shelldump_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 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 "shelldump_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::SHELL_DUMP), data, size);
return 0;
}

View File

@ -0,0 +1,63 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("ShutDownDeviceFuzzTest") {
module_out_path = module_output_path
fuzz_config_file = "${powermgr_root_path}/test/fuzztest/shutdowndevice_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./shutdowndevice_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 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 "shutdowndevice_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::SHUTDOWN_DEVICE), data, size);
return 0;
}

View File

@ -0,0 +1,63 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("SuspendDeviceFuzzTest") {
module_out_path = module_output_path
fuzz_config_file = "${powermgr_root_path}/test/fuzztest/suspenddevice_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./suspenddevice_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 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 "suspenddevice_fuzzer"
#include "power_fuzzer.h"
#include "power_mgr_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(static_cast<uint32_t>(PowerMgrInterfaceCode::SUSPEND_DEVICE), data, size);
return 0;
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2022-2023 Huawei Device Co., Ltd.
# Copyright (c) 2023 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
@ -17,19 +17,22 @@ import("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("PowerFuzzTest") {
ohos_fuzztest("SyncShutdownCallbackFuzzTest") {
module_out_path = module_output_path
fuzz_config_file = "${powermgr_root_path}/test/fuzztest/power_fuzzer"
fuzz_config_file =
"${powermgr_root_path}/test/fuzztest/syncshutdowncallback_fuzzer"
include_dirs = [
"./",
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"${powermgr_utils_path}:utils_config",
"../power_utils",
]
configs = [ "${powermgr_utils_path}:coverage_flags" ]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
@ -37,9 +40,11 @@ ohos_fuzztest("PowerFuzzTest") {
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "./power_fuzzer.cpp" ]
sources = [
"../power_utils/power_fuzzer.cpp",
"./syncshutdowncallback_fuzzer_test.cpp",
]
deps = [
"${powermgr_inner_api}:powermgr_client",
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
@ -57,15 +62,3 @@ ohos_fuzztest("PowerFuzzTest") {
"sensor:sensor_interface_native",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":PowerFuzzTest",
]
}
###############################################################################

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2023 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 "syncshutdowncallback_fuzzer"
#include "power_fuzzer.h"
#include "shutdown/shutdown_client_ipc_interface_code.h"
using namespace OHOS::PowerMgr;
namespace {
PowerFuzzerTest g_serviceTest;
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
g_serviceTest.TestPowerServiceStub(
static_cast<uint32_t>(ShutdownClientInterfaceCode::CMD_REG_SYNC_SHUTDOWN_CALLBACK), data, size);
g_serviceTest.TestPowerServiceStub(
static_cast<uint32_t>(ShutdownClientInterfaceCode::CMD_UNREG_SYNC_SHUTDOWN_CALLBACK), data, size);
return 0;
}

View File

@ -0,0 +1,64 @@
# Copyright (c) 2023 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("../../../powermgr.gni")
module_output_path = "${powermgr_part_name}/powermgr_native"
##############################fuzztest##########################################
ohos_fuzztest("TakeOverShutdownCallbackFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${powermgr_root_path}/test/fuzztest/takeovershutdowncallback_fuzzer"
include_dirs = [
"${powermgr_service_path}/native/src/shutdown",
"${powermgr_service_path}/native/src/suspend",
"${powermgr_service_path}/native/src/wakeup",
"../power_utils",
]
configs = [
"${powermgr_utils_path}:coverage_flags",
"${powermgr_utils_path}:utils_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"../power_utils/power_fuzzer.cpp",
"./takeovershutdowncallback_fuzzer_test.cpp",
]
deps = [
"${powermgr_service_path}:powermgr_stub",
"${powermgr_service_path}:powermgrservice",
"${powermgr_service_path}/native/src/actions:powermgr_actions",
"//third_party/jsoncpp:jsoncpp",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
"power_manager:power_ffrt",
"sensor:sensor_interface_native",
]
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>180</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

Some files were not shown because too many files have changed in this diff Show More