Skip to content

Commit

Permalink
[libc] Remove startup option from integration tests
Browse files Browse the repository at this point in the history
This generalizes handling of the integration tests. We now implicitly
depend on the `libc.startup.${LIBC_TARGET_OS}.crt1` file rather than
passing it in manually. This simplifies the interface.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D146237
  • Loading branch information
jhuber6 committed Mar 16, 2023
1 parent 4c22990 commit d9c1dbc
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 66 deletions.
15 changes: 7 additions & 8 deletions libc/cmake/modules/LLVMLibCTestRules.cmake
Expand Up @@ -402,7 +402,6 @@ endfunction(add_libc_fuzzer)
# SUITE <the suite to which the test should belong>
# SRCS <src1.cpp> [src2.cpp ...]
# HDRS [hdr1.cpp ...]
# STARTUP <fully qualified startup system target name>
# DEPENDS <list of entrypoint or other object targets>
# ARGS <list of command line arguments to be passed to the test>
# ENV <list of environment variables to set before running the test>
Expand All @@ -420,28 +419,28 @@ function(add_integration_test test_name)
cmake_parse_arguments(
"INTEGRATION_TEST"
"" # No optional arguments
"SUITE;STARTUP" # Single value arguments
"SUITE" # Single value arguments
"SRCS;HDRS;DEPENDS;ARGS;ENV;COMPILE_OPTIONS" # Multi-value arguments
${ARGN}
)

if(NOT INTEGRATION_TEST_SUITE)
message(FATAL_ERROR "SUITE not specified for ${fq_target_name}")
endif()
if(NOT INTEGRATION_TEST_STARTUP)
message(FATAL_ERROR "The STARTUP to link to the integration test is missing.")
endif()
if(NOT INTEGRATION_TEST_SRCS)
message(FATAL_ERROR "The SRCS list for add_integration_test is missing.")
endif()
if(NOT TARGET libc.startup.${LIBC_TARGET_OS}.crt1)
message(FATAL_ERROR "The 'crt1' target for the integration test is missing.")
endif()

get_fq_target_name(${test_name}.libc fq_libc_target_name)

get_fq_deps_list(fq_deps_list ${INTEGRATION_TEST_DEPENDS})
list(APPEND fq_deps_list
# All integration tests need to inherit the same dependencies as the
# startup code.
${INTEGRATION_TEST_STARTUP}
# All integration tests use the operating system's startup object and need
# to inherit the same dependencies.
libc.startup.${LIBC_TARGET_OS}.crt1
# We always add the memory functions objects. This is because the
# compiler's codegen can emit calls to the C memory functions.
libc.src.string.bcmp
Expand Down
4 changes: 0 additions & 4 deletions libc/test/integration/src/__support/threads/CMakeLists.txt
Expand Up @@ -11,8 +11,6 @@ add_integration_test(
libc-support-threads-integration-tests
SRCS
thread_detach_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.src.__support.threads.mutex
libc.src.__support.threads.thread
Expand All @@ -24,8 +22,6 @@ add_integration_test(
libc-support-threads-integration-tests
SRCS
thread_tls_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.src.__support.threads.thread
)
14 changes: 0 additions & 14 deletions libc/test/integration/src/pthread/CMakeLists.txt
Expand Up @@ -6,8 +6,6 @@ add_integration_test(
libc-pthread-integration-tests
SRCS
pthread_mutex_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.include.pthread
libc.src.errno.errno
Expand All @@ -25,8 +23,6 @@ add_integration_test(
libc-pthread-integration-tests
SRCS
pthread_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.include.pthread
libc.src.pthread.pthread_create
Expand All @@ -39,8 +35,6 @@ add_integration_test(
libc-pthread-integration-tests
SRCS
pthread_equal_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.include.pthread
libc.src.errno.errno
Expand All @@ -60,8 +54,6 @@ add_integration_test(
libc-pthread-integration-tests
SRCS
pthread_name_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.include.errno
libc.include.pthread
Expand All @@ -83,8 +75,6 @@ add_integration_test(
libc-pthread-integration-tests
SRCS
pthread_exit_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.include.pthread
libc.src.pthread.pthread_create
Expand All @@ -98,8 +88,6 @@ add_integration_test(
libc-pthread-integration-tests
SRCS
pthread_tss_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.include.pthread
libc.src.pthread.pthread_create
Expand All @@ -117,8 +105,6 @@ add_integration_test(
libc-pthread-integration-tests
SRCS
pthread_once_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.include.pthread
libc.src.pthread.pthread_once
Expand Down
2 changes: 0 additions & 2 deletions libc/test/integration/src/spawn/CMakeLists.txt
Expand Up @@ -26,8 +26,6 @@ add_integration_test(
spawn-integration-tests
SRCS
posix_spawn_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc_posix_spawn_test_binary
libc.test.integration.src.spawn.test_binary_properties
Expand Down
4 changes: 0 additions & 4 deletions libc/test/integration/src/stdio/CMakeLists.txt
Expand Up @@ -9,8 +9,6 @@ add_integration_test(
stdio-integration-tests
SRCS
sprintf_size_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.src.stdio.sprintf
ARGS
Expand All @@ -26,8 +24,6 @@ add_integration_test(
stdio-integration-tests
SRCS
sprintf_size_test.cpp
STARTUP
libc.startup.linux.crt1
ARGS
"%s %c %d"
"First arg"
Expand Down
2 changes: 0 additions & 2 deletions libc/test/integration/src/stdlib/CMakeLists.txt
Expand Up @@ -7,8 +7,6 @@ add_integration_test(
stdlib-integration-tests
SRCS
getenv_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.src.stdlib.getenv
ENV
Expand Down
14 changes: 0 additions & 14 deletions libc/test/integration/src/threads/CMakeLists.txt
Expand Up @@ -6,8 +6,6 @@ add_integration_test(
libc-threads-integration-tests
SRCS
mtx_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.include.threads
libc.src.errno.errno
Expand All @@ -25,8 +23,6 @@ add_integration_test(
libc-threads-integration-tests
SRCS
thrd_equal_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.include.threads
libc.src.threads.mtx_destroy
Expand All @@ -45,8 +41,6 @@ add_integration_test(
libc-threads-integration-tests
SRCS
thrd_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.include.threads
libc.src.errno.errno
Expand All @@ -60,8 +54,6 @@ add_integration_test(
libc-threads-integration-tests
SRCS
thrd_exit_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.include.threads
libc.src.threads.thrd_create
Expand All @@ -75,8 +67,6 @@ add_integration_test(
libc-threads-integration-tests
SRCS
tss_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.include.threads
libc.src.threads.thrd_create
Expand All @@ -94,8 +84,6 @@ add_integration_test(
libc-threads-integration-tests
SRCS
call_once_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.include.threads
libc.src.threads.call_once
Expand All @@ -114,8 +102,6 @@ add_integration_test(
libc-threads-integration-tests
SRCS
cnd_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.include.threads
libc.src.threads.cnd_init
Expand Down
8 changes: 0 additions & 8 deletions libc/test/integration/src/unistd/CMakeLists.txt
Expand Up @@ -7,8 +7,6 @@ add_integration_test(
unistd-integration-tests
SRCS
getcwd_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.src.__support.CPP.string_view
libc.src.errno.errno
Expand All @@ -22,8 +20,6 @@ add_integration_test(
unistd-integration-tests
SRCS
fork_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.include.errno
libc.include.signal
Expand Down Expand Up @@ -67,8 +63,6 @@ add_integration_test(
unistd-integration-tests
SRCS
execv_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc_execv_test_normal_exit
libc_execv_test_signal_exit
Expand All @@ -86,8 +80,6 @@ add_integration_test(
unistd-integration-tests
SRCS
execve_test.cpp
STARTUP
libc.startup.linux.crt1
DEPENDS
libc_execv_test_normal_exit
libc_execv_test_signal_exit
Expand Down
10 changes: 0 additions & 10 deletions libc/test/integration/startup/linux/CMakeLists.txt
Expand Up @@ -9,8 +9,6 @@ add_dependencies(libc-integration-tests libc-startup-tests)
add_integration_test(
startup_args_test
SUITE libc-startup-tests
STARTUP
libc.startup.linux.crt1
SRCS
args_test.cpp
ARGS
Expand All @@ -23,26 +21,20 @@ add_integration_test(
add_integration_test(
startup_no_envp_test
SUITE libc-startup-tests
STARTUP
libc.startup.linux.crt1
SRCS
main_without_envp.cpp
)

add_integration_test(
startup_no_args_test
SUITE libc-startup-tests
STARTUP
libc.startup.linux.crt1
SRCS
main_without_args.cpp
)

add_integration_test(
startup_tls_test
SUITE libc-startup-tests
STARTUP
libc.startup.linux.crt1
SRCS
tls_test.cpp
DEPENDS
Expand All @@ -55,8 +47,6 @@ add_integration_test(
add_integration_test(
init_fini_array_test
SUITE libc-startup-tests
STARTUP
libc.startup.linux.crt1
SRCS
init_fini_array_test.cpp
)

0 comments on commit d9c1dbc

Please sign in to comment.