# 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/tests.gni")
import("${chip_root}/src/ble/ble.gni")
import("${chip_root}/src/lwip/lwip.gni")
import("${chip_root}/src/platform/device.gni")

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

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

  # 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" ]
}

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/asn1/tests",
      "${chip_root}/src/lib/core/tests",
      "${chip_root}/src/messaging/tests",
      "${chip_root}/src/protocols/bdx/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/support/tests",
        "${chip_root}/src/protocols/secure_channel/tests",
        "${chip_root}/src/system/tests",
        "${chip_root}/src/transport/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",
        "${chip_root}/src/controller/tests/data_model",
      ]
    }

    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" ]
  }
}
