mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 06:50:40 +00:00
add window stub fuzz test
Signed-off-by: wangjian10 <wangjian10@huawei.com>
This commit is contained in:
parent
1410349103
commit
e9c1715cf9
@ -26,6 +26,9 @@ group("fuzztest") {
|
||||
"windowmanageragentstubstatus_fuzzer:fuzztest",
|
||||
"windowmanageragentstubtype_fuzzer:fuzztest",
|
||||
"windowscene_fuzzer:fuzztest",
|
||||
"windowstubget_fuzzer:fuzztest",
|
||||
"windowstubnotify_fuzzer:fuzztest",
|
||||
"windowstubupdate_fuzzer:fuzztest",
|
||||
"windowutilmath_fuzzer:fuzztest",
|
||||
]
|
||||
}
|
||||
|
71
test/fuzztest/wms/windowstubget_fuzzer/BUILD.gn
Normal file
71
test/fuzztest/wms/windowstubget_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,71 @@
|
||||
# Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
import("../../../../windowmanager_aafwk.gni")
|
||||
|
||||
module_output_path = "window_manager/window_manager"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("WindowStubGetFuzzTest") {
|
||||
fuzz_config_file = "."
|
||||
module_out_path = module_output_path
|
||||
include_dirs = [
|
||||
"../../../../utils/include",
|
||||
"../../../../interfaces/innerkits/wm",
|
||||
"../../../../interfaces/include",
|
||||
"../../../../utils/include",
|
||||
"../../../../interfaces/innerkits/wm",
|
||||
"../../../../interfaces/innerkits/dm",
|
||||
"../../../../wm/include",
|
||||
"../../../../wm/include/zidl",
|
||||
]
|
||||
|
||||
configs = [
|
||||
"../..:configs_cc_ld",
|
||||
"../../../../resources/config/build:coverage_flags",
|
||||
"../../../../resources/config/build:testcase_flags",
|
||||
]
|
||||
|
||||
sources = [ "windowstubget_fuzzer.cpp" ]
|
||||
deps = [
|
||||
"../../../..//utils:libwmutil",
|
||||
"../../../..//wm:libwm",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:configuration",
|
||||
"ability_runtime:ability_context_native",
|
||||
"ability_runtime:app_manager",
|
||||
"ace_engine:ace_uicontent",
|
||||
"c_utils:utils",
|
||||
"graphic_2d:librender_service_client",
|
||||
"hilog:libhilog",
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_single",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
|
||||
deps += [
|
||||
# deps file
|
||||
":WindowStubGetFuzzTest",
|
||||
]
|
||||
}
|
||||
###############################################################################
|
14
test/fuzztest/wms/windowstubget_fuzzer/corpus/init
Normal file
14
test/fuzztest/wms/windowstubget_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
25
test/fuzztest/wms/windowstubget_fuzzer/project.xml
Normal file
25
test/fuzztest/wms/windowstubget_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fuzz_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>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <parcel.h>
|
||||
#include <securec.h>
|
||||
|
||||
#include <iremote_stub.h>
|
||||
#include "message_option.h"
|
||||
#include "message_parcel.h"
|
||||
#include "marshalling_helper.h"
|
||||
#include "window.h"
|
||||
#include "window_agent.h"
|
||||
#include "window_impl.h"
|
||||
#include "window_manager.h"
|
||||
#include "windowstubget_fuzzer.h"
|
||||
|
||||
using namespace OHOS::Rosen;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t DATA_MIN_SIZE = 2;
|
||||
}
|
||||
|
||||
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size < DATA_MIN_SIZE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel parcel;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
parcel.WriteInterfaceToken(WindowStub::GetDescriptor());
|
||||
parcel.WriteBuffer(data, size);
|
||||
parcel.RewindRead(0);
|
||||
|
||||
sptr<WindowOption> windowOption = new(std::nothrow)WindowOption();
|
||||
if (windowOption == nullptr) {
|
||||
return false;
|
||||
}
|
||||
sptr<WindowImpl> window = new(std::nothrow)WindowImpl(windowOption);
|
||||
if (window == nullptr) {
|
||||
return false;
|
||||
}
|
||||
sptr<WindowAgent> windowStub = new(std::nothrow)WindowAgent(window);
|
||||
if (windowStub == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_GET_WINDOW_PROPERTY),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_DUMP_INFO),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_RESTORE_SPLIT_WINDOW_MODE),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_CONSUME_KEY_EVENT),
|
||||
parcel, reply, option);
|
||||
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;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_WINDOW_STUB_GET_FUZZER_H
|
||||
#define TEST_FUZZTEST_WINDOW_STUB_GET_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "windowstubget_fuzzer"
|
||||
|
||||
#endif
|
71
test/fuzztest/wms/windowstubnotify_fuzzer/BUILD.gn
Normal file
71
test/fuzztest/wms/windowstubnotify_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,71 @@
|
||||
# Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
import("../../../../windowmanager_aafwk.gni")
|
||||
|
||||
module_output_path = "window_manager/window_manager"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("WindowStubNotifyFuzzTest") {
|
||||
fuzz_config_file = "."
|
||||
module_out_path = module_output_path
|
||||
include_dirs = [
|
||||
"../../../../utils/include",
|
||||
"../../../../interfaces/innerkits/wm",
|
||||
"../../../../interfaces/include",
|
||||
"../../../../utils/include",
|
||||
"../../../../interfaces/innerkits/wm",
|
||||
"../../../../interfaces/innerkits/dm",
|
||||
"../../../../wm/include",
|
||||
"../../../../wm/include/zidl",
|
||||
]
|
||||
|
||||
configs = [
|
||||
"../..:configs_cc_ld",
|
||||
"../../../../resources/config/build:coverage_flags",
|
||||
"../../../../resources/config/build:testcase_flags",
|
||||
]
|
||||
|
||||
sources = [ "windowstubnotify_fuzzer.cpp" ]
|
||||
deps = [
|
||||
"../../../..//utils:libwmutil",
|
||||
"../../../..//wm:libwm",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:configuration",
|
||||
"ability_runtime:ability_context_native",
|
||||
"ability_runtime:app_manager",
|
||||
"ace_engine:ace_uicontent",
|
||||
"c_utils:utils",
|
||||
"graphic_2d:librender_service_client",
|
||||
"hilog:libhilog",
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_single",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
|
||||
deps += [
|
||||
# deps file
|
||||
":WindowStubNotifyFuzzTest",
|
||||
]
|
||||
}
|
||||
###############################################################################
|
14
test/fuzztest/wms/windowstubnotify_fuzzer/corpus/init
Normal file
14
test/fuzztest/wms/windowstubnotify_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
25
test/fuzztest/wms/windowstubnotify_fuzzer/project.xml
Normal file
25
test/fuzztest/wms/windowstubnotify_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fuzz_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>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <parcel.h>
|
||||
#include <securec.h>
|
||||
|
||||
#include <iremote_stub.h>
|
||||
#include "message_option.h"
|
||||
#include "message_parcel.h"
|
||||
#include "marshalling_helper.h"
|
||||
#include "window.h"
|
||||
#include "window_agent.h"
|
||||
#include "window_impl.h"
|
||||
#include "window_manager.h"
|
||||
#include "windowstubnotify_fuzzer.h"
|
||||
|
||||
using namespace OHOS::Rosen;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t DATA_MIN_SIZE = 2;
|
||||
}
|
||||
|
||||
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size < DATA_MIN_SIZE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel parcel;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
parcel.WriteInterfaceToken(WindowStub::GetDescriptor());
|
||||
parcel.WriteBuffer(data, size);
|
||||
parcel.RewindRead(0);
|
||||
|
||||
sptr<WindowOption> windowOption = new(std::nothrow)WindowOption();
|
||||
if (windowOption == nullptr) {
|
||||
return false;
|
||||
}
|
||||
sptr<WindowImpl> window = new(std::nothrow)WindowImpl(windowOption);
|
||||
if (window == nullptr) {
|
||||
return false;
|
||||
}
|
||||
sptr<WindowAgent> windowStub = new(std::nothrow)WindowAgent(window);
|
||||
if (windowStub == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_OUTSIDE_PRESSED),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_SCREEN_SHOT),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_DESTROY),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_FOREGROUND),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_BACKGROUND),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_CLIENT_POINT_UP),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(
|
||||
static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_FOREGROUND_INTERACTIVE_STATUS),
|
||||
parcel, reply, option);
|
||||
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;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_WINDOW_STUB_NOTIFY_FUZZER_H
|
||||
#define TEST_FUZZTEST_WINDOW_STUB_NOTIFY_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "windowstubnotify_fuzzer"
|
||||
|
||||
#endif
|
71
test/fuzztest/wms/windowstubupdate_fuzzer/BUILD.gn
Normal file
71
test/fuzztest/wms/windowstubupdate_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,71 @@
|
||||
# Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
import("../../../../windowmanager_aafwk.gni")
|
||||
|
||||
module_output_path = "window_manager/window_manager"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("WindowStubUpdateFuzzTest") {
|
||||
fuzz_config_file = "."
|
||||
module_out_path = module_output_path
|
||||
include_dirs = [
|
||||
"../../../../utils/include",
|
||||
"../../../../interfaces/innerkits/wm",
|
||||
"../../../../interfaces/include",
|
||||
"../../../../utils/include",
|
||||
"../../../../interfaces/innerkits/wm",
|
||||
"../../../../interfaces/innerkits/dm",
|
||||
"../../../../wm/include",
|
||||
"../../../../wm/include/zidl",
|
||||
]
|
||||
|
||||
configs = [
|
||||
"../..:configs_cc_ld",
|
||||
"../../../../resources/config/build:coverage_flags",
|
||||
"../../../../resources/config/build:testcase_flags",
|
||||
]
|
||||
|
||||
sources = [ "windowstubupdate_fuzzer.cpp" ]
|
||||
deps = [
|
||||
"../../../..//utils:libwmutil",
|
||||
"../../../..//wm:libwm",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:configuration",
|
||||
"ability_runtime:ability_context_native",
|
||||
"ability_runtime:app_manager",
|
||||
"ace_engine:ace_uicontent",
|
||||
"c_utils:utils",
|
||||
"graphic_2d:librender_service_client",
|
||||
"hilog:libhilog",
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_single",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
|
||||
deps += [
|
||||
# deps file
|
||||
":WindowStubUpdateFuzzTest",
|
||||
]
|
||||
}
|
||||
###############################################################################
|
14
test/fuzztest/wms/windowstubupdate_fuzzer/corpus/init
Normal file
14
test/fuzztest/wms/windowstubupdate_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
25
test/fuzztest/wms/windowstubupdate_fuzzer/project.xml
Normal file
25
test/fuzztest/wms/windowstubupdate_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fuzz_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>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <parcel.h>
|
||||
#include <securec.h>
|
||||
|
||||
#include <iremote_stub.h>
|
||||
#include "message_option.h"
|
||||
#include "message_parcel.h"
|
||||
#include "marshalling_helper.h"
|
||||
#include "window.h"
|
||||
#include "window_agent.h"
|
||||
#include "window_impl.h"
|
||||
#include "window_manager.h"
|
||||
#include "windowstubupdate_fuzzer.h"
|
||||
|
||||
using namespace OHOS::Rosen;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t DATA_MIN_SIZE = 2;
|
||||
}
|
||||
|
||||
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size < DATA_MIN_SIZE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel parcel;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
parcel.WriteInterfaceToken(WindowStub::GetDescriptor());
|
||||
parcel.WriteBuffer(data, size);
|
||||
parcel.RewindRead(0);
|
||||
|
||||
sptr<WindowOption> windowOption = new(std::nothrow)WindowOption();
|
||||
if (windowOption == nullptr) {
|
||||
return false;
|
||||
}
|
||||
sptr<WindowImpl> window = new(std::nothrow)WindowImpl(windowOption);
|
||||
if (window == nullptr) {
|
||||
return false;
|
||||
}
|
||||
sptr<WindowAgent> windowStub = new(std::nothrow)WindowAgent(window);
|
||||
if (windowStub == nullptr) {
|
||||
return false;
|
||||
}
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_WINDOW_RECT),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_WINDOW_MODE),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_FOCUS_STATUS),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_MODE_SUPPORT_INFO),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_AVOID_AREA),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_WINDOW_STATE),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_DRAG_EVENT),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_DISPLAY_ID),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_OCCUPIED_AREA),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_OCCUPIED_AREA_AND_RECT),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_ACTIVE_STATUS),
|
||||
parcel, reply, option);
|
||||
windowStub->OnRemoteRequest(static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_ZOOM_TRANSFORM),
|
||||
parcel, reply, option);
|
||||
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;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_WINDOW_STUB_UPDATE_FUZZER_H
|
||||
#define TEST_FUZZTEST_WINDOW_STUB_UPDATE_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "windowstubupdate_fuzzer"
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user