kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [KVM-AUTOTEST PATCH v2] KVM test: use kvm_utils.find_command() where appropriate
@ 2010-07-05 16:26 Michael Goldish
  2010-07-05 23:08 ` Amos Kong
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Goldish @ 2010-07-05 16:26 UTC (permalink / raw)
  To: autotest, kvm; +Cc: Michael Goldish

Instead of hardcoding binary paths, use kvm_utils.find_command().
This should make the KVM test a little more distro independent.

Changes from v1:
- Fix a mistake in kvm_preprocessing.py (used 'command' instead of 'cmd')

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/kvm_preprocessing.py |    6 +++---
 client/tests/kvm/kvm_utils.py         |    7 ++++---
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py
index ee279bd..9ae0e08 100644
--- a/client/tests/kvm/kvm_preprocessing.py
+++ b/client/tests/kvm/kvm_preprocessing.py
@@ -208,10 +208,10 @@ def preprocess(test, params, env):
         env["tcpdump"].close()
         del env["tcpdump"]
     if "tcpdump" not in env and params.get("run_tcpdump", "yes") == "yes":
-        command = "/usr/sbin/tcpdump -npvi any 'dst port 68'"
-        logging.debug("Starting tcpdump (%s)...", command)
+        cmd = "%s -npvi any 'dst port 68'" % kvm_utils.find_command("tcpdump")
+        logging.debug("Starting tcpdump (%s)...", cmd)
         env["tcpdump"] = kvm_subprocess.kvm_tail(
-            command=command,
+            command=cmd,
             output_func=_update_address_cache,
             output_params=(env["address_cache"],))
         if kvm_utils.wait_for(lambda: not env["tcpdump"].is_alive(),
diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index a57a334..4183f1c 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -250,19 +250,20 @@ def verify_ip_address_ownership(ip, macs, timeout=10.0):
     regex = re.compile(r"\b%s\b.*\b(%s)\b" % (ip, mac_regex), re.IGNORECASE)
 
     # Check the ARP cache
-    o = commands.getoutput("/sbin/arp -n")
+    o = commands.getoutput("%s -n" % find_command("arp"))
     if regex.search(o):
         return True
 
     # Get the name of the bridge device for arping
-    o = commands.getoutput("/sbin/ip route get %s" % ip)
+    o = commands.getoutput("%s route get %s" % (find_command("ip"), ip))
     dev = re.findall("dev\s+\S+", o, re.IGNORECASE)
     if not dev:
         return False
     dev = dev[0].split()[-1]
 
     # Send an ARP request
-    o = commands.getoutput("/sbin/arping -f -c 3 -I %s %s" % (dev, ip))
+    o = commands.getoutput("%s -f -c 3 -I %s %s" %
+                           (find_command("arping"), dev, ip))
     return bool(regex.search(o))
 
 
-- 
1.5.4.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [KVM-AUTOTEST PATCH v2] KVM test: use kvm_utils.find_command() where appropriate
  2010-07-05 16:26 [KVM-AUTOTEST PATCH v2] KVM test: use kvm_utils.find_command() where appropriate Michael Goldish
@ 2010-07-05 23:08 ` Amos Kong
  0 siblings, 0 replies; 2+ messages in thread
From: Amos Kong @ 2010-07-05 23:08 UTC (permalink / raw)
  To: Michael Goldish; +Cc: autotest, kvm

On Mon, Jul 05, 2010 at 07:26:12PM +0300, Michael Goldish wrote:
> Instead of hardcoding binary paths, use kvm_utils.find_command().
> This should make the KVM test a little more distro independent.
> 
> Changes from v1:
> - Fix a mistake in kvm_preprocessing.py (used 'command' instead of 'cmd')
> 
> Signed-off-by: Michael Goldish <mgoldish@redhat.com>

Reviewed-by: Amos Kong <akong@redhat.com>
Looks good for me, In the past, I've to create symbolic links for fix this issue.

> ---
>  client/tests/kvm/kvm_preprocessing.py |    6 +++---
>  client/tests/kvm/kvm_utils.py         |    7 ++++---
>  2 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py
> index ee279bd..9ae0e08 100644
> --- a/client/tests/kvm/kvm_preprocessing.py
> +++ b/client/tests/kvm/kvm_preprocessing.py
> @@ -208,10 +208,10 @@ def preprocess(test, params, env):
>          env["tcpdump"].close()
>          del env["tcpdump"]
>      if "tcpdump" not in env and params.get("run_tcpdump", "yes") == "yes":
> -        command = "/usr/sbin/tcpdump -npvi any 'dst port 68'"
> -        logging.debug("Starting tcpdump (%s)...", command)
> +        cmd = "%s -npvi any 'dst port 68'" % kvm_utils.find_command("tcpdump")
> +        logging.debug("Starting tcpdump (%s)...", cmd)
>          env["tcpdump"] = kvm_subprocess.kvm_tail(
> -            command=command,
> +            command=cmd,
>              output_func=_update_address_cache,
>              output_params=(env["address_cache"],))
>          if kvm_utils.wait_for(lambda: not env["tcpdump"].is_alive(),
> diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
> index a57a334..4183f1c 100644
> --- a/client/tests/kvm/kvm_utils.py
> +++ b/client/tests/kvm/kvm_utils.py
> @@ -250,19 +250,20 @@ def verify_ip_address_ownership(ip, macs, timeout=10.0):
>      regex = re.compile(r"\b%s\b.*\b(%s)\b" % (ip, mac_regex), re.IGNORECASE)
>  
>      # Check the ARP cache
> -    o = commands.getoutput("/sbin/arp -n")
> +    o = commands.getoutput("%s -n" % find_command("arp"))
>      if regex.search(o):
>          return True
>  
>      # Get the name of the bridge device for arping
> -    o = commands.getoutput("/sbin/ip route get %s" % ip)
> +    o = commands.getoutput("%s route get %s" % (find_command("ip"), ip))
>      dev = re.findall("dev\s+\S+", o, re.IGNORECASE)
>      if not dev:
>          return False
>      dev = dev[0].split()[-1]
>  
>      # Send an ARP request
> -    o = commands.getoutput("/sbin/arping -f -c 3 -I %s %s" % (dev, ip))
> +    o = commands.getoutput("%s -f -c 3 -I %s %s" %
> +                           (find_command("arping"), dev, ip))
>      return bool(regex.search(o))
>  
>  
> -- 
> 1.5.4.1
> 
> --
> 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] 2+ messages in thread

end of thread, other threads:[~2010-07-05 23:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-05 16:26 [KVM-AUTOTEST PATCH v2] KVM test: use kvm_utils.find_command() where appropriate Michael Goldish
2010-07-05 23:08 ` Amos Kong

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