tests: More wpa_supplicant/bss.c OOM coverage

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2016-06-17 20:41:09 +03:00 committed by Jouni Malinen
parent 4425b1ed71
commit 20c7d26f80
4 changed files with 71 additions and 2 deletions

View file

@ -17,7 +17,7 @@ import socket
import subprocess import subprocess
import hostapd import hostapd
from utils import HwsimSkip, skip_with_fips from utils import HwsimSkip, skip_with_fips, alloc_fail
import hwsim_utils import hwsim_utils
from tshark import run_tshark from tshark import run_tshark
from wlantest import Wlantest from wlantest import Wlantest
@ -212,6 +212,37 @@ def test_ap_anqp_sharing(dev, apdev):
if res1['anqp_nai_realm'] == res2['anqp_nai_realm']: if res1['anqp_nai_realm'] == res2['anqp_nai_realm']:
raise Exception("ANQP results were not unshared") raise Exception("ANQP results were not unshared")
def test_ap_anqp_sharing_oom(dev, apdev):
"""ANQP sharing within ESS and explicit unshare OOM"""
check_eap_capa(dev[0], "MSCHAPV2")
dev[0].flush_scan_cache()
bssid = apdev[0]['bssid']
params = hs20_ap_params()
params['hessid'] = bssid
hostapd.add_ap(apdev[0], params)
bssid2 = apdev[1]['bssid']
params = hs20_ap_params()
params['hessid'] = bssid
params['nai_realm'] = [ "0,example.com,13[5:6],21[2:4][5:7]" ]
hostapd.add_ap(apdev[1], params)
dev[0].hs20_enable()
id = dev[0].add_cred_values({ 'realm': "example.com", 'username': "test",
'password': "secret",
'domain': "example.com" })
dev[0].scan_for_bss(bssid, freq="2412")
dev[0].scan_for_bss(bssid2, freq="2412")
interworking_select(dev[0], None, "home", freq="2412")
dev[0].dump_monitor()
with alloc_fail(dev[0], 1, "wpa_bss_anqp_clone"):
dev[0].request("ANQP_GET " + bssid + " 263")
ev = dev[0].wait_event(["RX-ANQP"], timeout=5)
if ev is None:
raise Exception("ANQP operation timed out")
def test_ap_nai_home_realm_query(dev, apdev): def test_ap_nai_home_realm_query(dev, apdev):
"""NAI Home Realm Query""" """NAI Home Realm Query"""
check_eap_capa(dev[0], "MSCHAPV2") check_eap_capa(dev[0], "MSCHAPV2")

View file

@ -492,6 +492,13 @@ def test_dbus_wps_oom(dev, apdev):
with alloc_fail_dbus(dev[0], 1, "=wpas_dbus_getter_bss_rates", "Get"): with alloc_fail_dbus(dev[0], 1, "=wpas_dbus_getter_bss_rates", "Get"):
bss_obj.Get(WPAS_DBUS_BSS, "Rates", bss_obj.Get(WPAS_DBUS_BSS, "Rates",
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
with alloc_fail(dev[0], 1,
"wpa_bss_get_bit_rates;wpas_dbus_getter_bss_rates"):
try:
bss_obj.Get(WPAS_DBUS_BSS, "Rates",
dbus_interface=dbus.PROPERTIES_IFACE)
except dbus.exceptions.DBusException, e:
pass
id = dev[0].add_network() id = dev[0].add_network()
dev[0].set_network(id, "disabled", "0") dev[0].set_network(id, "disabled", "0")

View file

@ -16,7 +16,7 @@ import struct
import hostapd import hostapd
from wpasupplicant import WpaSupplicant from wpasupplicant import WpaSupplicant
from tshark import run_tshark from tshark import run_tshark
from utils import alloc_fail, skip_with_fips from utils import alloc_fail, wait_fail_trigger, skip_with_fips
from hwsim import HWSimRadio from hwsim import HWSimRadio
def hs20_ap_params(): def hs20_ap_params():
@ -918,6 +918,13 @@ def test_gas_anqp_oom_wpas(dev, apdev):
dev[0].scan_for_bss(bssid, freq="2412", force_scan=True) dev[0].scan_for_bss(bssid, freq="2412", force_scan=True)
with alloc_fail(dev[0], 1, "wpa_bss_anqp_alloc"):
if "OK" not in dev[0].request("ANQP_GET " + bssid + " 258"):
raise Exception("ANQP_GET command failed")
ev = dev[0].wait_event(["ANQP-QUERY-DONE"], timeout=5)
if ev is None:
raise Exception("ANQP query did not complete")
with alloc_fail(dev[0], 1, "gas_build_req"): with alloc_fail(dev[0], 1, "gas_build_req"):
if "FAIL" not in dev[0].request("ANQP_GET " + bssid + " 258"): if "FAIL" not in dev[0].request("ANQP_GET " + bssid + " 258"):
raise Exception("Unexpected ANQP_GET command success (OOM)") raise Exception("Unexpected ANQP_GET command success (OOM)")

View file

@ -1092,6 +1092,10 @@ def test_scan_fail(dev, apdev):
wpas.request("SET preassoc_mac_addr 0") wpas.request("SET preassoc_mac_addr 0")
wpas.dump_monitor() wpas.dump_monitor()
hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
with alloc_fail(dev[0], 1, "wpa_bss_add"):
dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412")
def test_scan_freq_list(dev, apdev): def test_scan_freq_list(dev, apdev):
"""Scan with SET freq_list and scan_cur_freq""" """Scan with SET freq_list and scan_cur_freq"""
try: try:
@ -1111,3 +1115,23 @@ def test_scan_freq_list(dev, apdev):
dev[0].request("SET scan_cur_freq 0") dev[0].request("SET scan_cur_freq 0")
dev[0].request("REMOVE_NETWORK all") dev[0].request("REMOVE_NETWORK all")
dev[0].wait_disconnected() dev[0].wait_disconnected()
def test_scan_bss_limit(dev, apdev):
"""Scan and wpa_supplicant BSS entry limit"""
try:
_test_scan_bss_limit(dev, apdev)
finally:
dev[0].request("SET bss_max_count 200")
pass
def _test_scan_bss_limit(dev, apdev):
# Trigger 'Increasing the MAX BSS count to 2 because all BSSes are in use.
# We should normally not get here!' message by limiting the maximum BSS
# count to one so that the second AP would not fit in the BSS list and the
# first AP cannot be removed from the list since it is still in use.
dev[0].request("SET bss_max_count 1")
hapd = hostapd.add_ap(apdev[0], { "ssid": "test-scan" })
dev[0].connect("test-scan", key_mgmt="NONE", scan_freq="2412")
hapd2 = hostapd.add_ap(apdev[1], { "ssid": "test-scan-2",
"channel": "6" })
dev[0].scan_for_bss(apdev[1]['bssid'], freq=2437, force_scan=True)