test_ap_roam.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. import time
  7. import subprocess
  8. import logging
  9. logger = logging.getLogger()
  10. import hwsim_utils
  11. import hostapd
  12. def test_ap_roam_open(dev, apdev):
  13. """Roam between two open APs"""
  14. hapd0 = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
  15. dev[0].connect("test-open", key_mgmt="NONE")
  16. hwsim_utils.test_connectivity(dev[0], hapd0)
  17. hapd1 = hostapd.add_ap(apdev[1]['ifname'], { "ssid": "test-open" })
  18. dev[0].scan(type="ONLY")
  19. dev[0].roam(apdev[1]['bssid'])
  20. hwsim_utils.test_connectivity(dev[0], hapd1)
  21. dev[0].roam(apdev[0]['bssid'])
  22. hwsim_utils.test_connectivity(dev[0], hapd0)
  23. def test_ap_roam_wpa2_psk(dev, apdev):
  24. """Roam between two WPA2-PSK APs"""
  25. params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678")
  26. hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
  27. dev[0].connect("test-wpa2-psk", psk="12345678")
  28. hwsim_utils.test_connectivity(dev[0], hapd0)
  29. hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
  30. dev[0].scan(type="ONLY")
  31. dev[0].roam(apdev[1]['bssid'])
  32. hwsim_utils.test_connectivity(dev[0], hapd1)
  33. dev[0].roam(apdev[0]['bssid'])
  34. hwsim_utils.test_connectivity(dev[0], hapd0)
  35. def test_ap_reassociation_to_same_bss(dev, apdev):
  36. """Reassociate to the same BSS"""
  37. hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
  38. dev[0].connect("test-open", key_mgmt="NONE")
  39. dev[0].request("REASSOCIATE")
  40. dev[0].wait_connected(timeout=10, error="Reassociation timed out")
  41. hwsim_utils.test_connectivity(dev[0], hapd)
  42. dev[0].request("REATTACH")
  43. dev[0].wait_connected(timeout=10, error="Reattach timed out")
  44. hwsim_utils.test_connectivity(dev[0], hapd)
  45. def test_ap_roam_set_bssid(dev, apdev):
  46. """Roam control"""
  47. hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
  48. hostapd.add_ap(apdev[1]['ifname'], { "ssid": "test-open" })
  49. id = dev[0].connect("test-open", key_mgmt="NONE", bssid=apdev[1]['bssid'],
  50. scan_freq="2412")
  51. if dev[0].get_status_field('bssid') != apdev[1]['bssid']:
  52. raise Exception("Unexpected BSS")
  53. # for now, these are just verifying that the code path to indicate
  54. # within-ESS roaming changes can be executed; the actual results of those
  55. # operations are not currently verified (that would require a test driver
  56. # that does BSS selection)
  57. dev[0].set_network(id, "bssid", "")
  58. dev[0].set_network(id, "bssid", apdev[0]['bssid'])
  59. dev[0].set_network(id, "bssid", apdev[1]['bssid'])