[libc-commits] [PATCH] D151291: [libc] Make hermetic test depend on the unit test if it exists.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue May 23 22:33:16 PDT 2023


sivachandra created this revision.
sivachandra added a reviewer: jhuber6.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added projects: libc-project, All.
sivachandra requested review of this revision.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151291

Files:
  libc/cmake/modules/LLVMLibCTestRules.cmake


Index: libc/cmake/modules/LLVMLibCTestRules.cmake
===================================================================
--- libc/cmake/modules/LLVMLibCTestRules.cmake
+++ libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -740,5 +740,12 @@
   endif()
   if(LIBC_ENABLE_HERMETIC_TESTS AND NOT LIBC_TEST_UNIT_TEST_ONLY)
     add_libc_hermetic_test(${test_name}.__hermetic__ ${LIBC_TEST_UNPARSED_ARGUMENTS})
+    get_fq_target_name(${test_name} fq_test_name)
+    if(TARGET ${fq_test_name}.__unit__)
+      # Tests like the file tests perform file operations on disk file. If we
+      # don't chain up the unit test and hermetic test, then those tests will
+      # step on each other's files.
+      add_dependencies(${fq_test_name}.__hermetic__ ${fq_test_name}.__unit__)
+    endif()
   endif()
 endfunction(add_libc_test)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151291.525007.patch
Type: text/x-patch
Size: 816 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230524/f7093e44/attachment.bin>


More information about the libc-commits mailing list