blob: 327d67a6e0092c74aef39d71e8affed51a8f5181 [file] [log] [blame]
# Copyright 2016 The Chromium 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 threading
import unittest
from import device_errors
from import device_utils
_devices_lock = threading.Lock()
_devices_condition = threading.Condition(_devices_lock)
_devices = set()
def PrepareDevices(*_args):
raw_devices = device_utils.DeviceUtils.HealthyDevices()
live_devices = []
for d in raw_devices:
d.WaitUntilFullyBooted(timeout=5, retries=0)
except (device_errors.CommandFailedError, device_errors.CommandTimeoutError,
with _devices_lock:
if not _devices:
raise Exception('No live devices attached.')
class DeviceTestCase(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(DeviceTestCase, self).__init__(*args, **kwargs)
self.serial = None
def setUp(self):
super(DeviceTestCase, self).setUp()
with _devices_lock:
while not _devices:
self.serial = _devices.pop()
def tearDown(self):
super(DeviceTestCase, self).tearDown()
with _devices_lock: