From 86f23e2a5d1207c199b88f64ff8f9cff22c5d3d2 Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Thu, 1 Feb 2024 08:59:39 +0100
Subject: [PATCH] [cmake] Set runtime parameter on larger benchmarks.

Wwhich exceed the ctest default of 1500 s.
---
 scripts/cmake/test/AddTest.cmake | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/scripts/cmake/test/AddTest.cmake b/scripts/cmake/test/AddTest.cmake
index fb0c30ba67a..4883c0d5e3b 100644
--- a/scripts/cmake/test/AddTest.cmake
+++ b/scripts/cmake/test/AddTest.cmake
@@ -96,11 +96,13 @@ function(AddTest)
     if(NOT DEFINED AddTest_REQUIREMENTS)
         set(AddTest_REQUIREMENTS TRUE)
     endif()
-    set(timeout ${ogs.ctest.large_runtime})
-    if(DEFINED AddTest_RUNTIME)
-        math(EXPR timeout "${AddTest_RUNTIME} * 3")
-    else()
+    if(NOT DEFINED AddTest_RUNTIME)
         set(AddTest_RUNTIME 1)
+    elseif(AddTest_RUNTIME GREATER 750)
+        # Set a timeout on jobs larger than the default ctest timeout of 1500 (s).
+        # The allowed runtime is twice as long as the given RUNTIME parameter.
+        math(EXPR timeout "${AddTest_RUNTIME} * 2")
+        set(timeout TIMEOUT ${timeout})
     endif()
     if(NOT DEFINED AddTest_WORKING_DIRECTORY)
         set(AddTest_WORKING_DIRECTORY ${AddTest_BINARY_PATH})
@@ -381,6 +383,7 @@ macro(_add_test TEST_NAME)
                    ${AddTest_DISABLED}
                    LABELS
                    "${labels}"
+                   ${timeout}
     )
 endmacro()
 
-- 
GitLab