summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin Chen <xinchan@google.com>2016-06-30 14:57:25 -0700
committerXin Chen <xinchan@google.com>2016-07-01 11:17:10 -0700
commit0b6442b09ae5911b2af3c0b122e5c1688e2a3817 (patch)
tree9f93edd2a8f57615336e0105f662ced7f1980261
parent5d96cdce5acfb8b2c3d2630e70ffe95b56c4e2dd (diff)
downloadadt-infra-0b6442b09ae5911b2af3c0b122e5c1688e2a3817.tar.gz
Add system image UI tests into adt recipe.
Also refactor some string and remove dead code in test_ui. Change-Id: I88472223812c1090957a3ad1235f0851847f918d
-rw-r--r--build/scripts/slave/recipes/adt/adt.py59
-rw-r--r--emu_test/test_ui/test_ui.py31
-rw-r--r--emu_test/utils/zip_upload_logs.py26
3 files changed, 72 insertions, 44 deletions
diff --git a/build/scripts/slave/recipes/adt/adt.py b/build/scripts/slave/recipes/adt/adt.py
index aa260884..7320998a 100644
--- a/build/scripts/slave/recipes/adt/adt.py
+++ b/build/scripts/slave/recipes/adt/adt.py
@@ -32,6 +32,7 @@ def RunSteps(api):
env_path = ['%(PATH)s']
emulator_branches = ['emu-master-dev', 'emu-2.2-release']
is_cts = "cts" in str(api.properties.get('scheduler'))
+ is_ui = "ui" in str(api.properties.get('scheduler'))
# find android sdk root directory
home_dir = os.path.expanduser('~')
@@ -178,22 +179,31 @@ def RunSteps(api):
def PythonTestStep(description,
session_dir,
test_pattern,
- cfg_file, cfg_filter, emulator_path):
- deferred_step_result = api.python(description, dotest_path,
- ['-l', 'INFO', '-exec', emulator_path,
- '-s', session_dir,
- '-p', test_pattern,
- '-c', api.path.join(script_root, 'config', cfg_file),
- '-n', buildername,
- '-f', cfg_filter],
- env=env, stderr=api.raw_io.output('err'))
+ cfg_file,
+ cfg_filter,
+ emulator_path,
+ skip_adb_perf=False):
+ test_args = ['-l', 'INFO', '-exec', emulator_path,
+ '-s', session_dir,
+ '-p', test_pattern,
+ '-c', api.path.join(script_root, 'config', cfg_file),
+ '-n', buildername,
+ '-f', cfg_filter]
+ if skip_adb_perf is True:
+ test_args.append('--skip-adb-perf')
+ deferred_step_result = api.python(description, dotest_path, test_args, env=env, stderr=api.raw_io.output('err'))
if not deferred_step_result.is_ok:
stderr_output = deferred_step_result.get_error().result.stderr
print stderr_output
lines = [line for line in stderr_output.split('\n')
if line.startswith('FAIL:') or line.startswith('TIMEOUT:')]
for line in lines:
- api.step.active_result.presentation.logs[line] = ''
+ if "UI" in description and line.startswith('FAIL:'):
+ test_method = line[6:]
+ api.step.active_result.presentation.links['View Report: ' + test_method] = \
+ api.path.join("..", "..", "..", "UI_Result", buildername.replace(" ", "_"), 'build_%s-rev_%s' % (buildnum, rev), test_method + '_report', "index.html")
+ else:
+ api.step.active_result.presentation.logs[line] = ''
else:
print deferred_step_result.get_result().stderr
if "CTS" in description:
@@ -210,7 +220,7 @@ def RunSteps(api):
for emu_branch in emulator_branch_to_use:
emulator_path = api.path.join(emu_branch, 'tools', 'emulator')
emu_desc = "sdk emulator" if emu_branch not in emulator_branches else emu_branch
- if not is_cts:
+ if not is_cts and not is_ui:
for step in steps_to_run:
step_data = bootSteps[step]
PythonTestStep('Boot Test - %s System Image - %s' % (step_data.description, emu_desc),
@@ -219,25 +229,34 @@ def RunSteps(api):
'boot_cfg.csv',
step_data.filter,
emulator_path)
- elif project in emulator_branches:
+ elif is_cts and project in emulator_branches:
PythonTestStep('Run Emulator CTS Test',
api.path.join(log_dir, 'CTS_test'),
'test_cts.*',
'cts_cfg.csv',
'{}',
emulator_path)
+ elif is_ui:
+ PythonTestStep('Run Emulator UI Test',
+ api.path.join(log_dir, 'UI_test'),
+ 'test_ui.*',
+ 'ui_cfg.csv',
+ '{}',
+ emulator_path,
+ True)
- api.python("Zip and Upload Logs", log_util_path,
- ['--dir', log_dir,
- '--name', 'build_%s-rev_%s.zip' % (buildnum, rev),
- '--ip', MASTER_IP,
- '--user', MASTER_USER,
- '--dst', '%s%s/'% (api.properties['logs_dir'], buildername)],
- env=env)
+ upload_log_args = ['--dir', log_dir,
+ '--name', 'build_%s-rev_%s.zip' % (buildnum, rev),
+ '--ip', MASTER_IP,
+ '--user', MASTER_USER,
+ '--dst', '%s%s/'% (api.properties['logs_dir'], buildername)]
+ if is_ui:
+ upload_log_args.append('--skiplog')
+ api.python("Zip and Upload Logs", log_util_path, upload_log_args, env=env)
# If this build is triggered by scheduler, and it passes above steps
# trigger build on cross builers
- if not is_cts and not is_cross_build:
+ if not is_cts and not is_ui and not is_cross_build:
setProps()
api.trigger(getProps())
diff --git a/emu_test/test_ui/test_ui.py b/emu_test/test_ui/test_ui.py
index 7c1b6e16..fb8cc116 100644
--- a/emu_test/test_ui/test_ui.py
+++ b/emu_test/test_ui/test_ui.py
@@ -45,8 +45,8 @@ class UiAutomatorBaseTestCase(EmuBaseTestCase):
self.m_logger.error("Error in cleanup - %r", e)
pass
- def _save_gradle_test_report(self, avd, gradle_report_path):
- dst_path = os.path.join(emu_args.session_dir, str(avd) + '_report')
+ def _save_gradle_test_report(self, test_method, gradle_report_path):
+ dst_path = os.path.join(emu_args.session_dir, test_method + '_report')
if os.path.exists(dst_path):
shutil.rmtree(dst_path)
shutil.copytree(gradle_report_path, dst_path)
@@ -67,16 +67,19 @@ class UiAutomatorBaseTestCase(EmuBaseTestCase):
def ui_test_check(self, avd):
self.launch_emu_and_wait(avd)
- self.m_logger.info('AVD %s, system image UI tests start.', avd)
+ self.m_logger.info('System image UI tests (%s) start.' % self._testMethodName)
uitest_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..', 'system_image_uitests')
proc = self._launch_ui_test_with_avd_configs(uitest_dir, avd)
(output, err) = proc.communicate()
- self.m_logger.info(output)
- self.m_logger.info(err)
- m = re.search('file://(.+)index\.html', err)
- self.assertIsNotNone(m.group(1), "Failed to find the gradle test report.")
- self._save_gradle_test_report(avd, m.group(1))
- self.m_logger.info('AVD %s, system image UI tests end.', avd)
+ self.m_logger.info('gradle_stdout:\n' + output)
+ self.m_logger.info('gradle_stderr:\n' + err)
+ if err is not None and len(err.strip()) > 0:
+ m = re.search('file://(.+)index\.html', err)
+ if m.group(1) is None:
+ self.m_logger.error("Failed to find the gradle test report.")
+ self._save_gradle_test_report(self._testMethodName, m.group(1))
+ self.m_logger.info('System image UI tests (%s) end.' % self._testMethodName)
+ self.assertTrue(err is None or len(err.strip()) == 0, "The UI tests failed.")
def run_ui_test(self, avd_config):
self.avd_config = avd_config
@@ -84,16 +87,8 @@ class UiAutomatorBaseTestCase(EmuBaseTestCase):
self.ui_test_check(avd_config)
-def create_test_case_for_avds():
- avd_list = emu_args.avd_list
- for avd in avd_list:
- def fn(i):
- return lambda self: self.ui_test_check(i)
- setattr(UiAutomatorBaseTestCase, "test_ui_%s" % avd, fn(avd))
-
-
if emu_args.config_file is None:
- create_test_case_for_avds()
+ sys.exit(0)
else:
create_test_case_from_file("ui", UiAutomatorBaseTestCase, UiAutomatorBaseTestCase.run_ui_test)
diff --git a/emu_test/utils/zip_upload_logs.py b/emu_test/utils/zip_upload_logs.py
index 00fb1f3e..8efe450f 100644
--- a/emu_test/utils/zip_upload_logs.py
+++ b/emu_test/utils/zip_upload_logs.py
@@ -15,6 +15,7 @@ parser.add_argument('--ip', dest='remote_ip', action='store',
help='remote ip')
parser.add_argument('--dst', dest='remote_dir', action='store',
help='remote directory')
+parser.add_argument('--skiplog', dest='skiplog', action='store_true', help='skip uploading log')
args = parser.parse_args()
@@ -26,14 +27,16 @@ def zip_and_upload():
try:
args.remote_dir = args.remote_dir.replace(" ", "_")
- verbose_call(['zip', '-r', args.zip_name, args.log_dir])
- remote_host = '%s@%s' % (args.remote_user, args.remote_ip)
- remote_path = '%s:%s' % (remote_host, args.remote_dir)
- verbose_call(['ssh', remote_host, 'mkdir -p %s' % args.remote_dir])
- verbose_call(['scp', args.zip_name, remote_path])
- cts_logdir = os.path.join(args.log_dir, "CTS_test")
+
+ if args.skiplog is False:
+ verbose_call(['zip', '-r', args.zip_name, args.log_dir])
+ remote_host = '%s@%s' % (args.remote_user, args.remote_ip)
+ remote_path = '%s:%s' % (remote_host, args.remote_dir)
+ verbose_call(['ssh', remote_host, 'mkdir -p %s' % args.remote_dir])
+ verbose_call(['scp', args.zip_name, remote_path])
# if cts result is available, upload to public_html directory
+ cts_logdir = os.path.join(args.log_dir, "CTS_test")
if os.path.isdir(cts_logdir):
for x in os.listdir(cts_logdir):
if os.path.isdir(os.path.join(cts_logdir,x)):
@@ -43,6 +46,17 @@ def zip_and_upload():
verbose_call(['ssh', remote_host, 'mkdir -p %s' % cts_dst])
verbose_call(['scp', '-r', os.path.join(cts_logdir, x, ''), '%s:%s' % (remote_host, os.path.join(cts_dst, args.zip_name[:-4]))])
+ # if ui result is available, upload to public_html directory
+ ui_logdir = os.path.join(args.log_dir, "UI_test")
+ if os.path.isdir(ui_logdir):
+ builderName = os.path.basename(os.path.normpath(args.remote_dir))
+ ui_dst = os.path.join(args.remote_dir, "..", "..", "public_html", "UI_Result", builderName)
+ ui_dst = os.path.normpath(ui_dst)
+ verbose_call(['ssh', remote_host, 'mkdir -p %s' % os.path.join(ui_dst, args.zip_name[:-4])])
+ for x in os.listdir(ui_logdir):
+ if os.path.isdir(os.path.join(ui_logdir,x)):
+ verbose_call(['scp', '-r', os.path.join(ui_logdir, x), '%s:%s' % (remote_host, os.path.join(ui_dst, args.zip_name[:-4]))])
+
# remove log directory
try:
print "Delete directory %s" % args.log_dir