From 0f6fb05d91120622048a84839d186250dcae5cae Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 26 Dec 2016 17:53:07 +0200 Subject: [PATCH] tests: Make hostapd_oom_wpa2_psk catch cases more robustly For some reason, a potential OOM in hostapd_config_read_wpa_psk() and hostapd_derive_psk() were missed in --codecov runs during the main iteration loop. Cover these specific cases with separate instances to avoid missing coverage. Signed-off-by: Jouni Malinen --- tests/hwsim/test_hostapd_oom.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/hwsim/test_hostapd_oom.py b/tests/hwsim/test_hostapd_oom.py index a3c0296bd..ed64fd1bd 100644 --- a/tests/hwsim/test_hostapd_oom.py +++ b/tests/hwsim/test_hostapd_oom.py @@ -50,6 +50,22 @@ def test_hostapd_oom_wpa2_psk(dev, apdev): params['wpa_psk_file'] = 'hostapd.wpa_psk' hostapd_oom_loop(apdev, params) + tests = [ "hostapd_config_read_wpa_psk", "hostapd_derive_psk" ] + for t in tests: + hapd = hostapd.add_ap(apdev[0], { "ssid": "ctrl" }) + hapd.request("TEST_ALLOC_FAIL 1:%s" % t) + try: + hostapd.add_ap(apdev[1], params, timeout=2.5) + raise Exception("Unexpected add_ap() success during OOM") + except Exception, e: + if "Failed to enable hostapd" in str(e): + pass + else: + raise + state = hapd.request('GET_ALLOC_FAIL') + if state != "0:%s" % t: + raise Exception("OOM not triggered") + @remote_compatible def test_hostapd_oom_wpa2_eap(dev, apdev): """hostapd failing to setup WPA2-EAP mode due to OOM"""