1# Copyright 2021 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import logging 6import os 7 8from autotest_lib.server import utils 9from autotest_lib.server.cros import chrome_sideloader 10 11AUTHOR = 'Chromium OS team' 12NAME = 'tast.lacros' 13TIME = 'MEDIUM' 14TEST_TYPE = 'Server' 15 16MAX_RESULT_SIZE_KB = 256 * 1024 17PY_VERSION = 3 18 19# tast.py uses binaries installed from autotest_server_package.tar.bz2. 20REQUIRE_SSP = True 21 22# Location to put the sideloaded chrome artifacts 23CHROME_DIR = '/usr/local/lacros' 24 25DOC = ''' 26Run the lacros test. 27 28This is a wrapper for lacros tast tests built by for Chromium builders. We 29mount a lacros artifact provisioned by TLS and configure the tast to execute 30lacros tests upon it. 31 32Tast is an integration-testing framework analogous to the test-running portion 33of Autotest. See https://chromium.googlesource.com/chromiumos/platform/tast/ 34for more information. 35 36See http://go/tast-failures for information about investigating failures. 37''' 38 39def run(machine): 40 host=hosts.create_host(machine) 41 varslist = [] 42 args_dict = utils.args_to_dict(args) 43 44 assert host.path_exists('/var/lib/imageloader/lacros'), ('lacros artifact' 45 'is not provisioned by CTP. Please check the CTP request.') 46 47 # Because this wrapper servers Chromium/Chrome CI builders, the Chrome version 48 # should be always fresher than the rootfs Chrome bundled in OS. 49 chrome_sideloader.setup_host(host, CHROME_DIR, None) 50 51 # lacros.DeployedBinary expects to set the directory containing chrome executable. 52 # If chrome is not under squashfs root, specify the relative path by exe_rel_path. 53 path_to_chrome = os.path.join(CHROME_DIR, 54 args_dict.get('exe_rel_path', 'chrome')) 55 assert host.path_exists(path_to_chrome), ( 56 'lacros artifact is not provisioned at expected path, %s' 57 % path_to_chrome) 58 59 expr = chrome_sideloader.get_tast_expr_from_file(host, args_dict, '%s/' % job.resultdir, CHROME_DIR) 60 if not expr: 61 expr = chrome_sideloader.get_tast_expr(args_dict) 62 logging.info('Tast expr: %s', expr) 63 64 varslist.append('lacros.DeployedBinary=%s' % 65 os.path.dirname(path_to_chrome) 66 ) 67 68 def cleanup(): 69 chrome_sideloader.cleanup_host(host, CHROME_DIR, None) 70 71 job.add_post_run_hook(cleanup) 72 73 job.run_test('tast', 74 host=host, 75 test_exprs=[expr], 76 download_data_lazily=False, 77 ignore_test_failures=False, max_run_sec=3600, 78 command_args=args, 79 varslist=varslist, 80 clear_tpm=True) 81 82parallel_simple(run, machines) 83