Kill test process if it takes more than 5 minutes to execute (#2454)

* Kill test process if it takes more than 5 minutes to execute

Signed-off-by: Alan Jowett <alanjo@microsoft.com>

* Update scripts/Test-FaultInjection.ps1

Co-authored-by: Dave Thaler <dthaler@microsoft.com>

---------

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
This commit is contained in:
Alan Jowett 2023-05-11 18:22:43 -06:00 коммит произвёл GitHub
Родитель 0ac0a2f552
Коммит f8f413a25d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 16 добавлений и 0 удалений

Просмотреть файл

@ -22,6 +22,16 @@ Set-Content -Path ($TestProgram + ".fault.log") ""
$iteration = 0
$timer = New-Object System.Timers.Timer
# Set timer for 5 minutes
$timer.Interval = 300000
# When the watchdog timer fires, kill the test binary.
Register-ObjectEvent -InputObject $timer -EventName Elapsed -Action {
Write-Error "Test binary exceeded time"
Get-Process -Name $TestProgram | Stop-Process -Force -ErrorAction SilentlyContinue
}
# Rerun failing tests until they pass
while ($true) {
$previous_passed_tests = $passed_tests
@ -45,9 +55,15 @@ while ($true) {
write-host "Running iteration #" $iteration
$remaining_tests | ForEach-Object { write-host "Running: $_" }
# Start the watchdog timer
$timer.Start()
# Run the test binary with any remaining tests.
& $TestProgram "-d yes" "--verbosity=quiet" "-f remaining_tests.txt"
# Stop the watchdog timer
$timer.Stop()
if ($LASTEXITCODE -eq 0) {
write-host "All tests passed"
break