CTest: Fix regression in calculating test timeout

Fixes: #25120
3 files changed