From patchwork Fri Jul 10 11:35:05 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?THVrw6HFoSBEb2t0b3I=?= X-Patchwork-Id: 34964 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 n6ABZC1v004313 for ; Fri, 10 Jul 2009 11:35:12 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751449AbZGJLfK (ORCPT ); Fri, 10 Jul 2009 07:35:10 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751394AbZGJLfK (ORCPT ); Fri, 10 Jul 2009 07:35:10 -0400 Received: from mx2.redhat.com ([66.187.237.31]:54318 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751330AbZGJLfJ (ORCPT ); Fri, 10 Jul 2009 07:35:09 -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 n6ABZ9K8031933 for ; Fri, 10 Jul 2009 07:35:09 -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 n6ABZ87s005255 for ; Fri, 10 Jul 2009 07:35:08 -0400 Received: from [10.34.33.254] (dhcp-lab-254.englab.brq.redhat.com [10.34.33.254]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n6ABZ73V030809 for ; Fri, 10 Jul 2009 07:35:07 -0400 Message-ID: <4A572769.4030105@redhat.com> Date: Fri, 10 Jul 2009 13:35:05 +0200 From: =?ISO-8859-2?Q?Luk=E1=B9_Doktor?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1b3pre) Gecko/20090513 Fedora/3.0-2.3.beta2.fc11 Thunderbird/3.0b2 MIME-Version: 1.0 To: KVM list Subject: [KVM_AUTOTEST][RFC] pre_command chaining 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 Hi, the way how kvm_autotest currently handle pre_command/post_command it don't allow to specify more than one command. BASH can handle this itself with a small change in the framework , as shown in the attachment. In .cfg file we just change variable from: pre_command = "command" to: pre_commane += "command &&" produce: $(command && true) Framework adds the last command true, which enclose whole command. This way we can chain infinite pre/post_commands without losing the return value (if something go wrong, other commands are not executed and return value is preserve. example: in cfg: pre_command += "echo A &&" pre_command += "echo B &&" pre_command += "echo C &&" framework params.get("pre_command"): "echo A && echo B && echo C &&" framework process_command execute on the host: "echo A && echo B && echo C && true" regards, Lukáš Doktor diff -Narup kvm-autotest/client/tests/kvm/kvm_preprocessing.py kvm-autotest-new/client/tests/kvm/kvm_preprocessing.py --- kvm-autotest/client/tests/kvm/kvm_preprocessing.py 2009-07-08 08:31:01.492284501 +0200 +++ kvm-autotest-new/client/tests/kvm/kvm_preprocessing.py 2009-07-10 13:18:35.407285172 +0200 @@ -229,7 +229,8 @@ def preprocess(test, params, env): #execute any pre_commands if params.get("pre_command"): - process_command(test, params, env, params.get("pre_command"), + process_command(test, params, env, + (params.get("pre_command") + " true"), params.get("pre_command_timeout"), params.get("pre_command_noncritical")) @@ -287,7 +288,8 @@ def postprocess(test, params, env): #execute any post_commands if params.get("post_command"): - process_command(test, params, env, params.get("post_command"), + process_command(test, params, env, + (params.get("post_command") + " true"), params.get("post_command_timeout"), params.get("post_command_noncritical"))