diff --git a/tests/hwsim/test_wpas_ctrl.py b/tests/hwsim/test_wpas_ctrl.py index 12f14a505..6fc6e64d4 100644 --- a/tests/hwsim/test_wpas_ctrl.py +++ b/tests/hwsim/test_wpas_ctrl.py @@ -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") diff --git a/tests/hwsim/utils.py b/tests/hwsim/utils.py index a763a259c..cd71365ba 100644 --- a/tests/hwsim/utils.py +++ b/tests/hwsim/utils.py @@ -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")