tests: Modify autogo_bridge test to use group interface
authorDavid Spinadel <david.spinadel@intel.com>
Fri, 6 Feb 2015 01:31:00 +0000 (20:31 -0500)
committerJouni Malinen <j@w1.fi>
Sat, 7 Feb 2015 13:37:13 +0000 (15:37 +0200)
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@intel.com>
tests/hwsim/test_p2p_autogo.py
tests/hwsim/wpasupplicant.py

index a3daa78..b359741 100644 (file)
@@ -438,12 +438,13 @@ def test_autogo_bridge(dev):
         if "OK" not in dev[0].request("AUTOSCAN periodic:1"):
             raise Exception("Failed to set autoscan")
         autogo(dev[0])
+        ifname = dev[0].get_group_ifname()
         subprocess.call(['brctl', 'addbr', 'p2p-br0'])
         subprocess.call(['brctl', 'setfd', 'p2p-br0', '0'])
-        subprocess.call(['brctl', 'addif', 'p2p-br0', dev[0].ifname])
+        subprocess.call(['brctl', 'addif', 'p2p-br0', ifname])
         subprocess.call(['ip', 'link', 'set', 'dev', 'p2p-br0', 'up'])
         time.sleep(0.1)
-        subprocess.call(['brctl', 'delif', 'p2p-br0', dev[0].ifname])
+        subprocess.call(['brctl', 'delif', 'p2p-br0', ifname])
         time.sleep(0.1)
         subprocess.call(['ip', 'link', 'set', 'dev', 'p2p-br0', 'down'])
         time.sleep(0.1)
@@ -451,12 +452,12 @@ 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(['brctl', 'delif', 'p2p-br0', dev[0].ifname],
+        subprocess.Popen(['brctl', 'delif', 'p2p-br0', ifname],
                          stderr=open('/dev/null', 'w'))
         subprocess.Popen(['ip', 'link', 'set', 'dev', 'p2p-br0', 'down'],
                          stderr=open('/dev/null', 'w'))
index a7b115c..cbba8c6 100644 (file)
@@ -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