From patchwork Fri Jun 18 09:28:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cao, Chen" X-Patchwork-Id: 106818 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o5I9S4tK005580 for ; Fri, 18 Jun 2010 09:28:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759071Ab0FRJ2C (ORCPT ); Fri, 18 Jun 2010 05:28:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6320 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756281Ab0FRJ2A (ORCPT ); Fri, 18 Jun 2010 05:28:00 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5I9Rx4v021887 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 18 Jun 2010 05:27:59 -0400 Received: from dhcp-91-197.nay.redhat.com (dhcp-91-197.nay.redhat.com [10.66.91.197]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5I9RvFN002536; Fri, 18 Jun 2010 05:27:58 -0400 Subject: [KVM-AUTOTEST PATCH 1/2] KVM-test: autoit: Generalize the variables in autoit.py To: lmr@redhat.com, autotest@test.kernel.org From: Chen Cao Cc: kvm@vger.kernel.org Date: Fri, 18 Jun 2010 17:28:04 +0800 Message-ID: <20100618092727.11860.87269.stgit@dhcp-91-197.nay.redhat.com> In-Reply-To: <20100618092426.11860.79768.stgit@dhcp-91-197.nay.redhat.com> References: <20100618092426.11860.79768.stgit@dhcp-91-197.nay.redhat.com> User-Agent: StGit/0.15-83-g972d5-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 18 Jun 2010 09:28:05 +0000 (UTC) diff --git a/client/tests/kvm/tests/autoit.py b/client/tests/kvm/tests/autoit.py index e3fa6f6..0373f38 100644 --- a/client/tests/kvm/tests/autoit.py +++ b/client/tests/kvm/tests/autoit.py @@ -5,10 +5,10 @@ import kvm_utils, kvm_test_utils def run_autoit(test, params, env): """ - A wrapper for AutoIt scripts. + A wrapper for running customized tests in guests. 1) Log into a guest. - 2) Run AutoIt script. + 2) Run script. 3) Wait for script execution to complete. 4) Pass/fail according to exit status of script. @@ -30,12 +30,13 @@ def run_autoit(test, params, env): logging.info("Starting script...") # Collect test parameters - binary = params.get("autoit_binary") - script = params.get("autoit_script") - autoit_entry = params.get("autoit_entry", "script.au3") - script_params = params.get("autoit_script_params", "") - timeout = float(params.get("autoit_script_timeout", 600)) + interpreter = params.get("interpreter") + script = params.get("guest_script") + dst_rsc_path = params.get("dst_rsc_path", "script.au3") + script_params = params.get("script_params", "") + test_timeout = float(params.get("test_timeout", 600)) + logging.debug("Starting preparing resouce files...") # Download the script resource from a remote server, or # prepare the script using rss? if params.get("download") == "yes": @@ -44,16 +45,16 @@ def run_autoit(test, params, env): rsc_dir = os.path.basename(rsc_server) dst_rsc_dir = params.get("dst_rsc_dir") - # Change dir to dst_rsc_dir, and remove 'autoit' there, + # Change dir to dst_rsc_dir, and remove the guest script dir there rm_cmd = "cd %s && (rmdir /s /q %s || del /s /q %s)" % \ (dst_rsc_dir, rsc_dir, rsc_dir) - if session.get_command_status(rm_cmd, timeout=timeout) != 0: + if session.get_command_status(rm_cmd, timeout=test_timeout) != 0: raise error.TestFail("Remove %s failed." % rsc_dir) logging.debug("Clean directory succeeded.") # then download the resource. rsc_cmd = "cd %s && %s %s" %(dst_rsc_dir, download_cmd, rsc_server) - if session.get_command_status(rsc_cmd, timeout=timeout) != 0: + if session.get_command_status(rsc_cmd, timeout=test_timeout) != 0: raise error.TestFail("Download test resource failed.") logging.info("Download resource finished.") else: @@ -70,12 +71,12 @@ def run_autoit(test, params, env): internal_timeout=0) file.close() - command = "cmd /c %s %s %s" % (binary, autoit_entry, script_params) + command = "cmd /c %s %s %s" %(interpreter, dst_rsc_path, script_params) logging.info("---------------- Script output ----------------") status = session.get_command_status(command, print_func=logging.info, - timeout=timeout) + timeout=test_timeout) logging.info("---------------- End of script output ----------------") if status is None: @@ -87,5 +88,7 @@ def run_autoit(test, params, env): if reboot == "yes": logging.debug("Rebooting guest after test ...") session = kvm_test_utils.reboot(vm, session, timeout=login_timeout) + + logging.debug("guest test PASSED.") finally: session.close() diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample index fc4fb0b..5b0da6a 100644 --- a/client/tests/kvm/tests_base.cfg.sample +++ b/client/tests/kvm/tests_base.cfg.sample @@ -251,19 +251,19 @@ variants: - autoit: install setup unattended_install.cdrom type = autoit login_timeout = 360 - autoit_binary = D:\AutoIt3.exe - autoit_script_timeout = 600 - autoit_script_params = + interpreter = D:\AutoIt3.exe + test_timeout = 600 + script_params = reboot = yes variants: - notepad: - autoit_script = autoit/notepad1.au3 + guest_script = autoit/notepad1.au3 - stub: download = yes download_cmd = "git clone" rsc_server = "git://the.resource.server/autoit" dst_rsc_dir = "C:\" - autoit_entry = "C:\autoit\stub\stub.au3" + dst_rsc_path = "C:\autoit\stub\stub.au3" - iozone_windows: unattended_install.cdrom type = iozone_windows