load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target")
load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest")
load("@fbsource//xplat/folly:defs.bzl", "folly_xplat_cxx_test")

oncall("fbcode_entropy_wardens_folly")

# xplat test rules

non_fbcode_target(
    _kind = folly_xplat_cxx_test,
    name = "at_fork_test",
    srcs = ["AtForkTest.cpp"],
    deps = [
        "fbsource//xplat/folly/portability:gmock",
        "fbsource//xplat/folly/portability:gtest",
        "//third-party/glog:glog",
        "//xplat/folly:utility",
        "//xplat/folly/system:at_fork",
    ],
)

non_fbcode_target(
    _kind = folly_xplat_cxx_test,
    name = "aux_vector_test",
    srcs = ["AuxVectorTest.cpp"],
    deps = [
        "fbsource//xplat/folly/portability:gtest",
        "//xplat/folly/system:aux_vector",
    ],
)

non_fbcode_target(
    _kind = folly_xplat_cxx_test,
    name = "env_util_test",
    srcs = ["EnvUtilTest.cpp"],
    deps = [
        "fbsource//xplat/folly/portability:fcntl",
        "fbsource//xplat/folly/portability:gflags",
        "fbsource//xplat/folly/portability:gtest",
        "fbsource//xplat/folly/portability:stdlib",
        "//third-party/boost:boost_algorithm",
        "//third-party/glog:glog",
        "//xplat/folly:memory",
        "//xplat/folly:subprocess",
        "//xplat/folly/container:array",
        "//xplat/folly/system:env_util",
    ],
)

non_fbcode_target(
    _kind = folly_xplat_cxx_test,
    name = "pid_test",
    srcs = ["PidTest.cpp"],
    deps = [
        "fbsource//xplat/folly/portability:gtest",
        "//third-party/glog:glog",
        "//xplat/folly/system:pid",
    ],
)

non_fbcode_target(
    _kind = folly_xplat_cxx_test,
    name = "memory_mapping_test",
    srcs = ["MemoryMappingTest.cpp"],
    deps = [
        "fbsource//xplat/folly/portability:gtest",
        "fbsource//xplat/folly/portability:sys_mman",
        "//third-party/glog:glog",
        "//xplat/folly:file_util",
        "//xplat/folly:random",
        "//xplat/folly/system:memory_mapping",
    ],
)

non_fbcode_target(
    _kind = folly_xplat_cxx_test,
    name = "shell_test",
    srcs = ["ShellTest.cpp"],
    deps = [
        "fbsource//xplat/folly/portability:gtest",
        "//third-party/glog:glog",
        "//xplat/folly/system:shell",
    ],
)

non_fbcode_target(
    _kind = folly_xplat_cxx_test,
    name = "thread_id_test",
    srcs = ["ThreadIdTest.cpp"],
    deps = [
        "fbsource//xplat/folly/portability:gtest",
        "fbsource//xplat/folly/portability:unistd",
        "//xplat/folly:benchmark",
        "//xplat/folly/system:thread_id",
    ],
)

non_fbcode_target(
    _kind = folly_xplat_cxx_test,
    name = "thread_name_test",
    srcs = ["ThreadNameTest.cpp"],
    deps = [
        "fbsource//xplat/folly/portability:gtest",
        "fbsource//xplat/folly/synchronization:baton",
        "//xplat/folly:scope_guard",
        "//xplat/folly/system:thread_name",
    ],
)

# fbcode test rules

fbcode_target(
    _kind = cpp_unittest,
    name = "at_fork_test",
    srcs = ["AtForkTest.cpp"],
    deps = [
        "//folly:utility",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
        "//folly/system:at_fork",
    ],
    external_deps = [
        "glog",
    ],
)

fbcode_target(
    _kind = cpp_unittest,
    name = "aux_vector_test",
    srcs = ["AuxVectorTest.cpp"],
    headers = [],
    deps = [
        "//folly/portability:gtest",
        "//folly/system:aux_vector",
    ],
)

fbcode_target(
    _kind = cpp_unittest,
    name = "env_util_test",
    srcs = ["EnvUtilTest.cpp"],
    headers = [],
    deps = [
        "//folly:subprocess",
        "//folly/container:array",
        "//folly/portability:fcntl",
        "//folly/portability:gflags",
        "//folly/portability:gtest",
        "//folly/portability:stdlib",
        "//folly/system:env_util",
    ],
    external_deps = [
        "glog",
        ("boost", None, "boost_algorithm"),
    ],
)

fbcode_target(
    _kind = cpp_unittest,
    name = "pid_test",
    srcs = ["PidTest.cpp"],
    deps = [
        "//folly/portability:gtest",
        "//folly/system:pid",
    ],
    external_deps = [
        "glog",
    ],
)

fbcode_target(
    _kind = cpp_unittest,
    name = "memory_mapping_test",
    srcs = ["MemoryMappingTest.cpp"],
    headers = [],
    deps = [
        "//folly:file_util",
        "//folly:random",
        "//folly/portability:gtest",
        "//folly/portability:sys_mman",
        "//folly/system:memory_mapping",
    ],
    external_deps = [
        "glog",
    ],
)

fbcode_target(
    _kind = cpp_unittest,
    name = "shell_test",
    srcs = ["ShellTest.cpp"],
    headers = [],
    deps = [
        "//folly/portability:gtest",
        "//folly/system:shell",
    ],
    external_deps = [
        "glog",
    ],
)

fbcode_target(
    _kind = cpp_unittest,
    name = "thread_id_test",
    srcs = ["ThreadIdTest.cpp"],
    headers = [],
    deps = [
        "//folly:benchmark",
        "//folly/portability:gtest",
        "//folly/portability:unistd",
        "//folly/system:thread_id",
    ],
)

fbcode_target(
    _kind = cpp_unittest,
    name = "thread_name_test",
    srcs = ["ThreadNameTest.cpp"],
    headers = [],
    deps = [
        "//folly:scope_guard",
        "//folly/portability:gtest",
        "//folly/synchronization:baton",
        "//folly/system:thread_name",
    ],
)
