TestIteration timeout in TestManager
Show older comments
Hello,
I am running a testManager having few testSuites, and each testSuite have a testCase with few TestIterations.
When running the TestManager a single TestIteration takes usually about 10min to complete, but in some cases the solver(my personal one) moves to smaller step size and the time for computation goes to 24+h per testIteartion. I do not want to spend 24h for a single step/testIteartion, but rather to skip it if it takes longer then 10min.
Is there a way to add a timeout in the TestManager/TestSuite for the testIteartions? If it takes more then 10min to just move to the next testIteartion with a message.
I was looking for this solution https://www.mathworks.com/help/matlab/ref/matlab.unittest.constraints.eventually-class.html but I am not sure I can add tic-tok inside the testManager.
I was also thinking to add timeout inside the TestSequence, but as simulation time stays at a given time step, while my solver is doing the computation for that time step, that is not working either.
Thank you for your help!
Answers (1)
Ishan
12 minutes ago
0 votes
I do not think matlab.unittest.constraints.Eventually is the right tool here. It waits for a condition to become true, but it does not interrupt a simulation that is blocked inside a long-running solver computation.
Similarly, a timeout implemented in a Test Sequence is unlikely to help if simulation time is not advancing. If the solver is spending a long wall-clock time inside a single timestep, the Test Sequence logic will not execute until control returns to the simulation engine.
As far as I can tell, Simulink Test does not provide a built-in wall-clock timeout for individual Test Iterations. The configured stop time is based on simulation time rather than elapsed execution time.
In this situation, the most reliable solution is usually to implement the timeout in the custom solver itself. The solver can periodically check elapsed wall-clock time and terminate gracefully if a predefined limit is exceeded. The iteration can then be marked as failed or errored, and the Test Manager can continue to the next iteration.
If the solver is implemented in C/C++ or inside an S-Function, the same approach can be implemented there. External MATLAB timers or Test Sequence logic generally cannot preempt a solver while it is executing a long computation.
Therefore, I would recommend:
- Add a wall-clock timeout/checkpoint inside the custom solver.
- Return a controlled error or diagnostic when the timeout is reached.
- Configure the test run so that a failed iteration does not stop the remaining iterations.
- Use the test results to identify which iterations exceeded the allowed runtime.
This is typically the most robust way to handle cases where simulation time is effectively stalled because the solver is spending excessive time on a single step.
Categories
Find more on Outputs in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!