]> git.ipfire.org Git - thirdparty/hostap.git/blame - tests/hwsim/test_ap_roam.py
tests: Pass wpas/hapd instance to test_connectivity()
[thirdparty/hostap.git] / tests / hwsim / test_ap_roam.py
CommitLineData
5126138c
JM
1# Roaming tests
2# Copyright (c) 2013, Jouni Malinen <j@w1.fi>
3#
4# This software may be distributed under the terms of the BSD license.
5# See README for more details.
6
7import time
8import subprocess
9import logging
c9aa4308 10logger = logging.getLogger()
5126138c
JM
11
12import hwsim_utils
13import hostapd
14
ae3ad328 15def test_ap_roam_open(dev, apdev):
5126138c 16 """Roam between two open APs"""
a8375c94 17 hapd0 = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
5126138c 18 dev[0].connect("test-open", key_mgmt="NONE")
a8375c94
JM
19 hwsim_utils.test_connectivity(dev[0], hapd0)
20 hapd1 = hostapd.add_ap(apdev[1]['ifname'], { "ssid": "test-open" })
5126138c 21 dev[0].scan(type="ONLY")
ae3ad328 22 dev[0].roam(apdev[1]['bssid'])
a8375c94 23 hwsim_utils.test_connectivity(dev[0], hapd1)
ae3ad328 24 dev[0].roam(apdev[0]['bssid'])
a8375c94 25 hwsim_utils.test_connectivity(dev[0], hapd0)
5126138c 26
ae3ad328 27def test_ap_roam_wpa2_psk(dev, apdev):
5126138c
JM
28 """Roam between two WPA2-PSK APs"""
29 params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678")
a8375c94 30 hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
5126138c 31 dev[0].connect("test-wpa2-psk", psk="12345678")
a8375c94
JM
32 hwsim_utils.test_connectivity(dev[0], hapd0)
33 hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
5126138c 34 dev[0].scan(type="ONLY")
ae3ad328 35 dev[0].roam(apdev[1]['bssid'])
a8375c94 36 hwsim_utils.test_connectivity(dev[0], hapd1)
ae3ad328 37 dev[0].roam(apdev[0]['bssid'])
a8375c94 38 hwsim_utils.test_connectivity(dev[0], hapd0)
99cd77a8
JM
39
40def test_ap_reassociation_to_same_bss(dev, apdev):
41 """Reassociate to the same BSS"""
a8375c94 42 hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
99cd77a8
JM
43 dev[0].connect("test-open", key_mgmt="NONE")
44
45 dev[0].request("REASSOCIATE")
46 ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
47 if ev is None:
48 raise Exception("Reassociation with the AP timed out")
a8375c94 49 hwsim_utils.test_connectivity(dev[0], hapd)
99cd77a8
JM
50
51 dev[0].request("REATTACH")
52 ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
53 if ev is None:
54 raise Exception("Reassociation (reattach) with the AP timed out")
a8375c94 55 hwsim_utils.test_connectivity(dev[0], hapd)
a567aae4
JM
56
57def test_ap_roam_set_bssid(dev, apdev):
58 """Roam control"""
59 hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
60 hostapd.add_ap(apdev[1]['ifname'], { "ssid": "test-open" })
61 id = dev[0].connect("test-open", key_mgmt="NONE", bssid=apdev[1]['bssid'],
62 scan_freq="2412")
63 if dev[0].get_status_field('bssid') != apdev[1]['bssid']:
64 raise Exception("Unexpected BSS")
65 # for now, these are just verifying that the code path to indicate
66 # within-ESS roaming changes can be executed; the actual results of those
67 # operations are not currently verified (that would require a test driver
68 # that does BSS selection)
69 dev[0].set_network(id, "bssid", "")
70 dev[0].set_network(id, "bssid", apdev[0]['bssid'])
71 dev[0].set_network(id, "bssid", apdev[1]['bssid'])