| OLD | NEW |
| 1 import os, logging | 1 import os, logging |
| 2 import kvm_utils | 2 from autotest_lib.client.virt import virt_utils |
| 3 | 3 |
| 4 | 4 |
| 5 def run_guest_test(test, params, env): | 5 def run_guest_test(test, params, env): |
| 6 """ | 6 """ |
| 7 A wrapper for running customized tests in guests. | 7 A wrapper for running customized tests in guests. |
| 8 | 8 |
| 9 1) Log into a guest. | 9 1) Log into a guest. |
| 10 2) Run script. | 10 2) Run script. |
| 11 3) Wait for script execution to complete. | 11 3) Wait for script execution to complete. |
| 12 4) Pass/fail according to exit status of script. | 12 4) Pass/fail according to exit status of script. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 (dst_rsc_dir, rsc_dir, rsc_dir) | 53 (dst_rsc_dir, rsc_dir, rsc_dir) |
| 54 session.cmd(rm_cmd, timeout=test_timeout) | 54 session.cmd(rm_cmd, timeout=test_timeout) |
| 55 logging.debug("Clean directory succeeded.") | 55 logging.debug("Clean directory succeeded.") |
| 56 | 56 |
| 57 # then download the resource. | 57 # then download the resource. |
| 58 rsc_cmd = "cd %s && %s %s" % (dst_rsc_dir, download_cmd, rsc_server) | 58 rsc_cmd = "cd %s && %s %s" % (dst_rsc_dir, download_cmd, rsc_server) |
| 59 session.cmd(rsc_cmd, timeout=test_timeout) | 59 session.cmd(rsc_cmd, timeout=test_timeout) |
| 60 logging.info("Download resource finished.") | 60 logging.info("Download resource finished.") |
| 61 else: | 61 else: |
| 62 session.cmd_output("del %s" % dst_rsc_path, internal_timeout=0) | 62 session.cmd_output("del %s" % dst_rsc_path, internal_timeout=0) |
| 63 script_path = kvm_utils.get_path(test.bindir, script) | 63 script_path = virt_utils.get_path(test.bindir, script) |
| 64 vm.copy_files_to(script_path, dst_rsc_path, timeout=60) | 64 vm.copy_files_to(script_path, dst_rsc_path, timeout=60) |
| 65 | 65 |
| 66 cmd = "%s %s %s" % (interpreter, dst_rsc_path, script_params) | 66 cmd = "%s %s %s" % (interpreter, dst_rsc_path, script_params) |
| 67 | 67 |
| 68 try: | 68 try: |
| 69 logging.info("------------ Script output ------------") | 69 logging.info("------------ Script output ------------") |
| 70 session.cmd(cmd, print_func=logging.info, timeout=test_timeout) | 70 session.cmd(cmd, print_func=logging.info, timeout=test_timeout) |
| 71 finally: | 71 finally: |
| 72 logging.info("------------ End of script output ------------") | 72 logging.info("------------ End of script output ------------") |
| 73 | 73 |
| 74 if reboot == "yes": | 74 if reboot == "yes": |
| 75 logging.debug("Rebooting guest after test ...") | 75 logging.debug("Rebooting guest after test ...") |
| 76 session = vm.reboot(session, timeout=login_timeout) | 76 session = vm.reboot(session, timeout=login_timeout) |
| 77 | 77 |
| 78 logging.debug("guest test PASSED.") | 78 logging.debug("guest test PASSED.") |
| 79 finally: | 79 finally: |
| 80 session.close() | 80 session.close() |
| OLD | NEW |