Skip to content

Commit 99a493e

Browse files
author
Siva Chandra Reddy
committed
[libc] Make hermetic test depend on the unit test if it exists.
We want to do this so that build system like ninja don't end up running the hermetic and unit tests in parallel. Running in parallel can cause problems for tests which read/write disk files as the hermetic and unit tests can end up stepping on each other. Reviewed By: jhuber6 Differential Revision: https://reviews.llvm.org/D151291
1 parent 8b90f8e commit 99a493e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

libc/cmake/modules/LLVMLibCTestRules.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,5 +740,12 @@ function(add_libc_test test_name)
740740
endif()
741741
if(LIBC_ENABLE_HERMETIC_TESTS AND NOT LIBC_TEST_UNIT_TEST_ONLY)
742742
add_libc_hermetic_test(${test_name}.__hermetic__ ${LIBC_TEST_UNPARSED_ARGUMENTS})
743+
get_fq_target_name(${test_name} fq_test_name)
744+
if(TARGET ${fq_test_name}.__unit__)
745+
# Tests like the file tests perform file operations on disk file. If we
746+
# don't chain up the unit test and hermetic test, then those tests will
747+
# step on each other's files.
748+
add_dependencies(${fq_test_name}.__hermetic__ ${fq_test_name}.__unit__)
749+
endif()
743750
endif()
744751
endfunction(add_libc_test)

0 commit comments

Comments
 (0)