[libc][NFC] Add few options to allow users to skip building and running some tests. (#199474)
These options will be used to reduce redundancy and time for precommit CIs: - LIBC_TEST_SKIP_DEATH_TESTS - LIBC_TEST_SKIP_SHARED_MATH_TESTS - LIBC_TEST_CHECK_LIBC_BUILD_ONLY
This commit is contained in:
parent
4472e93567
commit
2f2122a143
4 changed files with 33 additions and 2 deletions
|
|
@ -19,6 +19,15 @@ function(_get_common_test_compile_options output_var c_test flags)
|
|||
${config_flags}
|
||||
${arch_flags})
|
||||
|
||||
# EXPECT_DEATH and ASSERT_DEATH might be quite slow. LIBC_TEST_SKIP_DEATH_TESTS
|
||||
# will make those tests no-op to reduce the overall test time.
|
||||
if(LIBC_TEST_SKIP_DEATH_TESTS)
|
||||
if(LIBC_CMAKE_VERBOSE_LOGGING)
|
||||
message(STATUS "LIBC_TEST_SKIP_DEATH_TESTS is set. EXPECT_DEATH/ASSERT_DEATH are no-op.")
|
||||
endif()
|
||||
list(APPEND compile_options "-DLIBC_TEST_SKIP_DEATH_TESTS")
|
||||
endif()
|
||||
|
||||
if(LLVM_LIBC_COMPILER_IS_GCC_COMPATIBLE)
|
||||
list(APPEND compile_options "-fpie")
|
||||
|
||||
|
|
|
|||
|
|
@ -26,20 +26,22 @@ configure_lit_site_cfg(
|
|||
"CMAKE_CROSSCOMPILING_EMULATOR"
|
||||
)
|
||||
|
||||
add_custom_target(check-libc-build)
|
||||
add_lit_testsuite(check-libc
|
||||
"Running libc tests via lit"
|
||||
${LIBC_BUILD_DIR}/test
|
||||
)
|
||||
add_dependencies(check-libc check-libc-build)
|
||||
|
||||
if (TARGET check-hdrgen)
|
||||
add_dependencies(check-libc check-hdrgen)
|
||||
endif()
|
||||
|
||||
if(LIBC_ENABLE_UNITTESTS AND NOT LIBC_TEST_HERMETIC_TEST_ONLY)
|
||||
add_dependencies(check-libc libc-unit-tests-build)
|
||||
add_dependencies(check-libc-build libc-unit-tests-build)
|
||||
endif()
|
||||
if(LIBC_ENABLE_HERMETIC_TESTS AND NOT LIBC_TEST_UNIT_TEST_ONLY)
|
||||
add_dependencies(check-libc libc-hermetic-tests-build)
|
||||
add_dependencies(check-libc-build libc-hermetic-tests-build)
|
||||
endif()
|
||||
|
||||
add_subdirectory(UnitTest)
|
||||
|
|
|
|||
|
|
@ -495,11 +495,20 @@ CString libc_make_test_file_path_func(const char *file_name);
|
|||
#define ASSERT_EXITS(FUNC, EXIT) \
|
||||
LIBC_TEST_PROCESS_(testProcessExits, FUNC, EXIT, return)
|
||||
|
||||
#ifdef LIBC_TEST_SKIP_DEATH_TESTS
|
||||
|
||||
#define EXPECT_DEATH(FUNC, SIG)
|
||||
#define ASSERT_DEATH(FUNC, SIG)
|
||||
|
||||
#else
|
||||
|
||||
#define EXPECT_DEATH(FUNC, SIG) \
|
||||
LIBC_TEST_PROCESS_(testProcessKilled, FUNC, SIG, )
|
||||
#define ASSERT_DEATH(FUNC, SIG) \
|
||||
LIBC_TEST_PROCESS_(testProcessKilled, FUNC, SIG, return)
|
||||
|
||||
#endif // LIBC_TEST_SKIP_DEATH_TESTS
|
||||
|
||||
#endif // ENABLE_SUBPROCESS_TESTS
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -1,5 +1,15 @@
|
|||
add_custom_target(libc-shared-tests)
|
||||
|
||||
# Shared math tests include the entire math library headers into a single file
|
||||
# so it might take some time to compile the tests. We do have dedicated
|
||||
# precommit CIs to build and test shared tests. So we provide a cmake option
|
||||
# LIBC_TEST_SKIP_SHARED_TESTS to reduce redundant testings and reduce test time
|
||||
# for other precommit CIs.
|
||||
if(LIBC_TEST_SKIP_SHARED_TESTS)
|
||||
if(LIBC_CMAKE_VERBOSE_LOGGING)
|
||||
message(STATUS "LIBC_TEST_SKIP_SHARED_MATH_TESTS is set. Skipping libc-shared-tests.")
|
||||
endif()
|
||||
else()
|
||||
add_fp_unittest(
|
||||
shared_math_test
|
||||
SUITE
|
||||
|
|
@ -802,6 +812,7 @@ add_fp_unittest(
|
|||
libc.src.__support.math.totalordermagf16
|
||||
libc.src.__support.math.totalordermagl
|
||||
)
|
||||
endif() # LIBC_TEST_SKIP_SHARED_MATH_TESTS
|
||||
|
||||
add_fp_unittest(
|
||||
shared_str_to_num_test
|
||||
|
|
|
|||
Loading…
Reference in a new issue