Bluetooth: begin testing infrastructure

Implement an XML-RPC server for both the Client (DUT) and Tester
based off the existing WiFi testing approach, with a server class
to proxy for them.

BUG=chromium:256771
TEST=simple test that instantiates both,
 verify xml-rpc server was running on both devices

Change-Id: Icbaf9409460f0d535c160f6a11f1db86f989f46a
Reviewed-on: https://gerrit.chromium.org/gerrit/62890
Reviewed-by: Scott James Remnant <keybuk@chromium.org>
Tested-by: Scott James Remnant <keybuk@chromium.org>
Commit-Queue: Scott James Remnant <keybuk@chromium.org>
diff --git a/server/cros/bluetooth/bluetooth_tester.py b/server/cros/bluetooth/bluetooth_tester.py
new file mode 100644
index 0000000..fde3683
--- /dev/null
+++ b/server/cros/bluetooth/bluetooth_tester.py
@@ -0,0 +1,46 @@
+# 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.
+
+import logging
+
+from autotest_lib.client.common_lib import error
+from autotest_lib.client.cros import constants
+from autotest_lib.server import autotest
+
+
+class BluetoothTester(object):
+    """BluetoothTester is a thin layer of logic over a remote tester."""
+
+    XMLRPC_BRINGUP_TIMEOUT_SECONDS = 60
+
+    @property
+    def host(self):
+        """@return host object representing the remote tester."""
+        return self._host
+
+    def __init__(self, tester_host):
+        """Construct a BluetoothTester.
+
+        @param tester_host host object representing a remote host.
+
+        """
+        self._host = tester_host
+        # Make sure the client library is on the device so that the proxy code
+        # is there when we try to call it.
+        client_at = autotest.Autotest(self.host)
+        client_at.install()
+        # Start up the XML-RPC proxy on the tester.
+        self._proxy = self.host.xmlrpc_connect(
+                constants.BLUETOOTH_TESTER_XMLRPC_SERVER_COMMAND,
+                constants.BLUETOOTH_TESTER_XMLRPC_SERVER_PORT,
+                command_name=
+                  constants.BLUETOOTH_TESTER_XMLRPC_SERVER_CLEANUP_PATTERN,
+                ready_test_name=
+                  constants.BLUETOOTH_TESTER_XMLRPC_SERVER_READY_METHOD,
+                timeout_seconds=self.XMLRPC_BRINGUP_TIMEOUT_SECONDS)
+
+    def close(self):
+        """Tear down state associated with the client."""
+        # This kills the RPC server.
+        self._host.close()