blob: 1cc5bb22dc23bcb8d8330d80f4139d7dc80c26cb [file] [log] [blame]
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/fuchsia/rules.gni")
import("//build/test.gni")
import("//build/test/test_package.gni")
group("tests") {
testonly = true
deps = [ ":uart16550-test-package" ]
}
# We need to build both a "normal" and a "testonly" version of the library,
# because its headers (and implementation) want to include testonly headers
# like hwreg/mock.h for the benefit of uart16550-test below.
#
# The config below is used to define a macro that is used by uart16550.h to
# conditionally include hwreg/mock.h, and define certain mocking-related
# types and methods.
config("testing.config") {
defines = [ "UART16550_TESTING=1" ]
}
# A template to define a source_set() target for the library. The `testonly`
# parameter is required.
template("define_common_lib") {
source_set(target_name) {
visibility = [ ":*" ]
configs += [
"//build/config:all_source",
"//build/unification/config:zircon-migrated",
"//build/config/fuchsia:enable_zircon_asserts",
]
sources = [ "uart16550.cc" ]
deps = [ "//sdk/fidl/fuchsia.hardware.serial:fuchsia.hardware.serial_c" ]
public_deps = [
"//sdk/banjo/ddk.protocol.acpi",
"//sdk/banjo/ddk.protocol.serial",
"//sdk/banjo/ddk.protocol.serialimpl",
"//src/lib/ddk",
# TODO(fxb/38132): Migrate to the new bind rules and delete the below
"//src/lib/ddk:ddk-deprecated-binding-headers",
"//src/lib/ddktl",
"//zircon/public/lib/fbl",
"//zircon/public/lib/hwreg",
"//zircon/public/lib/zx",
"//zircon/system/ulib/uart",
]
if (invoker.testonly) {
testonly = true
public_deps += [ "//zircon/public/lib/hwreg-mock" ]
public_configs = [ ":testing.config" ]
}
}
}
# This version of the library doesn't have any mocking support, but can
# be used by all other targets.
define_common_lib("uart16550_lib") {
testonly = false
}
# This version of the library has mocking support, but requires testonly = true.
define_common_lib("uart16550_lib_for_testing") {
testonly = true
}
driver_module("uart16550") {
configs += [ "//build/unification/config:zircon-migrated" ]
deps = [
":uart16550_lib",
"//src/devices/lib/driver",
]
}
test("uart16550-test") {
configs += [ "//build/unification/config:zircon-migrated" ]
output_name = "uart16550-test"
sources = [ "uart16550-test.cc" ]
deps = [
":uart16550_lib_for_testing",
"//src/devices/testing/fake_ddk",
"//zircon/public/lib/hwreg-mock",
"//zircon/public/lib/zx",
"//zircon/public/lib/zxtest",
]
}
unittest_package("uart16550-test-package") {
package_name = "uart16550-test"
deps = [ ":uart16550-test" ]
tests = [
{
name = "uart16550-test"
},
]
}