]> git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_hostapd_oom.py
tests: Fix ft_psk_key_lifetime_in_memory with new PTK derivation debug
[thirdparty/hostap.git] / tests / hwsim / test_hostapd_oom.py
1 # hostapd and out-of-memory error paths
2 # Copyright (c) 2015, Jouni Malinen
3 #
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
6
7 import logging
8 logger = logging.getLogger()
9
10 import hostapd
11 from utils import HwsimSkip
12
13 def hostapd_oom_loop(apdev, params):
14 hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "ctrl" })
15 hapd_global = hostapd.HostapdGlobal()
16
17 count = 0
18 for i in range(1, 1000):
19 if "OK" not in hapd.request("TEST_ALLOC_FAIL %d:main" % i):
20 raise HwsimSkip("TEST_ALLOC_FAIL not supported")
21 try:
22 hostapd.add_ap(apdev[1]['ifname'], params)
23 logger.info("Iteration %d - success" % i)
24 hapd_global.remove(apdev[1]['ifname'])
25
26 state = hapd.request('GET_ALLOC_FAIL')
27 logger.info("GET_ALLOC_FAIL: " + state)
28 hapd.request("TEST_ALLOC_FAIL 0:")
29 if i < 3:
30 raise Exception("AP setup succeeded during out-of-memory")
31 if not state.startswith('0:'):
32 count += 1
33 if count == 5:
34 break
35 except Exception, e:
36 logger.info("Iteration %d - %s" % (i, str(e)))
37
38 def test_hostapd_oom_open(dev, apdev):
39 """hostapd failing to setup open mode due to OOM"""
40 params = { "ssid": "open" }
41 hostapd_oom_loop(apdev, params)
42
43 def test_hostapd_oom_wpa2_psk(dev, apdev):
44 """hostapd failing to setup WPA2-PSK mode due to OOM"""
45 params = hostapd.wpa2_params(ssid="test", passphrase="12345678")
46 params['wpa_psk_file'] = 'hostapd.wpa_psk'
47 hostapd_oom_loop(apdev, params)
48
49 def test_hostapd_oom_wpa2_eap(dev, apdev):
50 """hostapd failing to setup WPA2-EAP mode due to OOM"""
51 params = hostapd.wpa2_eap_params(ssid="test")
52 params['acct_server_addr'] = "127.0.0.1"
53 params['acct_server_port'] = "1813"
54 params['acct_server_shared_secret'] = "radius"
55 hostapd_oom_loop(apdev, params)