[PATCH 3/3] tests: p2p: verify that changing p2p_disabled removes/adds P2P device

Benjamin Berg benjamin at sipsolutions.net
Wed Oct 15 08:44:01 PDT 2025


From: Benjamin Berg <benjamin.berg at intel.com>

Add a test to verify that if p2p_disabled is changed on the (possible)
parent device for a dedicated P2P device, then the dedicated P2P device
is added or removed as appropriate.

Signed-off-by: Benjamin Berg <benjamin.berg at intel.com>
Reviewed-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
Reviewed-by: Ilan Peer <ilan.peer at intel.com>
---
 tests/hwsim/test_p2p_device.py | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/tests/hwsim/test_p2p_device.py b/tests/hwsim/test_p2p_device.py
index 47ca25bdd0..7fb660c318 100644
--- a/tests/hwsim/test_p2p_device.py
+++ b/tests/hwsim/test_p2p_device.py
@@ -604,3 +604,37 @@ def test_p2p_device_persistent_group_go_bssid(dev):
         ev = wpas.wait_global_event(["P2P-GROUP-STARTED"], timeout=30)
         if ev is None:
             raise Exception("Timeout on group restart")
+
+def test_p2p_device_test_dynamic_disable(dev, apdev):
+    """P2P device removal and addition via p2p_disable"""
+    with HWSimRadio(use_p2p_device=True) as (radio, iface):
+        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
+        wpas.interface_add(iface)
+
+        res = dev[0].p2p_start_go()
+        bssid = dev[0].get_group_status_field('bssid')
+
+        wpas.scan_for_bss(bssid, res['freq'])
+        res2 = connect_cli(dev[0], wpas, freq=res['freq'])
+        if not res2['ifname'].startswith('p2p-' + iface):
+            raise Exception("Unexpected group ifname: " + res2['ifname'])
+
+        # connected, disable P2P which will disconnect and remove all interfaces
+        wpas.request(f"SET p2p_disabled 1")
+        interfaces = wpas.request("INTERFACES").split()
+        if len(interfaces) != 1 or interfaces[0] != iface:
+            raise Exception(f'Unexpected interfaces after disablement: {interfaces}')
+
+        wpas.request(f"SET p2p_disabled 0")
+        interfaces = wpas.request("INTERFACES").split()
+        if len(interfaces) != 2:
+            raise Exception(f'Expected two interfaces, got: {interfaces}')
+
+        # connect a second time after re-adding the p2p device
+        wpas.scan_for_bss(bssid, res['freq'])
+        res2 = connect_cli(dev[0], wpas, freq=res['freq'])
+        if not res2['ifname'].startswith('p2p-' + iface):
+            raise Exception("Unexpected group ifname: " + res2['ifname'])
+
+
+        terminate_group(dev[0], wpas)
-- 
2.51.0




More information about the Hostap mailing list