Tests: Cover ctest waiting on insufficient non-zero spare test-load

This commit is contained in:
Brad King
2023-11-17 18:31:26 -05:00
parent 6f8532fbfa
commit c896dc78f9
5 changed files with 21 additions and 15 deletions

View File

@@ -229,19 +229,21 @@ function(run_TestLoad name load)
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
add_test(TestLoad1 \"${CMAKE_COMMAND}\" -E echo \"test of --test-load\")
set_tests_properties(TestLoad1 PROPERTIES PROCESSORS 2)
add_test(TestLoad2 \"${CMAKE_COMMAND}\" -E echo \"test of --test-load\")
set_tests_properties(TestLoad2 PROPERTIES PROCESSORS 2)
")
run_cmake_command(${name} ${CMAKE_CTEST_COMMAND} -VV -j2 --test-load ${load})
run_cmake_command(${name} ${CMAKE_CTEST_COMMAND} -VV -j8 --test-load ${load})
endfunction()
# Tests for the --test-load feature of ctest
#
# Spoof a load average value to make these tests more reliable.
set(ENV{__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING} 5)
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-wait 3)
run_TestLoad(test-load-wait1 8)
# Verify that warning message is displayed but tests still start when
# an invalid argument is given.
@@ -249,7 +251,7 @@ run_TestLoad(test-load-invalid 'two')
# Verify that new tests are started when the load average falls below
# our threshold.
run_TestLoad(test-load-pass 10)
run_TestLoad(test-load-pass 12)
unset(ENV{__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING})

View File

@@ -2,7 +2,7 @@ Test project [^
]*/Tests/RunCMake/CTestCommandLine/TestLoad(
[^*][^
]*)*
\*\*\*\*\* WAITING, System Load: 5, Max Allowed Load: 3, Smallest test TestLoad[1-2] requires 1\*\*\*\*\*
\*\*\*\*\* WAITING, System Load: 7, Max Allowed Load: 8, Smallest test TestLoad[1-2] requires 2\*\*\*\*\*
test 1
Start 1: TestLoad1
+(

View File

@@ -1,8 +1,8 @@
Test project [^
]*/Tests/RunCMake/ctest_test/CTestTestLoadWait-build(
]*/Tests/RunCMake/ctest_test/CTestTestLoadWait1-build(
[^*][^
]*)*
\*\*\*\*\* WAITING, System Load: 5, Max Allowed Load: 4, Smallest test RunCMakeVersion requires 1\*\*\*\*\*
\*\*\*\*\* WAITING, System Load: 7, Max Allowed Load: 8, Smallest test RunCMakeVersion requires 2\*\*\*\*\*
test 1
Start 1: RunCMakeVersion
+(

View File

@@ -14,16 +14,19 @@ run_ctest_test(TestQuiet QUIET)
# Tests for the 'Test Load' feature of ctest
#
# Spoof a load average value to make these tests more reliable.
set(ENV{__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING} 5)
set(ENV{__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING} 7)
set(RunCTest_VERBOSE_FLAG -VV)
set(CASE_CMAKELISTS_SUFFIX_CODE [[
set_property(TEST RunCMakeVersion PROPERTY PROCESSORS 2)
]])
# Verify that new tests are started when the load average falls below
# our threshold.
run_ctest_test(TestLoadPass TEST_LOAD 6)
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(TestLoadWait TEST_LOAD 2)
run_ctest_test(TestLoadWait1 TEST_LOAD 8 PARALLEL_LEVEL 8)
# Verify that when an invalid "TEST_LOAD" value is given, a warning
# message is displayed and the value is ignored.
@@ -31,13 +34,13 @@ run_ctest_test(TestLoadInvalid TEST_LOAD "ERR1")
# Verify that new tests are started when the load average falls below
# our threshold.
set(CASE_CTEST_TEST_LOAD 7)
set(CASE_CTEST_TEST_LOAD 9)
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 4)
run_ctest_test(CTestTestLoadWait)
set(CASE_CTEST_TEST_LOAD 8)
run_ctest_test(CTestTestLoadWait1 PARALLEL_LEVEL 8)
# Verify that when an invalid "CTEST_TEST_LOAD" value is given,
# a warning message is displayed and the value is ignored.
@@ -51,6 +54,7 @@ run_ctest_test(TestLoadOrder TEST_LOAD "ERR4")
unset(ENV{__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING})
unset(CASE_CTEST_TEST_LOAD)
unset(CASE_CMAKELISTS_SUFFIX_CODE)
unset(RunCTest_VERBOSE_FLAG)
block()

View File

@@ -1,8 +1,8 @@
Test project [^
]*/Tests/RunCMake/ctest_test/TestLoadWait-build(
]*/Tests/RunCMake/ctest_test/TestLoadWait1-build(
[^*][^
]*)*
\*\*\*\*\* WAITING, System Load: 5, Max Allowed Load: 2, Smallest test RunCMakeVersion requires 1\*\*\*\*\*
\*\*\*\*\* WAITING, System Load: 7, Max Allowed Load: 8, Smallest test RunCMakeVersion requires 2\*\*\*\*\*
test 1
Start 1: RunCMakeVersion
+(