From 67e0a5180f578261cf4d8a0364bb2bc4b6ef64c9 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 26 Dec 2019 17:59:16 +0200 Subject: [PATCH] tests: SHOW_NEIGHBOR Signed-off-by: Jouni Malinen --- tests/hwsim/test_rrm.py | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/hwsim/test_rrm.py b/tests/hwsim/test_rrm.py index 4f62ee0fa..d7d1ed3ba 100644 --- a/tests/hwsim/test_rrm.py +++ b/tests/hwsim/test_rrm.py @@ -68,6 +68,22 @@ def test_rrm_neighbor_db(dev, apdev): """hostapd ctrl_iface SET_NEIGHBOR""" params = {"ssid": "test", "rrm_neighbor_report": "1"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) + params = {"ssid": "test2", "rrm_neighbor_report": "1"} + hapd2 = hostapd.add_ap(apdev[1]['ifname'], params) + + res = hapd.request("SHOW_NEIGHBOR") + if len(res.splitlines()) != 1: + raise Exception("Unexpected SHOW_NEIGHBOR output(1): " + res) + if apdev[0]['bssid'] not in res: + raise Exception("Own BSS not visible in SHOW_NEIGHBOR output") + + if "OK" not in hapd2.request("SET_NEIGHBOR " + res.strip()): + raise Exception("Failed to copy neighbor entry to another hostapd") + res2 = hapd2.request("SHOW_NEIGHBOR") + if len(res2.splitlines()) != 2: + raise Exception("Unexpected SHOW_NEIGHBOR output: " + res2) + if res not in res2: + raise Exception("Copied entry not visible") # Bad BSSID if "FAIL" not in hapd.request("SET_NEIGHBOR 00:11:22:33:44:gg ssid=\"test1\" nr=" + nr): @@ -105,10 +121,28 @@ def test_rrm_neighbor_db(dev, apdev): if "OK" not in hapd.request("SET_NEIGHBOR 00:11:22:33:44:55 ssid=\"test1\" nr=" + nr + " lci=" + lci + " civic=" + civic): raise Exception("Set neighbor failed") + res = hapd.request("SHOW_NEIGHBOR") + if len(res.splitlines()) != 2: + raise Exception("Unexpected SHOW_NEIGHBOR output(2): " + res) + if apdev[0]['bssid'] not in res: + raise Exception("Own BSS not visible in SHOW_NEIGHBOR output") + if "00:11:22:33:44:55" not in res: + raise Exception("Added BSS not visible in SHOW_NEIGHBOR output") + # Another BSSID with the same SSID if "OK" not in hapd.request("SET_NEIGHBOR 00:11:22:33:44:56 ssid=\"test1\" nr=" + nr + " lci=" + lci + " civic=" + civic): raise Exception("Set neighbor failed") + res = hapd.request("SHOW_NEIGHBOR") + if len(res.splitlines()) != 3: + raise Exception("Unexpected SHOW_NEIGHBOR output(3): " + res) + if apdev[0]['bssid'] not in res: + raise Exception("Own BSS not visible in SHOW_NEIGHBOR output") + if "00:11:22:33:44:55" not in res: + raise Exception("Added BSS not visible in SHOW_NEIGHBOR output") + if "00:11:22:33:44:56" not in res: + raise Exception("Second added BSS not visible in SHOW_NEIGHBOR output") + # Fewer parameters if "OK" not in hapd.request("SET_NEIGHBOR 00:11:22:33:44:55 ssid=\"test1\" nr=" + nr): raise Exception("Set neighbor failed") @@ -146,6 +180,12 @@ def test_rrm_neighbor_db(dev, apdev): if "OK" not in hapd.request("SET_NEIGHBOR 00:11:22:33:44:55 ssid=\"test3\" nr=" + nr + " lci=" + lci + " civic=" + civic + " stat"): raise Exception("Set neighbor failed") + res = hapd.request("SHOW_NEIGHBOR") + if len(res.splitlines()) != 2: + raise Exception("Unexpected SHOW_NEIGHBOR output(4): " + res) + if "00:11:22:33:44:55" not in res or " stat" not in res: + raise Exception("Unexpected SHOW_NEIGHBOR output(4b): " + res) + if "OK" not in hapd.request("REMOVE_NEIGHBOR 00:11:22:33:44:55 ssid=\"test3\""): raise Exception("Remove neighbor failed") @@ -165,6 +205,12 @@ def test_rrm_neighbor_db(dev, apdev): if "OK" not in hapd.request("REMOVE_NEIGHBOR 00:11:22:33:44:55"): raise Exception("Remove neighbor without SSID failed") + res = hapd.request("SHOW_NEIGHBOR") + if len(res.splitlines()) != 1: + raise Exception("Unexpected SHOW_NEIGHBOR output(5): " + res) + if apdev[0]['bssid'] not in res: + raise Exception("Own BSS not visible in SHOW_NEIGHBOR output") + def test_rrm_neighbor_rep_req(dev, apdev): """wpa_supplicant ctrl_iface NEIGHBOR_REP_REQUEST""" check_rrm_support(dev[0])