]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: avoid race conditions between concurrent prm tests 14615/head
authorMatthias Maier <tamiko@43-1.org>
Mon, 26 Dec 2022 04:01:03 +0000 (22:01 -0600)
committerMatthias Maier <tamiko@43-1.org>
Mon, 26 Dec 2022 04:16:06 +0000 (22:16 -0600)
We need to serialize all tests that share a common executable target.
This involves tests with .threads=N. and .mpirun=N. annotation, as well
as tests with parameter files (that might share a common executable
target).

Running multiple variants of tests with the same target executable in
parallel triggers a race condition where the same (not yet existent)
target is built concurrently leading to undefined outcomes.

cmake/macros/macro_deal_ii_add_test.cmake

index 73c3cd6af46fd20e3c377d5350e2dda9d88d36a9..6cafff13853897183f8e552c75b735b1aa2a6ad3 100644 (file)
@@ -571,11 +571,19 @@ function(deal_ii_add_test _category _test_name _comparison_file)
         set_tests_properties(${_test_full} PROPERTIES PROCESSORS ${_slots})
       endif()
 
-      if(NOT "${_n_cpu}${_n_threads}" STREQUAL "00")
+      #
+      # Serialize all tests that share a common executable target. This
+      # involves tests with .threads=N. and .mpirun=N. annotation, as well
+      # as tests with parameter files (that might share a common executable
+      # target).
+      #
+      if( NOT "${_n_cpu}${_n_threads}" STREQUAL "00" OR
+          "${_source_file}" MATCHES "(prm|json)$" )
         #
-        # Running multiple variants in parallel triggers a race condition
-        # where the same (not yet existent) executable is built
-        # concurrently leading to undefined outcomes.
+        # Running multiple variants of tests with the same target
+        # executable in parallel triggers a race condition where the same
+        # (not yet existent) target is built concurrently leading to
+        # undefined outcomes.
         #
         # Luckily CMake has a mechanism to force a test to be run after
         # another has finished (and both are scheduled):

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.