Parallel ctest starts too many tests when a test depends on another test that uses the RUN_SERIAL property
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
Parallel ctest can start too many tests (unbounded number) when a test that can be run in parallel depends on a test that uses the RUN_SERIAL property. This can cause an unbounded number of tests to spawn which will hang the test machine if not caught right away.
Here is the case I debugged
Parallel level for ctest = 4 Current # tests running = 1
Try to start a new test A which should take only 1 processor so it should be able to start in parallel with the current 1 processors test. However when trying to start test A the dependencies are checked; instead of starting A the dependent test B is started which takes 4 processors becuse it is set to RUN_SERIAL=true.
The check on whether the test can be started only checks the number of processors required by test A (cmCTestMultiProcessHandler.cxx:265) so test B is allowed to start in place of test A.
As a result test B is started and now there are 5 processors in use even though the parallel level is supposed to be 4. This causes unsigned overflow when looking for the number of tests to run in the next step ( cmCTestMultiProcessHandler::StartNextTests() first line)
I do not have a simple CMakeLists to reproduce the problem. I can only reproduce this in cmake 2.8.4 before the switch from sort -> stable_sort as the tests get reordered which prevents this bug from being triggered. Based on code inspection, it looks like this bug still exists in master although I no longer have a reproducing case.