blob: f7a67ed37c04cab16bc2f9730a26e235bab5f292 [file] [log] [blame]
# Copyright 2020 The Fuchsia Authors
#
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT
import("//build/components.gni")
import("//build/cpp/cpp_fuzzer.gni")
import("//build/test.gni")
import("//build/zircon/migrated_targets.gni")
zx_library("memalloc") {
sdk = "source"
sdk_headers = [
"lib/memalloc/pool-mem-config.h",
"lib/memalloc/pool.h",
"lib/memalloc/range.h",
]
sources = [
"algorithm.cc",
"pool.cc",
"range.cc",
]
deps = [
"//sdk/lib/fit",
"//sdk/lib/stdcompat",
"//zircon/system/ulib/fbl",
"//zircon/system/ulib/pretty",
"//zircon/system/ulib/zxc",
]
if (is_kernel) {
deps += [ "//zircon/kernel/lib/libc" ]
} else {
sources += [ "ostream.cc" ]
}
public_deps = [
"//sdk/lib/stdcompat:headers",
# <lib/memalloc/pool.h> has #include <lib/fit/function.h>.
# <lib/memalloc/range.h> has #include <lib/fit/function.h>.
"//sdk/lib/fit:headers",
# <lib/memalloc/pool.h> has #include <fbl/intrusive_double_list.h>.
"//zircon/system/ulib/fbl:headers",
# <lib/memalloc/pool.h> has #include <lib/fitx/result.h>.
"//zircon/system/ulib/zxc:headers",
]
}
source_set("testing") {
testonly = true
public_deps = [
":memalloc",
# test.h has #include <gtest/gtest.h>.
"//third_party/googletest:gtest",
]
}
if (!is_kernel) {
test("memalloc-test") {
sources = [
"algorithm-test.cc",
"pool-mem-config-test.cc",
"pool-test.cc",
]
deps = [
":memalloc",
":testing",
"//sdk/lib/fit",
"//src/lib/fxl/test:gtest_main",
"//third_party/googletest:gmock",
"//third_party/googletest:gtest",
]
}
fuchsia_unittest_package("memalloc-test-package") {
package_name = "memalloc-tests"
deps = [
":memalloc-test",
"//src/sys/test_runners:tmp_storage",
]
}
fuzzer_package("memalloc-fuzzers") {
fuzz_host = true
cpp_fuzzers = [
":find-fuzzer",
":pool-fuzzer",
]
}
cpp_fuzzer("find-fuzzer") {
sources = [ "find-fuzzer.cc" ]
deps = [
":memalloc",
":testing",
]
}
cpp_fuzzer("pool-fuzzer") {
sources = [ "pool-fuzzer.cc" ]
deps = [
":memalloc",
":testing",
"//sdk/lib/stdcompat",
]
}
group("tests") {
testonly = true
deps = [
":memalloc-fuzzers",
":memalloc-test($host_toolchain)",
":memalloc-test-package",
]
}
}