# Copyright (c) 2020-2021 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_root}/config/compiler/compiler.gni")
import("${chip_root}/build/chip/java/config.gni")
import("${chip_root}/build/chip/tests.gni")
import("${chip_root}/src/ble/ble.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/src/tracing/tracing_args.gni")

declare_args() {
  # Build monolithic test library.
  chip_monolithic_tests = false
}

# chip_root relative to root_build_dir for macro-prefix-map.
# "/." avoids trailing "/" in result when chip_root is "//"
build_relative_chip_root = rebase_path("${chip_root}/.", root_build_dir)

config("includes") {
  include_dirs = [
    "include",
    ".",
    "${root_gen_dir}/include",
  ]

  if (chip_device_platform == "external" &&
      chip_external_platform_include_dir != "") {
    include_dirs += [ "${chip_external_platform_include_dir}" ]
  }

  # TODO: generated file dependency should be a lib NOT an include
  include_dirs += [ "${chip_root}/zzz_generated/app-common" ]

  defines = [ "CHIP_HAVE_CONFIG_H=1" ]

  # Make __FILE__ and related macros relative to chip_root
  cflags = [ "-fmacro-prefix-map=${build_relative_chip_root}/=" ]
}

if (chip_build_tests) {
  import("${chip_root}/build/chip/chip_test_group.gni")

  chip_test_group("tests") {
    deps = [
      "${chip_root}/src/access/tests",
      "${chip_root}/src/crypto/tests",
      "${chip_root}/src/inet/tests",
      "${chip_root}/src/lib/address_resolve/tests",
      "${chip_root}/src/lib/asn1/tests",
      "${chip_root}/src/lib/core/tests",
      "${chip_root}/src/messaging/tests",
      "${chip_root}/src/protocols/bdx/tests",
      "${chip_root}/src/protocols/interaction_model/tests",
      "${chip_root}/src/protocols/user_directed_commissioning/tests",
      "${chip_root}/src/transport/retransmit/tests",
    ]

    # Skip DNSSD tests for Mbed platform due to flash memory size limitations
    if (current_os != "mbed") {
      deps += [
        "${chip_root}/src/lib/dnssd/minimal_mdns/core/tests",
        "${chip_root}/src/lib/dnssd/minimal_mdns/responders/tests",
        "${chip_root}/src/lib/dnssd/minimal_mdns/tests",
        "${chip_root}/src/lib/dnssd/tests",
      ]
    }

    if (current_os != "zephyr" && current_os != "mbed") {
      deps += [ "${chip_root}/src/lib/dnssd/minimal_mdns/records/tests" ]
    }

    if (current_os != "zephyr" && current_os != "mbed" &&
        chip_device_platform != "efr32") {
      deps += [
        "${chip_root}/src/setup_payload/tests",
        "${chip_root}/src/transport/raw/tests",
      ]
    }

    if (chip_device_platform != "efr32") {
      deps += [
        # TODO(#10447): App test has HF on EFR32.
        "${chip_root}/src/app/tests",
        "${chip_root}/src/credentials/tests",
        "${chip_root}/src/lib/format/tests",
        "${chip_root}/src/lib/support/tests",
        "${chip_root}/src/protocols/secure_channel/tests",
        "${chip_root}/src/system/tests",
        "${chip_root}/src/transport/tests",
      ]

      if (matter_enable_tracing_support &&
          matter_trace_config == "multiplexed") {
        deps += [ "${chip_root}/src/tracing/tests" ]
      }
    }

    if (chip_device_platform != "none") {
      deps += [ "${chip_root}/src/lib/dnssd/minimal_mdns/tests" ]
    }

    if (chip_device_platform != "esp32" && chip_device_platform != "efr32" &&
        chip_device_platform != "ameba") {
      deps += [ "${chip_root}/src/platform/tests" ]
    }

    if (chip_config_network_layer_ble) {
      deps += [ "${chip_root}/src/ble/tests" ]
    }

    # On nrfconnect, the controller tests run into
    # https://github.com/project-chip/connectedhomeip/issues/9630
    if (chip_device_platform != "nrfconnect" &&
        chip_device_platform != "efr32") {
      # TODO(#10447): Controller test has HF on EFR32.
      deps += [ "${chip_root}/src/controller/tests/data_model" ]

      # Skip controller test for Open IoT SDK
      # https://github.com/project-chip/connectedhomeip/issues/23747
      if (chip_device_platform != "openiotsdk") {
        deps += [ "${chip_root}/src/controller/tests" ]
      }
    }

    if (current_os != "zephyr" && current_os != "mbed" &&
        chip_device_platform != "esp32" && chip_device_platform != "ameba") {
      deps += [ "${chip_root}/src/lib/shell/tests" ]
    }

    if (chip_monolithic_tests) {
      build_monolithic_library = true
      output_name = "libCHIP_tests"
      output_dir = "${root_out_dir}/lib"
    }
  }

  chip_test_group("fake_platform_tests") {
    deps = [ "${chip_root}/src/lib/dnssd/platform/tests" ]
  }

  # Tests to run with each Crypto PAL
  chip_test_group("crypto_tests") {
    deps = [
      "${chip_root}/src/credentials/tests",
      "${chip_root}/src/crypto/tests",
    ]
  }

  if (matter_enable_java_compilation) {
    group("java_controller_tests") {
      deps = [ "${chip_root}/src/controller/java:unit_tests" ]
    }
  }
}
