tests: Verify VHT20 with center freq seq0 set to zero
[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[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
64         hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
65     except Exception, e:
66         if isinstance(e, Exception) and str(e) == "AP startup failed":
67             if not vht_supported():
68                 logger.info("80 MHz channel not supported in regulatory information")
69                 return "skip"
70         raise
71     finally:
72         subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
73
74 def test_ap_vht_20(devs, apdevs):
75     dev = devs[0]
76     ap = apdevs[0]
77     try:
78         params = { "ssid": "test-vht20",
79                    "country_code": "DE",
80                    "hw_mode": "a",
81                    "channel": "36",
82                    "ieee80211n": "1",
83                    "ieee80211ac": "1",
84                    "ht_capab": "",
85                    "vht_capab": "",
86                    "vht_oper_chwidth": "0",
87                    "vht_oper_centr_freq_seg0_idx": "0",
88                    "require_vht": "1",
89                  }
90         hostapd.add_ap(ap['ifname'], params)
91         dev.connect("test-vht20", scan_freq="5180", key_mgmt="NONE")
92         hwsim_utils.test_connectivity(dev.ifname, ap['ifname'])
93     finally:
94         subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])