# 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/nlfaultinjection.gni")
import("//build_overrides/pigweed.gni")

import("${chip_root}/build/chip/tests.gni")
import("${chip_root}/build/chip/tools.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/src/system/system.gni")

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

config("tests_config") {
  include_dirs = [ "." ]
}

static_library("helpers") {
  output_name = "libInetTestHelpers"
  output_dir = "${root_out_dir}/lib"

  sources = [
    "TestInetCommon.h",
    "TestInetCommonOptions.cpp",
    "TestInetCommonOptions.h",
    "TestInetCommonPosix.cpp",
    "TestInetLayerCommon.cpp",
    "TestInetLayerCommon.hpp",
    "TestSetupSignalling.h",
    "TestSetupSignallingPosix.cpp",
  ]

  cflags = [ "-Wconversion" ]

  public_deps = [
    "${chip_root}/src/inet",
    "${chip_root}/src/lib/core",
    "${chip_root}/src/platform",
  ]

  if (chip_with_nlfaultinjection) {
    sources += [
      "TestSetupFaultInjection.h",
      "TestSetupFaultInjectionPosix.cpp",
    ]
  }
}

if (chip_build_tests) {
  chip_test_suite("tests") {
    output_name = "libInetLayerTests"

    public_configs = [ ":tests_config" ]

    public_deps = [
      ":helpers",
      "${chip_root}/src/inet",
      "${chip_root}/src/lib/core",
    ]
    test_sources = [
      "TestBasicPacketFilters.cpp",
      "TestInetAddress.cpp",
      "TestInetErrorStr.cpp",
    ]
    sources = []

    if (chip_system_config_use_sockets && current_os != "zephyr") {
      test_sources += [ "TestInetEndPoint.cpp" ]
    }

    cflags = [ "-Wconversion" ]
  }
}

executable("inet-layer-test-tool") {
  sources = [ "inet-layer-test-tool.cpp" ]

  cflags = [ "-Wconversion" ]

  public_deps = [
    ":helpers",
    "${chip_root}/src/inet",
    "${chip_root}/src/lib/core",
    "${chip_root}/src/platform",
    "${chip_root}/src/platform/logging:default",
  ]

  output_dir = root_out_dir
}
