[Pkg-libvirt-commits] [libguestfs] 26/65: v2v: test-harness: Improve boot loop.
Hilko Bengen
bengen at moszumanska.debian.org
Tue Apr 21 12:10:58 UTC 2015
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch experimental
in repository libguestfs.
commit ddeec8b5045125a4134fadc8b3975f985672e9d8
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Thu Apr 9 17:40:16 2015 +0100
v2v: test-harness: Improve boot loop.
Take screenshots each time around the loop (every 10 seconds). These
are very useful for debugging.
Check for the final screenshot on every iteration. If the final
screenshot is encountered then the guest is terminated immediately.
Reverse a few loop tests to try to make the code more readable.
---
v2v/test-harness/v2v_test_harness.ml | 50 ++++++++++++++++++++++--------------
1 file changed, 31 insertions(+), 19 deletions(-)
diff --git a/v2v/test-harness/v2v_test_harness.ml b/v2v/test-harness/v2v_test_harness.ml
index 4511cfe..b570f0f 100644
--- a/v2v/test-harness/v2v_test_harness.ml
+++ b/v2v/test-harness/v2v_test_harness.ml
@@ -289,23 +289,37 @@ let run ~test ?input_disk ?input_xml ?(test_plan = default_plan) () =
let t = time () in
if t -. start > float test_plan.boot_max_time then
bootfail t "guest timed out before reaching final state";
- let active, stats = get_disk_activity stats in
- if active then (
- printf "%s: disk activity detected\n" (timestamp t);
- loop start t stats
- ) else (
- if t -. last_activity <= float test_plan.boot_idle_time then (
- let screenshot = take_screenshot t in
- (* Reached the final screenshot? *)
- let done_ =
- match test_plan.boot_plan with
- | Boot_to_screenshot final_screenshot ->
- if display_matches_screenshot screenshot final_screenshot then (
- printf "%s: guest reached final screenshot\n" (timestamp t);
- true
- ) else false
- | _ -> false in
- if not done_ then (
+
+ (* Make sure we take a screenshot on every iteration, as they
+ * are incredibly useful for debugging.
+ *)
+ let screenshot = take_screenshot t in
+
+ (* Reached the final screenshot? Reaching this state
+ * terminates the boot immediately.
+ *)
+ let reached_final_screenshot =
+ match test_plan.boot_plan with
+ | Boot_to_screenshot final_screenshot ->
+ if display_matches_screenshot screenshot final_screenshot then (
+ printf "%s: guest reached final screenshot\n" (timestamp t);
+ true
+ ) else false
+ | _ -> false in
+ if not reached_final_screenshot then (
+ (* Is the disk active? *)
+ let is_active, stats = get_disk_activity stats in
+ let is_idle = t -. last_activity > float test_plan.boot_idle_time in
+
+ if is_active then (
+ printf "%s: disk activity detected\n" (timestamp t);
+ loop start t stats
+ ) else (
+ if is_idle then (
+ if test_plan.boot_plan <> Boot_to_idle then
+ bootfail t "guest timed out with no disk activity before reaching final state"
+ (* else Boot_to_idle, so we exit the loop here *)
+ ) else (
(* A screenshot matching one of the screenshots in the set
* resets the timeouts.
*)
@@ -319,8 +333,6 @@ let run ~test ?input_disk ?input_xml ?(test_plan = default_plan) () =
loop start last_activity stats
)
)
- else
- bootfail t "guest timed out with no disk activity before reaching final state"
)
in
loop start last_activity stats;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list