Add kernel_usb test suite

Boards on diff kernel version were separated from pool:stress not
to interfere with stress test suite.
Main kernel_usb test suite purpose is to catch USB detection
regressions.
Adding one test to run as part of the suite.

BUG=chromium:356880
TEST=Tested locally

Change-Id: I2ea0195503effd5a675f90690c088816c4b52369
Reviewed-on: https://chromium-review.googlesource.com/228892
Reviewed-by: Kris Rambish <krisr@chromium.org>
Tested-by: Kalin Stoyanov <kalin@chromium.org>
Commit-Queue: Kalin Stoyanov <kalin@chromium.org>
diff --git a/server/site_tests/platform_ExternalUsbPeripherals/control.set2 b/server/site_tests/platform_ExternalUsbPeripherals/control.set2
new file mode 100644
index 0000000..351eeff
--- /dev/null
+++ b/server/site_tests/platform_ExternalUsbPeripherals/control.set2
@@ -0,0 +1,87 @@
+# Copyright (c) 2012 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.server import utils
+
+AUTHOR = "Chrome OS Team"
+NAME = "ExternalUsbPeripheralsSet2"
+PURPOSE = "Servo based USB detection test"
+CRITERIA = "This test will fail if any of the actions or checks fail."
+TIME = "LONG"
+TEST_CATEGORY = "Functional"
+TEST_CLASS = "platform"
+TEST_TYPE = "server"
+SUITE = "kernel_usb"
+DEPENDENCIES = "servo"
+
+DOC = """
+This test uses servo to connect/disconnect servo USB hub before and
+after events like reboot, login, suspend, resume etc.
+
+The test fails if
+- crash files are generated
+- device is pingable when suspended
+- wrong action passed through action_sequence flag
+- USB detected peripherals are different than expected
+- there is no servo board attached
+- USB peripherals checks(usb_checks below) on command line fail
+Other detection checks can be added for each peripheral
+
+Set2 is set of six USB peripherals plugged:
+- USB headset
+- USB Webcam
+- USB SD card reader
+- Android phone
+- USB mouse
+- GSM modem
+"""
+
+args_dict = utils.args_to_dict(args)
+servo_args = hosts.CrosHost.get_servo_arguments(args_dict)
+
+def run(machine):
+    host = hosts.create_host(machine, servo_args=servo_args)
+
+    repeat = int(args_dict.get("repeat", 2))
+
+    default_actions = str("reboot,unplug,plug,login,unplug,plug,"
+                          "suspend,resume,unplug,suspend,plug,resume,"
+                          "suspend,unplug,resume,plug")
+
+    action_sequence = str(args_dict.get("action_sequence", default_actions))
+
+    usb_list = ["Chicony Electronics Co., Ltd",
+                "Alcor Micro Corp.",
+                "Microsoft Corp.",
+                "Huawei Technologies Co., Ltd. Modem/Networkcard",
+                "Realtek Semiconductor Corp.",
+                "LG Electronics, Inc.",]
+    usb_checks = {
+        # Audio thread - active USB audio
+        str("loggedin:cras_test_client --dump_audio_thread | "
+            "awk '/devices/,/stream_dump/'") :
+            ["output dev.*USB Audio", "input dev.*USB Audio"],
+        # USB Audio Output devices
+        str("cras_test_client --dump_server_info | "
+            "awk '/Output Devices:/,/Output Nodes:/'") :
+            ["Microsoft LifeChat LX-3000: USB Audio" ],
+        # USB Audio Input devices
+        str("cras_test_client --dump_server_info | "
+            "awk '/Input Devices:/,/Input Nodes:/'") :
+            ["TeckNet: USB Audio",
+             "Microsoft LifeChat LX-3000: USB Audio"],
+        # USB stick four partitions volumes
+        "loggedin:ls -l /media/removable/" :
+            ["USB Drive"],
+        # USB Web camera
+        "cat /sys/class/video4linux/video*/name" :
+            ["TeckNet"],
+        }
+
+    job.run_test("platform_ExternalUsbPeripherals", host=host,
+                 disable_sysinfo=True, client_autotest="desktopui_SimpleLogin",
+                 action_sequence=action_sequence, repeat=repeat,
+                 usb_list=usb_list, usb_checks=usb_checks)
+
+parallel_simple(run, machines)
\ No newline at end of file
diff --git a/suite_scheduler.ini b/suite_scheduler.ini
index 4a94389..0f8a31e 100644
--- a/suite_scheduler.ini
+++ b/suite_scheduler.ini
@@ -342,6 +342,13 @@
 pool: stress5
 file_bugs: True
 
+[NightlyKernelUsb]
+run_on: nightly
+suite: kernel_usb
+branch_specs: ==tot
+pool: kernel_usb
+file_bugs: True
+
 [Gizmo]
 run_on: nightly
 suite: bvt-cq
diff --git a/test_suites/control.kernel_usb b/test_suites/control.kernel_usb
new file mode 100644
index 0000000..8f60d50
--- /dev/null
+++ b/test_suites/control.kernel_usb
@@ -0,0 +1,49 @@
+# Copyright (c) 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 = "Chrome OS Team"
+NAME = "kernel_usb"
+PURPOSE = "USB peripherals detection."
+CRITERIA = "All tests with SUITE=kernel_usb must pass."
+
+TIME = "LONG"
+TEST_CATEGORY = "Functional"
+TEST_CLASS = "suite"
+TEST_TYPE = "Server"
+
+DOC = """
+This is the kernel_usb test suite.
+
+This suite is meant to cover boards on different kernel version
+for ARM and non-ARM boards. USB detection tests will be exercizing
+short detect tests and stress scenarios.
+Consistent failure to detect peripherals will indicate kernel
+regression.
+
+@param build: The name of the image to test.
+              Ex: x86-mario-release/R17-1412.33.0-a1-b29
+@param board: The board to test on.  Ex: x86-mario
+@param pool: The pool of machines to utilize for scheduling. If pool=None
+             board is used.
+@param check_hosts: require appropriate live hosts to exist in the lab.
+@param SKIP_IMAGE: (optional) If present and True, don't re-image devices.
+"""
+
+import common
+from autotest_lib.server.cros import provision
+from autotest_lib.server.cros.dynamic_suite import dynamic_suite
+
+_BUG_TEMPLATE = {
+    'labels': ['OS-Chrome', 'Cr-OS-Kernel', 'KernelUsb-Bug'],
+    'owner': 'kalin@chromium.org',
+}
+
+
+dynamic_suite.reimage_and_run(
+    build=build, board=board, name='kernel_usb', job=job, pool=pool,
+    check_hosts=check_hosts, add_experimental=True, num=num,
+    file_bugs=file_bugs, priority=priority, timeout_mins=timeout_mins,
+    devserver_url=devserver_url, version_prefix=provision.CROS_VERSION_PREFIX,
+    wait_for_results=wait_for_results, job_retry=job_retry,
+    bug_template=_BUG_TEMPLATE)