1# Copyright (c) 2023 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/security/device_auth/deps_adapter/deviceauth_hals.gni")
15import("//base/security/device_auth/services/deviceauth.gni")
16
17#####################hydra-fuzz###################
18import("//build/config/features.gni")
19import("//build/ohos.gni")
20import("//build/test.gni")
21module_output_path = "device_auth/device_auth"
22
23##############################fuzztest##########################################
24ohos_fuzztest("DevAuthFuzzTest") {
25  module_out_path = module_output_path
26  fuzz_config_file = "${deviceauth_path}/test/fuzztest/devauth_fuzzer"
27  include_dirs = inc_path + hals_inc_path
28  include_dirs += [
29    ".",
30    "${frameworks_path}/inc/standard",
31    "${dev_frameworks_path}/inc/hiview_adapter",
32    "${dev_frameworks_path}/inc/permission_adapter",
33  ]
34  if (support_os_account) {
35    include_dirs += [ "${dev_frameworks_path}/inc/account_subscriber" ]
36    include_dirs += [ "${dev_frameworks_path}/inc/sa_subscriber" ]
37  }
38  include_dirs += identity_manager_inc
39
40  sources = [ "devauth_fuzzer.cpp" ]
41  sources += deviceauth_ipc_files
42  sources += permission_adapter_files
43  sources += [ "${frameworks_path}/src/ipc_service.c" ]
44  sources += deviceauth_files
45  if (support_os_account) {
46    sources += account_subscriber_files
47    sources += sa_subscriber_files
48  }
49  sources += hiview_adapter_files
50  sources += identity_manager_files
51  defines = [ "HILOG_ENABLE" ]
52  defines += [ "DEV_AUTH_HIVIEW_ENABLE" ]
53  defines += [ "DEV_AUTH_FUZZ_TEST" ]
54  cflags = [
55    "-g",
56    "-O0",
57    "-Wno-unused-variable",
58    "-fno-omit-frame-pointer",
59    "-DHILOG_ENABLE",
60  ]
61  cflags += build_flags
62  cflags += [
63    "-DDEV_AUTH_WORK_THREAD_STACK_SIZE=${device_auth_hichain_thread_stack_size}",
64    "-DMAX_AUTH_SESSION_COUNT=${max_auth_session_count}",
65  ]
66  sanitize = {
67    cfi = true
68    cfi_cross_dso = true
69    integer_overflow = true
70    boundary_sanitize = true
71    ubsan = true
72    debug = true
73  }
74  if (target_cpu == "arm") {
75    cflags += [ "-DBINDER_IPC_32BIT" ]
76  }
77  deps = [ "${deps_adapter_path}:${hal_module_test_name}" ]
78  external_deps = [
79    "access_token:libaccesstoken_sdk",
80    "access_token:libnativetoken",
81    "access_token:libtoken_setproc",
82    "cJSON:cjson",
83    "c_utils:utils",
84    "dsoftbus:softbus_client",
85    "hilog:libhilog",
86    "hisysevent:libhisysevent",
87    "hitrace:hitrace_meter",
88    "init:libbegetutil",
89    "ipc:ipc_core",
90    "samgr:samgr_proxy",
91  ]
92  if (support_os_account) {
93    external_deps += [
94      "ability_base:want",
95      "common_event_service:cesfwk_innerkits",
96      "ipc:ipc_single",
97      "os_account:os_account_innerkits",
98      "samgr:samgr_proxy",
99    ]
100  }
101}
102
103###############################################################################
104group("fuzztest") {
105  testonly = true
106  deps = []
107  deps += [
108    # deps file
109    ":DevAuthFuzzTest",
110  ]
111}
112###############################################################################
113