[PATCH 17/24] tests: Modify test_autogo_bridge() test to use group interface

Ilan Peer ilan.peer
Wed Feb 4 01:30:29 PST 2015


From: David Spinadel <david.spinadel at intel.com>

1. Add get_group_ifname() to wpasupplicant.py
2. Use the function to get the interface name for the bridge.

Signed-off-by: David Spinadel <david.spinadel at intel.com>
---
 tests/hwsim/test_p2p_autogo.py | 10 +++++-----
 tests/hwsim/wpasupplicant.py   |  3 +++
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/tests/hwsim/test_p2p_autogo.py b/tests/hwsim/test_p2p_autogo.py
index 460fa55..77e789f 100644
--- a/tests/hwsim/test_p2p_autogo.py
+++ b/tests/hwsim/test_p2p_autogo.py
@@ -440,10 +440,10 @@ def test_autogo_bridge(dev):
         autogo(dev[0])
         subprocess.call(['sudo', 'brctl', 'addbr', 'p2p-br0'])
         subprocess.call(['sudo', 'brctl', 'setfd', 'p2p-br0', '0'])
-        subprocess.call(['sudo', 'brctl', 'addif', 'p2p-br0', dev[0].ifname])
+        subprocess.call(['sudo', 'brctl', 'addif', 'p2p-br0', dev[0].get_group_ifname()])
         subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'p2p-br0', 'up'])
         time.sleep(0.1)
-        subprocess.call(['sudo', 'brctl', 'delif', 'p2p-br0', dev[0].ifname])
+        subprocess.call(['sudo', 'brctl', 'delif', 'p2p-br0', dev[0].get_group_ifname()])
         time.sleep(0.1)
         subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'p2p-br0', 'down'])
         time.sleep(0.1)
@@ -451,17 +451,17 @@ def test_autogo_bridge(dev):
         ev = dev[0].wait_global_event(["P2P-GROUP-REMOVED"], timeout=1)
         if ev is not None:
             raise Exception("P2P group removed unexpectedly")
-        if dev[0].get_status_field('wpa_state') != "COMPLETED":
+        if dev[0].get_group_status_field('wpa_state') != "COMPLETED":
             raise Exception("Unexpected wpa_state")
-        dev[0].remove_group()
     finally:
         dev[0].request("AUTOSCAN ")
-        subprocess.Popen(['sudo', 'brctl', 'delif', 'p2p-br0', dev[0].ifname],
+        subprocess.Popen(['sudo', 'brctl', 'delif', 'p2p-br0', dev[0].get_group_ifname()],
                          stderr=open('/dev/null', 'w'))
         subprocess.Popen(['sudo', 'ip', 'link', 'set', 'dev', 'p2p-br0', 'down'],
                          stderr=open('/dev/null', 'w'))
         subprocess.Popen(['sudo', 'brctl', 'delbr', 'p2p-br0'],
                          stderr=open('/dev/null', 'w'))
+        dev[0].remove_group()
 
 def test_presence_req_on_group_interface(dev):
     """P2P_PRESENCE_REQ on group interface"""
diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py
index 0ee653b..ad6f4e7 100644
--- a/tests/hwsim/wpasupplicant.py
+++ b/tests/hwsim/wpasupplicant.py
@@ -1041,3 +1041,6 @@ class WpaSupplicant:
         if ev is None:
             raise Exception(error)
         return ev
+
+    def get_group_ifname(self):
+        return self.group_ifname if self.group_ifname else self.ifname
-- 
1.8.3.2




More information about the Hostap mailing list