tests: Add roaming test cases

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2013-03-30 11:28:39 +02:00
parent fcbccf1aae
commit 5126138c9e
2 changed files with 65 additions and 0 deletions

View file

@ -0,0 +1,45 @@
#!/usr/bin/python
#
# Roaming tests
# Copyright (c) 2013, Jouni Malinen <j@w1.fi>
#
# This software may be distributed under the terms of the BSD license.
# See README for more details.
import time
import subprocess
import logging
logger = logging.getLogger(__name__)
import hwsim_utils
import hostapd
ap_ifname = 'wlan2'
bssid = "02:00:00:00:02:00"
ap2_ifname = 'wlan3'
bssid2 = "02:00:00:00:03:00"
def test_ap_roam_open(dev):
"""Roam between two open APs"""
hostapd.add_ap(ap_ifname, { "ssid": "test-open" })
dev[0].connect("test-open", key_mgmt="NONE")
hwsim_utils.test_connectivity(dev[0].ifname, ap_ifname)
hostapd.add_ap(ap2_ifname, { "ssid": "test-open" })
dev[0].scan(type="ONLY")
dev[0].roam(bssid2)
hwsim_utils.test_connectivity(dev[0].ifname, ap2_ifname)
dev[0].roam(bssid)
hwsim_utils.test_connectivity(dev[0].ifname, ap_ifname)
def test_ap_roam_wpa2_psk(dev):
"""Roam between two WPA2-PSK APs"""
params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678")
hostapd.add_ap(ap_ifname, params)
dev[0].connect("test-wpa2-psk", psk="12345678")
hwsim_utils.test_connectivity(dev[0].ifname, ap_ifname)
hostapd.add_ap(ap2_ifname, params)
dev[0].scan(type="ONLY")
dev[0].roam(bssid2)
hwsim_utils.test_connectivity(dev[0].ifname, ap2_ifname)
dev[0].roam(bssid)
hwsim_utils.test_connectivity(dev[0].ifname, ap_ifname)

View file

@ -315,3 +315,23 @@ class WpaSupplicant:
if wep_key0:
self.set_network(id, "wep_key0", wep_key0)
self.connect_network(id)
def scan(self, type=None):
if type:
cmd = "SCAN TYPE=" + type
else:
cmd = "SCAN"
self.dump_monitor()
if not "OK" in self.request(cmd):
raise Exception("Failed to trigger scan")
ev = self.wait_event(["CTRL-EVENT-SCAN-RESULTS"], 15)
if ev is None:
raise Exception("Scan timed out")
def roam(self, bssid):
self.dump_monitor()
self.request("ROAM " + bssid)
ev = self.wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
if ev is None:
raise Exception("Roaming with the AP timed out")
self.dump_monitor()