From patchwork Fri Feb 5 11:16:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 77320 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 o15BGsao009228 for ; Fri, 5 Feb 2010 11:16:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754596Ab0BELQv (ORCPT ); Fri, 5 Feb 2010 06:16:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42474 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753734Ab0BELQu (ORCPT ); Fri, 5 Feb 2010 06:16:50 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o15BGmGC023861 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 5 Feb 2010 06:16:49 -0500 Received: from localhost.localdomain (vpn-10-70.rdu.redhat.com [10.11.10.70]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o15BGktm013357; Fri, 5 Feb 2010 06:16:47 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH] KVM test: Ensure multiple pre/post commands can run Date: Fri, 5 Feb 2010 09:16:43 -0200 Message-Id: <1265368603-4156-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 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, 05 Feb 2010 11:16:54 +0000 (UTC) diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py index 8a0c151..2e35d9f 100644 --- a/client/tests/kvm/kvm_preprocessing.py +++ b/client/tests/kvm/kvm_preprocessing.py @@ -126,7 +126,7 @@ def postprocess_vm(test, params, env, name): vm.destroy(gracefully = params.get("kill_vm_gracefully") == "yes") -def process_command(test, params, env, command, command_timeout, +def process_command(test, params, env, commands, command_timeout, command_noncritical): """ Pre- or post- custom commands to be executed before/after a test is run @@ -134,22 +134,23 @@ 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: Command to be run. + @param commands: List of commands to be run. @param command_timeout: Timeout for command execution. @param command_noncritical: If True test will not fail if command fails. """ # Export environment vars for k in params.keys(): os.putenv("KVM_TEST_%s" % k, str(params[k])) - # Execute command - try: - utils.system("cd %s; %s" % (test.bindir, command)) - except error.CmdError, e: - logging.warn("Custom processing command '%s' failed, output is: %s", - command, str(e)) - if not command_noncritical: - raise error.TestError("Custom processing command failed: %s" % - str(e)) + # Execute commands + for command in commands: + try: + utils.system("cd %s; %s" % (test.bindir, command)) + except error.CmdError, e: + logging.warn("Custom processing command '%s' failed, output is: %s", + command, str(e)) + if not command_noncritical: + raise error.TestError("Custom processing command failed: %s" % + str(e)) def process(test, params, env, image_func, vm_func): @@ -220,7 +221,8 @@ def preprocess(test, params, env): # Execute any pre_commands if params.get("pre_command"): - process_command(test, params, env, params.get("pre_command"), + pre_commands = params.get("pre_command").spit() + process_command(test, params, env, pre_commands, int(params.get("pre_command_timeout", "600")), params.get("pre_command_noncritical") == "yes") @@ -296,7 +298,8 @@ def postprocess(test, params, env): # Execute any post_commands if params.get("post_command"): - process_command(test, params, env, params.get("post_command"), + post_commands = params.get("post_command").split() + process_command(test, params, env, post_commands, int(params.get("post_command_timeout", "600")), params.get("post_command_noncritical") == "yes") diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample index 91daf48..8f88f3b 100644 --- a/client/tests/kvm/tests_base.cfg.sample +++ b/client/tests/kvm/tests_base.cfg.sample @@ -66,7 +66,7 @@ variants: kill_vm_gracefully = yes kill_vm_on_error = yes force_create_image = yes - pre_command = scripts/unattended.py + pre_command += " scripts/unattended.py" floppy = "images/floppy.img" extra_params += " -boot d" nic_mode = user @@ -953,7 +953,7 @@ variants: variants: - @smallpages: - hugepages: - pre_command = "/usr/bin/python scripts/hugepage.py /mnt/kvm_hugepage" + pre_command += " scripts/hugepage.py" extra_params += " -mem-path /mnt/kvm_hugepage"