* Re: [KVM_AUTOTEST][RFC] pre_command chaining
[not found] <1691222823.286001247239165845.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
@ 2009-07-10 15:27 ` Michael Goldish
2009-07-13 7:40 ` Lukáš Doktor
0 siblings, 1 reply; 3+ messages in thread
From: Michael Goldish @ 2009-07-10 15:27 UTC (permalink / raw)
To: Lukáš Doktor; +Cc: KVM list
----- "Lukáš Doktor" <ldoktor@redhat.com> wrote:
> 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.
Why do you say the framework doesn't allow chaining pre_commands?
What's wrong with:
pre_command = "command0"
pre_command += " && command1"
pre_command += " && command2"
> 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
In any case, the proposed solution does not allow the user to use
pre_command in the most straightforward way:
pre_command = "command"
because that would get translated into:
"command true"
So the user must append && to the command, which makes little sense.
There could be other solutions, like
1. Specifying "pre_command = true" at the top of the config file, and
then using:
pre_command += " && command0"
pre_command += " && command1"
"pre_command = command" will also work fine in this case.
2. Removing the final "&&" from the command, if any, so that if the
user enters:
pre_command = "command0 &&"
pre_command += "command1 &&"
the framework will run:
"command0 && command1" instead of "command0 && command1 &&".
In any case, can you provide an example where it's impossible or
difficult to do command chaining without changing the framework?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [KVM_AUTOTEST][RFC] pre_command chaining
2009-07-10 15:27 ` [KVM_AUTOTEST][RFC] pre_command chaining Michael Goldish
@ 2009-07-13 7:40 ` Lukáš Doktor
0 siblings, 0 replies; 3+ messages in thread
From: Lukáš Doktor @ 2009-07-13 7:40 UTC (permalink / raw)
To: Michael Goldish; +Cc: KVM list
Hi Michael,
you are right, it is possible. But if I specify "pre_command = true" at
the top of my config file, this command will be executed even if no
additional command is added into the queue. (tests with pre_commands are
not selected)
That is my reason why I'd like to see this two lines change into the
framework.
Still you are right that it's basically a "cosmetic" modification for
simplification the config file.
Dne 10.7.2009 17:27, Michael Goldish napsal(a):
> ----- "Lukáš Doktor"<ldoktor@redhat.com> wrote:
>
>> 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.
>
> Why do you say the framework doesn't allow chaining pre_commands?
> What's wrong with:
> pre_command = "command0"
> pre_command += "&& command1"
> pre_command += "&& command2"
>
>> 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
>
> In any case, the proposed solution does not allow the user to use
> pre_command in the most straightforward way:
> pre_command = "command"
> because that would get translated into:
> "command true"
> So the user must append&& to the command, which makes little sense.
>
> There could be other solutions, like
>
> 1. Specifying "pre_command = true" at the top of the config file, and
> then using:
> pre_command += "&& command0"
> pre_command += "&& command1"
>
> "pre_command = command" will also work fine in this case.
>
> 2. Removing the final "&&" from the command, if any, so that if the
> user enters:
> pre_command = "command0&&"
> pre_command += "command1&&"
> the framework will run:
> "command0&& command1" instead of "command0&& command1&&".
>
> In any case, can you provide an example where it's impossible or
> difficult to do command chaining without changing the framework?
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* [KVM_AUTOTEST][RFC] pre_command chaining
@ 2009-07-10 11:35 Lukáš Doktor
0 siblings, 0 replies; 3+ messages in thread
From: Lukáš Doktor @ 2009-07-10 11:35 UTC (permalink / raw)
To: KVM list
[-- 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"))
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-07-13 7:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[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
2009-07-10 11:35 Lukáš Doktor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).