Create the first 802.11ac perf test

BUG=chrome-os-partner:34851,chromium:444622,chromium:444627
TEST=Ran it.

Change-Id: Ifd209fe23ad1b7be1a1c62d3279adbe34b32f07f
Reviewed-on: https://chromium-review.googlesource.com/236973
Reviewed-by: Kris Rambish <krisr@chromium.org>
Tested-by: Kris Rambish <krisr@chromium.org>
Commit-Queue: Kris Rambish <krisr@chromium.org>
Reviewed-by: Christopher Wiley <wiley@chromium.org>
diff --git a/client/common_lib/cros/network/iw_runner.py b/client/common_lib/cros/network/iw_runner.py
index c5333e8..914ee3a 100644
--- a/client/common_lib/cros/network/iw_runner.py
+++ b/client/common_lib/cros/network/iw_runner.py
@@ -644,3 +644,11 @@
         self._log_id += 1
         return iw_event_logger.IwEventLogger(self._host, self._command_iw,
                                              local_file)
+
+
+    def vht_supported(self):
+        """Returns True if VHT is supported; False otherwise."""
+        result = self._run('%s list' % self._command_iw).stdout
+        if 'VHT Capabilities' in result:
+            return True
+        return False
diff --git a/server/cros/network/wifi_client.py b/server/cros/network/wifi_client.py
index 4bdbae9..584c6b2 100644
--- a/server/cros/network/wifi_client.py
+++ b/server/cros/network/wifi_client.py
@@ -268,6 +268,11 @@
         self.host.run('ff_debug +wifi')
 
 
+    def vht_supported(self):
+        """Returns True if VHT supported; False otherwise"""
+        return self.iw_runner.vht_supported()
+
+
     def _supports_method(self, method_name):
         """Checks if |method_name| is supported on the remote XMLRPC proxy.
 
diff --git a/server/site_linux_router.py b/server/site_linux_router.py
index 08473bc..7b59ba6 100644
--- a/server/site_linux_router.py
+++ b/server/site_linux_router.py
@@ -383,6 +383,11 @@
         if multi_interface is None and (self.hostapd_instances or
                                         self.station_instances):
             self.deconfig()
+        if configuration.is_11ac:
+            router_caps = self.get_capabilities()
+            if site_linux_system.LinuxSystem.CAPABILITY_VHT not in router_caps:
+                raise error.TestNAError('Router does not have AC support')
+
         self.start_hostapd(configuration)
         interface = self.hostapd_instances[-1].interface
         self.iw_runner.set_tx_power(interface, 'auto')
diff --git a/server/site_tests/network_WiFi_Perf/control.vht80 b/server/site_tests/network_WiFi_Perf/control.vht80
new file mode 100644
index 0000000..4f49ecb
--- /dev/null
+++ b/server/site_tests/network_WiFi_Perf/control.vht80
@@ -0,0 +1,41 @@
+# Copyright 2014 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+AUTHOR = 'wiley, pstew, quiche'
+NAME = 'network_WiFi_Perf.vht80'
+# Add to the suite when crbug.com/444207 is fixed
+# SUITE = 'wifi_perf'
+TIME = 'SHORT'
+TEST_TYPE = 'Server'
+DEPENDENCIES = 'wificell'
+
+DOC = """
+This test uses netperf to measure the maximal receiving and transmitting
+throughput on a DUT with an open HT80 802.11ac network.
+"""
+
+
+from autotest_lib.server.cros.network import hostap_config
+
+
+def run(machine):
+    n_caps = [hostap_config.HostapConfig.N_CAPABILITY_HT40_PLUS]
+    ac_caps = [hostap_config.HostapConfig.AC_CAPABILITY_SHORT_GI_80]
+    ac_mode = hostap_config.HostapConfig.MODE_11AC_MIXED
+    channel_width_80_mhz = hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_80
+    configs = [hostap_config.HostapConfig(
+                    channel=channel,
+                    mode=ac_mode,
+                    n_capabilities=n_caps,
+                    vht_channel_width=channel_width_80_mhz,
+                    vht_center_channel=vht_center_channel,
+                    ac_capabilities=ac_caps)
+               for channel, vht_center_channel in [(44, 42), (157, 155)]]
+    host = hosts.create_host(machine)
+    job.run_test('network_WiFi_Perf', tag=NAME.split('.')[1],
+                 host=host, raw_cmdline_args=args,
+                 additional_params=configs)
+
+
+parallel_simple(run, machines)
diff --git a/server/site_tests/network_WiFi_Perf/network_WiFi_Perf.py b/server/site_tests/network_WiFi_Perf/network_WiFi_Perf.py
index 3421bc5..274fa0f 100644
--- a/server/site_tests/network_WiFi_Perf/network_WiFi_Perf.py
+++ b/server/site_tests/network_WiFi_Perf/network_WiFi_Perf.py
@@ -5,6 +5,7 @@
 import logging
 import time
 
+from autotest_lib.client.common_lib import error
 from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
 from autotest_lib.server.cros.network import netperf_runner
 from autotest_lib.server.cros.network import netperf_session
@@ -49,6 +50,8 @@
         for ap_config in self._ap_configs:
             # Set up the router and associate the client with it.
             self.context.configure(ap_config)
+            if ap_config.is_11ac and not self.context.client.vht_supported():
+                raise error.TestNAError('Client does not have AC support')
             assoc_params = xmlrpc_datatypes.AssociationParameters(
                     ssid=self.context.router.get_ssid(),
                     security_config=ap_config.security_config)