public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Lukáš Doktor" <ldoktor@redhat.com>
To: KVM list <kvm@vger.kernel.org>
Subject: [KVM_AUTOTEST][RFC] pre_command chaining
Date: Fri, 10 Jul 2009 13:35:05 +0200	[thread overview]
Message-ID: <4A572769.4030105@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 875 bytes --]

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

[-- Attachment #2: command_chaining.patch --]
[-- Type: text/plain, Size: 1168 bytes --]

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"))
 

             reply	other threads:[~2009-07-10 11:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-10 11:35 Lukáš Doktor [this message]
     [not found] <1691222823.286001247239165845.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-07-10 15:27 ` [KVM_AUTOTEST][RFC] pre_command chaining Michael Goldish
2009-07-13  7:40   ` Lukáš Doktor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A572769.4030105@redhat.com \
    --to=ldoktor@redhat.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox