Skip to content

Commit

Permalink
Fail test run when QEMU fails too quickly
Browse files Browse the repository at this point in the history
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
  • Loading branch information
kostyanf14 committed Jan 25, 2024
1 parent 0d3f735 commit 72d6126
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/setupmanagers/qemuhck/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
module AutoHCK
# A custom QemuHCKError error exception
class QemuHCKError < SetupManagerError; end

class QemuRunError < QemuHCKError; end
end
18 changes: 17 additions & 1 deletion lib/setupmanagers/qemuhck/qemu_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ def run_qemu(scope)
qemu
end

def check_fails_too_quickly(status)
if status&.zero?
@first_fail_time = nil
false
end

if @first_fail_time.nil?
@first_fail_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
false
else
(Process.clock_gettime(Process::CLOCK_MONOTONIC) - @first_fail_time) <= 10
end
end

def run_vm
@machine.dump_config

Expand All @@ -99,7 +113,7 @@ def run_vm
@machine.run_pre_start_commands

qemu = run_qemu(scope)
qemu.wait_no_fail
@fails_quickly = check_fails_too_quickly(qemu.wait_no_fail&.exitstatus)
qemu = nil
ensure
unless qemu.nil?
Expand All @@ -109,6 +123,8 @@ def run_vm
@machine.run_post_stop_commands
end

raise QemuRunError, 'QEMU fails repeated too quickly' if @fails_quickly

break unless @keep_alive
end
end
Expand Down

0 comments on commit 72d6126

Please sign in to comment.