117fd14ceSopenharmony_ci# Copyright (c) 2023 Huawei Device Co., Ltd.
217fd14ceSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
317fd14ceSopenharmony_ci# you may not use this file except in compliance with the License.
417fd14ceSopenharmony_ci# You may obtain a copy of the License at
517fd14ceSopenharmony_ci#
617fd14ceSopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
717fd14ceSopenharmony_ci#
817fd14ceSopenharmony_ci# Unless required by applicable law or agreed to in writing, software
917fd14ceSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
1017fd14ceSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1117fd14ceSopenharmony_ci# See the License for the specific language governing permissions and
1217fd14ceSopenharmony_ci# limitations under the License.
1317fd14ceSopenharmony_ci
1417fd14ceSopenharmony_ciimport("//base/security/device_auth/deps_adapter/deviceauth_hals.gni")
1517fd14ceSopenharmony_ciimport("//base/security/device_auth/services/deviceauth.gni")
1617fd14ceSopenharmony_ci
1717fd14ceSopenharmony_ci#####################hydra-fuzz###################
1817fd14ceSopenharmony_ciimport("//build/config/features.gni")
1917fd14ceSopenharmony_ciimport("//build/ohos.gni")
2017fd14ceSopenharmony_ciimport("//build/test.gni")
2117fd14ceSopenharmony_cimodule_output_path = "device_auth/device_auth"
2217fd14ceSopenharmony_ci
2317fd14ceSopenharmony_ci##############################fuzztest##########################################
2417fd14ceSopenharmony_ciohos_fuzztest("DevAuthFuzzTest") {
2517fd14ceSopenharmony_ci  module_out_path = module_output_path
2617fd14ceSopenharmony_ci  fuzz_config_file = "${deviceauth_path}/test/fuzztest/devauth_fuzzer"
2717fd14ceSopenharmony_ci  include_dirs = inc_path + hals_inc_path
2817fd14ceSopenharmony_ci  include_dirs += [
2917fd14ceSopenharmony_ci    ".",
3017fd14ceSopenharmony_ci    "${frameworks_path}/inc/standard",
3117fd14ceSopenharmony_ci    "${dev_frameworks_path}/inc/hiview_adapter",
3217fd14ceSopenharmony_ci    "${dev_frameworks_path}/inc/permission_adapter",
3317fd14ceSopenharmony_ci  ]
3417fd14ceSopenharmony_ci  if (support_os_account) {
3517fd14ceSopenharmony_ci    include_dirs += [ "${dev_frameworks_path}/inc/account_subscriber" ]
3617fd14ceSopenharmony_ci    include_dirs += [ "${dev_frameworks_path}/inc/sa_subscriber" ]
3717fd14ceSopenharmony_ci  }
3817fd14ceSopenharmony_ci  include_dirs += identity_manager_inc
3917fd14ceSopenharmony_ci
4017fd14ceSopenharmony_ci  sources = [ "devauth_fuzzer.cpp" ]
4117fd14ceSopenharmony_ci  sources += deviceauth_ipc_files
4217fd14ceSopenharmony_ci  sources += permission_adapter_files
4317fd14ceSopenharmony_ci  sources += [ "${frameworks_path}/src/ipc_service.c" ]
4417fd14ceSopenharmony_ci  sources += deviceauth_files
4517fd14ceSopenharmony_ci  if (support_os_account) {
4617fd14ceSopenharmony_ci    sources += account_subscriber_files
4717fd14ceSopenharmony_ci    sources += sa_subscriber_files
4817fd14ceSopenharmony_ci  }
4917fd14ceSopenharmony_ci  sources += hiview_adapter_files
5017fd14ceSopenharmony_ci  sources += identity_manager_files
5117fd14ceSopenharmony_ci  defines = [ "HILOG_ENABLE" ]
5217fd14ceSopenharmony_ci  defines += [ "DEV_AUTH_HIVIEW_ENABLE" ]
5317fd14ceSopenharmony_ci  defines += [ "DEV_AUTH_FUZZ_TEST" ]
5417fd14ceSopenharmony_ci  cflags = [
5517fd14ceSopenharmony_ci    "-g",
5617fd14ceSopenharmony_ci    "-O0",
5717fd14ceSopenharmony_ci    "-Wno-unused-variable",
5817fd14ceSopenharmony_ci    "-fno-omit-frame-pointer",
5917fd14ceSopenharmony_ci    "-DHILOG_ENABLE",
6017fd14ceSopenharmony_ci  ]
6117fd14ceSopenharmony_ci  cflags += build_flags
6217fd14ceSopenharmony_ci  cflags += [
6317fd14ceSopenharmony_ci    "-DDEV_AUTH_WORK_THREAD_STACK_SIZE=${device_auth_hichain_thread_stack_size}",
6417fd14ceSopenharmony_ci    "-DMAX_AUTH_SESSION_COUNT=${max_auth_session_count}",
6517fd14ceSopenharmony_ci  ]
6617fd14ceSopenharmony_ci  sanitize = {
6717fd14ceSopenharmony_ci    cfi = true
6817fd14ceSopenharmony_ci    cfi_cross_dso = true
6917fd14ceSopenharmony_ci    integer_overflow = true
7017fd14ceSopenharmony_ci    boundary_sanitize = true
7117fd14ceSopenharmony_ci    ubsan = true
7217fd14ceSopenharmony_ci    debug = true
7317fd14ceSopenharmony_ci  }
7417fd14ceSopenharmony_ci  if (target_cpu == "arm") {
7517fd14ceSopenharmony_ci    cflags += [ "-DBINDER_IPC_32BIT" ]
7617fd14ceSopenharmony_ci  }
7717fd14ceSopenharmony_ci  deps = [ "${deps_adapter_path}:${hal_module_test_name}" ]
7817fd14ceSopenharmony_ci  external_deps = [
7917fd14ceSopenharmony_ci    "access_token:libaccesstoken_sdk",
8017fd14ceSopenharmony_ci    "access_token:libnativetoken",
8117fd14ceSopenharmony_ci    "access_token:libtoken_setproc",
8217fd14ceSopenharmony_ci    "cJSON:cjson",
8317fd14ceSopenharmony_ci    "c_utils:utils",
8417fd14ceSopenharmony_ci    "dsoftbus:softbus_client",
8517fd14ceSopenharmony_ci    "hilog:libhilog",
8617fd14ceSopenharmony_ci    "hisysevent:libhisysevent",
8717fd14ceSopenharmony_ci    "hitrace:hitrace_meter",
8817fd14ceSopenharmony_ci    "init:libbegetutil",
8917fd14ceSopenharmony_ci    "ipc:ipc_core",
9017fd14ceSopenharmony_ci    "samgr:samgr_proxy",
9117fd14ceSopenharmony_ci  ]
9217fd14ceSopenharmony_ci  if (support_os_account) {
9317fd14ceSopenharmony_ci    external_deps += [
9417fd14ceSopenharmony_ci      "ability_base:want",
9517fd14ceSopenharmony_ci      "common_event_service:cesfwk_innerkits",
9617fd14ceSopenharmony_ci      "ipc:ipc_single",
9717fd14ceSopenharmony_ci      "json:nlohmann_json_static",
9817fd14ceSopenharmony_ci      "os_account:os_account_innerkits",
9917fd14ceSopenharmony_ci      "samgr:samgr_proxy",
10017fd14ceSopenharmony_ci    ]
10117fd14ceSopenharmony_ci  }
10217fd14ceSopenharmony_ci}
10317fd14ceSopenharmony_ci
10417fd14ceSopenharmony_ci###############################################################################
10517fd14ceSopenharmony_cigroup("fuzztest") {
10617fd14ceSopenharmony_ci  testonly = true
10717fd14ceSopenharmony_ci  deps = []
10817fd14ceSopenharmony_ci  deps += [
10917fd14ceSopenharmony_ci    # deps file
11017fd14ceSopenharmony_ci    ":DevAuthFuzzTest",
11117fd14ceSopenharmony_ci  ]
11217fd14ceSopenharmony_ci}
11317fd14ceSopenharmony_ci###############################################################################
114