tests: Additional bgscan coverage

Verify error cases in bgscan module parameters. Increase learn bgscan
module coverage with parsing of the saved data and probe frequency
selection.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2015-01-05 18:35:14 +02:00
parent 51f3427019
commit c975e1c1da

View file

@ -21,6 +21,26 @@ def test_bgscan_simple(dev, apdev):
dev[1].connect("bgscan", key_mgmt="NONE", scan_freq="2412", dev[1].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
bgscan="simple:1:-45:2") bgscan="simple:1:-45:2")
dev[2].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
bgscan="simple:1:-45")
dev[2].request("REMOVE_NETWORK all")
dev[2].wait_disconnected()
dev[2].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
bgscan="simple:0:0")
dev[2].request("REMOVE_NETWORK all")
dev[2].wait_disconnected()
dev[2].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
bgscan="simple")
dev[2].request("REMOVE_NETWORK all")
dev[2].wait_disconnected()
dev[2].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
bgscan="simple:1")
dev[2].request("REMOVE_NETWORK all")
dev[2].wait_disconnected()
ev = dev[0].wait_event(["CTRL-EVENT-SIGNAL-CHANGE"], timeout=10) ev = dev[0].wait_event(["CTRL-EVENT-SIGNAL-CHANGE"], timeout=10)
if ev is None: if ev is None:
raise Exception("dev0 did not indicate signal change event") raise Exception("dev0 did not indicate signal change event")
@ -61,8 +81,28 @@ def test_bgscan_learn(dev, apdev):
try: try:
dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412", dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
bgscan="learn:1:-20:2") bgscan="learn:1:-20:2")
dev[1].connect("bgscan", key_mgmt="NONE", scan_freq="2412", id = dev[1].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
bgscan="learn:1:-45:2:/tmp/test_bgscan_learn.bgscan") bgscan="learn:1:-45:2:/tmp/test_bgscan_learn.bgscan")
dev[2].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
bgscan="learn:1:-45")
dev[2].request("REMOVE_NETWORK all")
dev[2].wait_disconnected()
dev[2].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
bgscan="learn:0:0")
dev[2].request("REMOVE_NETWORK all")
dev[2].wait_disconnected()
dev[2].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
bgscan="learn")
dev[2].request("REMOVE_NETWORK all")
dev[2].wait_disconnected()
dev[2].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
bgscan="learn:1")
dev[2].request("REMOVE_NETWORK all")
dev[2].wait_disconnected()
ev = dev[0].wait_event(["CTRL-EVENT-SIGNAL-CHANGE"], timeout=10) ev = dev[0].wait_event(["CTRL-EVENT-SIGNAL-CHANGE"], timeout=10)
if ev is None: if ev is None:
@ -94,7 +134,6 @@ def test_bgscan_learn(dev, apdev):
dev[0].request("DISCONNECT") dev[0].request("DISCONNECT")
dev[1].request("DISCONNECT") dev[1].request("DISCONNECT")
dev[0].request("REMOVE_NETWORK all") dev[0].request("REMOVE_NETWORK all")
dev[1].request("REMOVE_NETWORK all")
with open("/tmp/test_bgscan_learn.bgscan", "r") as f: with open("/tmp/test_bgscan_learn.bgscan", "r") as f:
lines = f.read().splitlines() lines = f.read().splitlines()
@ -108,6 +147,19 @@ def test_bgscan_learn(dev, apdev):
raise Exception("Missing BSS1->BSS2 neighbor entry") raise Exception("Missing BSS1->BSS2 neighbor entry")
if 'NEIGHBOR 02:00:00:00:04:00 02:00:00:00:03:00' not in lines: if 'NEIGHBOR 02:00:00:00:04:00 02:00:00:00:03:00' not in lines:
raise Exception("Missing BSS2->BSS1 neighbor entry") raise Exception("Missing BSS2->BSS1 neighbor entry")
dev[1].set_network(id, "scan_freq", "")
dev[1].connect_network(id)
ev = dev[1].wait_event(["CTRL-EVENT-SCAN-STARTED"], timeout=10)
if ev is None:
raise Exception("dev1 did not start a scan")
ev = dev[1].wait_event(["CTRL-EVENT-SCAN-RESULTS"], 10)
if ev is None:
raise Exception("dev1 did not complete a scan")
dev[1].request("REMOVE_NETWORK all")
finally: finally:
try: try:
os.remove("/tmp/test_bgscan_learn.bgscan") os.remove("/tmp/test_bgscan_learn.bgscan")