blob: 1615729222d5c18bc447256d789312ff2b8de913 [file] [log] [blame]
# Copyright 2021 The Chromium OS 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 base64
import logging
import os
from autotest_lib.client.common_lib.error import TestFail
from autotest_lib.server import utils
AUTHOR = 'Chromium OS team'
NAME = 'tast.lacros'
TEST_TYPE = 'Server'
MAX_RESULT_SIZE_KB = 256 * 1024
# uses binaries installed from autotest_server_package.tar.bz2.
DOC = '''
Run the lacros test.
This is a wrapper for lacros tast tests built by for Chromium builders. We
mount a lacros artifact provisioned by TLS and configure the tast to execute
lacros tests upon it.
Tast is an integration-testing framework analogous to the test-running portion
of Autotest. See
for more information.
See http://go/tast-failures for information about investigating failures.
def run(machine):
varslist = []
args_dict = utils.args_to_dict(args)
expr = args_dict.get('tast_expr')
if not expr:
expr_b64 = args_dict.get('tast_expr_b64')
if expr_b64:
expr = base64.b64decode(expr_b64)
if not expr:
raise TestFail(
'Attribute expression is unspecified; set tast_expr in --args.\n'
' Example: test_that --args="tast_expr=lacros.Basic"\n'
' If the expression contains spaces, consider transforming it to\n'
' base64 and passing it via tast_expr_b64 flag.\n'
' Example: test_that --args="tast_expr_b64=KCJncm91cDptYWlubGluZSIgJiYgImRlcDpsYWNyb3MiKQ=="\n'
' More details at go/lacros-on-skylab.')'Tast expr: %s', expr)
assert host.path_exists('/var/lib/imageloader/lacros'), ('lacros artifact'
'is not provisioned by CTP. Please check the CTP request.')
# Because this wrapper servers Chromium/Chrome CI builders, the Chrome version
# should be always fresher than the rootfs Chrome bundled in OS.
try:'mkdir -p /tmp/lacros /usr/local/lacros && '
'imageloader --mount --mount_component=lacros'
' --mount_point=/tmp/lacros && '
# The provisioned path of squashfs file will be cleared by
# clear_tpm, so we do hard copy after the mount.
'cp -r /tmp/lacros/* /usr/local/lacros/')
except Exception as e:
raise TestFail('Exception while mount lacros artifact: %s', e)
finally:'imageloader --unmount --mount_point=/tmp/lacros;'
'rm -rf /tmp/lacros')
# lacrosDeployedBinary expects to set the directory containing chrome executable.
# If chrome is not under squashfs root, specify the relative path by exe_rel_path.
path_to_chrome = os.path.join('/usr/local/lacros',
args_dict.get('exe_rel_path', 'chrome'))
assert host.path_exists(path_to_chrome), (
'lacros artifact is not provisioned at expected path, %s'
% path_to_chrome)
varslist.append('lacrosDeployedBinary=%s' %
def cleanup():
try:'rm -rf /usr/local/lacros')
except Exception as e:
logging.exception('Exception while clear lacros: %s', e)
ignore_test_failures=False, max_run_sec=3600,
parallel_simple(run, machines)