Index: libc/cmake/modules/LLVMLibCRules.cmake =================================================================== --- libc/cmake/modules/LLVMLibCRules.cmake +++ libc/cmake/modules/LLVMLibCRules.cmake @@ -287,6 +287,17 @@ ) endfunction(add_redirector_library) +function(get_suite_prefix name) + string(REPLACE "${LIBC_SOURCE_DIR}/" "" relative_path ${CMAKE_CURRENT_SOURCE_DIR}) + string(REPLACE "/" "." dotted_path ${relative_path}) + set(${name} libc.${dotted_path} PARENT_SCOPE) +endfunction(get_suite_prefix) + +function(get_suite_name name) + get_suite_prefix(prefix) + set(${name} ${prefix}.all PARENT_SCOPE) +endfunction(get_suite_name) + # Rule to add a gtest unittest. # Usage # add_libc_unittest( @@ -301,10 +312,13 @@ return() endif() + get_suite_prefix(prefix) + set(target_name "${prefix}.${target_name}") + cmake_parse_arguments( "LIBC_UNITTEST" "" # No optional arguments - "SUITE" # Single value arguments + "" # Single value arguments "SRCS;HDRS;DEPENDS" # Multi-value arguments ${ARGN} ) @@ -315,6 +329,9 @@ message(FATAL_ERROR "'add_libc_unittest' target requires a DEPENDS list of 'add_entrypoint_object' targets.") endif() + get_suite_name(SUITE_NAME) + set(LIBC_UNITTEST_SUITE ${SUITE_NAME}) + set(library_deps "") foreach(dep IN LISTS LIBC_UNITTEST_DEPENDS) get_target_property(dep_type ${dep} "TARGET_TYPE") @@ -371,3 +388,9 @@ ) endif() endfunction(add_libc_unittest) + +function(libc_create_suite) + get_suite_name(suite) + add_custom_target(${suite}) + add_dependencies(check-libc ${suite}) +endfunction(libc_create_suite) Index: libc/test/CMakeLists.txt =================================================================== --- libc/test/CMakeLists.txt +++ libc/test/CMakeLists.txt @@ -1,4 +1,4 @@ -add_custom_target(check_libc) +add_custom_target(check-libc) add_subdirectory(config) add_subdirectory(src) Index: libc/test/config/linux/CMakeLists.txt =================================================================== --- libc/test/config/linux/CMakeLists.txt +++ libc/test/config/linux/CMakeLists.txt @@ -1,4 +1,4 @@ add_custom_target(libc_linux_tests) -add_dependencies(check_libc libc_linux_tests) +add_dependencies(check-libc libc_linux_tests) add_subdirectory(x86_64) Index: libc/test/config/linux/x86_64/CMakeLists.txt =================================================================== --- libc/test/config/linux/x86_64/CMakeLists.txt +++ libc/test/config/linux/x86_64/CMakeLists.txt @@ -1,10 +1,9 @@ -add_custom_target(libc_linux_x86_64_tests) -add_dependencies(libc_linux_tests libc_linux_x86_64_tests) +libc_create_suite() add_libc_unittest( - libc_linux_x86_64_syscall_unittest - SUITE libc_linux_x86_64_tests - SRCS syscall_test.cpp + syscall_test + SRCS + syscall_test.cpp DEPENDS syscall_impl_h support_common_h Index: libc/test/src/errno/CMakeLists.txt =================================================================== --- libc/test/src/errno/CMakeLists.txt +++ libc/test/src/errno/CMakeLists.txt @@ -1,10 +1,7 @@ -add_custom_target(libc_errno_unittests) -add_dependencies(check_libc libc_errno_unittests) +libc_create_suite() add_libc_unittest( errno_test - SUITE - libc_errno_unittests SRCS errno_test.cpp DEPENDS Index: libc/test/src/string/CMakeLists.txt =================================================================== --- libc/test/src/string/CMakeLists.txt +++ libc/test/src/string/CMakeLists.txt @@ -1,10 +1,6 @@ -add_custom_target(libc_string_unittests) -add_dependencies(check_libc libc_string_unittests) - +libc_create_suite() add_libc_unittest( strcat_test - SUITE - libc_string_unittests SRCS strcat_test.cpp DEPENDS @@ -14,8 +10,6 @@ add_libc_unittest( strcpy_test - SUITE - libc_string_unittests SRCS strcpy_test.cpp DEPENDS Index: libc/test/src/sys/mman/CMakeLists.txt =================================================================== --- libc/test/src/sys/mman/CMakeLists.txt +++ libc/test/src/sys/mman/CMakeLists.txt @@ -1,10 +1,7 @@ -add_custom_target(libc_sys_mman_unittests) -add_dependencies(check_libc libc_sys_mman_unittests) +libc_create_suite() add_libc_unittest( mmap_test - SUITE - libc_sys_mman_unittests SRCS mmap_test.cpp DEPENDS