autotest: Migrate network_WiFiMatFunc/010CheckRxFrag to new framework

Also added HostapConfig flags for fragmentation threshold.

BUG=chromium:230660
TEST=This is a test.  It passes.

Change-Id: I981499ef0c7f2dc7d517fb9bddbccc1bf18360e9
Reviewed-on: https://gerrit.chromium.org/gerrit/50088
Tested-by: Christopher Wiley <wiley@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Christopher Wiley <wiley@chromium.org>
diff --git a/server/cros/wlan/hostap_config.py b/server/cros/wlan/hostap_config.py
index 7f31167..631e112 100644
--- a/server/cros/wlan/hostap_config.py
+++ b/server/cros/wlan/hostap_config.py
@@ -114,7 +114,7 @@
 
     def __init__(self, mode=None, channel=None, frequency=None,
                  n_capabilities=None, hide_ssid=None, beacon_interval=None,
-                 dtim_period=None):
+                 dtim_period=None, frag_threshold=None):
         """Construct a HostapConfig.
 
         You may specify channel or frequency, but not both.  Both options
@@ -128,7 +128,7 @@
         @param hide_ssid True if we should set up a hidden SSID.
         @param beacon_interval int beacon interval of AP.
         @param dtim_period int include a DTIM every |dtim_period| beacons.
-
+        @param frag_threshold int maximum outgoing data frame size.
         """
         super(HostapConfig, self).__init__()
         if channel is not None and frequency is not None:
@@ -207,3 +207,4 @@
         self.hide_ssid = hide_ssid
         self.beacon_interval = beacon_interval
         self.dtim_period = dtim_period
+        self.frag_threshold = frag_threshold
diff --git a/server/site_linux_router.py b/server/site_linux_router.py
index 9d43e42..84f3c86 100644
--- a/server/site_linux_router.py
+++ b/server/site_linux_router.py
@@ -268,6 +268,8 @@
             conf['beacon_int'] = configuration.beacon_interval
         if configuration.dtim_period:
             conf['dtim_period'] = configuration.dtim_period
+        if configuration.frag_threshold:
+            conf['fragm_threshold'] = configuration.frag_threshold
         self.start_hostapd(conf, {})
         # Configure transmit power
         tx_power_params = {'interface': conf['interface']}
diff --git a/server/site_tests/network_WiFiMatFunc/010CheckRxFrag b/server/site_tests/network_WiFiMatFunc/010CheckRxFrag
deleted file mode 100644
index 9266951..0000000
--- a/server/site_tests/network_WiFiMatFunc/010CheckRxFrag
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright (c) 2010 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.
-
-# Purpose: This test verifies that DUT can successfuly reassemble fragmented
-# packets sent by an AP.
-
-# When fragthreshold is set, packets larger than the threshold are broken up
-# by the AP and sent in fragments. DUT needs to reassemble these fragments to
-# reconstruct the original packets before processing them.
-
-{ "name":"CheckRxFrag",
-  "steps":[
-    [ "create",         { "type":"hostap" } ],
-    [ "config",         { "channel":"2437", "mode":"11g", "fragthreshold":"256" } ],
-    [ "connect",        { "security":"none" } ],
-    [ "server_ping",    { "count":"10", "size":"256" } ],
-    [ "server_ping",    { "count":"10", "size":"512" } ],
-    [ "server_ping",    { "count":"10", "size":"1024" } ],
-    [ "server_ping",    { "count":"10", "size":"1500" } ],
-    # XXX check rx frag stats
-    [ "destroy" ],
-  ],
-}
diff --git a/server/site_tests/network_WiFi_RxFrag/control.check_rxfrag b/server/site_tests/network_WiFi_RxFrag/control.check_rxfrag
new file mode 100644
index 0000000..96d63cc
--- /dev/null
+++ b/server/site_tests/network_WiFi_RxFrag/control.check_rxfrag
@@ -0,0 +1,23 @@
+# Copyright (c) 2013 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@chromium.com'
+NAME = 'network_WiFi_RxFrag'
+TIME = 'SHORT'
+TEST_TYPE = 'Server'
+
+DOC = """
+This test verifies that DUT can successfuly reassemble fragmented
+packets sent by an AP.
+"""
+
+
+def run(machine):
+    host = hosts.create_host(machine)
+    job.run_test('network_WiFi_RxFrag',
+                 host=host,
+                 raw_cmdline_args=args)
+
+
+parallel_simple(run, machines)
diff --git a/server/site_tests/network_WiFi_RxFrag/network_WiFi_RxFrag.py b/server/site_tests/network_WiFi_RxFrag/network_WiFi_RxFrag.py
new file mode 100644
index 0000000..656534d
--- /dev/null
+++ b/server/site_tests/network_WiFi_RxFrag/network_WiFi_RxFrag.py
@@ -0,0 +1,37 @@
+# Copyright (c) 2013 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.
+
+from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
+from autotest_lib.server.cros.wlan import hostap_config
+from autotest_lib.server.cros.wlan import wifi_test_base
+
+
+class network_WiFi_RxFrag(wifi_test_base.WiFiTestBase):
+    """Test that the DUT can reassemble packet fragments."""
+    version = 1
+
+
+    def run_once_impl(self):
+        """Test body.
+
+        When fragthreshold is set, packets larger than the threshold are
+        broken up by the AP and sent in fragments. The DUT needs to reassemble
+        these fragments to reconstruct the original packets before processing
+        them.
+
+        """
+        configuration = hostap_config.HostapConfig(
+                frequency=2437,
+                mode=hostap_config.HostapConfig.MODE_11G,
+                frag_threshold=256)
+        self.context.configure(configuration)
+        assoc_params = xmlrpc_datatypes.AssociationParameters()
+        assoc_params.ssid = self.context.router.get_ssid()
+        self.assert_connect_wifi(assoc_params)
+        self.assert_ping_from_server(additional_ping_params={'size': 256})
+        self.assert_ping_from_server(additional_ping_params={'size': 512})
+        self.assert_ping_from_server(additional_ping_params={'size': 1024})
+        self.assert_ping_from_server(additional_ping_params={'size': 1500})
+        self.context.client.shill.disconnect(assoc_params.ssid)
+        self.context.router.deconfig()