]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Make hostapd_oom_wpa2_psk catch cases more robustly
authorJouni Malinen <j@w1.fi>
Mon, 26 Dec 2016 15:53:07 +0000 (17:53 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 26 Dec 2016 16:24:05 +0000 (18:24 +0200)
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 <j@w1.fi>
tests/hwsim/test_hostapd_oom.py

index a3c0296bd3447fac1815abaea1d6ad2433a2baad..ed64fd1bd0c51872a0581f88a97cb51dc0d222fc 100644 (file)
@@ -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"""