From: Uri Lublin <[email protected]>

To prevent repetitions.

'run' raises an exception upon command failure.

Use it to configure + clean + make + install.

Signed-off-by: Uri Lublin <[email protected]>

diff --git a/client/tests/kvm_runtest_2/kvm_install.py 
b/client/tests/kvm_runtest_2/kvm_install.py
index 6d8fcb2..75cbd9b 100755
--- a/client/tests/kvm_runtest_2/kvm_install.py
+++ b/client/tests/kvm_runtest_2/kvm_install.py
@@ -241,41 +241,22 @@ def __install_kvm(test, srcdir):
     # start working...
     kvm_log.info("Building KVM...")
 
-    # run './configure'
-    (status, pid, output) = kvm_utils.run_bg("./configure --prefix=%s" % 
kvm_build_dir,
-            None, kvm_log.info, "(configure) ", timeout=30)
-    if status != 0:
-        kvm_utils.safe_kill(pid, signal.SIGTERM)
-        message = "'./configure' failed"
-        kvm_log.error(message)
-        raise error.TestFail, message
-
-    # run 'make clean'
-    (status, pid, output) = kvm_utils.run_bg("make clean",
-            None, kvm_log.info, "(make clean) ", timeout=30)
-    if status != 0:
-        kvm_utils.safe_kill(pid, signal.SIGTERM)
-        message = "'make clean' failed"
-        kvm_log.error(message)
-        raise error.TestFail, message
-
-    # run 'make'
-    (status, pid, output) = kvm_utils.run_bg("make",
-            None, kvm_log.info, "(make) ", timeout=1200)
-    if status != 0:
-        kvm_utils.safe_kill(pid, signal.SIGTERM)
-        message = "'make' failed"
-        kvm_log.error(message)
-        raise error.TestFail, message
-
-    # run 'make -C qemu install'
-    (status, pid, output) = kvm_utils.run_bg("make -C qemu install",
-            None, kvm_log.info, "(make install) ", timeout=120)
-    if status != 0:
-        kvm_utils.safe_kill(pid, signal.SIGTERM)
-        message = "'make -C qemu install' failed"
-        kvm_log.error(message)
-        raise error.TestFail, message
+    def run(cmd, title, timeout):
+        (status, pid, output) = kvm_utils.run_bg(cmd, None, kvm_log.info,
+                                                 '(%s)' % title, 
timeout=timeout)
+        if status != 0:
+            kvm_utils.safe_kill(pid, signal.SIGTERM)
+            message = "%s' failed" % cmd
+            kvm_log.error(message)
+            raise error.TestFail, message
+
+    # configure + make
+    run("./configure --prefix=%s" % kvm_build_dir, "configure", 30)
+    run("make clean", "make clean", 30)
+    run("make", "make", 1200)
+
+    # install from qemu directory
+    run("make -C qemu install", "(make install) ", 120)
 
     # create symlinks
     qemu_path = os.path.join(test.bindir, "qemu")
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to