| Index: common/battor/battor/battor_wrapper_devicetest.py
|
| diff --git a/common/battor/battor/battor_wrapper_devicetest.py b/common/battor/battor/battor_wrapper_devicetest.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..91fb0cce484f15825075952f9cb05e56facdc9a7
|
| --- /dev/null
|
| +++ b/common/battor/battor/battor_wrapper_devicetest.py
|
| @@ -0,0 +1,70 @@
|
| +# 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 logging
|
| +import platform
|
| +import os
|
| +import sys
|
| +import time
|
| +import unittest
|
| +
|
| +if __name__ == '__main__':
|
| + sys.path.append(
|
| + os.path.join(os.path.dirname(__file__), '..'))
|
| +
|
| +from battor import battor_wrapper
|
| +from devil.utils import battor_device_mapping
|
| +from devil.utils import find_usb_devices
|
| +
|
| +
|
| +_SUPPORTED_CQ_PLATFORMS = ['win']
|
| +
|
| +class BattorWrapperDeviceTest(unittest.TestCase):
|
| + def setUp(self):
|
| + test_platform = platform.system()
|
| +
|
| + if 'Win' in test_platform:
|
| + self._platform = 'win'
|
| + else:
|
| + device_tree = find_usb_devices.GetBusNumberToDeviceTreeMap()
|
| + self._battor_list = battor_device_mapping.GetBattorList(device_tree)
|
| + if 'Linux' in test_platform:
|
| + self._platform = 'linux'
|
| + elif 'Darwin' in test_platform:
|
| + self._platform = 'mac'
|
| +
|
| + def testFullRun(self):
|
| + if self._platform not in _SUPPORTED_CQ_PLATFORMS:
|
| + logging.critical('Platform %s is not supported on CQ.' % self._platform)
|
| + return
|
| + if self._platform != 'win' and len(self._battor_list) < 1:
|
| + logging.critical('No BattOrs attached. Cannot run tests.')
|
| + return # No battors, cannot run test.
|
| + battor = battor_wrapper.BattorWrapper(self._platform)
|
| + battor.StartShell()
|
| + battor.StartTracing()
|
| + battor.RecordClockSyncMarker('abc')
|
| + time.sleep(1)
|
| + battor.StopTracing()
|
| + if self._platform == 'win':
|
| + # This is a work around for crbug.com/603971.
|
| + time.sleep(5)
|
| + battor._battor_shell.kill()
|
| + results = battor.CollectTraceData()
|
| + self.assertTrue('# BattOr' in results[0])
|
| + self.assertTrue('# voltage_range' in results[1])
|
| + self.assertTrue('# current_range' in results[2])
|
| + self.assertTrue('# sample_rate' in results[3])
|
| + # First line with results. Should be 3 'words'.
|
| + self.assertTrue(len(results[4].split()) == 3)
|
| + clock_sync_found = False
|
| + for entry in results:
|
| + if '<abc>' in entry:
|
| + clock_sync_found = True
|
| + break
|
| + self.assertTrue(clock_sync_found, 'BattOr Data:%s\n' % repr(results))
|
| +if __name__ == '__main__':
|
| + logging.getLogger().setLevel(logging.DEBUG)
|
| + unittest.main(verbosity=2)
|
| +
|
|
|