tests: Memory allocation failure in wpa_supplicant blacklist

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2015-01-05 22:00:22 +02:00
parent 81e787b750
commit f12240a371
2 changed files with 21 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import time
import hostapd
from wpasupplicant import WpaSupplicant
from utils import alloc_fail
def test_wpas_ctrl_network(dev):
"""wpa_supplicant ctrl_iface network set/get"""
@ -896,6 +897,12 @@ def test_wpas_ctrl_blacklist(dev):
if dev[0].request("BLACKLIST") != "":
raise Exception("Unexpected blacklist contents")
def test_wpas_ctrl_blacklist_oom(dev):
"""wpa_supplicant ctrl_iface BLACKLIST and out-of-memory"""
with alloc_fail(dev[0], 1, "wpa_blacklist_add"):
if "FAIL" not in dev[0].request("BLACKLIST aa:bb:cc:dd:ee:ff"):
raise Exception("Unexpected success with allocation failure")
def test_wpas_ctrl_log_level(dev):
"""wpa_supplicant ctrl_iface LOG_LEVEL"""
level = dev[2].request("LOG_LEVEL")

View File

@ -19,3 +19,17 @@ class HwsimSkip(Exception):
self.reason = reason
def __str__(self):
return self.reason
class alloc_fail(object):
def __init__(self, dev, count, funcs):
self._dev = dev
self._count = count
self._funcs = funcs
def __enter__(self):
cmd = "TEST_ALLOC_FAIL %d:%s" % (self._count, self._funcs)
if "OK" not in self._dev.request(cmd):
raise HwsimSkip("TEST_ALLOC_FAIL not supported")
def __exit__(self, type, value, traceback):
if type is None:
if self._dev.request("GET_ALLOC_FAIL") != "0:%s" % self._funcs:
raise Exception("Allocation failure did not trigger")