From patchwork Mon Jul 20 15:07:24 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 36358 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 n6KF4JvF016769 for ; Mon, 20 Jul 2009 15:04:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751565AbZGTPDn (ORCPT ); Mon, 20 Jul 2009 11:03:43 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752073AbZGTPDn (ORCPT ); Mon, 20 Jul 2009 11:03:43 -0400 Received: from mx2.redhat.com ([66.187.237.31]:59946 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751537AbZGTPDj (ORCPT ); Mon, 20 Jul 2009 11:03:39 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n6KF3dNZ000642; Mon, 20 Jul 2009 11:03:39 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n6KF3cRV025268; Mon, 20 Jul 2009 11:03:38 -0400 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n6KF39lU007669; Mon, 20 Jul 2009 11:03:37 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 17/17] KVM test: make some style changes in kvm_preprocessing.py Date: Mon, 20 Jul 2009 18:07:24 +0300 Message-Id: <788a7179006d8edbc1f2a31c5110e0fdbc0e8092.1248102188.git.mgoldish@redhat.com> In-Reply-To: References: <1248102444-31111-1-git-send-email-mgoldish@redhat.com> <4980fdb4f9630c89ba21bd4af49a3b7626fb29f1.1248102188.git.mgoldish@redhat.com> <747abbb55932d4fde553cf5187f7481aaced4d8c.1248102188.git.mgoldish@redhat.com> <53d7f316f181c7efb429e7b9f138ed3e8b239cce.1248102188.git.mgoldish@redhat.com> <7c14834269583764af3beb2e811ac62bec3a2c96.1248102188.git.mgoldish@redhat.com> <7f24fe107f3dc8e2693e12142ba97010c7063166.1248102188.git.mgoldish@redhat.com> <79d9f4e9e8ca62388f1a8be1a0f450a2f2329fc3.1248102188.git.mgoldish@redhat.com> <8cb328ac5429d808714dd252a456e6d3dd3a96b2.1248102188.git.mgoldish@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Make some small style changes to handling of pre- and post-commands. These changes are not required, but they make the code slightly shorter and more consistent with the rest of the code (IMO). Also, do not print "Adding ... to environment" for each parameter in the dict because in some cases there are too many parameters and this generates a lot of output. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_preprocessing.py | 38 +++++++++++++-------------------- 1 files changed, 15 insertions(+), 23 deletions(-) diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py index 71f7a6b..d118826 100644 --- a/client/tests/kvm/kvm_preprocessing.py +++ b/client/tests/kvm/kvm_preprocessing.py @@ -141,30 +141,22 @@ def process_command(test, params, env, command, command_timeout, @param test: An Autotest test object. @param params: A dict containing all VM and image parameters. @param env: The environment (a dict-like object). - @param command: Script containing the command to be run. - @param commmand_timeout: Timeout for command execution. - @param command_noncritical: if 'yes' test will not fail if command fails. + @param command: Command to be run. + @param command_timeout: Timeout for command execution. + @param command_noncritical: If True test will not fail if command fails. """ - if command_timeout is None: - command_timeout = "600" - - if command_noncritical is None: - command_noncritical = "no" - - # export environment vars + # Export environment vars for k in params.keys(): - logging.info("Adding KVM_TEST_%s to Environment" % (k)) - os.putenv("KVM_TEST_%s" % (k), str(params[k])) - # execute command + os.putenv("KVM_TEST_%s" % k, str(params[k])) + # Execute command logging.info("Executing command '%s'..." % command) - timeout = int(command_timeout) (status, output) = kvm_subprocess.run_fg("cd %s; %s" % (test.bindir, command), logging.debug, "(command) ", - timeout=timeout) + timeout=command_timeout) if status != 0: - logging.warn("Custom processing command failed: '%s'..." % command) - if command_noncritical != "yes": + logging.warn("Custom processing command failed: '%s'" % command) + if not command_noncritical: raise error.TestError("Custom processing command failed") @@ -214,11 +206,11 @@ def preprocess(test, params, env): vm.destroy() del env[key] - #execute any pre_commands + # Execute any pre_commands if params.get("pre_command"): process_command(test, params, env, params.get("pre_command"), - params.get("pre_command_timeout"), - params.get("pre_command_noncritical")) + int(params.get("pre_command_timeout", "600")), + params.get("pre_command_noncritical") == "yes") # Preprocess all VMs and images process(test, params, env, preprocess_image, preprocess_vm) @@ -280,11 +272,11 @@ def postprocess(test, params, env): rm_cmd = "rm -vf %s" % os.path.join(test.debugdir, "*.ppm") kvm_subprocess.run_fg(rm_cmd, logging.debug, "(rm) ", timeout=5.0) - #execute any post_commands + # Execute any post_commands if params.get("post_command"): process_command(test, params, env, params.get("post_command"), - params.get("post_command_timeout"), - params.get("post_command_noncritical")) + int(params.get("post_command_timeout", "600")), + params.get("post_command_noncritical") == "yes") def postprocess_on_error(test, params, env):