# Copyright (c) 2020 Project CHIP Authors
#
# 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.

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/pigweed.gni")

import("${build_root}/config/compiler/compiler.gni")
import("${chip_root}/build/chip/tests.gni")
import("${dir_pw_unit_test}/test.gni")

declare_args() {
  #Fuzz testing using libfuzzer
  enable_fuzz_test_targets =
      (is_libfuzzer || oss_fuzz) && is_clang && chip_build_tests &&
      (current_os == "linux" || current_os == "mac")

  #Fuzz testing using pw_fuzzer and FuzzTest Framework
  pw_enable_fuzz_test_targets = false
}

# Define a fuzz target for chip.
#
# Fuzz generally only apply on the following environments:
#   - linux and mac host builds when using clang
#
# Sample usage
#
# chip_fuzz_target("fuzz-target-name") {
#   sources = [
#      "FuzzTarget.cpp", # Fuzz target
#   ]
#
#   public_deps = [
#     "${chip_root}/src/lib/foo",         # add dependencies here
#   ]
# }
#
#
template("chip_fuzz_target") {
  if (enable_fuzz_test_targets) {
    executable(target_name) {
      forward_variables_from(invoker, "*")

      fuzz_configs = []
      if (oss_fuzz) {
        fuzz_configs += [ "//build/config/compiler:oss_fuzz" ]
      } else {
        fuzz_configs += [
          "//build/config/compiler:libfuzzer_fuzzing",
          "//build/config/compiler:sanitize_address",
        ]
      }

      if (defined(public_configs)) {
        public_configs += fuzz_configs
      } else {
        public_configs = fuzz_configs
      }
      if (!defined(oubput_dir)) {
        output_dir = "${root_out_dir}/tests"
      }
    }
  }
}

# Define a fuzz target for Matter using pw_fuzzer and Google FuzzTest Framework.
#
# Google FuzzTest is only supported on Linux and MacOS using Clang:
#
# Sample usage
#
# chip_pw_fuzz_target("fuzz-target-name") {
#   test_source = [
#      "FuzzTarget.cpp", # Fuzz target
#   ]
#
#   public_deps = [
#     "${chip_root}/src/lib/foo",         # add dependencies here
#   ]
# }
#
#
template("chip_pw_fuzz_target") {
  if (defined(invoker.test_source)) {
    _test_output_dir = "${root_out_dir}/tests"

    if (defined(invoker.output_dir)) {
      _test_output_dir = invoker.output_dir
    }

    pw_test(target_name) {
      forward_variables_from(invoker,
                             [
                               "deps",
                               "public_deps",
                               "cflags",
                               "configs",
                               "remove_configs",
                             ])

      # TODO: remove this after pw_fuzzer's integration with OSS-Fuzz is complete.
      #just a test for running FuzzTest with libfuzzer-compatibility mode, since this is the mode supported by OSS-fuzz
      # defines = [
      # "FUZZTEST_COMPATIBILITY_MODE=libfuzzer",
      #   "MAKE_BUILD_TYPE=RelWithDebug",
      #  ]

      sources = invoker.test_source
      output_dir = _test_output_dir

      deps = [ "$dir_pw_fuzzer:fuzztest" ]

      # this is necessary so FuzzTest is compiled into an executable in third_party/pigweed/repo/pw_unit_test/test.gni
      # otherwise it will be built successfully but with FuzzTarget.DISABLED.ninja and no executable.
      enable_if = true
    }
  }
}
