get_command_output() is safer because it waits for the prompt to return.
sendline() returns immediately, and the output generated in response to the
command can appear later and interfere with the test.
For example, the prompt can appear while the Autotest wrapper waits for an
Autotest test to complete, and this will make the wrapper exit as if the test
has completed.

Signed-off-by: Michael Goldish <mgold...@redhat.com>
---
 client/tests/kvm/tests/autoit.py   |    7 +++----
 client/tests/kvm/tests/autotest.py |    9 ++++-----
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/client/tests/kvm/tests/autoit.py b/client/tests/kvm/tests/autoit.py
index fd2a2cb..9435d7c 100644
--- a/client/tests/kvm/tests/autoit.py
+++ b/client/tests/kvm/tests/autoit.py
@@ -30,18 +30,17 @@ def run_autoit(test, params, env):
 
         # Send AutoIt script to guest (this code will be replaced once we
         # support sending files to Windows guests)
-        session.sendline("del script.au3")
+        session.get_command_output("del script.au3", internal_timeout=0)
         file = open(kvm_utils.get_path(test.bindir, script))
         for line in file.readlines():
             # Insert a '^' before each character
             line = "".join("^" + c for c in line.rstrip())
             if line:
                 # Append line to the file
-                session.sendline("echo %s>>script.au3" % line)
+                session.get_command_output("echo %s>>script.au3" % line,
+                                           internal_timeout=0)
         file.close()
 
-        session.read_up_to_prompt()
-
         command = "cmd /c %s script.au3 %s" % (binary, script_params)
 
         logging.info("---------------- Script output ----------------")
diff --git a/client/tests/kvm/tests/autotest.py 
b/client/tests/kvm/tests/autotest.py
index 5c9b2aa..798217d 100644
--- a/client/tests/kvm/tests/autotest.py
+++ b/client/tests/kvm/tests/autotest.py
@@ -85,7 +85,7 @@ def run_autotest(test, params, env):
     extract(vm, "autotest.tar.bz2")
 
     # mkdir autotest/tests
-    session.sendline("mkdir autotest/tests")
+    session.get_command_output("mkdir autotest/tests")
 
     # Extract <test_name>.tar.bz2 into autotest/tests
     extract(vm, test_name + ".tar.bz2", "autotest/tests")
@@ -99,10 +99,9 @@ def run_autotest(test, params, env):
 
     # Run the test
     logging.info("Running test '%s'..." % test_name)
-    session.sendline("cd autotest")
-    session.sendline("rm -f control.state")
-    session.sendline("rm -rf results/*")
-    session.read_up_to_prompt()
+    session.get_command_output("cd autotest")
+    session.get_command_output("rm -f control.state")
+    session.get_command_output("rm -rf results/*")
     logging.info("---------------- Test output ----------------")
     status = session.get_command_status("bin/autotest control",
                                         timeout=test_timeout,
-- 
1.5.4.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to