From 5126138c9e1a0120136a0db3db7d578009b95b15 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 30 Mar 2013 11:28:39 +0200 Subject: [PATCH] tests: Add roaming test cases Signed-hostap: Jouni Malinen --- tests/hwsim/test_ap_roam.py | 45 ++++++++++++++++++++++++++++++++++++ tests/hwsim/wpasupplicant.py | 20 ++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 tests/hwsim/test_ap_roam.py diff --git a/tests/hwsim/test_ap_roam.py b/tests/hwsim/test_ap_roam.py new file mode 100644 index 000000000..ade11f09c --- /dev/null +++ b/tests/hwsim/test_ap_roam.py @@ -0,0 +1,45 @@ +#!/usr/bin/python +# +# Roaming tests +# Copyright (c) 2013, Jouni Malinen +# +# 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) diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index f0f297a7c..10adb3ef6 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -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()