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