Prefixed (unique) names for executables in cmake

PiperOrigin-RevId: 347335966
Change-Id: Ic8cc22b882fa489d37b636406a1a5fe51745d808
This commit is contained in:
Wiktor Garbacz 2020-12-14 01:13:03 -08:00 committed by Copybara-Service
parent d172411d7b
commit 742fafa433
17 changed files with 342 additions and 184 deletions

View File

@ -19,10 +19,15 @@
# SOURCES is a list of files that should be embedded. If a source names a
# target the target binary is embedded instead.
macro(sapi_cc_embed_data)
cmake_parse_arguments(_sapi_embed "" "NAME;NAMESPACE" "SOURCES" ${ARGN})
cmake_parse_arguments(_sapi_embed "" "OUTPUT_NAME;NAME;NAMESPACE" "SOURCES" ${ARGN})
foreach(src IN LISTS _sapi_embed_SOURCES)
if(TARGET "${src}")
list(APPEND _sapi_embed_in "${CMAKE_CURRENT_BINARY_DIR}/${src}")
get_target_property(_sapi_embed_src_OUTPUT_NAME ${src} OUTPUT_NAME)
if(NOT _sapi_embed_src_OUTPUT_NAME)
set(_sapi_embed_src_OUTPUT_NAME "${src}")
endif()
list(APPEND _sapi_embed_in
"${CMAKE_CURRENT_BINARY_DIR}/${_sapi_embed_src_OUTPUT_NAME}")
else()
list(APPEND _sapi_embed_in "${src}")
endif()
@ -30,22 +35,25 @@ macro(sapi_cc_embed_data)
file(RELATIVE_PATH _sapi_embed_pkg
"${PROJECT_BINARY_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}")
if(NOT _sapi_embed_OUTPUT_NAME)
set(_sapi_embed_OUTPUT_NAME "${_sapi_embed_NAME}")
endif()
add_custom_command(
OUTPUT "${_sapi_embed_NAME}.h"
"${_sapi_embed_NAME}.cc"
OUTPUT "${_sapi_embed_OUTPUT_NAME}.h"
"${_sapi_embed_OUTPUT_NAME}.cc"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND filewrapper "${_sapi_embed_pkg}"
"${_sapi_embed_NAME}"
"${_sapi_embed_OUTPUT_NAME}"
"${_sapi_embed_NAMESPACE}"
"${CMAKE_CURRENT_BINARY_DIR}/${_sapi_embed_NAME}.h"
"${CMAKE_CURRENT_BINARY_DIR}/${_sapi_embed_NAME}.cc"
"${CMAKE_CURRENT_BINARY_DIR}/${_sapi_embed_OUTPUT_NAME}.h"
"${CMAKE_CURRENT_BINARY_DIR}/${_sapi_embed_OUTPUT_NAME}.cc"
${_sapi_embed_in}
DEPENDS ${_sapi_embed_SOURCES}
VERBATIM
)
add_library("${_sapi_embed_NAME}" STATIC
"${_sapi_embed_NAME}.h"
"${_sapi_embed_NAME}.cc"
"${_sapi_embed_OUTPUT_NAME}.h"
"${_sapi_embed_OUTPUT_NAME}.cc"
)
target_link_libraries("${_sapi_embed_NAME}" PRIVATE
sapi::base

View File

@ -16,10 +16,11 @@ add_subdirectory(lib)
if(SAPI_ENABLE_TESTS)
# sandboxed_api/examples/stringop:main_stringop
add_executable(main_stringop
add_executable(sapi_main_stringop
main_stringop.cc
)
target_link_libraries(main_stringop PRIVATE
set_target_properties(sapi_main_stringop PROPERTIES OUTPUT_NAME main_stringop)
target_link_libraries(sapi_main_stringop PRIVATE
absl::memory
absl::strings
absl::time
@ -31,5 +32,5 @@ if(SAPI_ENABLE_TESTS)
sapi::test_main
sapi::vars
)
gtest_discover_tests(main_stringop)
gtest_discover_tests(sapi_main_stringop)
endif()

View File

@ -18,6 +18,7 @@ add_subdirectory(lib)
add_executable(sapi_main_sum
main_sum.cc
)
set_target_properties(sapi_main_sum PROPERTIES OUTPUT_NAME main_sum)
add_executable(sapi::main_sum ALIAS sapi_main_sum)
target_link_libraries(sapi_main_sum PRIVATE
absl::memory

View File

@ -28,10 +28,11 @@ target_link_libraries(zlib-sapi PRIVATE
)
# sandboxed_api/examples/zlib:main_zlib
add_executable(main_zlib
add_executable(sapi_main_zlib
main_zlib.cc
)
target_link_libraries(main_zlib PRIVATE
set_target_properties(sapi_main_zlib PROPERTIES OUTPUT_NAME main_zlib)
target_link_libraries(sapi_main_zlib PRIVATE
absl::status
sapi::base
glog::glog

View File

@ -197,12 +197,13 @@ target_link_libraries(sandbox2_limits PRIVATE
)
# sandboxed_api/sandbox2:forkserver_bin
add_executable(forkserver_bin # Need unprefixed name here
add_executable(sandbox2_forkserver_bin
forkserver_bin.cc
)
add_executable(sandbox2_forkserver_bin ALIAS forkserver_bin)
add_executable(sandbox2::forkserver_bin ALIAS forkserver_bin)
target_link_libraries(forkserver_bin PRIVATE
set_target_properties(sandbox2_forkserver_bin PROPERTIES
OUTPUT_NAME forkserver_bin)
add_executable(sandbox2::forkserver_bin ALIAS sandbox2_forkserver_bin)
target_link_libraries(sandbox2_forkserver_bin PRIVATE
absl::core_headers
absl::strings
glog::glog
@ -216,12 +217,12 @@ target_link_libraries(forkserver_bin PRIVATE
)
# sandboxed_api/sandbox2:forkserver_bin_embed
sapi_cc_embed_data(NAME forkserver_bin_embed # Need unprefixed name here
sapi_cc_embed_data(NAME sandbox2_forkserver_bin_embed
OUTPUT_NAME forkserver_bin_embed
NAMESPACE ""
SOURCES forkserver_bin
SOURCES sandbox2::forkserver_bin
)
add_library(sandbox2_forkserver_bin_embed ALIAS forkserver_bin_embed)
add_library(sandbox2::forkserver_bin_embed ALIAS forkserver_bin_embed)
add_library(sandbox2::forkserver_bin_embed ALIAS sandbox2_forkserver_bin_embed)
# sandboxed_api/sandbox2:global_forkserver
add_library(sandbox2_global_forkserver STATIC
@ -603,25 +604,31 @@ if(SAPI_ENABLE_TESTS)
add_subdirectory(testcases)
# sandboxed_api/sandbox2:syscall_test
add_executable(syscall_test
add_executable(sandbox2_syscall_test
syscall_test.cc
)
target_link_libraries(syscall_test PRIVATE
set_target_properties(sandbox2_syscall_test PROPERTIES
OUTPUT_NAME syscall_test
)
target_link_libraries(sandbox2_syscall_test PRIVATE
absl::strings
sandbox2::config
sandbox2::syscall
sapi::test_main
)
gtest_discover_tests(syscall_test)
gtest_discover_tests(sandbox2_syscall_test)
# sandboxed_api/sandbox2:mounts_test
add_executable(mounts_test
add_executable(sandbox2_mounts_test
mounts_test.cc
)
add_dependencies(mounts_test
set_target_properties(sandbox2_mounts_test PROPERTIES
OUTPUT_NAME mounts_test
)
add_dependencies(sandbox2_mounts_test
sandbox2::testcase_minimal_dynamic
)
target_link_libraries(mounts_test PRIVATE
target_link_libraries(sandbox2_mounts_test PRIVATE
absl::strings
sandbox2::file_base
sandbox2::mounts
@ -630,20 +637,23 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(mounts_test PROPERTIES
gtest_discover_tests(sandbox2_mounts_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
# sandboxed_api/sandbox2:namespace_test
add_executable(namespace_test
add_executable(sandbox2_namespace_test
namespace_test.cc
)
add_dependencies(mounts_test
set_target_properties(sandbox2_namespace_test PROPERTIES
OUTPUT_NAME namespace_test
)
add_dependencies(sandbox2_namespace_test
sandbox2::testcase_hostname
sandbox2::testcase_namespace
)
target_link_libraries(namespace_test PRIVATE
target_link_libraries(sandbox2_namespace_test PRIVATE
absl::memory
absl::strings
sandbox2::comms
@ -656,19 +666,22 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(namespace_test PROPERTIES
gtest_discover_tests(sandbox2_namespace_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
# sandboxed_api/sandbox2:buffer_test
add_executable(buffer_test
add_executable(sandbox2_buffer_test
buffer_test.cc
)
add_dependencies(buffer_test
set_target_properties(sandbox2_buffer_test PROPERTIES
OUTPUT_NAME buffer_test
)
add_dependencies(sandbox2_buffer_test
sandbox2::testcase_buffer
)
target_link_libraries(buffer_test PRIVATE
target_link_libraries(sandbox2_buffer_test PRIVATE
absl::memory
sandbox2::buffer
sandbox2::comms
@ -678,7 +691,7 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(buffer_test PROPERTIES
gtest_discover_tests(sandbox2_buffer_test PROPERTIES
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
@ -698,10 +711,13 @@ if(SAPI_ENABLE_TESTS)
)
# sandboxed_api/sandbox2:comms_test
add_executable(comms_test
add_executable(sandbox2_comms_test
comms_test.cc
)
target_link_libraries(comms_test PRIVATE
set_target_properties(sandbox2_comms_test PROPERTIES
OUTPUT_NAME comms_test
)
target_link_libraries(sandbox2_comms_test PRIVATE
absl::fixed_array
absl::strings
glog::glog
@ -711,17 +727,20 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(comms_test)
gtest_discover_tests(sandbox2_comms_test)
# sandboxed_api/sandbox2:forkserver_test
add_executable(forkserver_test
add_executable(sandbox2_forkserver_test
forkserver_test.cc
global_forkclient.h
)
add_dependencies(forkserver_test
set_target_properties(sandbox2_forkserver_test PROPERTIES
OUTPUT_NAME forkserver_test
)
add_dependencies(sandbox2_forkserver_test
sandbox2::testcase_minimal
)
target_link_libraries(forkserver_test PRIVATE
target_link_libraries(sandbox2_forkserver_test PRIVATE
absl::strings
glog::glog
sandbox2::comms
@ -731,20 +750,23 @@ if(SAPI_ENABLE_TESTS)
sandbox2::testing
sapi::test_main
)
gtest_discover_tests(forkserver_test PROPERTIES
gtest_discover_tests(sandbox2_forkserver_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
# sandboxed_api/sandbox2:limits_test
add_executable(limits_test
add_executable(sandbox2_limits_test
limits_test.cc
)
add_dependencies(limits_test
set_target_properties(sandbox2_limits_test PROPERTIES
OUTPUT_NAME limits_test
)
add_dependencies(sandbox2_limits_test
sandbox2::testcase_limits
sandbox2::testcase_minimal
)
target_link_libraries(limits_test PRIVATE
target_link_libraries(sandbox2_limits_test PRIVATE
absl::memory
sandbox2::bpf_helper
sandbox2::config
@ -754,20 +776,23 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(limits_test PROPERTIES
gtest_discover_tests(sandbox2_limits_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
# sandboxed_api/sandbox2:notify_test
add_executable(notify_test
add_executable(sandbox2_notify_test
notify_test.cc
)
add_dependencies(notify_test
set_target_properties(sandbox2_notify_test PROPERTIES
OUTPUT_NAME notify_test
)
add_dependencies(sandbox2_notify_test
sandbox2::testcase_personality
sandbox2::testcase_pidcomms
)
target_link_libraries(notify_test PRIVATE
target_link_libraries(sandbox2_notify_test PRIVATE
absl::memory
absl::strings
sandbox2::bpf_helper
@ -777,23 +802,26 @@ if(SAPI_ENABLE_TESTS)
sandbox2::testing
sapi::test_main
)
gtest_discover_tests(notify_test PROPERTIES
gtest_discover_tests(sandbox2_notify_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
# sandboxed_api/sandbox2:policy_test
add_executable(policy_test
add_executable(sandbox2_policy_test
policy_test.cc
)
add_dependencies(policy_test
set_target_properties(sandbox2_policy_test PROPERTIES
OUTPUT_NAME policy_test
)
add_dependencies(sandbox2_policy_test
sandbox2::testcase_add_policy_on_syscalls
sandbox2::testcase_malloc_system
sandbox2::testcase_minimal
sandbox2::testcase_minimal_dynamic
sandbox2::testcase_policy
)
target_link_libraries(policy_test PRIVATE
target_link_libraries(sandbox2_policy_test PRIVATE
absl::memory
absl::strings
sandbox2::bpf_helper
@ -804,22 +832,25 @@ if(SAPI_ENABLE_TESTS)
sandbox2::testing
sapi::test_main
)
gtest_discover_tests(policy_test PROPERTIES
gtest_discover_tests(sandbox2_policy_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
# sandboxed_api/sandbox2:sandbox2_test
add_executable(sandbox2_test
add_executable(sandbox2_sandbox2_test
sandbox2_test.cc
)
add_dependencies(sandbox2_test
set_target_properties(sandbox2_sandbox2_test PROPERTIES
OUTPUT_NAME sandbox2_test
)
add_dependencies(sandbox2_sandbox2_test
sandbox2::testcase_abort
sandbox2::testcase_minimal
sandbox2::testcase_sleep
sandbox2::testcase_tsync
)
target_link_libraries(sandbox2_test PRIVATE
target_link_libraries(sandbox2_sandbox2_test PRIVATE
absl::memory
absl::strings
sandbox2::bpf_helper
@ -829,19 +860,22 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(sandbox2_test PROPERTIES
gtest_discover_tests(sandbox2_sandbox2_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
# sandboxed_api/sandbox2:sanitizer_test
add_executable(sanitizer_test
add_executable(sandbox2_sanitizer_test
sanitizer_test.cc
)
add_dependencies(sanitizer_test
set_target_properties(sandbox2_sanitizer_test PROPERTIES
OUTPUT_NAME sanitizer_test
)
add_dependencies(sandbox2_sanitizer_test
sandbox2::testcase_sanitizer
)
target_link_libraries(sanitizer_test PRIVATE
target_link_libraries(sandbox2_sanitizer_test PRIVATE
absl::memory
absl::strings
sandbox2::bpf_helper
@ -854,31 +888,37 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(sanitizer_test PROPERTIES
gtest_discover_tests(sandbox2_sanitizer_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
# sandboxed_api/sandbox2:util_test
add_executable(util_test
add_executable(sandbox2_util_test
util_test.cc
)
target_link_libraries(util_test PRIVATE
set_target_properties(sandbox2_util_test PROPERTIES
OUTPUT_NAME util_test
)
target_link_libraries(sandbox2_util_test PRIVATE
sandbox2::file_base
sandbox2::testing
sandbox2::util
sapi::test_main
)
gtest_discover_tests(util_test)
gtest_discover_tests(sandbox2_util_test)
# sandboxed_api/sandbox2:stack_trace_test
add_executable(stack_trace_test
add_executable(sandbox2_stack_trace_test
stack_trace_test.cc
)
add_dependencies(stack_trace_test
set_target_properties(sandbox2_stack_trace_test PROPERTIES
OUTPUT_NAME stack_trace_test
)
add_dependencies(sandbox2_stack_trace_test
sandbox2::testcase_symbolize
)
target_link_libraries(stack_trace_test PRIVATE
target_link_libraries(sandbox2_stack_trace_test PRIVATE
absl::memory
absl::status
absl::strings
@ -893,19 +933,22 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(stack_trace_test PROPERTIES
gtest_discover_tests(sandbox2_stack_trace_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
# sandboxed_api/sandbox2:ipc_test
add_executable(ipc_test
add_executable(sandbox2_ipc_test
ipc_test.cc
)
add_dependencies(ipc_test
set_target_properties(sandbox2_ipc_test PROPERTIES
OUTPUT_NAME ipc_test
)
add_dependencies(sandbox2_ipc_test
sandbox2::testcase_ipc
)
target_link_libraries(ipc_test PRIVATE
target_link_libraries(sandbox2_ipc_test PRIVATE
absl::memory
sandbox2::bpf_helper
sandbox2::comms
@ -915,7 +958,7 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(ipc_test PROPERTIES
gtest_discover_tests(sandbox2_ipc_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
@ -933,13 +976,16 @@ if(SAPI_ENABLE_TESTS)
)
# sandboxed_api/sandbox2:policybuilder_test
add_executable(policybuilder_test
add_executable(sandbox2_policybuilder_test
policybuilder_test.cc
)
add_dependencies(policybuilder_test
set_target_properties(sandbox2_policybuilder_test PROPERTIES
OUTPUT_NAME policybuilder_test
)
add_dependencies(sandbox2_policybuilder_test
sandbox2::testcase_print_fds
)
target_link_libraries(policybuilder_test PRIVATE
target_link_libraries(sandbox2_policybuilder_test PRIVATE
absl::memory
absl::strings
glog::glog
@ -951,7 +997,7 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(policybuilder_test PROPERTIES
gtest_discover_tests(sandbox2_policybuilder_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)

View File

@ -31,11 +31,12 @@ target_link_libraries(sandbox2_crc4sandbox PRIVATE
)
# sandboxed_api/sandbox2/examples/crc4:crc4bin
add_executable(crc4bin
add_executable(sandbox2_crc4bin
crc4bin.cc
)
add_executable(sandbox2::crc4bin ALIAS crc4bin)
target_link_libraries(crc4bin PRIVATE
set_target_properties(sandbox2_crc4bin PROPERTIES OUTPUT_NAME crc4bin)
add_executable(sandbox2::crc4bin ALIAS sandbox2_crc4bin)
target_link_libraries(sandbox2_crc4bin PRIVATE
absl::core_headers
sandbox2::client
sandbox2::comms

View File

@ -33,11 +33,14 @@ target_link_libraries(sandbox2_custom_fork_sandbox PRIVATE
)
# sandboxed_api/sandbox2/examples/custom_fork:custom_fork_bin
add_executable(custom_fork_bin
add_executable(sandbox2_custom_fork_bin
custom_fork_bin.cc
)
add_executable(sandbox2::custom_fork_bin ALIAS custom_fork_bin)
target_link_libraries(custom_fork_bin PRIVATE
set_target_properties(sandbox2_custom_fork_bin PROPERTIES
OUTPUT_NAME custom_fork_bin
)
add_executable(sandbox2::custom_fork_bin ALIAS sandbox2_custom_fork_bin)
target_link_libraries(sandbox2_custom_fork_bin PRIVATE
sandbox2::comms
sandbox2::forkingclient
sandbox2::util

View File

@ -32,11 +32,12 @@ target_link_libraries(sandbox2_network_sandbox PRIVATE
)
# sandboxed_api/sandbox2/examples/network_bin:network_bin
add_executable(network_bin
add_executable(sandbox2_network_bin
network_bin.cc
)
add_executable(sandbox2::network_bin ALIAS network_bin)
target_link_libraries(network_bin PRIVATE
set_target_properties(sandbox2_network_bin PROPERTIES OUTPUT_NAME network_bin)
add_executable(sandbox2::network_bin ALIAS sandbox2_network_bin)
target_link_libraries(sandbox2_network_bin PRIVATE
absl::str_format
glog::glog
gflags::gflags

View File

@ -35,6 +35,9 @@ target_link_libraries(sandbox2_networkproxy_sandbox PRIVATE
add_executable(sandbox2_networkproxy_bin
networkproxy_bin.cc
)
set_target_properties(sandbox2_networkproxy_bin PROPERTIES
OUTPUT_NAME networkproxy_bin
)
add_executable(sandbox2::networkproxy_bin ALIAS sandbox2_networkproxy_bin)
target_link_libraries(sandbox2_networkproxy_bin PRIVATE
absl::status

View File

@ -30,11 +30,12 @@ target_link_libraries(sandbox2_static_sandbox PRIVATE
)
# sandboxed_api/sandbox2/examples/static:static_bin
add_executable(static_bin
add_executable(sandbox2_static_bin
static_bin.cc
)
add_executable(sandbox2::static_bin ALIAS static_bin)
target_link_libraries(static_bin PRIVATE
set_target_properties(sandbox2_static_bin PROPERTIES OUTPUT_NAME static_bin)
add_executable(sandbox2::static_bin ALIAS sandbox2_static_bin)
target_link_libraries(sandbox2_static_bin PRIVATE
sapi::base
-static # Fully static link
)

View File

@ -16,6 +16,7 @@
add_executable(sandbox2_sandbox2tool
sandbox2tool.cc
)
set_target_properties(sandbox2_sandbox2tool PROPERTIES OUTPUT_NAME sandbox2tool)
add_executable(sandbox2::sandbox2tool ALIAS sandbox2_sandbox2tool)
target_link_libraries(sandbox2_sandbox2tool PRIVATE
absl::memory

View File

@ -31,10 +31,11 @@ target_link_libraries(sandbox2_zpipe_sandbox PRIVATE
)
# sandboxed_api/sandbox2/examples/zlib:zpipe
add_executable(zpipe
add_executable(sandbox2_zpipe
zpipe.c
)
add_executable(sandbox2::zpipe ALIAS zpipe)
target_link_libraries(zpipe PRIVATE
set_target_properties(sandbox2_zpipe PROPERTIES OUTPUT_NAME zpipe)
add_executable(sandbox2::zpipe ALIAS sandbox2_zpipe)
target_link_libraries(sandbox2_zpipe PRIVATE
ZLIB::ZLIB
)

View File

@ -62,10 +62,13 @@ target_link_libraries(sandbox2_network_proxy_client PRIVATE
if(SAPI_ENABLE_TESTS)
# sandboxed_api/sandbox2/network_proxy:filtering_test
add_executable(filtering_test
add_executable(sandbox2_filtering_test
filtering_test.cc
)
target_link_libraries(filtering_test PRIVATE
set_target_properties(sandbox2_filtering_test PROPERTIES
OUTPUT_NAME filtering_test
)
target_link_libraries(sandbox2_filtering_test PRIVATE
absl::strings
glog::glog
gflags::gflags
@ -75,5 +78,5 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(filtering_test)
gtest_discover_tests(sandbox2_filtering_test)
endif()

View File

@ -15,31 +15,39 @@
set(_sandbox2_fully_static_linkopts -static)
# sandboxed_api/sandbox2/testcases:abort
add_executable(abort
add_executable(sandbox2_testcase_abort
abort.cc
)
add_executable(sandbox2::testcase_abort ALIAS abort)
target_link_libraries(abort PRIVATE
set_target_properties(sandbox2_testcase_abort PROPERTIES
OUTPUT_NAME abort)
add_executable(sandbox2::testcase_abort ALIAS sandbox2_testcase_abort)
target_link_libraries(sandbox2_testcase_abort PRIVATE
sapi::base
sapi::raw_logging
)
# sandboxed_api/sandbox2/testcases:add_policy_on_syscalls
add_executable(add_policy_on_syscalls
add_executable(sandbox2_testcase_add_policy_on_syscalls
add_policy_on_syscalls.cc
)
add_executable(sandbox2::testcase_add_policy_on_syscalls
ALIAS add_policy_on_syscalls)
target_link_libraries(add_policy_on_syscalls PRIVATE
ALIAS sandbox2_testcase_add_policy_on_syscalls)
set_target_properties(sandbox2_testcase_add_policy_on_syscalls PROPERTIES
OUTPUT_NAME add_policy_on_syscalls
)
target_link_libraries(sandbox2_testcase_add_policy_on_syscalls PRIVATE
${_sandbox2_fully_static_linkopts}
)
# sandboxed_api/sandbox2/testcases:buffer
add_executable(buffer
add_executable(sandbox2_testcase_buffer
buffer.cc
)
add_executable(sandbox2::testcase_buffer ALIAS buffer)
target_link_libraries(buffer PRIVATE
add_executable(sandbox2::testcase_buffer ALIAS sandbox2_testcase_buffer)
set_target_properties(sandbox2_testcase_buffer PROPERTIES
OUTPUT_NAME buffer
)
target_link_libraries(sandbox2_testcase_buffer PRIVATE
absl::str_format
sandbox2::buffer
sandbox2::comms
@ -48,11 +56,14 @@ target_link_libraries(buffer PRIVATE
)
# sandboxed_api/sandbox2/testcases:ipc
add_executable(ipc
add_executable(sandbox2_testcase_ipc
ipc.cc
)
add_executable(sandbox2::testcase_ipc ALIAS ipc)
target_link_libraries(ipc PRIVATE
set_target_properties(sandbox2_testcase_ipc PROPERTIES
OUTPUT_NAME ipc
)
add_executable(sandbox2::testcase_ipc ALIAS sandbox2_testcase_ipc)
target_link_libraries(sandbox2_testcase_ipc PRIVATE
absl::strings
-Wl,--whole-archive
gflags::gflags
@ -65,50 +76,68 @@ target_link_libraries(ipc PRIVATE
)
# sandboxed_api/sandbox2/testcases:malloc_system
add_executable(malloc_system
add_executable(sandbox2_testcase_malloc_system
malloc.cc
)
add_executable(sandbox2::testcase_malloc_system ALIAS malloc_system)
target_link_libraries(malloc_system PRIVATE
add_executable(sandbox2::testcase_malloc_system ALIAS
sandbox2_testcase_malloc_system)
set_target_properties(sandbox2_testcase_malloc_system PROPERTIES
OUTPUT_NAME malloc_system
)
target_link_libraries(sandbox2_testcase_malloc_system PRIVATE
sapi::base
${_sandbox2_fully_static_linkopts}
)
# sandboxed_api/sandbox2/testcases:minimal_dynamic
add_executable(minimal_dynamic
add_executable(sandbox2_testcase_minimal_dynamic
minimal.cc
)
add_executable(sandbox2::testcase_minimal_dynamic ALIAS minimal_dynamic)
target_link_libraries(minimal_dynamic PRIVATE
set_target_properties(sandbox2_testcase_minimal_dynamic PROPERTIES
OUTPUT_NAME minimal_dynamic
)
add_executable(sandbox2::testcase_minimal_dynamic ALIAS
sandbox2_testcase_minimal_dynamic)
target_link_libraries(sandbox2_testcase_minimal_dynamic PRIVATE
sapi::base
)
# sandboxed_api/sandbox2/testcases:minimal
add_executable(minimal
add_executable(sandbox2_testcase_minimal
minimal.cc
)
add_executable(sandbox2::testcase_minimal ALIAS minimal)
target_link_libraries(minimal PRIVATE
add_executable(sandbox2::testcase_minimal ALIAS sandbox2_testcase_minimal)
set_target_properties(sandbox2_testcase_minimal PROPERTIES
OUTPUT_NAME minimal
)
target_link_libraries(sandbox2_testcase_minimal PRIVATE
sapi::base
${_sandbox2_fully_static_linkopts}
)
# sandboxed_api/sandbox2/testcases:personality
add_executable(personality
add_executable(sandbox2_testcase_personality
personality.cc
)
add_executable(sandbox2::testcase_personality ALIAS personality)
target_link_libraries(personality PRIVATE
add_executable(sandbox2::testcase_personality ALIAS
sandbox2_testcase_personality)
set_target_properties(sandbox2_testcase_personality PROPERTIES
OUTPUT_NAME personality
)
target_link_libraries(sandbox2_testcase_personality PRIVATE
sapi::base
${_sandbox2_fully_static_linkopts}
)
# sandboxed_api/sandbox2/testcases:pidcomms
add_executable(pidcomms
add_executable(sandbox2_testcase_pidcomms
pidcomms.cc
)
add_executable(sandbox2::testcase_pidcomms ALIAS pidcomms)
target_link_libraries(pidcomms PRIVATE
add_executable(sandbox2::testcase_pidcomms ALIAS sandbox2_testcase_pidcomms)
set_target_properties(sandbox2_testcase_pidcomms PROPERTIES
OUTPUT_NAME pidcomms
)
target_link_libraries(sandbox2_testcase_pidcomms PRIVATE
-Wl,--whole-archive
gflags::gflags
-Wl,--no-whole-archive
@ -121,52 +150,67 @@ target_link_libraries(pidcomms PRIVATE
)
# sandboxed_api/sandbox2/testcases:policy
add_executable(policy
add_executable(sandbox2_testcase_policy
policy.cc
)
add_executable(sandbox2::testcase_policy ALIAS policy)
target_link_libraries(policy PRIVATE
add_executable(sandbox2::testcase_policy ALIAS sandbox2_testcase_policy)
set_target_properties(sandbox2_testcase_policy PROPERTIES
OUTPUT_NAME policy
)
target_link_libraries(sandbox2_testcase_policy PRIVATE
sapi::base
sandbox2::config
${_sandbox2_fully_static_linkopts}
)
# sandboxed_api/sandbox2/testcases:print_fds
add_executable(print_fds
add_executable(sandbox2_testcase_print_fds
print_fds.cc
)
add_executable(sandbox2::testcase_print_fds ALIAS print_fds)
target_link_libraries(print_fds PRIVATE
add_executable(sandbox2::testcase_print_fds ALIAS sandbox2_testcase_print_fds)
set_target_properties(sandbox2_testcase_print_fds PROPERTIES
OUTPUT_NAME print_fds
)
target_link_libraries(sandbox2_testcase_print_fds PRIVATE
sapi::base
${_sandbox2_fully_static_linkopts}
)
# sandboxed_api/sandbox2/testcases:sanitizer
add_executable(sanitizer
add_executable(sandbox2_testcase_sanitizer
sanitizer.cc
)
add_executable(sandbox2::testcase_sanitizer ALIAS sanitizer)
target_link_libraries(sanitizer PRIVATE
add_executable(sandbox2::testcase_sanitizer ALIAS sandbox2_testcase_sanitizer)
set_target_properties(sandbox2_testcase_sanitizer PROPERTIES
OUTPUT_NAME sanitizer
)
target_link_libraries(sandbox2_testcase_sanitizer PRIVATE
sapi::base
${_sandbox2_fully_static_linkopts}
)
# sandboxed_api/sandbox2/testcases:sleep
add_executable(sleep
add_executable(sandbox2_testcase_sleep
sleep.cc
)
add_executable(sandbox2::testcase_sleep ALIAS sleep)
target_link_libraries(sleep PRIVATE
add_executable(sandbox2::testcase_sleep ALIAS sandbox2_testcase_sleep)
set_target_properties(sandbox2_testcase_sleep PROPERTIES
OUTPUT_NAME sleep
)
target_link_libraries(sandbox2_testcase_sleep PRIVATE
sapi::base
${_sandbox2_fully_static_linkopts}
)
# sandboxed_api/sandbox2/testcases:symbolize
add_executable(symbolize
add_executable(sandbox2_testcase_symbolize
symbolize.cc
)
add_executable(sandbox2::testcase_symbolize ALIAS symbolize)
target_link_libraries(symbolize PRIVATE
add_executable(sandbox2::testcase_symbolize ALIAS sandbox2_testcase_symbolize)
set_target_properties(sandbox2_testcase_symbolize PROPERTIES
OUTPUT_NAME symbolize
)
target_link_libraries(sandbox2_testcase_symbolize PRIVATE
absl::core_headers
absl::strings
sandbox2::temp_file
@ -176,21 +220,27 @@ target_link_libraries(symbolize PRIVATE
)
# sandboxed_api/sandbox2/testcases:starve
add_executable(starve
add_executable(sandbox2_testcase_starve
starve.cc
)
add_executable(sandbox2::testcase_starve ALIAS starve)
target_link_libraries(starve PRIVATE
add_executable(sandbox2::testcase_starve ALIAS sandbox2_testcase_starve)
set_target_properties(sandbox2_testcase_starve PROPERTIES
OUTPUT_NAME starve
)
target_link_libraries(sandbox2_testcase_starve PRIVATE
sapi::base
)
# sandboxed_api/sandbox2/testcases:tsync
add_executable(tsync
add_executable(sandbox2_testcase_tsync
tsync.cc
)
add_executable(sandbox2::testcase_tsync ALIAS tsync)
target_link_libraries(tsync PRIVATE
add_executable(sandbox2::testcase_tsync ALIAS sandbox2_testcase_tsync)
set_target_properties(sandbox2_testcase_tsync PROPERTIES
OUTPUT_NAME tsync
)
target_link_libraries(sandbox2_testcase_tsync PRIVATE
-Wl,--whole-archive
gflags::gflags
-Wl,--no-whole-archive
@ -202,31 +252,40 @@ target_link_libraries(tsync PRIVATE
)
# sandboxed_api/sandbox2/testcases:hostname
add_executable(hostname
add_executable(sandbox2_testcase_hostname
hostname.cc
)
add_executable(sandbox2::testcase_hostname ALIAS hostname)
target_link_libraries(hostname PRIVATE
add_executable(sandbox2::testcase_hostname ALIAS sandbox2_testcase_hostname)
set_target_properties(sandbox2_testcase_hostname PROPERTIES
OUTPUT_NAME hostname
)
target_link_libraries(sandbox2_testcase_hostname PRIVATE
sapi::base
${_sandbox2_fully_static_linkopts}
)
# sandboxed_api/sandbox2/testcases:limits
add_executable(limits
add_executable(sandbox2_testcase_limits
limits.cc
)
add_executable(sandbox2::testcase_limits ALIAS limits)
target_link_libraries(limits PRIVATE
add_executable(sandbox2::testcase_limits ALIAS sandbox2_testcase_limits)
set_target_properties(sandbox2_testcase_limits PROPERTIES
OUTPUT_NAME limits
)
target_link_libraries(sandbox2_testcase_limits PRIVATE
sapi::base
${_sandbox2_fully_static_linkopts}
)
# sandboxed_api/sandbox2/testcases:namespace
add_executable(namespace
add_executable(sandbox2_testcase_namespace
namespace.cc
)
add_executable(sandbox2::testcase_namespace ALIAS namespace)
target_link_libraries(namespace PRIVATE
add_executable(sandbox2::testcase_namespace ALIAS sandbox2_testcase_namespace)
set_target_properties(sandbox2_testcase_namespace PROPERTIES
OUTPUT_NAME namespace
)
target_link_libraries(sandbox2_testcase_namespace PRIVATE
sapi::base
${_sandbox2_fully_static_linkopts}
)

View File

@ -127,22 +127,28 @@ target_link_libraries(sandbox2_util_runfiles PRIVATE
if(SAPI_ENABLE_TESTS)
# sandboxed_api/sandbox2/util:file_helpers_test
add_executable(file_helpers_test
add_executable(sandbox2_file_helpers_test
file_helpers_test.cc
)
target_link_libraries(file_helpers_test PRIVATE
set_target_properties(sandbox2_file_helpers_test PROPERTIES
OUTPUT_NAME file_helpers_test
)
target_link_libraries(sandbox2_file_helpers_test PRIVATE
absl::strings
sandbox2::file_helpers
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(file_helpers_test)
gtest_discover_tests(sandbox2_file_helpers_test)
# sandboxed_api/sandbox2/util:fileops_test
add_executable(fileops_test
add_executable(sandbox2_fileops_test
fileops_test.cc
)
target_link_libraries(fileops_test PRIVATE
set_target_properties(sandbox2_fileops_test PROPERTIES
OUTPUT_NAME fileops_test
)
target_link_libraries(sandbox2_fileops_test PRIVATE
absl::strings
sandbox2::file_helpers
sandbox2::fileops
@ -150,42 +156,51 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(fileops_test PROPERTIES
gtest_discover_tests(sandbox2_fileops_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
# sandboxed_api/sandbox2/util:file_base_test
add_executable(file_base_test
add_executable(sandbox2_file_base_test
path_test.cc
)
target_link_libraries(file_base_test PRIVATE
set_target_properties(sandbox2_file_base_test PROPERTIES
OUTPUT_NAME file_base_test
)
target_link_libraries(sandbox2_file_base_test PRIVATE
absl::strings
sandbox2::file_base
sapi::test_main
)
gtest_discover_tests(file_base_test)
gtest_discover_tests(sandbox2_file_base_test)
# sandboxed_api/sandbox2/util:strerror
add_executable(strerror_test
add_executable(sandbox2_strerror_test
strerror_test.cc
)
target_link_libraries(strerror_test PRIVATE
set_target_properties(sandbox2_strerror_test PROPERTIES
OUTPUT_NAME strerror_test
)
target_link_libraries(sandbox2_strerror_test PRIVATE
absl::strings
sandbox2::strerror
sapi::test_main
)
gtest_discover_tests(strerror_test)
gtest_discover_tests(sandbox2_strerror_test)
# sandboxed_api/sandbox2/util:minielf_test
add_executable(minielf_test
add_executable(sandbox2_minielf_test
minielf_test.cc
)
set_target_properties(sandbox2_minielf_test PROPERTIES
OUTPUT_NAME minielf_test
)
configure_file(testdata/hello_world
testdata/hello_world COPYONLY)
configure_file(testdata/chrome_grte_header
testdata/chrome_grte_header COPYONLY)
target_link_libraries(minielf_test PRIVATE
target_link_libraries(sandbox2_minielf_test PRIVATE
absl::algorithm_container
absl::strings
sandbox2::file_helpers
@ -195,16 +210,19 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(minielf_test PROPERTIES
gtest_discover_tests(sandbox2_minielf_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
# sandboxed_api/sandbox2/util:temp_file_test
add_executable(temp_file_test
add_executable(sandbox2_temp_file_test
temp_file_test.cc
)
target_link_libraries(temp_file_test PRIVATE
set_target_properties(sandbox2_temp_file_test PROPERTIES
OUTPUT_NAME temp_file_test
)
target_link_libraries(sandbox2_temp_file_test PRIVATE
sandbox2::file_base
sandbox2::fileops
sandbox2::temp_file
@ -212,16 +230,19 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(temp_file_test)
gtest_discover_tests(sandbox2_temp_file_test)
# sandboxed_api/sandbox2/util:maps_parser_test
add_executable(maps_parser_test
add_executable(sandbox2_maps_parser_test
maps_parser_test.cc
)
target_link_libraries(maps_parser_test PRIVATE
set_target_properties(sandbox2_maps_parser_test PROPERTIES
OUTPUT_NAME maps_parser_test
)
target_link_libraries(sandbox2_maps_parser_test PRIVATE
sandbox2::maps_parser
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(maps_parser_test)
gtest_discover_tests(sandbox2_maps_parser_test)
endif()

View File

@ -31,12 +31,15 @@ sapi_cc_embed_data(NAME filewrapper_embedded
if(SAPI_ENABLE_TESTS)
# sandboxed_api/tools/filewrapper:filewrapper_test
add_executable(filewrapper_test
add_executable(sapi_filewrapper_test
filewrapper_test.cc
)
set_target_properties(sapi_filewrapper_test PROPERTIES
OUTPUT_NAME filewrapper_test
)
configure_file(testdata/filewrapper_embedded.bin
testdata/filewrapper_embedded.bin COPYONLY)
target_link_libraries(filewrapper_test PRIVATE
target_link_libraries(sapi_filewrapper_test PRIVATE
absl::strings
filewrapper_embedded
sandbox2::file_helpers
@ -45,7 +48,7 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(filewrapper_test PROPERTIES
gtest_discover_tests(sapi_filewrapper_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)

View File

@ -92,28 +92,32 @@ if(SAPI_ENABLE_TESTS)
)
# sandboxed_api/util:status_test
add_executable(status_test
add_executable(sapi_status_test
status_test.cc
)
target_link_libraries(status_test PRIVATE
set_target_properties(sapi_status_test PROPERTIES OUTPUT_NAME status_test)
target_link_libraries(sapi_status_test PRIVATE
sapi::status
sapi::status_matchers
sapi::test_main
absl::status
absl::type_traits
)
gtest_discover_tests(status_test)
gtest_discover_tests(sapi_status_test)
# sandboxed_api/util:status_macros_test
add_executable(status_macros_test
add_executable(sapi_status_macros_test
status_macros_test.cc
)
target_link_libraries(status_macros_test PRIVATE
set_target_properties(sapi_status_macros_test PROPERTIES
OUTPUT_NAME status_macros_test
)
target_link_libraries(sapi_status_macros_test PRIVATE
sapi::status_matchers
sapi::test_main
absl::status
absl::statusor
absl::type_traits
)
gtest_discover_tests(status_macros_test)
gtest_discover_tests(sapi_status_macros_test)
endif()