From 8aa334c7f10d33b74428f8004b212eaabe28439e Mon Sep 17 00:00:00 2001 From: zaki Date: Thu, 15 Sep 2022 21:34:31 +0800 Subject: [PATCH] add gn args option of coverage generation Signed-off-by: zaki Change-Id: Ie0c8e00be41fb4fe4a03d2de38a2216f4a0933cc --- bundle.json | 2 +- common/interface/BUILD.gn | 5 +- frameworks/aafwk/test/BUILD.gn | 5 +- frameworks/acfwk/test/BUILD.gn | 5 +- frameworks/asacfwk/test/BUILD.gn | 5 +- frameworks/common/test/BUILD.gn | 5 +- interfaces/innerkits/aafwk/BUILD.gn | 5 +- interfaces/innerkits/acfwk/BUILD.gn | 5 +- interfaces/innerkits/asacfwk/BUILD.gn | 5 +- interfaces/innerkits/common/BUILD.gn | 5 +- interfaces/innerkits/test/fuzztest/BUILD.gn | 9 +- .../accessibilityconfig_fuzzer/BUILD.gn | 8 +- .../BUILD.gn | 8 +- .../accessibleabilityclient_fuzzer/BUILD.gn | 8 +- interfaces/kits/napi/BUILD.gn | 2 +- .../kits/napi/accessibility_config/BUILD.gn | 2 +- resources/config/build/BUILD.gn | 23 +++++ services/aams/BUILD.gn | 5 +- services/aams/test/BUILD.gn | 85 +++++++++++++++---- services/test/BUILD.gn | 30 +++++-- 20 files changed, 175 insertions(+), 52 deletions(-) create mode 100644 resources/config/build/BUILD.gn diff --git a/bundle.json b/bundle.json index c0a57021..653189f3 100644 --- a/bundle.json +++ b/bundle.json @@ -18,7 +18,7 @@ "SystemCapability.BarrierFree.Accessibility.Hearing", "SystemCapability.BarrierFree.Accessibility.Vision" ], - "features": [], + "features": [ "accessibility_feature_coverage = false" ], "adapted_system_type": [ "standard" ], diff --git a/common/interface/BUILD.gn b/common/interface/BUILD.gn index 43150581..5f9f054d 100644 --- a/common/interface/BUILD.gn +++ b/common/interface/BUILD.gn @@ -69,7 +69,10 @@ ohos_shared_library("accessibility_interface") { sources = accessibility_interface_src sources += accessibility_data_parcel_src - configs = [ ":accessibility_interface_private_config" ] + configs = [ + ":accessibility_interface_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] public_configs = [ ":accessibility_interface_public_config" ] diff --git a/frameworks/aafwk/test/BUILD.gn b/frameworks/aafwk/test/BUILD.gn index 9004d575..5ef47646 100755 --- a/frameworks/aafwk/test/BUILD.gn +++ b/frameworks/aafwk/test/BUILD.gn @@ -102,7 +102,10 @@ ohos_unittest("accessible_ability_test") { ] sources += aams_mock_multimodalinput_src - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "//base/global/resource_management/frameworks/resmgr:global_resmgr", diff --git a/frameworks/acfwk/test/BUILD.gn b/frameworks/acfwk/test/BUILD.gn index 73843085..a418daa5 100644 --- a/frameworks/acfwk/test/BUILD.gn +++ b/frameworks/acfwk/test/BUILD.gn @@ -50,7 +50,10 @@ ohos_unittest("ac_unit_test") { "unittest/accessibility_config_impl_test.cpp", ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "//base/global/resource_management/frameworks/resmgr:global_resmgr", diff --git a/frameworks/asacfwk/test/BUILD.gn b/frameworks/asacfwk/test/BUILD.gn index 15cbab11..e5f06ce6 100644 --- a/frameworks/asacfwk/test/BUILD.gn +++ b/frameworks/asacfwk/test/BUILD.gn @@ -88,7 +88,10 @@ ohos_unittest("asac_unit_test") { "unittest/accessibility_system_ability_client_impl_test.cpp", ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "//base/global/resource_management/frameworks/resmgr:global_resmgr", diff --git a/frameworks/common/test/BUILD.gn b/frameworks/common/test/BUILD.gn index b9233aac..8fcec8cf 100644 --- a/frameworks/common/test/BUILD.gn +++ b/frameworks/common/test/BUILD.gn @@ -42,7 +42,10 @@ ohos_unittest("accessibility_common_test") { "unittest/accessibility_window_info_test.cpp", ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "//foundation/barrierfree/accessibility/interfaces/innerkits/common:accessibility_common", diff --git a/interfaces/innerkits/aafwk/BUILD.gn b/interfaces/innerkits/aafwk/BUILD.gn index b55b51c9..99bb8b24 100644 --- a/interfaces/innerkits/aafwk/BUILD.gn +++ b/interfaces/innerkits/aafwk/BUILD.gn @@ -46,7 +46,10 @@ ohos_shared_library("accessibleability") { configs = [ ":accessibleability_private_config" ] - public_configs = [ ":accessibleability_public_config" ] + public_configs = [ + ":accessibleability_public_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", diff --git a/interfaces/innerkits/acfwk/BUILD.gn b/interfaces/innerkits/acfwk/BUILD.gn index c3d8aa25..80246713 100755 --- a/interfaces/innerkits/acfwk/BUILD.gn +++ b/interfaces/innerkits/acfwk/BUILD.gn @@ -41,7 +41,10 @@ acfwk_src = [ ohos_shared_library("accessibilityconfig") { sources = acfwk_src - configs = [ ":accessibilityconfig_private_config" ] + configs = [ + ":accessibilityconfig_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] public_configs = [ ":accessibilityconfig_public_config" ] diff --git a/interfaces/innerkits/asacfwk/BUILD.gn b/interfaces/innerkits/asacfwk/BUILD.gn index e95322d5..bd31158e 100644 --- a/interfaces/innerkits/asacfwk/BUILD.gn +++ b/interfaces/innerkits/asacfwk/BUILD.gn @@ -41,7 +41,10 @@ asacfwk_src = [ ohos_shared_library("accessibilityclient") { sources = asacfwk_src - configs = [ ":accessibilityclient_private_config" ] + configs = [ + ":accessibilityclient_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] public_configs = [ ":accessibilityclient_public_config" ] diff --git a/interfaces/innerkits/common/BUILD.gn b/interfaces/innerkits/common/BUILD.gn index 58a959f5..ef2895c0 100644 --- a/interfaces/innerkits/common/BUILD.gn +++ b/interfaces/innerkits/common/BUILD.gn @@ -44,7 +44,10 @@ accessibility_common_src = [ ohos_shared_library("accessibility_common") { sources = accessibility_common_src - configs = [ ":accessibility_common_private_config" ] + configs = [ + ":accessibility_common_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] public_configs = [ ":accessibility_common_public_config" ] diff --git a/interfaces/innerkits/test/fuzztest/BUILD.gn b/interfaces/innerkits/test/fuzztest/BUILD.gn index cf58fbb7..9ad0cd1e 100644 --- a/interfaces/innerkits/test/fuzztest/BUILD.gn +++ b/interfaces/innerkits/test/fuzztest/BUILD.gn @@ -10,7 +10,14 @@ # 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. - +config("configs_cc_ld") { + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] +} group("fuzztest") { testonly = true diff --git a/interfaces/innerkits/test/fuzztest/accessibilityconfig_fuzzer/BUILD.gn b/interfaces/innerkits/test/fuzztest/accessibilityconfig_fuzzer/BUILD.gn index 01c84860..a2294de2 100644 --- a/interfaces/innerkits/test/fuzztest/accessibilityconfig_fuzzer/BUILD.gn +++ b/interfaces/innerkits/test/fuzztest/accessibilityconfig_fuzzer/BUILD.gn @@ -20,11 +20,9 @@ ohos_fuzztest("AccessibilityConfigFuzzTest") { module_out_path = "accessibility/acfwk" fuzz_config_file = "../../fuzztest/accessibilityconfig_fuzzer" - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", + configs = [ + "//foundation/barrierfree/accessibility/interfaces/innerkits/test/fuzztest:configs_cc_ld", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", ] sources = [ "accessibilityconfig_fuzzer.cpp" ] deps = [ "//foundation/barrierfree/accessibility/interfaces/innerkits/acfwk:accessibilityconfig" ] diff --git a/interfaces/innerkits/test/fuzztest/accessibilitysystemabilityclient_fuzzer/BUILD.gn b/interfaces/innerkits/test/fuzztest/accessibilitysystemabilityclient_fuzzer/BUILD.gn index a83de12e..82d7e7c6 100644 --- a/interfaces/innerkits/test/fuzztest/accessibilitysystemabilityclient_fuzzer/BUILD.gn +++ b/interfaces/innerkits/test/fuzztest/accessibilitysystemabilityclient_fuzzer/BUILD.gn @@ -21,11 +21,9 @@ ohos_fuzztest("AccessibilitySystemAbilityClientFuzzTest") { fuzz_config_file = "../../fuzztest/accessibilitysystemabilityclient_fuzzer" include_dirs = [] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", + configs = [ + "//foundation/barrierfree/accessibility/interfaces/innerkits/test/fuzztest:configs_cc_ld", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", ] sources = [ "accessibilitysystemabilityclient_fuzzer.cpp" ] deps = [ "//foundation/barrierfree/accessibility/interfaces/innerkits/asacfwk:accessibilityclient" ] diff --git a/interfaces/innerkits/test/fuzztest/accessibleabilityclient_fuzzer/BUILD.gn b/interfaces/innerkits/test/fuzztest/accessibleabilityclient_fuzzer/BUILD.gn index ada3a587..db10b25c 100644 --- a/interfaces/innerkits/test/fuzztest/accessibleabilityclient_fuzzer/BUILD.gn +++ b/interfaces/innerkits/test/fuzztest/accessibleabilityclient_fuzzer/BUILD.gn @@ -21,11 +21,9 @@ ohos_fuzztest("AccessibleAbilityClientFuzzTest") { fuzz_config_file = "../../fuzztest/accessibleabilityclient_fuzzer" include_dirs = [] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", + configs = [ + "//foundation/barrierfree/accessibility/interfaces/innerkits/test/fuzztest:configs_cc_ld", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", ] sources = [ "accessibleabilityclient_fuzzer.cpp" ] deps = [ "//foundation/barrierfree/accessibility/interfaces/innerkits/aafwk:accessibleability" ] diff --git a/interfaces/kits/napi/BUILD.gn b/interfaces/kits/napi/BUILD.gn index 456fc38b..24ad0cce 100644 --- a/interfaces/kits/napi/BUILD.gn +++ b/interfaces/kits/napi/BUILD.gn @@ -33,7 +33,7 @@ ohos_shared_library("accessibility") { "./src/native_module.cpp", ] - configs = [] + configs = [ "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags" ] deps = [ "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", diff --git a/interfaces/kits/napi/accessibility_config/BUILD.gn b/interfaces/kits/napi/accessibility_config/BUILD.gn index 38feda1e..6f354749 100644 --- a/interfaces/kits/napi/accessibility_config/BUILD.gn +++ b/interfaces/kits/napi/accessibility_config/BUILD.gn @@ -30,7 +30,7 @@ ohos_shared_library("config_napi") { "./src/native_module.cpp", ] - configs = [] + configs = [ "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags" ] deps = [ "//foundation/ability/ability_runtime/frameworks/native/ability/native:abilitykit_native", diff --git a/resources/config/build/BUILD.gn b/resources/config/build/BUILD.gn new file mode 100644 index 00000000..54330a70 --- /dev/null +++ b/resources/config/build/BUILD.gn @@ -0,0 +1,23 @@ +# 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. + +declare_args() { + accessibility_feature_coverage = false +} + +config("coverage_flags") { + if (accessibility_feature_coverage) { + cflags = [ "--coverage" ] + ldflags = [ "--coverage" ] + } +} diff --git a/services/aams/BUILD.gn b/services/aams/BUILD.gn index 34917807..2fd4d7da 100755 --- a/services/aams/BUILD.gn +++ b/services/aams/BUILD.gn @@ -64,7 +64,10 @@ accessibleabilityms_files = [ ohos_shared_library("accessibleabilityms") { sources = accessibleabilityms_files - configs = [ ":aams_service_config" ] + configs = [ + ":aams_service_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "//foundation/barrierfree/accessibility/common/interface:accessibility_interface", diff --git a/services/aams/test/BUILD.gn b/services/aams/test/BUILD.gn index 26d3f00f..08786859 100644 --- a/services/aams/test/BUILD.gn +++ b/services/aams/test/BUILD.gn @@ -90,7 +90,10 @@ ohos_unittest("accessibility_account_data_test") { ] sources += aams_mock_distributeddatamgr_src - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "${ability_runtime_inner_api_path}/ability_manager:ability_manager", @@ -142,7 +145,10 @@ ohos_unittest("accessible_ability_manager_service_test") { ] sources += aams_mock_distributeddatamgr_src - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", @@ -208,7 +214,10 @@ ohos_unittest("accessibility_touch_guider_test") { ] sources += aams_mock_distributeddatamgr_src - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", @@ -264,7 +273,10 @@ ohos_unittest("accessibility_common_event_registry_test") { ] sources += aams_mock_distributeddatamgr_src - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", @@ -334,7 +346,10 @@ ohos_unittest("accessibility_input_interceptor_test") { sources += aams_mock_distributeddatamgr_src sources += aams_mock_multimodalinput_src - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "${ability_runtime_inner_api_path}/ability_manager:ability_manager", @@ -389,7 +404,10 @@ ohos_unittest("accessibility_window_manager_test") { ] sources += aams_mock_distributeddatamgr_src - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "${ability_runtime_inner_api_path}/ability_manager:ability_manager", @@ -454,7 +472,10 @@ ohos_unittest("accessibility_keyevent_filter_test") { ] sources += aams_mock_distributeddatamgr_src - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", @@ -533,7 +554,10 @@ ohos_unittest("accessible_ability_connection_test") { ] sources += aams_mock_distributeddatamgr_src - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", @@ -576,7 +600,10 @@ ohos_unittest("accessibility_display_manager_test") { ] sources += aams_mock_distributeddatamgr_src - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", @@ -636,7 +663,10 @@ ohos_unittest("accessibility_dumper_test") { ] sources += aams_mock_multimodalinput_src - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "//foundation/barrierfree/accessibility/interfaces/innerkits/common:accessibility_common", @@ -678,7 +708,10 @@ ohos_unittest("accessibility_touchevent_injector_test") { ] sources += aams_mock_distributeddatamgr_src - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", @@ -739,7 +772,10 @@ ohos_unittest("accessible_ability_channel_test") { ] sources += aams_mock_distributeddatamgr_src - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "//foundation/barrierfree/accessibility/interfaces/innerkits/common:accessibility_common", @@ -781,7 +817,10 @@ ohos_unittest("accessibility_mouse_autoclick_test") { ] sources += aams_mock_distributeddatamgr_src - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", @@ -820,7 +859,10 @@ ohos_unittest("accessibility_mouse_key_test") { "unittest/accessibility_mouse_key_test.cpp", ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "//foundation/barrierfree/accessibility/interfaces/innerkits/common:accessibility_common", @@ -858,7 +900,10 @@ ohos_unittest("accessibility_short_key_test") { ] sources += aams_mock_distributeddatamgr_src - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", @@ -898,7 +943,10 @@ ohos_unittest("accessibility_settings_config_test") { "unittest/accessibility_settings_config_test.cpp", ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "${ability_runtime_inner_api_path}/ability_manager:ability_manager", @@ -950,7 +998,10 @@ ohos_unittest("accessibility_zoom_gesture_test") { ] sources += aams_mock_distributeddatamgr_src - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", diff --git a/services/test/BUILD.gn b/services/test/BUILD.gn index a83127f6..ebb07d21 100644 --- a/services/test/BUILD.gn +++ b/services/test/BUILD.gn @@ -125,7 +125,10 @@ ohos_moduletest("aams_accessibility_touch_guider_test") { sources += aams_mock_powermanager_src sources += MockDistributedscheduleSrc - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "//base/global/resource_management/frameworks/resmgr:global_resmgr", @@ -206,7 +209,10 @@ ohos_moduletest("aams_accessibility_touchEvent_injector_test") { sources += aams_mock_powermanager_src sources += MockDistributedscheduleSrc - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "//base/global/resource_management/frameworks/resmgr:global_resmgr", @@ -293,7 +299,10 @@ ohos_moduletest("aams_accessible_ability_channel_test") { sources += aams_mock_powermanager_src sources += MockDistributedscheduleSrc - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "//base/global/resource_management/frameworks/resmgr:global_resmgr", @@ -378,7 +387,10 @@ ohos_moduletest("aams_server_test") { sources += aams_mock_powermanager_src sources += MockDistributedscheduleSrc - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "//base/global/resource_management/frameworks/resmgr:global_resmgr", @@ -457,7 +469,10 @@ ohos_moduletest("aams_accessibility_keyevent_filter_test") { sources += aams_mock_powermanager_src sources += MockDistributedscheduleSrc - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "//base/global/resource_management/frameworks/resmgr:global_resmgr", @@ -542,7 +557,10 @@ ohos_moduletest("aams_common_event_registry_test") { sources += aams_mock_powermanager_src sources += MockDistributedscheduleSrc - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "//foundation/barrierfree/accessibility/resources/config/build:coverage_flags", + ] deps = [ "//base/global/resource_management/frameworks/resmgr:global_resmgr",