tests: Add a test case for HT40 co-ex scan
[mech_eap.git] / tests / hwsim / test_ap_ht.py
1 #!/usr/bin/python
2 #
3 # Test cases for HT operations with hostapd
4 # Copyright (c) 2013, Jouni Malinen <j@w1.fi>
5 #
6 # This software may be distributed under the terms of the BSD license.
7 # See README for more details.
8
9 import time
10 import logging
11 logger = logging.getLogger()
12
13 import hostapd
14
15 def test_ap_ht40_scan(dev, apdev):
16     """HT40 co-ex scan"""
17     params = { "ssid": "test-ht40",
18                "channel": "5",
19                "ht_capab": "[HT40-]"}
20     hapd = hostapd.add_ap(apdev[0]['ifname'], params)
21
22     state = hapd.get_status_field("state")
23     if state != "HT_SCAN":
24         time.wait(0.1)
25         state = hapd.get_status_field("state")
26         if state != "HT_SCAN":
27             raise Exception("Unexpected interface state - expected HT_SCAN")
28
29     ev = hapd.wait_event(["AP-ENABLED"], timeout=10)
30     if not ev:
31         raise Exception("AP setup timed out")
32
33     state = hapd.get_status_field("state")
34     if state != "ENABLED":
35         raise Exception("Unexpected interface state - expected ENABLED")
36
37     freq = hapd.get_status_field("freq")
38     if freq != "2432":
39         raise Exception("Unexpected frequency")
40     pri = hapd.get_status_field("channel")
41     if pri != "5":
42         raise Exception("Unexpected primary channel")
43     sec = hapd.get_status_field("secondary_channel")
44     if sec != "-1":
45         raise Exception("Unexpected secondary channel")
46
47     dev[0].connect("test-ht40", key_mgmt="NONE", scan_freq=freq)