From patchwork Tue Dec 1 07:16:32 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cao, Chen" X-Patchwork-Id: 63866 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nB17C5Wh003808 for ; Tue, 1 Dec 2009 07:12:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753455AbZLAHLj (ORCPT ); Tue, 1 Dec 2009 02:11:39 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752915AbZLAHLi (ORCPT ); Tue, 1 Dec 2009 02:11:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:26175 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752150AbZLAHLi (ORCPT ); Tue, 1 Dec 2009 02:11:38 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nB17BhQa022141 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 1 Dec 2009 02:11:43 -0500 Received: from localhost.localdomain (dhcp-66-70-2.nay.redhat.com [10.66.70.2]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nB17Be8k026360; Tue, 1 Dec 2009 02:11:41 -0500 From: "Cao, Chen" To: autotest@test.kernel.org, lmr@redhat.com Cc: kvm@vger.kernel.org, mgoldish@redhat.com, "Cao, Chen" Subject: [KVM-AUTOTEST PATCH] Improve kvm subtest AutoIt - add option to download script from remote server Date: Tue, 1 Dec 2009 15:16:32 +0800 Message-Id: <1259651792-22609-1-git-send-email-kcao@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample index 5e15b30..f688b97 100644 --- a/client/tests/kvm/kvm_tests.cfg.sample +++ b/client/tests/kvm/kvm_tests.cfg.sample @@ -169,6 +169,12 @@ variants: variants: - notepad: autoit_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" - guest_s4: install setup unattended_install type = guest_s4 diff --git a/client/tests/kvm/tests/autoit.py b/client/tests/kvm/tests/autoit.py index 9435d7c..ed1d491 100644 --- a/client/tests/kvm/tests/autoit.py +++ b/client/tests/kvm/tests/autoit.py @@ -25,23 +25,40 @@ def run_autoit(test, params, env): # 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)) - # Send AutoIt script to guest (this code will be replaced once we - # support sending files to Windows guests) - 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.get_command_output("echo %s>>script.au3" % line, - internal_timeout=0) - file.close() - - command = "cmd /c %s script.au3 %s" % (binary, script_params) + # Download the script resource from a remote server, or + # prepare the script using rss? + if params.get("download") == "yes": + download_cmd = params.get("download_cmd") + rsc_server = params.get("rsc_server") + dst_rsc_dir = params.get("dst_rsc_dir") + + # Change dir to dst_rsc_dir, and remove 'autoit' there, then + # download the resource. + rsc_cmd = "cd %s && (rmdir /s /q autoit || del /s /q autoit) && " \ + "%s %s" % (dst_rsc_dir, download_cmd, rsc_server) + + if session.get_command_status(rsc_cmd, timeout=timeout) != 0: + raise error.TestFail("Download test resource failed.") + logging.info("Download resource finished.") + else: + # Send AutoIt script to guest (this code will be replaced once we + # support sending files to Windows guests) + 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.get_command_output("echo %s>>script.au3" % line, + internal_timeout=0) + file.close() + + command = "cmd /c %s %s %s" % (binary, autoit_entry, script_params) logging.info("---------------- Script output ----------------") status = session.get_command_status(command,