summaryrefslogtreecommitdiff
path: root/libc/cmake
diff options
context:
space:
mode:
authorJoseph Huber <jhuber6@vols.utk.edu>2023-05-02 15:54:29 -0500
committerJoseph Huber <jhuber6@vols.utk.edu>2023-05-02 18:51:12 -0500
commit644b63bd31f55aaaf1ebafc7df7cd7cea2aa26a8 (patch)
tree48862dc70805b8726c86b7aa2d6a0c3e208400d4 /libc/cmake
parent9a20e024a25ce1e20556dc4e567a9d943bff4c7e (diff)
downloadllvm-644b63bd31f55aaaf1ebafc7df7cd7cea2aa26a8.tar.gz
[libc] Add 'UNIT_TEST_ONLY' and 'HERMETIC_TEST_ONLY' to 'add_libc_test'
The `add_libc_test` option allows us to enable both kinds of tests in a single option. However, some tests cannot be made hermetic with the current approach. Such as tests that rely on system utilities or libraries. This patch adds two options `UNIT_TEST_ONLY` and `HERMETIC_TEST_ONLY` to offer more fine-grained control over which version gets built. This makes it explicit which version a test supports and why. Depends on D149662 Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D149691
Diffstat (limited to 'libc/cmake')
-rw-r--r--libc/cmake/modules/LLVMLibCTestRules.cmake15
1 files changed, 11 insertions, 4 deletions
diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index a99274ce5ce3..d1d536cb97dc 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -693,10 +693,17 @@ endfunction(add_libc_hermetic_test)
# A convenience function to add both a unit test as well as a hermetic test.
function(add_libc_test test_name)
- if(LIBC_ENABLE_UNITTESTS)
- add_libc_unittest(${test_name}.__unit__ ${ARGN})
+ cmake_parse_arguments(
+ "LIBC_TEST"
+ "UNIT_TEST_ONLY;HERMETIC_TEST_ONLY" # Optional arguments
+ "" # Single value arguments
+ "" # Multi-value arguments
+ ${ARGN}
+ )
+ if(LIBC_ENABLE_UNITTESTS AND NOT LIBC_TEST_HERMETIC_TEST_ONLY)
+ add_libc_unittest(${test_name}.__unit__ ${LIBC_TEST_UNPARSED_ARGUMENTS})
endif()
- if(LIBC_ENABLE_HERMETIC_TESTS)
- add_libc_hermetic_test(${test_name}.__hermetic__ ${ARGN})
+ if(LIBC_ENABLE_HERMETIC_TESTS AND NOT LIBC_TEST_UNIT_TEST_ONLY)
+ add_libc_hermetic_test(${test_name}.__hermetic__ ${LIBC_TEST_UNPARSED_ARGUMENTS})
endif()
endfunction(add_libc_test)