]> git.ipfire.org Git - thirdparty/hostap.git/blame - tests/hwsim/test_radio_work.py
tests: Invalid VENDOR command
[thirdparty/hostap.git] / tests / hwsim / test_radio_work.py
CommitLineData
26b84667
JM
1# Radio work tests
2# Copyright (c) 2014, 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
7import time
8import logging
9logger = logging.getLogger()
10import subprocess
11
12import hostapd
8ec83adf 13from wpasupplicant import WpaSupplicant
26b84667
JM
14
15def test_ext_radio_work(dev, apdev):
16 """External radio work item"""
17 id = dev[0].request("RADIO_WORK add test-work-a")
18 if "FAIL" in id:
19 raise Exception("Failed to add radio work")
20 id2 = dev[0].request("RADIO_WORK add test-work-b freq=2417")
21 if "FAIL" in id2:
22 raise Exception("Failed to add radio work")
23 id3 = dev[0].request("RADIO_WORK add test-work-c")
24 if "FAIL" in id3:
25 raise Exception("Failed to add radio work")
26
27 ev = dev[0].wait_event(["EXT-RADIO-WORK-START"])
28 if ev is None:
29 raise Exception("Timeout while waiting radio work to start")
30 if "EXT-RADIO-WORK-START " + id not in ev:
31 raise Exception("Unexpected radio work start id")
32
33 items = dev[0].request("RADIO_WORK show")
34 if "ext:test-work-a@wlan0:0:1:" not in items:
35 logger.info("Pending radio work items:\n" + items)
36 raise Exception("Radio work item(a) missing from the list")
37 if "ext:test-work-b@wlan0:2417:0:" not in items:
38 logger.info("Pending radio work items:\n" + items)
39 raise Exception("Radio work item(b) missing from the list")
40 if "ext:test-work-c@wlan0:0:0:" not in items:
41 logger.info("Pending radio work items:\n" + items)
42 raise Exception("Radio work item(c) missing from the list")
43
44 dev[0].request("RADIO_WORK done " + id2)
45 dev[0].request("RADIO_WORK done " + id)
46
47 ev = dev[0].wait_event(["EXT-RADIO-WORK-START"])
48 if ev is None:
49 raise Exception("Timeout while waiting radio work to start")
50 if "EXT-RADIO-WORK-START " + id3 not in ev:
51 raise Exception("Unexpected radio work start id")
52 dev[0].request("RADIO_WORK done " + id3)
53 items = dev[0].request("RADIO_WORK show")
54 if "ext:" in items:
55 logger.info("Pending radio work items:\n" + items)
56 raise Exception("Unexpected remaining radio work item")
9d89c639
JM
57
58 id = dev[0].request("RADIO_WORK add test-work timeout=1")
59 ev = dev[0].wait_event(["EXT-RADIO-WORK-START"])
60 if ev is None:
61 raise Exception("Timeout while waiting radio work to start")
62 ev = dev[0].wait_event(["EXT-RADIO-WORK-TIMEOUT"], timeout=2)
63 if ev is None:
64 raise Exception("Timeout while waiting radio work to time out")
65 if id not in ev:
66 raise Exception("Radio work id mismatch")
8ec83adf
JM
67
68def test_radio_work_cancel(dev, apdev):
69 """Radio work items cancelled on interface removal"""
70 params = hostapd.wpa2_params(ssid="radio", passphrase="12345678")
71 hostapd.add_ap(apdev[0]['ifname'], params)
72 wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
73 wpas.interface_add("wlan5")
74 wpas.scan(freq="2412")
75
76 id = wpas.request("RADIO_WORK add test-work-a")
77 if "FAIL" in id:
78 raise Exception("Failed to add radio work")
79 ev = wpas.wait_event(["EXT-RADIO-WORK-START"])
80 if ev is None:
81 raise Exception("Timeout while waiting radio work to start")
82 if "EXT-RADIO-WORK-START " + id not in ev:
83 raise Exception("Unexpected radio work start id")
84
85 wpas.connect("radio", psk="12345678", scan_freq="2412",
86 wait_connect=False)
87 time.sleep(1)
88 wpas.interface_remove("wlan5")
89 # add to allow log file renaming
90 wpas.interface_add("wlan5")