| # 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' |
| TIME = 'MEDIUM' |
| TEST_TYPE = 'Server' |
| |
| MAX_RESULT_SIZE_KB = 256 * 1024 |
| PY_VERSION = 3 |
| |
| # tast.py uses binaries installed from autotest_server_package.tar.bz2. |
| REQUIRE_SSP = True |
| |
| 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 https://chromium.googlesource.com/chromiumos/platform/tast/ |
| for more information. |
| |
| See http://go/tast-failures for information about investigating failures. |
| ''' |
| |
| def run(machine): |
| host=hosts.create_host(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.') |
| logging.info('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: |
| host.run('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: |
| host.run('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' % |
| os.path.dirname(path_to_chrome) |
| ) |
| |
| def cleanup(): |
| try: |
| host.run('rm -rf /usr/local/lacros') |
| except Exception as e: |
| logging.exception('Exception while clear lacros: %s', e) |
| |
| job.add_post_run_hook(cleanup) |
| |
| job.run_test('tast', |
| host=host, |
| test_exprs=[expr], |
| download_data_lazily=False, |
| ignore_test_failures=False, max_run_sec=3600, |
| command_args=args, |
| varslist=varslist, |
| clear_tpm=True) |
| |
| parallel_simple(run, machines) |