tests: Verify P2P operations with a separate group interface
This extends P2P test coverage to include the case of separate group interface use with autonomous GO and group formation through GO negotiation. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
158b090cda
commit
19ae1d0788
4 changed files with 144 additions and 2 deletions
|
@ -12,6 +12,7 @@ import logging
|
|||
logger = logging.getLogger()
|
||||
|
||||
import hwsim_utils
|
||||
import utils
|
||||
from wlantest import Wlantest
|
||||
|
||||
def autogo(go, freq=None):
|
||||
|
@ -24,16 +25,74 @@ def connect_cli(go, client):
|
|||
logger.info("Try to connect the client to the GO")
|
||||
pin = client.wps_read_pin()
|
||||
go.p2p_go_authorize_client(pin)
|
||||
client.p2p_connect_group(go.p2p_dev_addr(), pin, timeout=60)
|
||||
res = client.p2p_connect_group(go.p2p_dev_addr(), pin, timeout=60)
|
||||
logger.info("Client connected")
|
||||
hwsim_utils.test_connectivity_p2p(go, client)
|
||||
return res
|
||||
|
||||
def test_autogo(dev):
|
||||
"""P2P autonomous GO and client joining group"""
|
||||
autogo(dev[0])
|
||||
res = autogo(dev[0])
|
||||
if "p2p-wlan" in res['ifname']:
|
||||
raise Exception("Unexpected group interface name on GO")
|
||||
res = connect_cli(dev[0], dev[1])
|
||||
if "p2p-wlan" in res['ifname']:
|
||||
raise Exception("Unexpected group interface name on client")
|
||||
dev[0].remove_group()
|
||||
dev[1].wait_go_ending_session()
|
||||
|
||||
def test_autogo2(dev):
|
||||
"""P2P autonomous GO with a separate group interface and client joining group"""
|
||||
dev[0].request("SET p2p_no_group_iface 0")
|
||||
res = autogo(dev[0])
|
||||
if "p2p-wlan" not in res['ifname']:
|
||||
raise Exception("Unexpected group interface name on GO")
|
||||
if res['ifname'] not in utils.get_ifnames():
|
||||
raise Exception("Could not find group interface netdev")
|
||||
connect_cli(dev[0], dev[1])
|
||||
dev[0].remove_group()
|
||||
dev[1].wait_go_ending_session()
|
||||
if res['ifname'] in utils.get_ifnames():
|
||||
raise Exception("Group interface netdev was not removed")
|
||||
|
||||
def test_autogo3(dev):
|
||||
"""P2P autonomous GO and client with a separate group interface joining group"""
|
||||
dev[1].request("SET p2p_no_group_iface 0")
|
||||
autogo(dev[0])
|
||||
res = connect_cli(dev[0], dev[1])
|
||||
if "p2p-wlan" not in res['ifname']:
|
||||
raise Exception("Unexpected group interface name on client")
|
||||
if res['ifname'] not in utils.get_ifnames():
|
||||
raise Exception("Could not find group interface netdev")
|
||||
dev[0].remove_group()
|
||||
dev[1].wait_go_ending_session()
|
||||
dev[1].ping()
|
||||
if res['ifname'] in utils.get_ifnames():
|
||||
raise Exception("Group interface netdev was not removed")
|
||||
|
||||
def test_autogo4(dev):
|
||||
"""P2P autonomous GO and client joining group (both with a separate group interface)"""
|
||||
dev[0].request("SET p2p_no_group_iface 0")
|
||||
dev[1].request("SET p2p_no_group_iface 0")
|
||||
res1 = autogo(dev[0])
|
||||
res2 = connect_cli(dev[0], dev[1])
|
||||
if "p2p-wlan" not in res1['ifname']:
|
||||
raise Exception("Unexpected group interface name on GO")
|
||||
if "p2p-wlan" not in res2['ifname']:
|
||||
raise Exception("Unexpected group interface name on client")
|
||||
ifnames = utils.get_ifnames()
|
||||
if res1['ifname'] not in ifnames:
|
||||
raise Exception("Could not find GO group interface netdev")
|
||||
if res2['ifname'] not in ifnames:
|
||||
raise Exception("Could not find client group interface netdev")
|
||||
dev[0].remove_group()
|
||||
dev[1].wait_go_ending_session()
|
||||
dev[1].ping()
|
||||
ifnames = utils.get_ifnames()
|
||||
if res1['ifname'] in ifnames:
|
||||
raise Exception("GO group interface netdev was not removed")
|
||||
if res2['ifname'] in ifnames:
|
||||
raise Exception("Client group interface netdev was not removed")
|
||||
|
||||
def test_autogo_2cli(dev):
|
||||
"""P2P autonomous GO and two clients joining group"""
|
||||
|
|
|
@ -13,6 +13,7 @@ import threading
|
|||
import Queue
|
||||
|
||||
import hwsim_utils
|
||||
import utils
|
||||
|
||||
def check_grpform_results(i_res, r_res):
|
||||
if i_res['result'] != 'success' or r_res['result'] != 'success':
|
||||
|
@ -62,6 +63,7 @@ def go_neg_pin(i_dev, r_dev, i_intent=None, r_intent=None, i_method='enter', r_m
|
|||
logger.info("Group formed")
|
||||
hwsim_utils.test_connectivity_p2p(r_dev, i_dev)
|
||||
i_dev.dump_monitor()
|
||||
return [i_res, r_res]
|
||||
|
||||
def go_neg_pin_authorized(i_dev, r_dev, i_intent=None, r_intent=None, expect_failure=False, i_go_neg_status=None, i_method='enter', r_method='display', test_data=True, i_freq=None, r_freq=None):
|
||||
r_dev.p2p_listen()
|
||||
|
@ -132,16 +134,79 @@ def test_grpform(dev):
|
|||
check_grpform_results(i_res, r_res)
|
||||
remove_group(dev[0], dev[1])
|
||||
|
||||
def test_grpform_a(dev):
|
||||
"""P2P group formation using PIN and authorized connection (init -> GO) (init: group iface)"""
|
||||
dev[0].request("SET p2p_no_group_iface 0")
|
||||
[i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
|
||||
r_dev=dev[1], r_intent=0)
|
||||
if "p2p-wlan" not in i_res['ifname']:
|
||||
raise Exception("Unexpected group interface name")
|
||||
check_grpform_results(i_res, r_res)
|
||||
remove_group(dev[0], dev[1])
|
||||
if i_res['ifname'] in utils.get_ifnames():
|
||||
raise Exception("Group interface netdev was not removed")
|
||||
|
||||
def test_grpform_b(dev):
|
||||
"""P2P group formation using PIN and authorized connection (init -> GO) (resp: group iface)"""
|
||||
dev[1].request("SET p2p_no_group_iface 0")
|
||||
[i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
|
||||
r_dev=dev[1], r_intent=0)
|
||||
if "p2p-wlan" not in r_res['ifname']:
|
||||
raise Exception("Unexpected group interface name")
|
||||
check_grpform_results(i_res, r_res)
|
||||
remove_group(dev[0], dev[1])
|
||||
if r_res['ifname'] in utils.get_ifnames():
|
||||
raise Exception("Group interface netdev was not removed")
|
||||
|
||||
def test_grpform_c(dev):
|
||||
"""P2P group formation using PIN and authorized connection (init -> GO) (group iface)"""
|
||||
dev[0].request("SET p2p_no_group_iface 0")
|
||||
dev[1].request("SET p2p_no_group_iface 0")
|
||||
[i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
|
||||
r_dev=dev[1], r_intent=0)
|
||||
if "p2p-wlan" not in i_res['ifname']:
|
||||
raise Exception("Unexpected group interface name")
|
||||
if "p2p-wlan" not in r_res['ifname']:
|
||||
raise Exception("Unexpected group interface name")
|
||||
check_grpform_results(i_res, r_res)
|
||||
remove_group(dev[0], dev[1])
|
||||
if i_res['ifname'] in utils.get_ifnames():
|
||||
raise Exception("Group interface netdev was not removed")
|
||||
if r_res['ifname'] in utils.get_ifnames():
|
||||
raise Exception("Group interface netdev was not removed")
|
||||
|
||||
def test_grpform2(dev):
|
||||
"""P2P group formation using PIN and authorized connection (resp -> GO)"""
|
||||
go_neg_pin_authorized(i_dev=dev[0], i_intent=0, r_dev=dev[1], r_intent=15)
|
||||
remove_group(dev[0], dev[1])
|
||||
|
||||
def test_grpform2_c(dev):
|
||||
"""P2P group formation using PIN and authorized connection (resp -> GO) (group iface)"""
|
||||
dev[0].request("SET p2p_no_group_iface 0")
|
||||
dev[1].request("SET p2p_no_group_iface 0")
|
||||
[i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0, r_dev=dev[1], r_intent=15)
|
||||
remove_group(dev[0], dev[1])
|
||||
if i_res['ifname'] in utils.get_ifnames():
|
||||
raise Exception("Group interface netdev was not removed")
|
||||
if r_res['ifname'] in utils.get_ifnames():
|
||||
raise Exception("Group interface netdev was not removed")
|
||||
|
||||
def test_grpform3(dev):
|
||||
"""P2P group formation using PIN and re-init GO Negotiation"""
|
||||
go_neg_pin(i_dev=dev[0], i_intent=15, r_dev=dev[1], r_intent=0)
|
||||
remove_group(dev[0], dev[1])
|
||||
|
||||
def test_grpform3_c(dev):
|
||||
"""P2P group formation using PIN and re-init GO Negotiation (group iface)"""
|
||||
dev[0].request("SET p2p_no_group_iface 0")
|
||||
dev[1].request("SET p2p_no_group_iface 0")
|
||||
[i_res, r_res] = go_neg_pin(i_dev=dev[0], i_intent=15, r_dev=dev[1], r_intent=0)
|
||||
remove_group(dev[0], dev[1])
|
||||
if i_res['ifname'] in utils.get_ifnames():
|
||||
raise Exception("Group interface netdev was not removed")
|
||||
if r_res['ifname'] in utils.get_ifnames():
|
||||
raise Exception("Group interface netdev was not removed")
|
||||
|
||||
def test_grpform_pbc(dev):
|
||||
"""P2P group formation using PBC and re-init GO Negotiation"""
|
||||
dev[0].request("SET ignore_old_scan_res 1")
|
||||
|
|
17
tests/hwsim/utils.py
Normal file
17
tests/hwsim/utils.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Testing utilities
|
||||
# Copyright (c) 2013, Jouni Malinen <j@w1.fi>
|
||||
#
|
||||
# This software may be distributed under the terms of the BSD license.
|
||||
# See README for more details.
|
||||
|
||||
def get_ifnames():
|
||||
ifnames = []
|
||||
with open("/proc/net/dev", "r") as f:
|
||||
lines = f.readlines()
|
||||
for l in lines:
|
||||
val = l.split(':', 1)
|
||||
if len(val) == 2:
|
||||
ifnames.append(val[0].strip(' '))
|
||||
return ifnames
|
|
@ -61,6 +61,7 @@ class WpaSupplicant:
|
|||
self.request("SET p2p_no_go_freq ")
|
||||
self.request("SET p2p_pref_chan ")
|
||||
self.request("SET disallow_aps ")
|
||||
self.request("SET p2p_no_group_iface 1")
|
||||
self.request("P2P_SET per_sta_psk 0")
|
||||
self.request("P2P_SET disabled 0")
|
||||
self.request("P2P_SERVICE_FLUSH")
|
||||
|
|
Loading…
Reference in a new issue