From: "Cao, Chen" Subject: [KVM-Autotest Patch] KVM Test: Add re.IGNORECASE to re.compile to verify_ip_address_ in kvm_utils.py - v2 Date: Wed, 28 Oct 2009 17:30:32 +0800 Message-ID: <1256722232-12246-1-git-send-email-kcao@redhat.com> References: <1256616216-7179-1-git-send-email-kcao@redhat.com> Cc: kvm@vger.kernel.org, mgoldish@redhat.com, "Cao, Chen" To: lmr@redhat.com, autotest@test.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:36651 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756849AbZJ1Jbv (ORCPT ); Wed, 28 Oct 2009 05:31:51 -0400 In-Reply-To: <1256616216-7179-1-git-send-email-kcao@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Since the mac address is (changed to) lowercase and the output of 'arping' is in uppercase, we need re.IGNORECASE in the re.compile. And substitute re.search(regex, 0, ...) with regex.search(o), as Michael Goldish (mgoldish@redhat.com) suggested. Signed-off-by: Cao, Chen --- client/tests/kvm/kvm_utils.py | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py index f72984a..b9219f6 100644 --- a/client/tests/kvm/kvm_utils.py +++ b/client/tests/kvm/kvm_utils.py @@ -190,11 +190,11 @@ def verify_ip_address_ownership(ip, macs, timeout=10.0): # Compile a regex that matches the given IP address and any of the given # MAC addresses mac_regex = "|".join("(%s)" % mac for mac in macs) - regex = re.compile(r"\b%s\b.*\b(%s)\b" % (ip, mac_regex)) + 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") - if re.search(regex, o, re.IGNORECASE): + if regex.search(o): return True # Get the name of the bridge device for arping @@ -206,7 +206,7 @@ def verify_ip_address_ownership(ip, macs, timeout=10.0): # Send an ARP request o = commands.getoutput("/sbin/arping -f -c 3 -I %s %s" % (dev, ip)) - return bool(re.search(regex, o, re.IGNORECASE)) + return bool(regex.search(o)) # Functions for working with the environment (a dict-like object) -- 1.6.0.6