Commit 5c49978f authored by rnephew's avatar rnephew Committed by Commit bot

Add AMP support to test runner.

BUG=

Review URL: https://codereview.chromium.org/745793002

Cr-Commit-Position: refs/heads/master@{#308139}
parent 1ec108af
...@@ -2,10 +2,14 @@ ...@@ -2,10 +2,14 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
from pylib.remote.device import remote_device_environment
def CreateEnvironment(_args, error_func): def CreateEnvironment(args, error_func):
# TODO(jbudorick) Add local device environment. # TODO(jbudorick) Add local device environment.
# TODO(jbudorick) Add local machine environment. # TODO(jbudorick) Add local machine environment.
error_func('No environments currently supported.')
if args.environment == 'remote_device':
return remote_device_environment.RemoteDeviceEnvironment(args,
error_func)
error_func('Unable to create %s environment.' % args.environment)
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
from pylib import constants from pylib import constants
from pylib.gtest import gtest_test_instance from pylib.gtest import gtest_test_instance
from pylib.utils import isolator from pylib.utils import isolator
from pylib.uirobot import uirobot_test_instance
def CreateTestInstance(args, error_func): def CreateTestInstance(args, error_func):
...@@ -12,7 +14,8 @@ def CreateTestInstance(args, error_func): ...@@ -12,7 +14,8 @@ def CreateTestInstance(args, error_func):
if args.command == 'gtest': if args.command == 'gtest':
return gtest_test_instance.GtestTestInstance( return gtest_test_instance.GtestTestInstance(
args, isolator.Isolator(constants.ISOLATE_DEPS_DIR)) args, isolator.Isolator(constants.ISOLATE_DEPS_DIR))
if args.command == 'uirobot':
return uirobot_test_instance.UirobotTestInstance(args)
# TODO(jbudorick) Add instrumentation test instance. # TODO(jbudorick) Add instrumentation test instance.
error_func('Unable to create %s test instance.' % args.command) error_func('Unable to create %s test instance.' % args.command)
...@@ -24,7 +24,7 @@ class TestRun(object): ...@@ -24,7 +24,7 @@ class TestRun(object):
def SetUp(self): def SetUp(self):
raise NotImplementedError raise NotImplementedError
def RunTest(self): def RunTests(self):
raise NotImplementedError raise NotImplementedError
def TearDown(self): def TearDown(self):
......
...@@ -2,9 +2,17 @@ ...@@ -2,9 +2,17 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
def CreateTestRun(_args, _env, _test_instance, error_func): from pylib.remote.device import remote_device_gtest_run
from pylib.remote.device import remote_device_uirobot_run
def CreateTestRun(args, env, test_instance, error_func):
if args.environment == 'remote_device':
if test_instance.TestType() == 'gtest':
return remote_device_gtest_run.RemoteDeviceGtestRun(env, test_instance)
if test_instance.TestType() == 'uirobot':
return remote_device_uirobot_run.RemoteDeviceUirobotRun(
env, test_instance)
# TODO(jbudorick) Add local gtest test runs # TODO(jbudorick) Add local gtest test runs
# TODO(jbudorick) Add local instrumentation test runs. # TODO(jbudorick) Add local instrumentation test runs.
error_func('No test runs are currently supported.') error_func('Unable to create %s test run in %s environment' % (
test_instance.TestType(), args.environment))
...@@ -202,9 +202,9 @@ PYTHON_UNIT_TEST_SUITES = { ...@@ -202,9 +202,9 @@ PYTHON_UNIT_TEST_SUITES = {
} }
LOCAL_MACHINE_TESTS = ['junit', 'python'] LOCAL_MACHINE_TESTS = ['junit', 'python']
VALID_ENVIRONMENTS = ['local'] VALID_ENVIRONMENTS = ['local', 'remote_device']
VALID_TEST_TYPES = ['gtest', 'instrumentation', 'junit', 'linker', 'monkey', VALID_TEST_TYPES = ['gtest', 'instrumentation', 'junit', 'linker', 'monkey',
'perf', 'python', 'uiautomator'] 'perf', 'python', 'uiautomator', 'uirobot']
def GetBuildType(): def GetBuildType():
......
...@@ -42,9 +42,12 @@ class GtestTestInstance(test_instance.TestInstance): ...@@ -42,9 +42,12 @@ class GtestTestInstance(test_instance.TestInstance):
def __init__(self, options, isolate_delegate): def __init__(self, options, isolate_delegate):
super(GtestTestInstance, self).__init__() super(GtestTestInstance, self).__init__()
# TODO(jbudorick): Support multiple test suites.
if len(options.suite_name) > 1:
raise ValueError('Platform mode currently supports only 1 gtest suite')
self._apk_path = os.path.join( self._apk_path = os.path.join(
constants.GetOutDirectory(), '%s_apk' % options.suite_name, constants.GetOutDirectory(), '%s_apk' % options.suite_name[0],
'%s-debug.apk' % options.suite_name) '%s-debug.apk' % options.suite_name[0])
self._data_deps = [] self._data_deps = []
self._gtest_filter = options.test_filter self._gtest_filter = options.test_filter
if options.isolate_file_path: if options.isolate_file_path:
......
...@@ -299,8 +299,8 @@ class TestRunner(base_test_runner.BaseTestRunner): ...@@ -299,8 +299,8 @@ class TestRunner(base_test_runner.BaseTestRunner):
if 'SmallTest' in annotations: if 'SmallTest' in annotations:
return 1 * 60 return 1 * 60
logging.warn(("Test size not found in annotations for test '{0}', using " + logging.warn(("Test size not found in annotations for test '%s', using " +
"1 minute for timeout.").format(test)) "1 minute for timeout.") % test)
return 1 * 60 return 1 * 60
def _RunTest(self, test, timeout): def _RunTest(self, test, timeout):
......
# Copyright 2014 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.
# Copyright 2014 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.
# Copyright 2014 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.
"""Environment setup and teardown for remote devices."""
import os
import sys
from pylib import constants
from pylib.base import environment
from pylib.remote.device import remote_device_helper
sys.path.append(os.path.join(
constants.DIR_SOURCE_ROOT, 'third_party', 'requests', 'src'))
sys.path.append(os.path.join(
constants.DIR_SOURCE_ROOT, 'third_party', 'appurify-python', 'src'))
import appurify.api
class RemoteDeviceEnvironment(environment.Environment):
"""An environment for running on remote devices."""
def __init__(self, args, error_func):
"""Constructor.
Args:
args: Command line arguments.
error_func: error to show when using bad command line arguments.
"""
super(RemoteDeviceEnvironment, self).__init__()
if args.api_key_file:
with open(args.api_key_file) as api_key_file:
self._api_key = api_key_file.read().strip()
elif args.api_key:
self._api_key = args.api_key
else:
error_func('Must set api key with --api-key or --api-key-file')
if args.api_secret_file:
with open(args.api_secret_file) as api_secret_file:
self._api_secret = api_secret_file.read().strip()
elif args.api_secret:
self._api_secret = args.api_secret
else:
error_func('Must set api secret with --api-secret or --api-secret-file')
self._api_protocol = args.api_protocol
self._api_address = args.api_address
self._api_port = args.api_port
self._access_token = ''
self._results_path = args.results_path
self._remote_device = args.remote_device
self._remote_device_os = args.remote_device_os
self._runner_package = args.runner_package
self._runner_type = args.runner_type
self._device = ''
if not args.trigger and not args.collect:
self._trigger = True
self._collect = True
else:
self._trigger = args.trigger
self._collect = args.collect
def SetUp(self):
"""Set up the test environment."""
os.environ['APPURIFY_API_PROTO'] = self._api_protocol
os.environ['APPURIFY_API_HOST'] = self._api_address
os.environ['APPURIFY_API_PORT'] = self._api_port
self._GetAccessToken()
if self._trigger:
self._device = self._SelectDevice()
def TearDown(self):
"""Teardown the test environment."""
self._RevokeAccessToken()
def __enter__(self):
"""Set up the test run when used as a context manager."""
self.SetUp()
return self
def __exit__(self, exc_type, exc_val, exc_tb):
"""Tears down the test run when used as a context manager."""
self.TearDown()
def _GetAccessToken(self):
"""Generates access token for remote device service."""
access_token_results = appurify.api.access_token_generate(
self._api_key, self._api_secret)
remote_device_helper.TestHttpResponse(access_token_results,
'Unable to generate access token.')
self._access_token = access_token_results.json()['response']['access_token']
def _RevokeAccessToken(self):
"""Destroys access token for remote device service."""
revoke_token_results = appurify.api.access_token_revoke(self._access_token)
remote_device_helper.TestHttpResponse(revoke_token_results,
'Unable to revoke access token.')
def _SelectDevice(self):
"""Select which device to use."""
dev_list_res = appurify.api.devices_list(self._access_token)
remote_device_helper.TestHttpResponse(dev_list_res,
'Unable to generate access token.')
device_list = dev_list_res.json()['response']
for device in device_list:
if (device['name'] == self._remote_device
and device['os_version'] == self._remote_device_os):
return device['device_type_id']
raise remote_device_helper.RemoteDeviceError(
'No device found: %s %s' % (self._remote_device,
self._remote_device_os))
@property
def device(self):
return self._device
@property
def token(self):
return self._access_token
@property
def results_path(self):
return self._results_path
@property
def runner_type(self):
return self._runner_type
@property
def runner_package(self):
return self._runner_package
@property
def trigger(self):
return self._trigger
@property
def collect(self):
return self._collect
# Copyright 2014 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.
"""Run specific test on specific environment."""
import logging
import os
import sys
from pylib import constants
from pylib.base import base_test_result
from pylib.remote.device import remote_device_test_run
from pylib.remote.device import remote_device_helper
sys.path.append(os.path.join(
constants.DIR_SOURCE_ROOT, 'third_party', 'requests', 'src'))
sys.path.append(os.path.join(
constants.DIR_SOURCE_ROOT, 'third_party', 'appurify-python', 'src'))
import appurify.api
import appurify.utils
class RemoteDeviceGtestRun(remote_device_test_run.RemoteDeviceTestRun):
"""Run gtests and uirobot tests on a remote device."""
DEFAULT_RUNNER_TYPE = 'robotium'
DEFAULT_RUNNER_PACKAGE = (
'org.chromium.native_test.ChromiumNativeTestInstrumentationTestRunner')
def TestPackage(self):
pass
#override
def _TriggerSetUp(self):
"""Set up the triggering of a test run."""
self._app_id = self._UploadAppToDevice(self._test_instance.apk)
if not self._env.runner_type:
runner_type = self.DEFAULT_RUNNER_TYPE
logging.info('Using default runner type: %s', self.DEFAULT_RUNNER_TYPE)
else:
runner_type = self._env.runner_type
if not self._env.runner_package:
runner_package = self.DEFAULT_RUNNER_PACKAGE
logging.info('Using default runner package: %s',
self.DEFAULT_RUNNER_TYPE)
else:
runner_package = self._env.runner_package
self._test_id = self._UploadTestToDevice(runner_type)
config_body = {'runner': runner_package}
self._SetTestConfig(runner_type, config_body)
#override
def _ParseTestResults(self):
# TODO(rnephew): Populate test results object.
results = base_test_result.TestRunResults()
return results
# Copyright 2014 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.
"""Common functions and Exceptions for remote_device_*"""
class RemoteDeviceError(Exception):
"""Exception to throw when problems occur with remote device service."""
pass
def TestHttpResponse(response, error_msg):
"""Checks the Http response from remote device service.
Args:
response: response dict from the remote device service.
error_msg: Error message to display if bad response is seen.
"""
if response.status_code != 200:
raise RemoteDeviceError(error_msg)
# Copyright 2014 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.
"""Run specific test on specific environment."""
import logging
import os
import sys
import tempfile
import time
from pylib import constants
from pylib.base import test_run
from pylib.remote.device import remote_device_helper
sys.path.append(os.path.join(
constants.DIR_SOURCE_ROOT, 'third_party', 'requests', 'src'))
sys.path.append(os.path.join(
constants.DIR_SOURCE_ROOT, 'third_party', 'appurify-python', 'src'))
import appurify.api
import appurify.utils
class RemoteDeviceTestRun(test_run.TestRun):
"""Run gtests and uirobot tests on a remote device."""
WAIT_TIME = 5
COMPLETE = 'complete'
def __init__(self, env, test_instance):
"""Constructor.
Args:
env: Environment the tests will run in.
test_instance: The test that will be run.
"""
super(RemoteDeviceTestRun, self).__init__(env, test_instance)
self._env = env
self._test_instance = test_instance
self._app_id = ''
self._test_id = ''
self._results = ''
def TestPackage(self):
pass
#override
def RunTests(self):
"""Run the test."""
if self._env.trigger:
test_start_res = appurify.api.tests_run(
self._env.token, self._env.device, self._app_id, self._test_id)
remote_device_helper.TestHttpResponse(
test_start_res, 'Unable to run test.')
test_run_id = test_start_res.json()['response']['test_run_id']
if not self._env.collect:
assert isinstance(self._env.trigger, basestring), (
'File for storing test_run_id must be a string.')
with open(self._env.trigger, 'w') as test_run_id_file:
test_run_id_file.write(test_run_id)
if self._env.collect:
if not self._env.trigger:
assert isinstance(self._env.trigger, basestring), (
'File for storing test_run_id must be a string.')
with open(self._env.collect, 'r') as test_run_id_file:
test_run_id = test_run_id_file.read()
while self._GetTestStatus(test_run_id) != self.COMPLETE:
time.sleep(self.WAIT_TIME)
self._DownloadTestResults(self._env.results_path)
return self._ParseTestResults()
#override
def TearDown(self):
"""Tear down the test run."""
pass
def __enter__(self):
"""Set up the test run when used as a context manager."""
self.SetUp()
return self
def __exit__(self, exc_type, exc_val, exc_tb):
"""Tear down the test run when used as a context manager."""
self.TearDown()
#override
def SetUp(self):
"""Set up a test run."""
if self._env.trigger:
self._TriggerSetUp()
def _TriggerSetUp(self):
"""Set up the triggering of a test run."""
raise NotImplementedError
def _ParseTestResults(self):
raise NotImplementedError
def _GetTestByName(self, test_name):
"""Gets test_id for specific test.
Args:
test_name: Test to find the ID of.
"""
test_list_res = appurify.api.tests_list(self._env.token)
remote_device_helper.TestHttpResponse(test_list_res,
'Unable to get tests list.')
for test in test_list_res.json()['response']:
if test['test_type'] == test_name:
return test['test_id']
raise remote_device_helper.RemoteDeviceError(
'No test found with name %s' % (test_name))
def _DownloadTestResults(self, results_path):
"""Download the test results from remote device service.
Args:
results_path: path to download results to.
"""
if results_path:
if not os.path.exists(os.path.basename(results_path)):
os.makedirs(os.path.basename(results_path))
appurify.utils.wget(self._results['results']['url'], results_path)
def _GetTestStatus(self, test_run_id):
"""Checks the state of the test, and sets self._results
Args:
test_run_id: Id of test on on remote service.
"""
test_check_res = appurify.api.tests_check_result(self._env.token,
test_run_id)
remote_device_helper.TestHttpResponse(test_check_res,
'Unable to get test status.')
self._results = test_check_res.json()['response']
return self._results['status']
def _UploadAppToDevice(self, apk_path):
"""Upload app to device."""
apk_name = os.path.basename(apk_path)
with open(apk_path, 'rb') as apk_src:
upload_results = appurify.api.apps_upload(self._env.token,
apk_src, 'raw', name=apk_name)
remote_device_helper.TestHttpResponse(
upload_results, 'Unable to upload %s.' %(apk_path))
return upload_results.json()['response']['app_id']
def _UploadTestToDevice(self, test_type):
"""Upload test to device
Args:
test_type: Type of test that is being uploaded. Ex. uirobot, gtest..
"""
with open(self._test_instance.apk, 'rb') as test_src:
upload_results = appurify.api.tests_upload(
self._env.token, test_src, 'raw', test_type, app_id=self._app_id)
remote_device_helper.TestHttpResponse(upload_results,
'Unable to upload %s.' %(self._test_instance.apk))
return upload_results.json()['response']['test_id']
def _SetTestConfig(self, runner_type, body):
"""Generates and uploads config file for test.
Args:
extras: Extra arguments to set in the config file.
"""
with tempfile.TemporaryFile() as config:
config_data = ['[appurify]', '[%s]' % runner_type]
config_data.extend('%s=%s' % (k, v) for k, v in body.iteritems())
config.write(''.join('%s\n' % l for l in config_data))
config.flush()
config.seek(0)
config_response = appurify.api.config_upload(self._env.token,
config, self._test_id)
remote_device_helper.TestHttpResponse(config_response,
'Unable to upload test config.')
# Copyright 2014 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.
"""Run specific test on specific environment."""
import logging
import os
import sys
from pylib import constants
from pylib.base import base_test_result
from pylib.remote.device import remote_device_test_run
from pylib.remote.device import remote_device_helper
sys.path.append(os.path.join(
constants.DIR_SOURCE_ROOT, 'third_party', 'requests', 'src'))
sys.path.append(os.path.join(
constants.DIR_SOURCE_ROOT, 'third_party', 'appurify-python', 'src'))
import appurify.api
import appurify.utils
class RemoteDeviceUirobotRun(remote_device_test_run.RemoteDeviceTestRun):
"""Run uirobot tests on a remote device."""
DEFAULT_RUNNER_TYPE = 'android_robot'
def __init__(self, env, test_instance):
"""Constructor.
Args:
env: Environment the tests will run in.
test_instance: The test that will be run.
"""
super(RemoteDeviceUirobotRun, self).__init__(env, test_instance)
def TestPackage(self):
pass
#override
def _TriggerSetUp(self):
"""Set up the triggering of a test run."""
self._app_id = self._UploadAppToDevice(self._test_instance.apk_under_test)
if not self._env.runner_type:
runner_type = self.DEFAULT_RUNNER_TYPE
logging.info('Using default runner type: %s', self.DEFAULT_RUNNER_TYPE)
else:
runner_type = self._env.runner_type
self._test_id = self._GetTestByName(runner_type)
config_body = {'duration': self._test_instance.minutes}
self._SetTestConfig(runner_type, config_body)
#override
def _ParseTestResults(self):
# TODO(rnephew): Populate test results object.
results = remote_device_test_run.TestRunResults()
return results
# Copyright 2014 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.
# Copyright 2014 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 os
from pylib import constants
from pylib.base import test_instance
class UirobotTestInstance(test_instance.TestInstance):
def __init__(self, args):
"""Constructor.
Args:
args: Command line arguments.
"""
super(UirobotTestInstance, self).__init__()
self._apk_under_test = os.path.join(
constants.GetOutDirectory(), args.apk_under_test)
self._minutes = args.minutes
#override
def TestType(self):
"""Returns type of test."""
return 'uirobot'
#override
def SetUp(self):
"""Setup for test."""
pass
#override
def TearDown(self):
"""Teardown for test."""
pass
@property
def apk_under_test(self):
"""Returns the app to run the test on."""
return self._apk_under_test
@property
def suite(self):
"""Returns the test suite, none for uirobot."""
return None
@property
def minutes(self):
"""Returns the number of minutes to run the uirobot for."""
return self._minutes
...@@ -119,6 +119,47 @@ def ProcessCommonOptions(args): ...@@ -119,6 +119,47 @@ def ProcessCommonOptions(args):
os.environ['PATH'] = adb_dir + os.pathsep + os.environ['PATH'] os.environ['PATH'] = adb_dir + os.pathsep + os.environ['PATH']
def AddRemoteDeviceOptions(parser):
group = parser.add_argument_group('Remote Device Options')
group.add_argument('--trigger', default='',
help=('Only triggers the test if set. Stores test_run_id '
'in given file path. '))
group.add_argument('--collect', default='',
help=('Only collects the test results if set. '
'Gets test_run_id from given file path.'))
group.add_argument('--remote-device', default='Nexus 5',
help=('Device type to run test on.'))
group.add_argument('--remote-device-os', default='4.4.2',
help=('OS to have on the device.'))
group.add_argument('--results-path', default='',
help=('File path to download results to.'))
group.add_argument('--api-protocol', default='http',
help=('HTTP protocol to use. (http or https)'))
group.add_argument('--api-address', default='172.22.21.180',
help=('Address to send HTTP requests.'))
group.add_argument('--api-port', default='80',
help=('Port to send HTTP requests to.'))
group.add_argument('--runner-type', default='',
help=('Type of test to run as.'))
group.add_argument('--runner-package', default='',
help=('Package name of test.'))
group.add_argument('--apk-under-test', default='apks/Chrome.apk',
help=('APK to run tests on.'))
api_secret_group = group.add_mutually_exclusive_group()
api_secret_group.add_argument('--api-secret', default='',
help=('API secret for remote devices.'))
api_secret_group.add_argument('--api-secret-file', default='',
help=('Path to file that contains API secret.'))
api_key_group = group.add_mutually_exclusive_group()
api_key_group.add_argument('--api-key', default='',
help=('API key for remote devices.'))
api_key_group.add_argument('--api-key-file', default='',
help=('Path to file that contains API key.'))
def AddDeviceOptions(parser): def AddDeviceOptions(parser):
"""Adds device options to |parser|.""" """Adds device options to |parser|."""
group = parser.add_argument_group(title='Device Options') group = parser.add_argument_group(title='Device Options')
...@@ -166,6 +207,7 @@ def AddGTestOptions(parser): ...@@ -166,6 +207,7 @@ def AddGTestOptions(parser):
'path') 'path')
AddDeviceOptions(parser) AddDeviceOptions(parser)
AddCommonOptions(parser) AddCommonOptions(parser)
AddRemoteDeviceOptions(parser)
def AddLinkerTestOptions(parser): def AddLinkerTestOptions(parser):
...@@ -426,7 +468,6 @@ def AddMonkeyTestOptions(parser): ...@@ -426,7 +468,6 @@ def AddMonkeyTestOptions(parser):
AddCommonOptions(parser) AddCommonOptions(parser)
AddDeviceOptions(parser) AddDeviceOptions(parser)
def ProcessMonkeyTestOptions(args): def ProcessMonkeyTestOptions(args):
"""Processes all monkey test options. """Processes all monkey test options.
...@@ -452,6 +493,17 @@ def ProcessMonkeyTestOptions(args): ...@@ -452,6 +493,17 @@ def ProcessMonkeyTestOptions(args):
args.seed, args.seed,
args.extra_args) args.extra_args)
def AddUirobotTestOptions(parser):
"""Adds uirobot test options to |option_parser|."""
group = parser.add_argument_group('Uirobot Test Options')
group.add_argument(
'--minutes', default=5, type=int,
help='Number of minutes to run uirobot test [default: %default].')
AddCommonOptions(parser)
AddDeviceOptions(parser)
AddRemoteDeviceOptions(parser)
def AddPerfTestOptions(parser): def AddPerfTestOptions(parser):
"""Adds perf test options to |parser|.""" """Adds perf test options to |parser|."""
...@@ -812,7 +864,7 @@ def RunTestsCommand(args, parser): ...@@ -812,7 +864,7 @@ def RunTestsCommand(args, parser):
ProcessCommonOptions(args) ProcessCommonOptions(args)
if args.enable_platform_mode: if args.enable_platform_mode:
return RunTestsInPlatformMode(args, parser.error) return RunTestsInPlatformMode(args, parser)
if command in constants.LOCAL_MACHINE_TESTS: if command in constants.LOCAL_MACHINE_TESTS:
devices = [] devices = []
...@@ -845,7 +897,7 @@ def RunTestsCommand(args, parser): ...@@ -845,7 +897,7 @@ def RunTestsCommand(args, parser):
_SUPPORTED_IN_PLATFORM_MODE = [ _SUPPORTED_IN_PLATFORM_MODE = [
# TODO(jbudorick): Add support for more test types. # TODO(jbudorick): Add support for more test types.
'gtest', 'gtest', 'uirobot',
] ]
...@@ -860,6 +912,9 @@ def RunTestsInPlatformMode(args, parser): ...@@ -860,6 +912,9 @@ def RunTestsInPlatformMode(args, parser):
args, env, test, parser.error) as test_run: args, env, test, parser.error) as test_run:
results = test_run.RunTests() results = test_run.RunTests()
if args.trigger:
return 0 # Not returning results, only triggering.
report_results.LogFull( report_results.LogFull(
results=results, results=results,
test_type=test.TestType(), test_type=test.TestType(),
...@@ -871,7 +926,7 @@ def RunTestsInPlatformMode(args, parser): ...@@ -871,7 +926,7 @@ def RunTestsInPlatformMode(args, parser):
json_results.GenerateJsonResultsFile( json_results.GenerateJsonResultsFile(
results, args.json_results_file) results, args.json_results_file)
return results return 0 if results.DidRunPass() else 1
CommandConfigTuple = collections.namedtuple( CommandConfigTuple = collections.namedtuple(
...@@ -902,6 +957,9 @@ VALID_COMMANDS = { ...@@ -902,6 +957,9 @@ VALID_COMMANDS = {
'linker': CommandConfigTuple( 'linker': CommandConfigTuple(
AddLinkerTestOptions, AddLinkerTestOptions,
'Linker tests'), 'Linker tests'),
'uirobot': CommandConfigTuple(
AddUirobotTestOptions,
'Uirobot test'),
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment