diff mbox series

[v2,2/2] tests: Test p2p_long_listen longer than remain-on-channel

Message ID 20200103211852.2187595-3-benjamin@sipsolutions.net
State Accepted
Headers show
Series wpa_supplicant: Always use global p2p_long_listen | expand

Commit Message

Benjamin Berg Jan. 3, 2020, 9:18 p.m. UTC
From: Benjamin Berg <bberg@redhat.com>

This tests an error, where the p2p_long_listen information from the
wrong device was used internally in wpa_supplicant. Note that to test
the hwsim option support_p2p_device needs to be enabled.

Signed-off-by: Benjamin Berg <bberg@redhat.com>
---
 tests/hwsim/start.sh              |  2 +-
 tests/hwsim/test_p2p_discovery.py | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

Comments

Johannes Berg Jan. 4, 2020, 10:03 p.m. UTC | #1
On Fri, 2020-01-03 at 22:18 +0100, Benjamin Berg wrote:
> From: Benjamin Berg <bberg@redhat.com>
> 
> This tests an error, where the p2p_long_listen information from the
> wrong device was used internally in wpa_supplicant. Note that to test
> the hwsim option support_p2p_device needs to be enabled.
> 
> Signed-off-by: Benjamin Berg <bberg@redhat.com>
> ---
>  tests/hwsim/start.sh              |  2 +-
>  tests/hwsim/test_p2p_discovery.py | 12 ++++++++++++
>  2 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/hwsim/start.sh b/tests/hwsim/start.sh
> index 7a26d2825..e3a1a4a19 100755
> --- a/tests/hwsim/start.sh
> +++ b/tests/hwsim/start.sh
> @@ -110,7 +110,7 @@ else
>  	NUM_CH=1
>  fi
>  
> -test -f /proc/modules && sudo modprobe mac80211_hwsim radios=7 channels=$NUM_CH support_p2p_device=0 dyndbg=+p
> +test -f /proc/modules && sudo modprobe mac80211_hwsim radios=7 channels=$NUM_CH support_p2p_device=1 dyndbg=+p

I'm not sure you really should change the default for this.

However, you *can* create a (temporary) hwsim radio with hwsim netlink
(there's a class for that somewhere in the tests) using the
HWSIM_ATTR_SUPPORT_P2P_DEVICE attribute, so you could do that for this
particular test.

johannes
Jouni Malinen Jan. 4, 2020, 10:10 p.m. UTC | #2
On Sat, Jan 04, 2020 at 11:03:13PM +0100, Johannes Berg wrote:
> On Fri, 2020-01-03 at 22:18 +0100, Benjamin Berg wrote:
> > diff --git a/tests/hwsim/start.sh b/tests/hwsim/start.sh
> > -test -f /proc/modules && sudo modprobe mac80211_hwsim radios=7 channels=$NUM_CH support_p2p_device=0 dyndbg=+p
> > +test -f /proc/modules && sudo modprobe mac80211_hwsim radios=7 channels=$NUM_CH support_p2p_device=1 dyndbg=+p
> 
> I'm not sure you really should change the default for this.

No, that would apply to all existing test cases and would result in
reduced testing coverage. In addition, this would not actually apply at
all to any testing done in VMs since module parameters are set in
vm/vm-run.sh for that.

> However, you *can* create a (temporary) hwsim radio with hwsim netlink
> (there's a class for that somewhere in the tests) using the
> HWSIM_ATTR_SUPPORT_P2P_DEVICE attribute, so you could do that for this
> particular test.

That's exactly what I changes this test case to do after noticing it was
passing for me (in a VM..) without patch 1/2 applied. In other words,
both patches are now applied.
Benjamin Berg Jan. 5, 2020, 10:05 a.m. UTC | #3
Hi,

On Sun, 2020-01-05 at 00:10 +0200, Jouni Malinen wrote:
> On Sat, Jan 04, 2020 at 11:03:13PM +0100, Johannes Berg wrote:
> > On Fri, 2020-01-03 at 22:18 +0100, Benjamin Berg wrote:
> > However, you *can* create a (temporary) hwsim radio with hwsim netlink
> > (there's a class for that somewhere in the tests) using the
> > HWSIM_ATTR_SUPPORT_P2P_DEVICE attribute, so you could do that for this
> > particular test.
> 
> That's exactly what I changes this test case to do after noticing it was
> passing for me (in a VM..) without patch 1/2 applied. In other words,
> both patches are now applied.

Aha! Thanks for fixing that up and doing a follow up cleanup to move
the variable.

Benjamin
diff mbox series

Patch

diff --git a/tests/hwsim/start.sh b/tests/hwsim/start.sh
index 7a26d2825..e3a1a4a19 100755
--- a/tests/hwsim/start.sh
+++ b/tests/hwsim/start.sh
@@ -110,7 +110,7 @@  else
 	NUM_CH=1
 fi
 
-test -f /proc/modules && sudo modprobe mac80211_hwsim radios=7 channels=$NUM_CH support_p2p_device=0 dyndbg=+p
+test -f /proc/modules && sudo modprobe mac80211_hwsim radios=7 channels=$NUM_CH support_p2p_device=1 dyndbg=+p
 
 sudo ifconfig hwsim0 up
 sudo $WLANTEST -i hwsim0 -n $LOGDIR/hwsim0.pcapng -c -dtN -L $LOGDIR/hwsim0 &
diff --git a/tests/hwsim/test_p2p_discovery.py b/tests/hwsim/test_p2p_discovery.py
index 5f9f6c940..b26e28390 100644
--- a/tests/hwsim/test_p2p_discovery.py
+++ b/tests/hwsim/test_p2p_discovery.py
@@ -654,6 +654,18 @@  def test_discovery_long_listen(dev):
     dev[1].p2p_stop_find()
     wpas.p2p_stop_find()
 
+def test_discovery_long_listen2(dev):
+    """Long P2P_LISTEN longer than remain-on-channel time"""
+    addr0 = dev[0].p2p_dev_addr()
+    dev[0].request("P2P_LISTEN 15")
+
+    # Wait for remain maximum remain-on-channel time to pass
+    time.sleep(7)
+
+    if not dev[1].discover_peer(addr0):
+        raise Exception("Device discovery timed out")
+    dev[1].p2p_stop_find()
+
 def pd_test(dev, addr):
     if not dev.discover_peer(addr, freq=2412):
         raise Exception("Device discovery timed out")