# 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")

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

  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 = []
    tests = [
      "${chip_root}/src/access/tests",
      "${chip_root}/src/app/data-model/tests",
      "${chip_root}/src/app/cluster-building-blocks/tests",
      "${chip_root}/src/app/data-model-provider/tests",
      "${chip_root}/src/app/icd/server/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/lib/format/tests",
      "${chip_root}/src/messaging/tests",
      "${chip_root}/src/protocols/bdx/tests",
      "${chip_root}/src/protocols/interaction_model/tests",
      "${chip_root}/src/protocols/secure_channel/tests",
      "${chip_root}/src/protocols/user_directed_commissioning/tests",
      "${chip_root}/src/system/tests",
      "${chip_root}/src/transport/retransmit/tests",
      "${chip_root}/src/transport/tests",
    ]

    # Skip DNSSD tests for Mbed platform due to flash memory size limitations
    if (current_os != "mbed") {
      tests += [
        "${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") {
      tests += [ "${chip_root}/src/lib/dnssd/minimal_mdns/records/tests" ]
    }

    if (current_os != "zephyr" && current_os != "mbed") {
      # Avoid these items from "one single binary" test executions. Once tests
      # are split, we can re-visit this (and likely many others).
      #
      # In particular: "app/codegen-data-model-provider/tests" contains
      # symbols for ember mocks which are used by other tests.

      tests += [
        "${chip_root}/src/app/codegen-data-model-provider/tests",
        "${chip_root}/src/setup_payload/tests",
        "${chip_root}/src/transport/raw/tests",
      ]
    }

    if (chip_device_platform != "efr32") {
      tests += [ "${chip_root}/src/app/tests" ]

      # Disabled for EFR32 because _open is not implemented.
      # https://github.com/project-chip/connectedhomeip/issues/35624
      tests += [
        "${chip_root}/src/credentials/tests",
        "${chip_root}/src/lib/support/tests",
      ]
    }

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

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

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

    if (chip_config_network_layer_ble) {
      tests += [ "${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") {
      tests += [ "${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") {
        tests += [ "${chip_root}/src/controller/tests" ]
      }
    }

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

    if (chip_monolithic_tests) {
      deps += [ "${chip_root}/src/lib/support:pw_tests_wrapper" ]
      build_monolithic_library = true
      output_name = "libCHIP_tests"
      output_dir = "${root_out_dir}/lib"
    }
  }

  chip_test_group("example_tests") {
    deps = []
    tests = []
    if (chip_device_platform != "esp32" && chip_device_platform != "efr32" &&
        current_os != "android") {
      tests += [ "${chip_root}/examples/energy-management-app/energy-management-common/tests" ]
    }
  }

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

  # Tests to run with each Crypto PAL
  chip_test_group("crypto_tests") {
    tests = [
      "${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" ]
    }
  }
}
