2015-07-03 19:04:58 +03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# ***** BEGIN LICENSE BLOCK *****
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
# ***** END LICENSE BLOCK *****
|
|
|
|
|
|
|
|
import copy
|
|
|
|
import datetime
|
2018-11-15 19:54:13 +03:00
|
|
|
import json
|
2015-07-03 19:04:58 +03:00
|
|
|
import os
|
2016-07-22 23:31:37 +03:00
|
|
|
import re
|
2015-07-03 19:04:58 +03:00
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
# load modules from parent dir
|
|
|
|
sys.path.insert(1, os.path.dirname(sys.path[0]))
|
|
|
|
|
|
|
|
from mozharness.base.log import FATAL
|
2018-10-11 18:47:55 +03:00
|
|
|
from mozharness.base.script import BaseScript, PreScriptAction
|
2019-01-14 17:58:41 +03:00
|
|
|
from mozharness.mozilla.automation import TBPL_RETRY
|
2015-07-03 19:04:58 +03:00
|
|
|
from mozharness.mozilla.mozbase import MozbaseMixin
|
2018-09-26 23:23:26 +03:00
|
|
|
from mozharness.mozilla.testing.android import AndroidMixin
|
2015-07-03 19:04:58 +03:00
|
|
|
from mozharness.mozilla.testing.testbase import TestingMixin, testing_config_options
|
2018-07-24 13:51:54 +03:00
|
|
|
from mozharness.mozilla.testing.codecoverage import (
|
|
|
|
CodeCoverageMixin,
|
|
|
|
code_coverage_config_options
|
|
|
|
)
|
2015-07-03 19:04:58 +03:00
|
|
|
|
2018-11-27 19:41:13 +03:00
|
|
|
SUITE_DEFAULT_E10S = ['geckoview-junit', 'mochitest', 'reftest']
|
|
|
|
SUITE_NO_E10S = ['cppunittest', 'geckoview-junit', 'xpcshell']
|
|
|
|
|
2015-07-03 19:04:58 +03:00
|
|
|
|
2018-09-26 23:23:26 +03:00
|
|
|
class AndroidEmulatorTest(TestingMixin, BaseScript, MozbaseMixin, CodeCoverageMixin,
|
|
|
|
AndroidMixin):
|
2018-05-18 01:19:00 +03:00
|
|
|
"""
|
|
|
|
A mozharness script for Android functional tests (like mochitests and reftests)
|
|
|
|
run on an Android emulator. This script starts and manages an Android emulator
|
|
|
|
for the duration of the required tests. This is like desktop_unittest.py, but
|
|
|
|
for Android emulator test platforms.
|
|
|
|
"""
|
2015-07-03 19:04:58 +03:00
|
|
|
config_options = [[
|
|
|
|
["--test-suite"],
|
|
|
|
{"action": "store",
|
|
|
|
"dest": "test_suite",
|
2017-10-17 23:45:07 +03:00
|
|
|
"default": None
|
2017-10-25 03:21:41 +03:00
|
|
|
}
|
2016-07-22 23:31:37 +03:00
|
|
|
], [
|
|
|
|
["--total-chunk"],
|
|
|
|
{"action": "store",
|
|
|
|
"dest": "total_chunks",
|
|
|
|
"default": None,
|
|
|
|
"help": "Number of total chunks",
|
2017-10-25 03:21:41 +03:00
|
|
|
}
|
2016-07-22 23:31:37 +03:00
|
|
|
], [
|
|
|
|
["--this-chunk"],
|
|
|
|
{"action": "store",
|
|
|
|
"dest": "this_chunk",
|
|
|
|
"default": None,
|
|
|
|
"help": "Number of this chunk",
|
2017-10-25 03:21:41 +03:00
|
|
|
}
|
2018-07-04 23:01:36 +03:00
|
|
|
], [
|
|
|
|
["--gpu-required"],
|
|
|
|
{"action": "store_true",
|
|
|
|
"dest": "gpu_required",
|
|
|
|
"default": False,
|
|
|
|
"help": "Run additional verification on modified tests using gpu instances.",
|
|
|
|
}
|
2018-07-03 16:33:44 +03:00
|
|
|
], [
|
|
|
|
["--log-raw-level"],
|
|
|
|
{"action": "store",
|
|
|
|
"dest": "log_raw_level",
|
|
|
|
"default": "info",
|
|
|
|
"help": "Set log level (debug|info|warning|error|critical|fatal)",
|
|
|
|
}
|
|
|
|
], [
|
|
|
|
["--log-tbpl-level"],
|
|
|
|
{"action": "store",
|
|
|
|
"dest": "log_tbpl_level",
|
|
|
|
"default": "info",
|
|
|
|
"help": "Set log level (debug|info|warning|error|critical|fatal)",
|
|
|
|
}
|
2018-11-27 19:41:13 +03:00
|
|
|
], [
|
2019-04-15 21:18:33 +03:00
|
|
|
['--disable-e10s', ],
|
|
|
|
{"action": "store_false",
|
2018-11-27 19:41:13 +03:00
|
|
|
"dest": "e10s",
|
2019-04-15 21:18:33 +03:00
|
|
|
"default": True,
|
|
|
|
"help": "Run tests without multiple processes (e10s).",
|
2018-11-27 19:41:13 +03:00
|
|
|
}
|
2019-04-10 20:29:47 +03:00
|
|
|
], [
|
|
|
|
['--enable-webrender'],
|
|
|
|
{"action": "store_true",
|
|
|
|
"dest": "enable_webrender",
|
|
|
|
"default": False,
|
|
|
|
"help": "Run with WebRender enabled.",
|
|
|
|
}
|
|
|
|
], [
|
|
|
|
['--disable-webrender'],
|
|
|
|
{"action": "store_true",
|
|
|
|
"dest": "disable_webrender",
|
|
|
|
"default": False,
|
|
|
|
"help": "Run with WebRender force-disabled.",
|
|
|
|
}
|
2018-07-24 13:51:54 +03:00
|
|
|
]] + copy.deepcopy(testing_config_options) + \
|
|
|
|
copy.deepcopy(code_coverage_config_options)
|
2015-07-03 19:04:58 +03:00
|
|
|
|
|
|
|
def __init__(self, require_config_file=False):
|
|
|
|
super(AndroidEmulatorTest, self).__init__(
|
|
|
|
config_options=self.config_options,
|
|
|
|
all_actions=['clobber',
|
|
|
|
'setup-avds',
|
|
|
|
'start-emulator',
|
|
|
|
'download-and-extract',
|
|
|
|
'create-virtualenv',
|
2018-09-26 23:23:26 +03:00
|
|
|
'verify-device',
|
2015-07-03 19:04:58 +03:00
|
|
|
'install',
|
|
|
|
'run-tests',
|
2017-10-25 03:21:41 +03:00
|
|
|
],
|
2015-07-03 19:04:58 +03:00
|
|
|
require_config_file=require_config_file,
|
|
|
|
config={
|
2018-01-20 17:41:53 +03:00
|
|
|
'virtualenv_modules': [],
|
|
|
|
'virtualenv_requirements': [],
|
2015-07-03 19:04:58 +03:00
|
|
|
'require_test_zip': True,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
# these are necessary since self.config is read only
|
|
|
|
c = self.config
|
|
|
|
abs_dirs = self.query_abs_dirs()
|
|
|
|
self.installer_url = c.get('installer_url')
|
|
|
|
self.installer_path = c.get('installer_path')
|
|
|
|
self.test_url = c.get('test_url')
|
2016-06-22 01:42:50 +03:00
|
|
|
self.test_packages_url = c.get('test_packages_url')
|
2015-07-03 19:04:58 +03:00
|
|
|
self.test_manifest = c.get('test_manifest')
|
|
|
|
self.robocop_path = os.path.join(abs_dirs['abs_work_dir'], "robocop.apk")
|
|
|
|
self.test_suite = c.get('test_suite')
|
2016-07-22 23:31:37 +03:00
|
|
|
self.this_chunk = c.get('this_chunk')
|
|
|
|
self.total_chunks = c.get('total_chunks')
|
2017-10-17 23:45:07 +03:00
|
|
|
if self.test_suite and self.test_suite not in self.config["suite_definitions"]:
|
2016-07-22 23:31:37 +03:00
|
|
|
# accept old-style test suite name like "mochitest-3"
|
|
|
|
m = re.match("(.*)-(\d*)", self.test_suite)
|
|
|
|
if m:
|
|
|
|
self.test_suite = m.group(1)
|
|
|
|
if self.this_chunk is None:
|
|
|
|
self.this_chunk = m.group(2)
|
2016-06-20 20:39:40 +03:00
|
|
|
self.xre_path = None
|
2018-07-03 16:33:44 +03:00
|
|
|
self.device_serial = 'emulator-5554'
|
|
|
|
self.log_raw_level = c.get('log_raw_level')
|
|
|
|
self.log_tbpl_level = c.get('log_tbpl_level')
|
2018-11-27 19:41:13 +03:00
|
|
|
self.e10s = c.get('e10s')
|
2019-04-10 20:29:47 +03:00
|
|
|
self.enable_webrender = c.get('enable_webrender')
|
|
|
|
self.disable_webrender = c.get('disable_webrender')
|
|
|
|
if self.enable_webrender:
|
|
|
|
# AndroidMixin uses this when launching the emulator. We only want
|
|
|
|
# GLES3 if we're running WebRender
|
|
|
|
self.use_gles3 = True
|
2015-07-03 19:04:58 +03:00
|
|
|
|
|
|
|
def query_abs_dirs(self):
|
|
|
|
if self.abs_dirs:
|
|
|
|
return self.abs_dirs
|
|
|
|
abs_dirs = super(AndroidEmulatorTest, self).query_abs_dirs()
|
|
|
|
dirs = {}
|
|
|
|
dirs['abs_test_install_dir'] = os.path.join(
|
|
|
|
abs_dirs['abs_work_dir'], 'tests')
|
2018-03-23 01:33:15 +03:00
|
|
|
dirs['abs_test_bin_dir'] = os.path.join(
|
|
|
|
abs_dirs['abs_work_dir'], 'tests', 'bin')
|
2015-07-03 19:04:58 +03:00
|
|
|
dirs['abs_xre_dir'] = os.path.join(
|
|
|
|
abs_dirs['abs_work_dir'], 'hostutils')
|
|
|
|
dirs['abs_modules_dir'] = os.path.join(
|
|
|
|
dirs['abs_test_install_dir'], 'modules')
|
|
|
|
dirs['abs_blob_upload_dir'] = os.path.join(
|
|
|
|
abs_dirs['abs_work_dir'], 'blobber_upload_dir')
|
2016-03-16 00:27:36 +03:00
|
|
|
dirs['abs_mochitest_dir'] = os.path.join(
|
|
|
|
dirs['abs_test_install_dir'], 'mochitest')
|
2017-10-17 23:45:07 +03:00
|
|
|
dirs['abs_reftest_dir'] = os.path.join(
|
|
|
|
dirs['abs_test_install_dir'], 'reftest')
|
|
|
|
dirs['abs_xpcshell_dir'] = os.path.join(
|
|
|
|
dirs['abs_test_install_dir'], 'xpcshell')
|
2016-08-24 17:06:15 +03:00
|
|
|
dirs['abs_marionette_dir'] = os.path.join(
|
2016-12-12 15:05:34 +03:00
|
|
|
dirs['abs_test_install_dir'], 'marionette', 'harness', 'marionette_harness')
|
2016-08-24 17:06:15 +03:00
|
|
|
dirs['abs_marionette_tests_dir'] = os.path.join(
|
|
|
|
dirs['abs_test_install_dir'], 'marionette', 'tests', 'testing',
|
2016-12-12 15:05:34 +03:00
|
|
|
'marionette', 'harness', 'marionette_harness', 'tests')
|
2016-05-17 18:53:40 +03:00
|
|
|
dirs['abs_avds_dir'] = self.config.get("avds_dir", "/home/cltbld/.android")
|
2015-07-03 19:04:58 +03:00
|
|
|
|
|
|
|
for key in dirs.keys():
|
|
|
|
if key not in abs_dirs:
|
|
|
|
abs_dirs[key] = dirs[key]
|
|
|
|
self.abs_dirs = abs_dirs
|
|
|
|
return self.abs_dirs
|
|
|
|
|
2018-05-18 01:19:00 +03:00
|
|
|
def _query_tests_dir(self, test_suite):
|
|
|
|
dirs = self.query_abs_dirs()
|
|
|
|
try:
|
|
|
|
test_dir = self.config["suite_definitions"][test_suite]["testsdir"]
|
|
|
|
except Exception:
|
|
|
|
test_dir = test_suite
|
|
|
|
return os.path.join(dirs['abs_test_install_dir'], test_dir)
|
|
|
|
|
2019-04-08 17:34:59 +03:00
|
|
|
def _get_mozharness_test_paths(self, suite):
|
|
|
|
test_paths = os.environ.get('MOZHARNESS_TEST_PATHS')
|
|
|
|
if not test_paths:
|
|
|
|
return
|
|
|
|
|
|
|
|
return json.loads(test_paths).get(suite)
|
|
|
|
|
2015-07-03 19:04:58 +03:00
|
|
|
def _build_command(self):
|
|
|
|
c = self.config
|
|
|
|
dirs = self.query_abs_dirs()
|
|
|
|
|
2016-07-22 23:31:37 +03:00
|
|
|
if self.test_suite not in self.config["suite_definitions"]:
|
|
|
|
self.fatal("Key '%s' not defined in the config!" % self.test_suite)
|
2015-08-14 23:54:08 +03:00
|
|
|
|
2015-07-03 19:04:58 +03:00
|
|
|
cmd = [
|
|
|
|
self.query_python_path('python'),
|
|
|
|
'-u',
|
|
|
|
os.path.join(
|
2018-05-18 01:19:00 +03:00
|
|
|
self._query_tests_dir(self.test_suite),
|
2016-07-22 23:31:37 +03:00
|
|
|
self.config["suite_definitions"][self.test_suite]["run_filename"]
|
2015-07-03 19:04:58 +03:00
|
|
|
),
|
|
|
|
]
|
|
|
|
|
|
|
|
raw_log_file = os.path.join(dirs['abs_blob_upload_dir'],
|
|
|
|
'%s_raw.log' % self.test_suite)
|
2015-07-20 12:39:03 +03:00
|
|
|
|
|
|
|
error_summary_file = os.path.join(dirs['abs_blob_upload_dir'],
|
|
|
|
'%s_errorsummary.log' % self.test_suite)
|
2015-07-03 19:04:58 +03:00
|
|
|
str_format_values = {
|
2018-07-03 16:33:44 +03:00
|
|
|
'device_serial': self.device_serial,
|
2018-05-18 01:19:00 +03:00
|
|
|
# IP address of the host as seen from the emulator
|
|
|
|
'remote_webserver': '10.0.2.2',
|
2016-06-20 20:39:40 +03:00
|
|
|
'xre_path': self.xre_path,
|
|
|
|
'utility_path': self.xre_path,
|
2018-07-03 16:33:44 +03:00
|
|
|
'http_port': '8854', # starting http port to use for the mochitest server
|
|
|
|
'ssl_port': '4454', # starting ssl port to use for the server
|
2015-07-03 19:04:58 +03:00
|
|
|
'certs_path': os.path.join(dirs['abs_work_dir'], 'tests/certs'),
|
|
|
|
# TestingMixin._download_and_extract_symbols() will set
|
|
|
|
# self.symbols_path when downloading/extracting.
|
|
|
|
'symbols_path': self.symbols_path,
|
|
|
|
'modules_dir': dirs['abs_modules_dir'],
|
|
|
|
'installer_path': self.installer_path,
|
|
|
|
'raw_log_file': raw_log_file,
|
2018-07-03 16:33:44 +03:00
|
|
|
'log_tbpl_level': self.log_tbpl_level,
|
|
|
|
'log_raw_level': self.log_raw_level,
|
2015-07-20 12:39:03 +03:00
|
|
|
'error_summary_file': error_summary_file,
|
2018-07-03 16:33:44 +03:00
|
|
|
'gecko_log': '-',
|
2016-08-24 17:06:15 +03:00
|
|
|
# marionette options
|
|
|
|
'address': c.get('marionette_address'),
|
2018-07-03 16:33:44 +03:00
|
|
|
'marionette_extra': c.get('marionette_extra', ''),
|
2018-07-03 16:33:47 +03:00
|
|
|
'xpcshell_extra': c.get('xpcshell_extra', ''),
|
2016-08-24 17:06:15 +03:00
|
|
|
'test_manifest': os.path.join(
|
|
|
|
dirs['abs_marionette_tests_dir'],
|
|
|
|
self.config.get('marionette_test_manifest', '')
|
|
|
|
),
|
2019-04-11 23:49:33 +03:00
|
|
|
'gtest_dir': os.path.join(dirs['abs_test_install_dir'], 'gtest',
|
|
|
|
'gtest_bin', 'gtest'),
|
2015-07-03 19:04:58 +03:00
|
|
|
}
|
2017-11-02 22:53:39 +03:00
|
|
|
|
2019-04-08 17:34:59 +03:00
|
|
|
user_paths = self._get_mozharness_test_paths(self.test_suite)
|
2018-11-15 19:54:13 +03:00
|
|
|
|
2016-07-22 23:31:37 +03:00
|
|
|
for option in self.config["suite_definitions"][self.test_suite]["options"]:
|
|
|
|
opt = option.split('=')[0]
|
|
|
|
# override configured chunk options with script args, if specified
|
2017-11-02 22:53:39 +03:00
|
|
|
if opt in ('--this-chunk', '--total-chunks'):
|
|
|
|
if user_paths or getattr(self, opt.replace('-', '_').strip('_'), None) is not None:
|
|
|
|
continue
|
|
|
|
|
2017-02-14 02:53:21 +03:00
|
|
|
if '%(app)' in option:
|
|
|
|
# only query package name if requested
|
2018-10-03 18:02:57 +03:00
|
|
|
cmd.extend([option % {'app': self.query_package_name()}])
|
2017-02-14 02:53:21 +03:00
|
|
|
else:
|
2018-07-03 16:33:47 +03:00
|
|
|
option = option % str_format_values
|
|
|
|
if option:
|
|
|
|
cmd.extend([option])
|
2015-07-03 19:04:58 +03:00
|
|
|
|
2018-11-27 19:41:13 +03:00
|
|
|
if 'mochitest' in self.test_suite:
|
|
|
|
category = 'mochitest'
|
|
|
|
elif 'reftest' in self.test_suite or 'crashtest' in self.test_suite:
|
|
|
|
category = 'reftest'
|
|
|
|
else:
|
|
|
|
category = self.test_suite
|
|
|
|
if category not in SUITE_NO_E10S:
|
|
|
|
if category in SUITE_DEFAULT_E10S and not self.e10s:
|
|
|
|
cmd.extend(['--disable-e10s'])
|
|
|
|
elif category not in SUITE_DEFAULT_E10S and self.e10s:
|
|
|
|
cmd.extend(['--e10s'])
|
|
|
|
|
2018-05-23 16:59:51 +03:00
|
|
|
if not (self.verify_enabled or self.per_test_coverage):
|
|
|
|
if user_paths:
|
2019-04-08 17:34:59 +03:00
|
|
|
cmd.extend(user_paths)
|
2018-05-23 16:59:51 +03:00
|
|
|
elif not (self.verify_enabled or self.per_test_coverage):
|
|
|
|
if self.this_chunk is not None:
|
|
|
|
cmd.extend(['--this-chunk', self.this_chunk])
|
|
|
|
if self.total_chunks is not None:
|
|
|
|
cmd.extend(['--total-chunks', self.total_chunks])
|
2015-07-03 19:04:58 +03:00
|
|
|
|
2019-04-10 20:29:47 +03:00
|
|
|
if self.disable_webrender:
|
|
|
|
cmd.extend(['--setenv', 'MOZ_WEBRENDER=0'])
|
|
|
|
elif self.enable_webrender:
|
|
|
|
cmd.extend(['--setenv', 'MOZ_WEBRENDER=1'])
|
|
|
|
|
2016-07-22 23:31:37 +03:00
|
|
|
try_options, try_tests = self.try_args(self.test_suite)
|
2015-09-22 19:55:29 +03:00
|
|
|
cmd.extend(try_options)
|
2018-04-20 00:56:50 +03:00
|
|
|
if not self.verify_enabled and not self.per_test_coverage:
|
2017-10-17 23:45:07 +03:00
|
|
|
cmd.extend(self.query_tests_args(
|
|
|
|
self.config["suite_definitions"][self.test_suite].get("tests"),
|
|
|
|
None,
|
|
|
|
try_tests))
|
2015-09-01 14:48:41 +03:00
|
|
|
|
2018-07-24 13:51:54 +03:00
|
|
|
if self.java_code_coverage_enabled:
|
|
|
|
cmd.extend(['--enable-coverage',
|
2018-09-06 19:59:57 +03:00
|
|
|
'--coverage-output-dir', self.java_coverage_output_dir])
|
2018-07-24 13:51:54 +03:00
|
|
|
|
2015-07-03 19:04:58 +03:00
|
|
|
return cmd
|
|
|
|
|
2018-05-10 01:33:27 +03:00
|
|
|
def _query_suites(self):
|
|
|
|
if self.test_suite:
|
|
|
|
return [(self.test_suite, self.test_suite)]
|
|
|
|
# per-test mode: determine test suites to run
|
2018-08-15 21:54:06 +03:00
|
|
|
|
|
|
|
# For each test category, provide a list of supported sub-suites and a mapping
|
|
|
|
# between the per_test_base suite name and the android suite name.
|
2018-05-10 01:33:27 +03:00
|
|
|
all = [('mochitest', {'plain': 'mochitest',
|
|
|
|
'chrome': 'mochitest-chrome',
|
2018-08-15 21:54:06 +03:00
|
|
|
'mochitest-media': 'mochitest-media',
|
2018-05-10 01:33:27 +03:00
|
|
|
'plain-clipboard': 'mochitest-plain-clipboard',
|
|
|
|
'plain-gpu': 'mochitest-plain-gpu'}),
|
|
|
|
('reftest', {'reftest': 'reftest',
|
2018-08-15 21:54:06 +03:00
|
|
|
'crashtest': 'crashtest',
|
|
|
|
'jsreftest': 'jsreftest'}),
|
2018-05-10 01:33:27 +03:00
|
|
|
('xpcshell', {'xpcshell': 'xpcshell'})]
|
|
|
|
suites = []
|
|
|
|
for (category, all_suites) in all:
|
|
|
|
cat_suites = self.query_per_test_category_suites(category, all_suites)
|
|
|
|
for k in cat_suites.keys():
|
|
|
|
suites.append((k, cat_suites[k]))
|
|
|
|
return suites
|
|
|
|
|
|
|
|
def _query_suite_categories(self):
|
|
|
|
if self.test_suite:
|
|
|
|
categories = [self.test_suite]
|
|
|
|
else:
|
|
|
|
# per-test mode
|
|
|
|
categories = ['mochitest', 'reftest', 'xpcshell']
|
|
|
|
return categories
|
|
|
|
|
|
|
|
##########################################
|
|
|
|
# Actions for AndroidEmulatorTest #
|
|
|
|
##########################################
|
|
|
|
|
2018-05-18 01:19:00 +03:00
|
|
|
def preflight_install(self):
|
|
|
|
# in the base class, this checks for mozinstall, but we don't use it
|
|
|
|
pass
|
|
|
|
|
2018-05-10 01:33:27 +03:00
|
|
|
@PreScriptAction('create-virtualenv')
|
|
|
|
def pre_create_virtualenv(self, action):
|
|
|
|
dirs = self.query_abs_dirs()
|
|
|
|
requirements = None
|
2018-09-21 22:23:48 +03:00
|
|
|
suites = self._query_suites()
|
|
|
|
if ('mochitest-media', 'mochitest-media') in suites:
|
2018-05-10 01:33:27 +03:00
|
|
|
# mochitest-media is the only thing that needs this
|
|
|
|
requirements = os.path.join(dirs['abs_mochitest_dir'],
|
|
|
|
'websocketprocessbridge',
|
|
|
|
'websocketprocessbridge_requirements.txt')
|
2018-09-21 22:23:48 +03:00
|
|
|
elif ('marionette', 'marionette') in suites:
|
2018-05-10 01:33:27 +03:00
|
|
|
requirements = os.path.join(dirs['abs_test_install_dir'],
|
|
|
|
'config', 'marionette_requirements.txt')
|
|
|
|
if requirements:
|
|
|
|
self.register_virtualenv_module(requirements=[requirements],
|
|
|
|
two_pass=True)
|
|
|
|
|
2015-07-03 19:04:58 +03:00
|
|
|
def download_and_extract(self):
|
|
|
|
"""
|
2018-09-26 23:23:26 +03:00
|
|
|
Download and extract fennec APK, tests.zip, host utils, and robocop (if required).
|
2015-07-03 19:04:58 +03:00
|
|
|
"""
|
2017-10-25 03:21:41 +03:00
|
|
|
super(AndroidEmulatorTest, self).download_and_extract(
|
|
|
|
suite_categories=self._query_suite_categories())
|
2015-07-03 19:04:58 +03:00
|
|
|
dirs = self.query_abs_dirs()
|
2017-10-17 23:45:07 +03:00
|
|
|
if self.test_suite and self.test_suite.startswith('robocop'):
|
2015-07-03 19:04:58 +03:00
|
|
|
robocop_url = self.installer_url[:self.installer_url.rfind('/')] + '/robocop.apk'
|
|
|
|
self.info("Downloading robocop...")
|
|
|
|
self.download_file(robocop_url, 'robocop.apk', dirs['abs_work_dir'], error_level=FATAL)
|
2018-10-03 18:02:57 +03:00
|
|
|
self.xre_path = self.download_hostutils(dirs['abs_xre_dir'])
|
2015-07-03 19:04:58 +03:00
|
|
|
|
|
|
|
def install(self):
|
|
|
|
"""
|
2018-09-26 23:23:26 +03:00
|
|
|
Install APKs on the device.
|
2015-07-03 19:04:58 +03:00
|
|
|
"""
|
2017-10-25 03:21:41 +03:00
|
|
|
install_needed = (not self.test_suite) or \
|
|
|
|
self.config["suite_definitions"][self.test_suite].get("install")
|
|
|
|
if install_needed is False:
|
2016-07-27 16:47:54 +03:00
|
|
|
self.info("Skipping apk installation for %s" % self.test_suite)
|
|
|
|
return
|
2016-11-22 23:49:46 +03:00
|
|
|
assert self.installer_path is not None, \
|
|
|
|
"Either add installer_path to the config or use --installer-path."
|
2018-09-26 23:23:26 +03:00
|
|
|
self.install_apk(self.installer_path)
|
2015-07-03 19:04:58 +03:00
|
|
|
# Install Robocop if required
|
2017-10-17 23:45:07 +03:00
|
|
|
if self.test_suite and self.test_suite.startswith('robocop'):
|
2018-09-26 23:23:26 +03:00
|
|
|
self.install_apk(self.robocop_path)
|
|
|
|
self.info("Finished installing apps for %s" % self.device_serial)
|
2015-07-03 19:04:58 +03:00
|
|
|
|
|
|
|
def run_tests(self):
|
|
|
|
"""
|
|
|
|
Run the tests
|
|
|
|
"""
|
2017-10-17 23:45:07 +03:00
|
|
|
self.start_time = datetime.datetime.now()
|
2018-04-19 20:19:31 +03:00
|
|
|
max_per_test_time = datetime.timedelta(minutes=60)
|
2017-10-17 23:45:07 +03:00
|
|
|
|
2018-04-19 20:19:31 +03:00
|
|
|
per_test_args = []
|
2017-10-17 23:45:07 +03:00
|
|
|
suites = self._query_suites()
|
2018-01-24 23:59:41 +03:00
|
|
|
minidump = self.query_minidump_stackwalk()
|
2018-04-19 20:19:31 +03:00
|
|
|
for (per_test_suite, suite) in suites:
|
2017-10-17 23:45:07 +03:00
|
|
|
self.test_suite = suite
|
|
|
|
|
|
|
|
cmd = self._build_command()
|
|
|
|
|
2018-09-26 23:23:26 +03:00
|
|
|
try:
|
|
|
|
cwd = self._query_tests_dir(self.test_suite)
|
|
|
|
except Exception:
|
|
|
|
self.fatal("Don't know how to run --test-suite '%s'!" % self.test_suite)
|
|
|
|
|
2017-10-17 23:45:07 +03:00
|
|
|
env = self.query_env()
|
2018-01-24 23:59:41 +03:00
|
|
|
if minidump:
|
|
|
|
env['MINIDUMP_STACKWALK'] = minidump
|
2017-10-17 23:45:07 +03:00
|
|
|
env['MOZ_UPLOAD_DIR'] = self.query_abs_dirs()['abs_blob_upload_dir']
|
|
|
|
env['MINIDUMP_SAVE_PATH'] = self.query_abs_dirs()['abs_blob_upload_dir']
|
|
|
|
env['RUST_BACKTRACE'] = 'full'
|
|
|
|
|
2018-05-28 13:44:24 +03:00
|
|
|
summary = {}
|
2018-04-19 20:19:31 +03:00
|
|
|
for per_test_args in self.query_args(per_test_suite):
|
|
|
|
if (datetime.datetime.now() - self.start_time) > max_per_test_time:
|
|
|
|
# Running tests has run out of time. That is okay! Stop running
|
|
|
|
# them so that a task timeout is not triggered, and so that
|
2017-10-17 23:45:07 +03:00
|
|
|
# (partial) results are made available in a timely manner.
|
2018-04-19 20:19:31 +03:00
|
|
|
self.info("TinderboxPrint: Running tests took too long: "
|
|
|
|
"Not all tests were executed.<br/>")
|
|
|
|
# Signal per-test time exceeded, to break out of suites and
|
2017-10-17 23:45:07 +03:00
|
|
|
# suite categories loops also.
|
2019-01-14 17:58:41 +03:00
|
|
|
return
|
2017-10-17 23:45:07 +03:00
|
|
|
|
|
|
|
final_cmd = copy.copy(cmd)
|
2018-04-19 20:19:31 +03:00
|
|
|
if len(per_test_args) > 0:
|
|
|
|
# in per-test mode, remove any chunk arguments from command
|
2017-10-17 23:45:07 +03:00
|
|
|
for arg in final_cmd:
|
|
|
|
if 'total-chunk' in arg or 'this-chunk' in arg:
|
|
|
|
final_cmd.remove(arg)
|
2018-04-19 20:19:31 +03:00
|
|
|
final_cmd.extend(per_test_args)
|
2017-10-17 23:45:07 +03:00
|
|
|
|
2018-05-18 01:19:00 +03:00
|
|
|
self.info("Running the command %s" % subprocess.list2cmdline(final_cmd))
|
2017-10-17 23:45:07 +03:00
|
|
|
self.info("##### %s log begins" % self.test_suite)
|
|
|
|
|
2018-01-20 17:41:53 +03:00
|
|
|
suite_category = self.test_suite
|
2017-10-17 23:45:07 +03:00
|
|
|
parser = self.get_test_output_parser(
|
|
|
|
suite_category,
|
|
|
|
config=self.config,
|
|
|
|
log_obj=self.log_obj,
|
2018-01-20 17:41:53 +03:00
|
|
|
error_list=[])
|
2017-10-17 23:45:07 +03:00
|
|
|
self.run_command(final_cmd, cwd=cwd, env=env, output_parser=parser)
|
2018-05-11 14:14:30 +03:00
|
|
|
tbpl_status, log_level, summary = parser.evaluate_parser(0,
|
|
|
|
previous_summary=summary)
|
2017-10-17 23:45:07 +03:00
|
|
|
parser.append_tinderboxprint_line(self.test_suite)
|
|
|
|
|
|
|
|
self.info("##### %s log ends" % self.test_suite)
|
|
|
|
|
2018-04-19 20:19:31 +03:00
|
|
|
if len(per_test_args) > 0:
|
2018-05-16 19:51:37 +03:00
|
|
|
self.record_status(tbpl_status, level=log_level)
|
2018-04-19 20:19:31 +03:00
|
|
|
self.log_per_test_status(per_test_args[-1], tbpl_status, log_level)
|
2019-01-14 17:58:41 +03:00
|
|
|
if tbpl_status == TBPL_RETRY:
|
|
|
|
self.info("Per-test run abandoned due to RETRY status")
|
|
|
|
return
|
2017-10-17 23:45:07 +03:00
|
|
|
else:
|
2018-05-16 19:51:37 +03:00
|
|
|
self.record_status(tbpl_status, level=log_level)
|
2017-10-17 23:45:07 +03:00
|
|
|
self.log("The %s suite: %s ran with return status: %s" %
|
|
|
|
(suite_category, suite, tbpl_status), level=log_level)
|
|
|
|
|
2017-10-25 03:21:41 +03:00
|
|
|
|
2015-07-03 19:04:58 +03:00
|
|
|
if __name__ == '__main__':
|
2018-09-26 23:23:26 +03:00
|
|
|
test = AndroidEmulatorTest()
|
|
|
|
test.run_and_exit()
|