tests: Create new radios for MCC tests

For tests that require a radio with multi-channel concurrency,
create a new one on the fly that does have more than 1 channel.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg 2014-11-27 17:05:20 +01:00 committed by Jouni Malinen
parent 788dc17f8c
commit 7ee6ec7aec

View file

@ -12,6 +12,8 @@ import time
import hostapd import hostapd
import hwsim_utils import hwsim_utils
from wpasupplicant import WpaSupplicant
from hwsim import HWSimRadio
from test_p2p_grpform import go_neg_pin_authorized from test_p2p_grpform import go_neg_pin_authorized
from test_p2p_grpform import check_grpform_results from test_p2p_grpform import check_grpform_results
from test_p2p_grpform import remove_group from test_p2p_grpform import remove_group
@ -238,115 +240,129 @@ def test_go_neg_with_bss_connected(dev, apdev):
def test_autogo_with_bss_on_disallowed_chan(dev, apdev): def test_autogo_with_bss_on_disallowed_chan(dev, apdev):
"""P2P channel selection: Autonomous GO with BSS on a disallowed channel""" """P2P channel selection: Autonomous GO with BSS on a disallowed channel"""
dev[0].request("SET p2p_no_group_iface 0") with HWSimRadio(n_channels=2) as (radio, iface):
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add(iface)
if dev[0].get_mcc() < 2: wpas.request("SET p2p_no_group_iface 0")
logger.info("Skipping test because driver does not support MCC")
return "skip" if wpas.get_mcc() < 2:
try: raise Exception("New radio does not support MCC")
hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz',
"channel": '1' }) try:
dev[0].request("P2P_SET disallow_freq 2412") hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz',
dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412") "channel": '1' })
res = autogo(dev[0]) wpas.request("P2P_SET disallow_freq 2412")
if res['freq'] == "2412": wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
raise Exception("GO set on a disallowed channel") res = autogo(wpas)
hwsim_utils.test_connectivity(dev[0], hapd) if res['freq'] == "2412":
finally: raise Exception("GO set on a disallowed channel")
dev[0].request("P2P_SET disallow_freq ") hwsim_utils.test_connectivity(wpas, hapd)
finally:
wpas.request("P2P_SET disallow_freq ")
def test_go_neg_with_bss_on_disallowed_chan(dev, apdev): def test_go_neg_with_bss_on_disallowed_chan(dev, apdev):
"""P2P channel selection: GO negotiation with station interface on a disallowed channel""" """P2P channel selection: GO negotiation with station interface on a disallowed channel"""
dev[0].request("SET p2p_no_group_iface 0") with HWSimRadio(n_channels=2) as (radio, iface):
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add(iface)
if dev[0].get_mcc() < 2: wpas.request("SET p2p_no_group_iface 0")
logger.info("Skipping test because driver does not support MCC")
return "skip"
try:
hapd = hostapd.add_ap(apdev[0]['ifname'],
{ "ssid": 'bss-2.4ghz', "channel": '1' })
dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
dev[0].request("P2P_SET disallow_freq 2412")
#dev[0] as GO if wpas.get_mcc() < 2:
[i_res, r_res] = go_neg_pbc(i_dev=dev[0], i_intent=10, r_dev=dev[1], raise Exception("New radio does not support MCC")
r_intent=1)
check_grpform_results(i_res, r_res)
if i_res['role'] != "GO":
raise Exception("GO not selected according to go_intent")
if i_res['freq'] == "2412":
raise Exception("Group formed on a disallowed channel")
hwsim_utils.test_connectivity(dev[0], hapd)
dev[0].remove_group(i_res['ifname'])
#dev[0] as client try:
[i_res2, r_res2] = go_neg_pbc(i_dev=dev[0], i_intent=1, r_dev=dev[1], hapd = hostapd.add_ap(apdev[0]['ifname'],
r_intent=10) { "ssid": 'bss-2.4ghz', "channel": '1' })
check_grpform_results(i_res2, r_res2) wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
if i_res2['role'] != "client": wpas.request("P2P_SET disallow_freq 2412")
raise Exception("GO not selected according to go_intent")
if i_res2['freq'] == "2412": #wpas as GO
raise Exception("Group formed on a disallowed channel") [i_res, r_res] = go_neg_pbc(i_dev=wpas, i_intent=10, r_dev=dev[1],
hwsim_utils.test_connectivity(dev[0], hapd) r_intent=1)
finally: check_grpform_results(i_res, r_res)
dev[0].request("P2P_SET disallow_freq ") if i_res['role'] != "GO":
raise Exception("GO not selected according to go_intent")
if i_res['freq'] == "2412":
raise Exception("Group formed on a disallowed channel")
hwsim_utils.test_connectivity(wpas, hapd)
wpas.remove_group(i_res['ifname'])
#wpas as client
[i_res2, r_res2] = go_neg_pbc(i_dev=wpas, i_intent=1, r_dev=dev[1],
r_intent=10)
check_grpform_results(i_res2, r_res2)
if i_res2['role'] != "client":
raise Exception("GO not selected according to go_intent")
if i_res2['freq'] == "2412":
raise Exception("Group formed on a disallowed channel")
hwsim_utils.test_connectivity(wpas, hapd)
finally:
wpas.request("P2P_SET disallow_freq ")
def test_autogo_force_diff_channel(dev, apdev): def test_autogo_force_diff_channel(dev, apdev):
"""P2P autonomous GO and station interface operate on different channels""" """P2P autonomous GO and station interface operate on different channels"""
if dev[0].get_mcc() < 2: with HWSimRadio(n_channels=2) as (radio, iface):
logger.info("Skiping test because the driver doesn't support MCC") wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
return "skip" wpas.interface_add(iface)
dev[0].request("SET p2p_no_group_iface 0") if wpas.get_mcc() < 2:
raise Exception("New radio does not support MCC")
hapd = hostapd.add_ap(apdev[0]['ifname'], wpas.request("SET p2p_no_group_iface 0")
{"ssid" : 'ap-test', "channel" : '1'})
dev[0].connect("ap-test", key_mgmt = "NONE", scan_freq = "2412") hapd = hostapd.add_ap(apdev[0]['ifname'],
channels = { 2 : 2417, 5 : 2432, 9 : 2452 } {"ssid" : 'ap-test', "channel" : '1'})
for key in channels: wpas.connect("ap-test", key_mgmt = "NONE", scan_freq = "2412")
res_go = autogo(dev[0], channels[key]) channels = { 2 : 2417, 5 : 2432, 9 : 2452 }
hwsim_utils.test_connectivity(dev[0], hapd) for key in channels:
if int(res_go['freq']) == 2412: res_go = autogo(wpas, channels[key])
raise Exception("Group operation channel is: 2412 excepted: " + res_go['freq']) hwsim_utils.test_connectivity(wpas, hapd)
dev[0].remove_group(res_go['ifname']) if int(res_go['freq']) == 2412:
raise Exception("Group operation channel is: 2412 excepted: " + res_go['freq'])
wpas.remove_group(res_go['ifname'])
def test_go_neg_forced_freq_diff_than_bss_freq(dev, apdev): def test_go_neg_forced_freq_diff_than_bss_freq(dev, apdev):
"""P2P channel selection: GO negotiation with forced freq different than station interface""" """P2P channel selection: GO negotiation with forced freq different than station interface"""
if dev[0].get_mcc() < 2: with HWSimRadio(n_channels=2) as (radio, iface):
logger.info("Skipping test because driver does not support MCC") wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
return "skip" wpas.interface_add(iface)
dev[0].request("SET p2p_no_group_iface 0") if wpas.get_mcc() < 2:
raise Exception("New radio does not support MCC")
hapd = hostapd.add_ap(apdev[0]['ifname'], wpas.request("SET p2p_no_group_iface 0")
{ "country_code": 'US',
"ssid": 'bss-5ghz', "hw_mode": 'a',
"channel": '40' })
dev[0].connect("bss-5ghz", key_mgmt="NONE", scan_freq="5200")
# GO and peer force the same freq, different than BSS freq, hapd = hostapd.add_ap(apdev[0]['ifname'],
# dev[0] to become GO { "country_code": 'US',
[i_res, r_res] = go_neg_pbc(i_dev=dev[1], i_intent=1, i_freq=5180, "ssid": 'bss-5ghz', "hw_mode": 'a',
r_dev=dev[0], r_intent=14, r_freq=5180) "channel": '40' })
check_grpform_results(i_res, r_res) wpas.connect("bss-5ghz", key_mgmt="NONE", scan_freq="5200")
if i_res['freq'] != "5180":
raise Exception("P2P group formed on unexpected frequency: " + i_res['freq'])
if r_res['role'] != "GO":
raise Exception("GO not selected according to go_intent")
hwsim_utils.test_connectivity(dev[0], hapd)
dev[0].remove_group(r_res['ifname'])
# GO and peer force the same freq, different than BSS freq, dev[0] to # GO and peer force the same freq, different than BSS freq,
# become client # wpas to become GO
[i_res2, r_res2] = go_neg_pbc(i_dev=dev[1], i_intent=14, i_freq=2422, [i_res, r_res] = go_neg_pbc(i_dev=dev[1], i_intent=1, i_freq=5180,
r_dev=dev[0], r_intent=1, r_freq=2422) r_dev=wpas, r_intent=14, r_freq=5180)
check_grpform_results(i_res2, r_res2) check_grpform_results(i_res, r_res)
if i_res2['freq'] != "2422": if i_res['freq'] != "5180":
raise Exception("P2P group formed on unexpected frequency: " + i_res2['freq']) raise Exception("P2P group formed on unexpected frequency: " + i_res['freq'])
if r_res2['role'] != "client": if r_res['role'] != "GO":
raise Exception("GO not selected according to go_intent") raise Exception("GO not selected according to go_intent")
hwsim_utils.test_connectivity(dev[0], hapd) hwsim_utils.test_connectivity(wpas, hapd)
wpas.remove_group(r_res['ifname'])
# GO and peer force the same freq, different than BSS freq, wpas to
# become client
[i_res2, r_res2] = go_neg_pbc(i_dev=dev[1], i_intent=14, i_freq=2422,
r_dev=wpas, r_intent=1, r_freq=2422)
check_grpform_results(i_res2, r_res2)
if i_res2['freq'] != "2422":
raise Exception("P2P group formed on unexpected frequency: " + i_res2['freq'])
if r_res2['role'] != "client":
raise Exception("GO not selected according to go_intent")
hwsim_utils.test_connectivity(wpas, hapd)
def test_go_pref_chan_bss_on_diff_chan(dev, apdev): def test_go_pref_chan_bss_on_diff_chan(dev, apdev):
"""P2P channel selection: Station on different channel than GO configured pref channel""" """P2P channel selection: Station on different channel than GO configured pref channel"""
@ -367,25 +383,28 @@ def test_go_pref_chan_bss_on_diff_chan(dev, apdev):
def test_go_pref_chan_bss_on_disallowed_chan(dev, apdev): def test_go_pref_chan_bss_on_disallowed_chan(dev, apdev):
"""P2P channel selection: Station interface on different channel than GO configured pref channel, and station channel is disallowed""" """P2P channel selection: Station interface on different channel than GO configured pref channel, and station channel is disallowed"""
if dev[0].get_mcc() < 2: with HWSimRadio(n_channels=2) as (radio, iface):
logger.info("Skipping test because driver does not support MCC") wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
return "skip" wpas.interface_add(iface)
dev[0].request("SET p2p_no_group_iface 0") if wpas.get_mcc() < 2:
raise Exception("New radio does not support MCC")
try: wpas.request("SET p2p_no_group_iface 0")
hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz',
"channel": '1' }) try:
dev[0].request("P2P_SET disallow_freq 2412") hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz',
dev[0].request("SET p2p_pref_chan 81:2") "channel": '1' })
dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412") wpas.request("P2P_SET disallow_freq 2412")
res2 = autogo(dev[0]) wpas.request("SET p2p_pref_chan 81:2")
if res2['freq'] != "2417": wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
raise Exception("GO channel did not follow pref_chan configuration") res2 = autogo(wpas)
hwsim_utils.test_connectivity(dev[0], hapd) if res2['freq'] != "2417":
finally: raise Exception("GO channel did not follow pref_chan configuration")
dev[0].request("P2P_SET disallow_freq ") hwsim_utils.test_connectivity(wpas, hapd)
dev[0].request("SET p2p_pref_chan ") finally:
wpas.request("P2P_SET disallow_freq ")
wpas.request("SET p2p_pref_chan ")
def test_no_go_freq(dev, apdev): def test_no_go_freq(dev, apdev):
"""P2P channel selection: no GO freq""" """P2P channel selection: no GO freq"""