1# Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import logging 6 7from autotest_lib.client.common_lib import error 8from autotest_lib.client.common_lib import utils 9from autotest_lib.server.cros import host_lock_manager 10from autotest_lib.server.cros import sonic_client_utils 11 12 13AUTHOR = "Chrome OS Team" 14NAME = "sonic_AppTest" 15PURPOSE = "Demonstrate the ability to start the chromecast app." 16CRITERIA = "This test will fail if the app fails to start." 17TIME = "SHORT" 18TEST_CATEGORY = "General" 19TEST_CLASS = "sonic" 20TEST_TYPE = "server" 21 22DOC = """ 23This is a sonic test that will cast a tab. 24 25Tab cast is achieved through desktopui_SonicExtension, which is a client 26test that handles all the extension manipulation necessary to talk to the 27sonic device. Note that the sonic host and the DUT need to be on the same 28subnet. 29 30Usage: test_that <ip of Cros DUT> --board=<boardname of DUT> 31 --args="sonic_hostname=<ip of sonichost>" 32""" 33 34args_dict = utils.args_to_dict(args) 35 36def run(machine): 37 extension_dir = args_dict.get('extension_dir') 38 lock_manager = host_lock_manager.HostLockManager() 39 40 # If the hostname of a sonic device to use with this test 41 # is passed through --args, just try to lock it, otherwise 42 # look for an unlocked host with the sonic label. The context 43 # manager handles unlocking hosts locked through the lock_manager. 44 with host_lock_manager.HostsLockedBy(lock_manager): 45 sonic_hostname = args_dict.get('sonic_hostname') 46 if sonic_hostname: 47 lock_manager.lock([sonic_hostname]) 48 else: 49 sonic_hostname = sonic_client_utils.acquire_sonic(lock_manager) 50 logging.info('Using sonic host: %s', sonic_hostname) 51 cros_host = hosts.create_host(machine) 52 sonic_host = hosts.create_host(sonic_hostname) 53 job.run_test('sonic_AppTest', cros_host=cros_host, 54 sonic_host=sonic_host, extension_dir=extension_dir, 55 disable_sysinfo=True) 56 57 58parallel_simple(run, machines) 59