# 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/ohos.gni")
import("//build/test.gni")

##############################fuzztest##########################################
ohos_fuzztest("UpdateActiveMachineFuzzTest") {
  module_output_path = "cellular_data/cellular_data"
  module_out_path = module_output_path
  SOURCE_DIR = "../../.."
  fuzz_config_file = "$SOURCE_DIR/test/fuzztest/updateactivemachine_fuzzer"
  include_dirs = [
    "$SOURCE_DIR/services/include",
    "$SOURCE_DIR/services/include/apn_manager",
    "$SOURCE_DIR/services/include/common",
    "$SOURCE_DIR/services/include/state_machine",
    "$SOURCE_DIR/services/include/utils",
    "$SOURCE_DIR/test/fuzztest/common_fuzzer",
  ]

  deps = [
    "$SOURCE_DIR:tel_cellular_data",
    "$SOURCE_DIR/frameworks/native:tel_cellular_data_api",
  ]

  external_deps = [
    "ability_runtime:ability_manager",
    "ability_runtime:data_ability_helper",
    "access_token:libaccesstoken_sdk",
    "access_token:libnativetoken",
    "access_token:libtoken_setproc",
    "bundle_framework:appexecfwk_core",
    "c_utils:utils",
    "common_event_service:cesfwk_innerkits",
    "core_service:libtel_common",
    "core_service:tel_core_service_api",
    "eventhandler:libeventhandler",
    "hilog:libhilog",
    "init:libbegetutil",
    "netmanager_base:net_conn_manager_if",
    "netmanager_base:net_policy_manager_if",
    "netmanager_base:net_stats_manager_if",
    "relational_store:native_rdb",
    "telephony_data:tel_telephony_data",
  ]

  defines = [
    "TELEPHONY_LOG_TAG = \"CellularDataFuzzTest\"",
    "LOG_DOMAIN = 0xD000F00",
  ]

  cflags = [
    "-g",
    "-O0",
    "-Wno-unused-variable",
    "-fno-omit-frame-pointer",
    "-flto",
    "-fsanitize=cfi",
    "-fsanitize-cfi-cross-dso",
    "-fvisibility=hidden",
  ]

  ldflags = [
    "-flto",
    "-fsanitize=cfi",
    "-fsanitize-cfi-cross-dso",
  ]

  sources = [
    "$SOURCE_DIR/test/fuzztest/common_fuzzer/adddatatoken_fuzzer.cpp",
    "$SOURCE_DIR/test/fuzztest/common_fuzzer/statemachine_fuzzer.cpp",
    "updateactivemachine_fuzzer.cpp",
  ]
}

###############################################################################
group("fuzztest") {
  testonly = true
  deps = []
  deps += [
    # deps file
    ":UpdateActiveMachineFuzzTest",
  ]
}
###############################################################################