diff mbox

[06/16] tests: Modify test_auto_m2d waiting for WPS-M2D

Message ID 1434547502-7475-7-git-send-email-ilan.peer@intel.com
State Changes Requested
Headers show

Commit Message

Peer, Ilan June 17, 2015, 1:24 p.m. UTC
In case a dedicated P2P Device interface is used,
the test needs to wait on the group interface, but since
a group is not formed, the wpasupplicant object does not
have the group interface name so it waits on the wrong
interface for the event.

Fix this by explicitly waiting on the right interface,
based on the driver capabilities.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
---
 tests/hwsim/test_p2p_autogo.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Jouni Malinen June 19, 2015, 7:58 a.m. UTC | #1
On Wed, Jun 17, 2015 at 04:24:52PM +0300, Ilan Peer wrote:
> In case a dedicated P2P Device interface is used,
> the test needs to wait on the group interface, but since
> a group is not formed, the wpasupplicant object does not
> have the group interface name so it waits on the wrong
> interface for the event.
> 
> Fix this by explicitly waiting on the right interface,
> based on the driver capabilities.

This looks pretty suspicious..

> diff --git a/tests/hwsim/test_p2p_autogo.py b/tests/hwsim/test_p2p_autogo.py
> @@ -186,7 +186,16 @@ def test_autogo_m2d(dev):
>      ev = dev[2].wait_global_event(["WPS-M2D"], timeout=10)
>      if ev is None:
>          raise Exception("No global M2D event (2)")
> -    ev = dev[2].wait_event(["WPS-M2D"], timeout=10)

I don't think it would be a good idea to get rid of that design in
non-P2P Device interface case (i.e., the default behavior for the hwsim
tests).

> +    ifaces = dev[2].request("INTERFACES").splitlines()
> +    res = dev[2].get_driver_status()
> +    if (int(res['capa.flags'], 0) & 0x20000000):
> +        iface = ifaces[0] if "p2p-wlan" in ifaces[0] else ifaces[1]
> +    else:
> +        iface = ifaces[0]
> +
> +    wpas = WpaSupplicant(ifname=iface)
> +    ev = wpas.wait_event(["WPS-M2D"], timeout=10)

And this opening of a new WpaSupplicant instance would not work properly
since it would not have queued the WPS-M2D event that would have already
happened by this code is run. The wpa_supplicant control interface
monitor needs to be already running at the time the command that
generates an event is issued. You might be able to catch the second
WPS-M2D event later, but that would add more latency here unnecessarily.
Peer, Ilan June 21, 2015, 1:54 p.m. UTC | #2
> -----Original Message-----
> From: Jouni Malinen [mailto:j@w1.fi]
> Sent: Friday, June 19, 2015 10:58
> To: Peer, Ilan
> Cc: hostap@lists.shmoo.com
> Subject: Re: [PATCH 06/16] tests: Modify test_auto_m2d waiting for WPS-
> M2D
> 
> On Wed, Jun 17, 2015 at 04:24:52PM +0300, Ilan Peer wrote:
> > In case a dedicated P2P Device interface is used, the test needs to
> > wait on the group interface, but since a group is not formed, the
> > wpasupplicant object does not have the group interface name so it
> > waits on the wrong interface for the event.
> >
> > Fix this by explicitly waiting on the right interface, based on the
> > driver capabilities.
> 
> This looks pretty suspicious..
> 
> > diff --git a/tests/hwsim/test_p2p_autogo.py
> > b/tests/hwsim/test_p2p_autogo.py @@ -186,7 +186,16 @@ def
> test_autogo_m2d(dev):
> >      ev = dev[2].wait_global_event(["WPS-M2D"], timeout=10)
> >      if ev is None:
> >          raise Exception("No global M2D event (2)")
> > -    ev = dev[2].wait_event(["WPS-M2D"], timeout=10)
> 
> I don't think it would be a good idea to get rid of that design in non-P2P
> Device interface case (i.e., the default behavior for the hwsim tests).
> 

I can handle this based on driver capabilities as below. 

> > +    ifaces = dev[2].request("INTERFACES").splitlines()
> > +    res = dev[2].get_driver_status()
> > +    if (int(res['capa.flags'], 0) & 0x20000000):
> > +        iface = ifaces[0] if "p2p-wlan" in ifaces[0] else ifaces[1]
> > +    else:
> > +        iface = ifaces[0]
> > +
> > +    wpas = WpaSupplicant(ifname=iface)
> > +    ev = wpas.wait_event(["WPS-M2D"], timeout=10)
> 
> And this opening of a new WpaSupplicant instance would not work properly
> since it would not have queued the WPS-M2D event that would have already
> happened by this code is run. The wpa_supplicant control interface monitor
> needs to be already running at the time the command that generates an event
> is issued. You might be able to catch the second WPS-M2D event later, but
> that would add more latency here unnecessarily.
> 

The delay is 1, as in the case of dev[1] (I only copied the same design used for it) so I considered it as ok. 

I can skip this test for case of the P2P Device interface ... it's the previous patch I'm more interested with :)

Regards,

Ilan.
diff mbox

Patch

diff --git a/tests/hwsim/test_p2p_autogo.py b/tests/hwsim/test_p2p_autogo.py
index 50ef071..2f27f09 100644
--- a/tests/hwsim/test_p2p_autogo.py
+++ b/tests/hwsim/test_p2p_autogo.py
@@ -186,7 +186,16 @@  def test_autogo_m2d(dev):
     ev = dev[2].wait_global_event(["WPS-M2D"], timeout=10)
     if ev is None:
         raise Exception("No global M2D event (2)")
-    ev = dev[2].wait_event(["WPS-M2D"], timeout=10)
+
+    ifaces = dev[2].request("INTERFACES").splitlines()
+    res = dev[2].get_driver_status()
+    if (int(res['capa.flags'], 0) & 0x20000000):
+        iface = ifaces[0] if "p2p-wlan" in ifaces[0] else ifaces[1]
+    else:
+        iface = ifaces[0]
+
+    wpas = WpaSupplicant(ifname=iface)
+    ev = wpas.wait_event(["WPS-M2D"], timeout=10)
     if ev is None:
         raise Exception("No M2D event on group interface (2)")