tests: Require HT/VHT as BSS membership selector in Supp Rates
[mech_eap.git] / tests / hwsim / test_ap_vht.py
1 # Test cases for VHT operations with hostapd
2 # Copyright (c) 2014, Qualcomm Atheros, Inc.
3 # Copyright (c) 2013, Intel Corporation
4 #
5 # This software may be distributed under the terms of the BSD license.
6 # See README for more details.
7
8 import logging
9 logger = logging.getLogger()
10 import subprocess, time
11
12 import hwsim_utils
13 import hostapd
14
15 def vht_supported():
16     cmd = subprocess.Popen(["iw", "reg", "get"], stdout=subprocess.PIPE)
17     reg = cmd.stdout.read()
18     if "@ 80)" in reg or "@ 160)" in reg:
19         return True
20     return False
21
22 def test_ap_vht80(dev, apdev):
23     """VHT with 80 MHz channel width"""
24     try:
25         params = { "ssid": "vht",
26                    "country_code": "FI",
27                    "hw_mode": "a",
28                    "channel": "36",
29                    "ht_capab": "[HT40+]",
30                    "ieee80211n": "1",
31                    "ieee80211ac": "1",
32                    "vht_oper_chwidth": "1",
33                    "vht_oper_centr_freq_seg0_idx": "42" }
34         hapd = hostapd.add_ap(apdev[0]['ifname'], params)
35
36         dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
37         hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
38     except Exception, e:
39         if isinstance(e, Exception) and str(e) == "AP startup failed":
40             if not vht_supported():
41                 logger.info("80 MHz channel not supported in regulatory information")
42                 return "skip"
43         raise
44     finally:
45         subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
46
47 def test_ap_vht80_params(dev, apdev):
48     """VHT with 80 MHz channel width and number of optional features enabled"""
49     try:
50         params = { "ssid": "vht",
51                    "country_code": "FI",
52                    "hw_mode": "a",
53                    "channel": "36",
54                    "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]",
55                    "ieee80211n": "1",
56                    "ieee80211ac": "1",
57                    "vht_oper_chwidth": "1",
58                    "vht_capab": "[MAX-MPDU-11454][RXLDPC][SHORT-GI-80][TX-STBC-2BY1][RX-STBC-1][MAX-A-MPDU-LEN-EXP0]",
59                    "vht_oper_centr_freq_seg0_idx": "42",
60                    "require_vht": "1" }
61         hapd = hostapd.add_ap(apdev[0]['ifname'], params)
62
63         dev[1].connect("vht", key_mgmt="NONE", scan_freq="5180",
64                        disable_vht="1", wait_connect=False)
65         dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
66         ev = dev[1].wait_event(["CTRL-EVENT-ASSOC-REJECT"])
67         if ev is None:
68             raise Exception("Association rejection timed out")
69         if "status_code=104" not in ev:
70             raise Exception("Unexpected rejection status code")
71         dev[1].request("DISCONNECT")
72         hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
73     except Exception, e:
74         if isinstance(e, Exception) and str(e) == "AP startup failed":
75             if not vht_supported():
76                 logger.info("80 MHz channel not supported in regulatory information")
77                 return "skip"
78         raise
79     finally:
80         subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
81
82 def test_ap_vht_20(devs, apdevs):
83     dev = devs[0]
84     ap = apdevs[0]
85     try:
86         params = { "ssid": "test-vht20",
87                    "country_code": "DE",
88                    "hw_mode": "a",
89                    "channel": "36",
90                    "ieee80211n": "1",
91                    "ieee80211ac": "1",
92                    "ht_capab": "",
93                    "vht_capab": "",
94                    "vht_oper_chwidth": "0",
95                    "vht_oper_centr_freq_seg0_idx": "0",
96                    "supported_rates": "60 120 240 360 480 540",
97                    "require_vht": "1",
98                  }
99         hostapd.add_ap(ap['ifname'], params)
100         dev.connect("test-vht20", scan_freq="5180", key_mgmt="NONE")
101         hwsim_utils.test_connectivity(dev.ifname, ap['ifname'])
102     finally:
103         subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])