import hostapd
from wpasupplicant import WpaSupplicant
+from utils import alloc_fail
def test_wpas_ctrl_network(dev):
"""wpa_supplicant ctrl_iface network set/get"""
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")
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")