解决res编译问题

Signed-off-by: zhaojian@huawei.com <zhaojian2@huawei.com>
Change-Id: Idf3a89abb01f6b44c67fd6748fd05dff0aa953fc
This commit is contained in:
zhaojian@huawei.com 2022-11-07 18:38:26 +08:00
parent 1d4f9def75
commit f843a57a79
7 changed files with 290 additions and 0 deletions

View File

@ -37,8 +37,10 @@ const char PROPERTY_DEVICE_TYPE_TV[] = "tv";
const char PROPERTY_DEVICE_TYPE_TABLET[] = "tablet";
const char PROPERTY_DEVICE_TYPE_WATCH[] = "watch";
const char PROPERTY_DEVICE_TYPE_CAR[] = "car";
#ifdef ENABLE_ROSEN_BACKEND
const char DISABLE_ROSEN_FILE_PATH[] = "/etc/disablerosen";
const char DISABLE_WINDOW_ANIMATION_PATH[] = "/etc/disable_window_size_animation";
#endif
const char ENABLE_DEBUG_BOUNDARY_KEY[] = "persist.ace.debug.boundary.enabled";
const char ANIMATION_SCALE_KEY[] = "persist.sys.arkui.animationscale";

View File

@ -19,6 +19,7 @@ group("fuzztest") {
if (!is_asan) {
deps = [
"imageloader_fuzzer:ImageLoaderFuzzTest",
"res2_fuzzer:Res2FuzzTest",
"res_fuzzer:ResFuzzTest",
"uiservice_fuzzer:UiServiceFuzzTest",
"util_fuzzer:UtilFuzzTest",

View File

@ -0,0 +1,163 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
import("//foundation/arkui/ace_engine/ace_config.gni")
module_output_path = "arkui/res2"
##############################fuzztest##########################################
ohos_fuzztest("Res2FuzzTest") {
module_out_path = module_output_path
fuzz_config_file = "//foundation/arkui/ace_engine/test/fuzztest/res2_fuzzer"
deps = [
"$ace_flutter_engine_root:third_party_flutter_engine_ohos",
"$ace_flutter_engine_root/skia:ace_skia_ohos",
"$ace_root/frameworks/core/components/theme:build_theme_code",
"$cjson_root:cjson_static",
# "//third_party/googletest:gtest_main",
]
sources = [
# base
"$ace_root/frameworks/base/json/json_util.cpp",
"$ace_root/frameworks/base/log/dump_log.cpp",
"$ace_root/frameworks/base/utils/base_id.cpp",
# properties
"$ace_root/frameworks/core/components/common/properties/border.cpp",
"$ace_root/frameworks/core/components/common/properties/border_edge.cpp",
"$ace_root/frameworks/core/components/common/properties/color.cpp",
"$ace_root/frameworks/core/components/common/properties/text_style.cpp",
"$ace_root/frameworks/core/mock/mock_ace_application_info.cpp",
# theme
"$ace_root/frameworks/core/components/theme/app_theme.cpp",
"$ace_root/frameworks/core/components/theme/theme_attributes.cpp",
"$ace_root/frameworks/core/components/theme/theme_constants.cpp",
#"$ace_root/frameworks/core/components/theme/theme_manager.cpp",
"$ace_root/frameworks/core/components/theme/theme_utils.cpp",
"$root_out_dir/arkui/framework/core/components/theme/theme_constants_default.cpp",
# animation
"$ace_root/frameworks/core/animation/animator.cpp",
"$ace_root/frameworks/core/animation/anticipate_curve.cpp",
"$ace_root/frameworks/core/animation/cubic_curve.cpp",
"$ace_root/frameworks/core/animation/curves.cpp",
"$ace_root/frameworks/core/animation/scheduler.cpp",
# common
"$ace_root/frameworks/base/geometry/animatable_dimension.cpp",
"$ace_root/frameworks/base/memory/memory_monitor.cpp",
"$ace_root/frameworks/core/common/ace_application_info.cpp",
"$ace_root/frameworks/core/common/ace_engine.cpp",
"$ace_root/frameworks/core/common/container.cpp",
"$ace_root/frameworks/core/common/container_scope.cpp",
"$ace_root/frameworks/core/common/thread_checker.cpp",
"$ace_root/frameworks/core/common/window.cpp",
# event
"$ace_root/frameworks/core/event/back_end_event_manager.cpp",
"$ace_root/frameworks/core/mock/mock_watch_dog.cpp",
#"theme_constants_test.cpp",
"$ace_root/frameworks/core/components/test/unittest/theme/theme_mock.cpp",
# mock
#"$ace_root/frameworks/core/mock/mock_system_properties.cpp",
#fuzz
"$ace_root/test/fuzztest/res2_fuzzer/res2_fuzzer.cpp",
"$ace_root/adapter/ohos/entrance/file_asset_provider.cpp",
"$ace_root/adapter/ohos/osal/system_properties.cpp",
"$ace_root/frameworks/base/resource/ace_res_config.cpp",
"$ace_root/frameworks/base/resource/ace_res_key_parser.cpp",
"$ace_root/frameworks/core/common/flutter/flutter_asset_manager.cpp",
#"$ace_root/frameworks/base/log/ace_trace.cpp",
"$ace_root/frameworks/core/components/test/unittest/mock/ace_trace_mock.cpp",
]
# add sources only needed by wearable like watch.
if (is_wearable_product) {
sources += [ "$root_out_dir/arkui/framework/core/components/theme/theme_constants_watch.cpp" ]
}
# add sources needed by phone and TV. wearable like watch do not need them
if (!is_wearable_product) {
sources += [
# theme
"$root_out_dir/arkui/framework/core/components/theme/theme_constants_tv.cpp",
]
}
configs = [
":config_theme_manager_test",
"$ace_root:ace_test_config",
]
if (is_standard_system) {
external_deps = [
"hiviewdfx_hilog_native:libhilog",
"init:libbegetutil",
]
deps += [ "$ace_flutter_engine_root/icu:ace_libicu_ohos" ]
} else {
external_deps = [
"hilog:libhilog",
"init_lite:libbegetutil",
]
}
external_deps += [ "c_utils:utils" ]
sources += [
"$ace_root/adapter/ohos/osal/log_wrapper.cpp",
"$ace_root/frameworks/core/mock/mock_resource_adapter.cpp",
]
part_name = ace_engine_part
include_dirs = [
"$ace_root/frameworks/core/components/common/properties",
"$ace_root/frameworks/core/components/theme",
"$ace_root/frameworks/core/event",
"$ace_root/frameworks/core",
"$ace_root/frameworks/base/utils",
"$ace_root/frameworks/base",
"$ace_root/frameworks/base/memory",
"$ace_root/frameworks/base/log",
"$ace_root/frameworks",
"$ace_root",
"//third_party/flutter/engine/flutter/assets",
"//third_party/flutter/engine",
"//third_party",
"//commonlibrary/c_utils/base/include",
]
}
config("config_theme_manager_test") {
visibility = [ ":*" ]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":Res2FuzzTest",
]
}
###############################################################################

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2022 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<fuzz_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>

View File

@ -0,0 +1,74 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//#define ENABLE_ROSEN_BACKEND
#include "res2_fuzzer.h"
#include <stddef.h>
#include <stdint.h>
#include "ace_type.h"
#include "adapter/ohos/entrance/file_asset_provider.h"
#include "core/common/flutter/flutter_asset_manager.h"
#include "core/components/theme/theme_constants_defines.h"
#include "frameworks/core/components/theme/theme_constants.h"
#include "core/components/test/unittest/theme/theme_mock.h"
namespace OHOS {
using namespace OHOS::Ace;
using namespace std;
int32_t WriteDataToFile(const string &path, const uint8_t* data, size_t size)
{
FILE *file = nullptr;
file = fopen(path.c_str(), "w+");
if (file == nullptr) {
return -1;
}
if (fwrite(data, 1, size, file) != size) {
(void)fclose(file);
return -1;
}
(void)fclose(file);
return 0;
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
{
bool result = false;
string cmd = "mkdir -p /data/test/arkui";
auto res = AceType::MakeRefPtr<ResourceAdapterMock>();
auto theme = AceType::MakeRefPtr<ThemeConstants>(res);
auto file = AceType::MakeRefPtr<FileAssetProvider>();
auto asset = AceType::MakeRefPtr<FlutterAssetManager>();
string pack = "/data/test/arkui";
vector<string> files = {""};
if(file->Initialize(pack,files)){
asset->PushBack(file);
}
theme->LoadCustomStyle(asset);
return result;
}
}
/* 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,25 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TEST_FUZZTEST_RES2_FUZZER_H
#define TEST_FUZZTEST_RES2_FUZZER_H
#include <climits>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
#include <unistd.h>
#define FUZZ_PROJECT_NAME "res2_fuzzer"
#endif // TEST_FUZZTEST_RES2_FUZZER_H