1#!/usr/bin/env vpython 2# Copyright 2016 The Chromium Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import logging 7import os 8import sys 9 10_CATAPULT_PATH = os.path.abspath( 11 os.path.join(os.path.dirname(__file__), '..', '..')) 12_DEVIL_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) 13_TYP_PATH = os.path.abspath(os.path.join(_CATAPULT_PATH, 'third_party', 'typ')) 14 15sys.path.append(_TYP_PATH) 16import typ 17 18sys.path.append(_DEVIL_PATH) 19from devil.android import device_test_case 20 21 22def _SetUpLogging(): 23 parsed_args = typ.arg_parser.ArgumentParser().parse_args(args=sys.argv[1:]) 24 verbosity = parsed_args.verbose 25 level = None 26 if verbosity == 0: 27 level = logging.WARNING 28 elif verbosity == 1: 29 level = logging.INFO 30 elif verbosity >= 2: 31 level = logging.DEBUG 32 else: 33 raise RuntimeError( 34 'Logging verbosity of {} is not allowed.'.format(verbosity)) 35 logging.basicConfig(level=level) 36 37 38def main(): 39 _SetUpLogging() 40 runner = typ.Runner() 41 runner.setup_fn = device_test_case.PrepareDevices 42 return runner.main( 43 coverage_source=[_DEVIL_PATH], 44 jobs=1, 45 suffixes=['*_devicetest.py'], 46 top_level_dir=_DEVIL_PATH) 47 48 49if __name__ == '__main__': 50 sys.exit(main()) 51