• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2025 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//base/notification/distributed_notification_service/notification.gni")
15import("//build/config/features.gni")
16import("//build/test.gni")
17
18# advancednotificationservice_fuzztest公共配置模板
19template("advancednotificationservice_fuzztest_target") {
20  assert(defined(invoker.sources_value), "sources_value must be defined")
21  assert(defined(invoker.fuzz_config_file_value), "fuzz_config_file_value must be defined")
22
23  ohos_fuzztest(target_name) {
24    module_out_path = service_fuzz_test_path
25    sources = [ "${component_path}/test/fuzztest/fuzz_common_base/mock/mock_notification_func.cpp", ]
26    sources += invoker.sources_value
27    fuzz_config_file = invoker.fuzz_config_file_value
28    include_dirs = [ "${services_path}/ans/include" ]
29    cflags = [
30      "-fno-math-errno",
31      "-fno-unroll-loops",
32      "-fmerge-all-constants",
33      "-fno-ident",
34      "-Oz",
35      "-flto",
36      "-ffunction-sections",
37      "-fdata-sections",
38    ]
39    defines = []
40    deps = []
41    if (defined(invoker.defines_value)) {
42        defines += invoker.defines_value
43    }
44
45    if (defined(invoker.deps_value)) {
46        deps += invoker.deps_value
47    }
48
49    if (defined(invoker.common_deps_value)) {
50      deps += invoker.common_deps_value
51    }
52
53    # 公共外部依赖
54    external_deps = [
55      "ability_base:configuration",
56      "ability_runtime:ability_manager",
57      "ability_runtime:app_manager",
58      "ability_runtime:appkit_native",
59      "ability_runtime:dataobs_manager",
60      "ability_runtime:extension_manager",
61      "ability_runtime:wantagent_innerkits",
62      "access_token:libaccesstoken_sdk",
63      "access_token:libtokenid_sdk",
64      "bundle_framework:appexecfwk_base",
65      "bundle_framework:appexecfwk_core",
66      "c_utils:utils",
67      "common_event_service:cesfwk_innerkits",
68      "config_policy:configpolicy_util",
69      "data_share:datashare_common",
70      "data_share:datashare_consumer",
71      "data_share:datashare_permission",
72      "device_manager:devicemanagersdk",
73      "ffrt:libffrt",
74      "hilog:libhilog",
75      "i18n:intl_util",
76      "image_framework:image_native",
77      "init:libbegetutil",
78      "kv_store:distributeddata_inner",
79      "openssl:libcrypto_shared",
80      "os_account:os_account_innerkits",
81      "relational_store:native_rdb",
82      "resource_management:global_resmgr",
83      "time_service:time_client",
84    ]
85    external_deps += component_external_deps
86
87    # 条件编译标志
88    if (is_double_framework) {
89      cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ]
90    }
91
92    if (distributed_notification_supported) {
93      defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ]
94      deps += [ "${services_path}/distributed:libans_distributed" ]
95      include_dirs += [ "${services_path}/distributed/include" ]
96    }
97
98    if (notification_smart_reminder_supported) {
99      defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ]
100    }
101
102    if (device_usage) {
103      external_deps += [ "device_usage_statistics:usagestatsinner" ]
104      defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ]
105    }
106
107    if (hisysevent_usage) {
108      cflags += [ "-DHAS_HISYSEVENT_PART" ]
109      external_deps += [ "hisysevent:libhisysevent" ]
110    }
111
112    if (standby_enable) {
113      external_deps += [ "device_standby:standby_innerkits" ]
114      defines += [ "DEVICE_STANDBY_ENABLE" ]
115    }
116
117    if (player_framework) {
118      external_deps += [ "player_framework:media_client" ]
119      defines += [ "PLAYER_FRAMEWORK_ENABLE" ]
120    }
121
122    if (ans_hitrace_usage) {
123      external_deps += [ "hitrace:hitrace_meter" ]
124      defines += [ "HITRACE_METER_ENABLE" ]
125    }
126
127    if (ans_config_policy_enable) {
128      external_deps += [ "config_policy:configpolicy_util" ]
129      defines += [ "CONFIG_POLICY_ENABLE" ]
130    }
131
132    if (screenlock_mgr_enable) {
133      external_deps += [ "screenlock_mgr:screenlock_client" ]
134      defines += [ "SCREENLOCK_MGR_ENABLE" ]
135    }
136
137    if (distributed_notification_service_feature_additional_control ||
138        distributed_notification_service_feature_privileged_message) {
139      defines += [ "ENABLE_ANS_EXT_WRAPPER" ]
140    }
141
142    if (distributed_notification_service_feature_additional_control) {
143      defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ]
144    }
145
146    if (telephony_cust) {
147      defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ]
148    }
149
150    if (distributed_notification_service_feature_disable_fa_model) {
151      defines += [ "ANS_DISABLE_FA_MODEL" ]
152    }
153  }
154}
155
156# 公共依赖(所有 fuzzer 共享)
157common_deps = [
158  "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base",
159  "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object",
160  "${frameworks_module_ans_path}:ans_innerkits",
161  "${services_path}/ans:ans_service_sources"
162]
163