summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-10-20 19:26:10 (GMT)
committerBrad King <brad.king@kitware.com>2023-11-17 23:42:17 (GMT)
commit8f1e8af0ccec06b69f25d01d1f27d967a3501f14 (patch)
tree19a2aeff9b190abd8d01da2c7222ea0b8b1ed2f0
parentbd0b4ca867c297a42b3128e0193c6ab01f1b53ec (diff)
downloadCMake-8f1e8af0ccec06b69f25d01d1f27d967a3501f14.zip
CMake-8f1e8af0ccec06b69f25d01d1f27d967a3501f14.tar.gz
CMake-8f1e8af0ccec06b69f25d01d1f27d967a3501f14.tar.bz2
cmCTestMultiProcessHandler: Stop searching for tests when limit is reached
Avoid an extra loop iteration if we have no room for more tests.
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx12
-rw-r--r--Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/CTestCommandLine/test-load-wait0-stdout.txt21
-rw-r--r--Tests/RunCMake/ctest_test/CTestTestLoadWait0-stdout.txt15
-rw-r--r--Tests/RunCMake/ctest_test/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/ctest_test/TestLoadWait0-stdout.txt15
6 files changed, 63 insertions, 4 deletions
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index d4cda42..31b7422 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -542,7 +542,7 @@ void cmCTestMultiProcessHandler::StartNextTests()
// Start tests in the preferred order, each subject to readiness checks.
auto ti = this->OrderedTests.begin();
- while (ti != this->OrderedTests.end()) {
+ while (numToStart > 0 && ti != this->OrderedTests.end()) {
// Increment the test iterator now because the current list
// entry may be deleted below.
int test = *ti++;
@@ -584,8 +584,6 @@ void cmCTestMultiProcessHandler::StartNextTests()
if (this->StartTest(test)) {
numToStart -= processors;
- } else if (numToStart == 0) {
- break;
}
}
@@ -606,7 +604,7 @@ void cmCTestMultiProcessHandler::StartNextTests()
} else if (onlyRunSerialTestsLeft) {
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Only RUN_SERIAL tests remain, awaiting available slot.");
- } else {
+ } else if (!testWithMinProcessors.empty()) {
/* clang-format off */
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"System Load: " << systemLoad << ", "
@@ -614,6 +612,12 @@ void cmCTestMultiProcessHandler::StartNextTests()
"Smallest test " << testWithMinProcessors <<
" requires " << minProcessorsRequired);
/* clang-format on */
+ } else {
+ /* clang-format off */
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "System Load: " << systemLoad << ", "
+ "Max Allowed Load: " << this->TestLoad);
+ /* clang-format on */
}
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "*****" << std::endl);
diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
index 8a9cc8c..1b8d0d9 100644
--- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
@@ -243,6 +243,7 @@ set(ENV{__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING} 7)
# Verify that new tests are not started when the load average exceeds
# our threshold and that they then run once the load average drops.
+run_TestLoad(test-load-wait0 5)
run_TestLoad(test-load-wait1 8)
# Verify that warning message is displayed but tests still start when
diff --git a/Tests/RunCMake/CTestCommandLine/test-load-wait0-stdout.txt b/Tests/RunCMake/CTestCommandLine/test-load-wait0-stdout.txt
new file mode 100644
index 0000000..d112fde
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/test-load-wait0-stdout.txt
@@ -0,0 +1,21 @@
+Test project [^
+]*/Tests/RunCMake/CTestCommandLine/TestLoad(
+[^*][^
+]*)*
+\*\*\*\*\* WAITING, System Load: 7, Max Allowed Load: 5\*\*\*\*\*
+test 1
+ Start 1: TestLoad1
++(
+[^*][^
+]*)*
+test 2
+ Start 2: TestLoad2
++(
+[^*][^
+]*)*
+1/2 Test #[1-2]: TestLoad[1-2] ........................ Passed +[0-9.]+ sec(
+[^*][^
+]*)*
+2/2 Test #[1-2]: TestLoad[1-2] ........................ Passed +[0-9.]+ sec
++
+100% tests passed, 0 tests failed out of 2
diff --git a/Tests/RunCMake/ctest_test/CTestTestLoadWait0-stdout.txt b/Tests/RunCMake/ctest_test/CTestTestLoadWait0-stdout.txt
new file mode 100644
index 0000000..60d70c9
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/CTestTestLoadWait0-stdout.txt
@@ -0,0 +1,15 @@
+Test project [^
+]*/Tests/RunCMake/ctest_test/CTestTestLoadWait0-build(
+[^*][^
+]*)*
+\*\*\*\*\* WAITING, System Load: 7, Max Allowed Load: 6\*\*\*\*\*
+test 1
+ Start 1: RunCMakeVersion
++(
+[^*][^
+]*)*
+1/1 Test #1: RunCMakeVersion .................. Passed +[0-9.]+ sec
++
+100% tests passed, 0 tests failed out of 1
++
+Total Test time \(real\) = +[0-9.]+ sec$
diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
index 9570c77..b1ec9ad 100644
--- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
@@ -26,6 +26,7 @@ run_ctest_test(TestLoadPass TEST_LOAD 8)
# Verify that new tests are not started when the load average exceeds
# our threshold and that they then run once the load average drops.
+run_ctest_test(TestLoadWait0 TEST_LOAD 4 PARALLEL_LEVEL 8)
run_ctest_test(TestLoadWait1 TEST_LOAD 8 PARALLEL_LEVEL 8)
# Verify that when an invalid "TEST_LOAD" value is given, a warning
@@ -39,6 +40,8 @@ run_ctest_test(CTestTestLoadPass)
# Verify that new tests are not started when the load average exceeds
# our threshold and that they then run once the load average drops.
+set(CASE_CTEST_TEST_LOAD 6)
+run_ctest_test(CTestTestLoadWait0 PARALLEL_LEVEL 8)
set(CASE_CTEST_TEST_LOAD 8)
run_ctest_test(CTestTestLoadWait1 PARALLEL_LEVEL 8)
diff --git a/Tests/RunCMake/ctest_test/TestLoadWait0-stdout.txt b/Tests/RunCMake/ctest_test/TestLoadWait0-stdout.txt
new file mode 100644
index 0000000..c7172aa
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/TestLoadWait0-stdout.txt
@@ -0,0 +1,15 @@
+Test project [^
+]*/Tests/RunCMake/ctest_test/TestLoadWait0-build(
+[^*][^
+]*)*
+\*\*\*\*\* WAITING, System Load: 7, Max Allowed Load: 4\*\*\*\*\*
+test 1
+ Start 1: RunCMakeVersion
++(
+[^*][^
+]*)*
+1/1 Test #1: RunCMakeVersion .................. Passed +[0-9.]+ sec
++
+100% tests passed, 0 tests failed out of 1
++
+Total Test time \(real\) = +[0-9.]+ sec$