| # Copyright 2019 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| from PB.infra.fuchsia import Fuchsia |
| from recipe_engine.recipe_api import Property |
| |
| DEPS = [ |
| 'fuchsia/artifacts', |
| 'fuchsia/build', |
| 'fuchsia/buildbucket_util', |
| 'fuchsia/checkout', |
| 'fuchsia/experimental', |
| 'fuchsia/fuchsia', |
| 'fuchsia/testing', |
| 'fuchsia/testing_requests', |
| 'fuchsia/testsharder', |
| 'recipe_engine/buildbucket', |
| 'recipe_engine/isolated', |
| 'recipe_engine/file', |
| 'recipe_engine/json', |
| 'recipe_engine/path', |
| # Needed because we pass our own api into FuchsiaBuildResults |
| 'recipe_engine/platform', |
| 'recipe_engine/properties', |
| 'recipe_engine/raw_io', |
| 'recipe_engine/step', |
| 'recipe_engine/swarming', |
| ] |
| |
| PROPERTIES = { |
| 'build_artifact_hash': |
| Property( |
| kind=str, |
| help='Hash for which build artifact may be downloaded', |
| default='abc'), |
| 'device_type': |
| Property( |
| kind=str, |
| help='Passed through to spec field Fuchsia.Test.device_type', |
| default='QEMU'), |
| 'pave': |
| Property( |
| kind=bool, |
| help='Passed through to spec field Fuchsia.Test.pave', |
| default=True), |
| 'test_in_shards': |
| Property( |
| kind=bool, |
| help='Passed through to spec field Fuchsia.Test.test_in_shards', |
| default=False), |
| 'collect_timeout_secs': |
| Property( |
| kind=int, |
| help=('Passed through to spec field ' |
| 'Fuchsia.Test.collect_timeout_secs'), |
| default=0), |
| 'deprecated': |
| Property( |
| kind=bool, |
| help='Whether to use the deprecated code path', |
| default=False), |
| 'per_test_timeout_secs': |
| Property( |
| kind=int, |
| help='Passed through to spec field Fuchsia.Test.per_test_timeout_secs', |
| default=0), |
| 'use_runtests': |
| Property(kind=bool, help='Whether to use runtests', default=False), |
| 'variants': |
| Property(kind=list, help='GN variants', default=[]), |
| } |
| |
| |
| def RunSteps(api, build_artifact_hash, device_type, pave, test_in_shards, |
| collect_timeout_secs, deprecated, per_test_timeout_secs, |
| use_runtests, variants): |
| |
| # Intended to be a minimal amount of code to create a valid FuchsiaBuildResults object. |
| checkout_root = api.path['start_dir'] |
| fuchsia_build_dir = checkout_root.join('out', 'default') |
| gn_results = api.build.GNResults(api, fuchsia_build_dir) |
| images_list = api.json.read('read images', |
| fuchsia_build_dir.join('images.json')).json.output |
| images_dict = {i['name']: i for i in images_list} |
| build_results = api.build.FuchsiaBuildResults( |
| api, checkout_root, 'arm64', variants, 'build-type', fuchsia_build_dir, |
| checkout_root.join('out', 'default.zircon'), '//boards/foo.gni', |
| '//products/foo.gni', gn_results, images_dict) |
| |
| # Configure context of uploaded artifacts for test task construction. |
| api.artifacts.gcs_bucket = 'fuchsia-artifacts' |
| api.artifacts.uuid = api.buildbucket_util.id |
| |
| test_spec = Fuchsia.Test( |
| device_type=device_type, |
| pave=pave, |
| pool='fuchsia.tests', |
| test_in_shards=test_in_shards, |
| collect_timeout_secs=collect_timeout_secs, |
| per_test_timeout_secs=per_test_timeout_secs, |
| use_runtests=use_runtests, |
| default_service_account='default_service_account', |
| targets_serial=True, |
| ) |
| |
| if deprecated: |
| shard_requests = api.testing_requests.deprecated_shard_requests( |
| build_results, |
| api.testing_requests.deprecated_test_cmds(test_spec), |
| test_spec.device_type, |
| test_spec.pool, |
| test_spec.timeout_secs, |
| test_spec.pave, |
| default_service_account=test_spec.default_service_account, |
| ) |
| assert len(shard_requests) == 1 |
| else: |
| shards = (api.testsharder.Shard( |
| 'NAME', (api.testsharder.Test( |
| name='TEST', |
| label='//path/to/test:test(//toolchain)', |
| os='linux', |
| path='/path/to/test', |
| deps=['/path/to/dep'], |
| ),), |
| dimensions={'device_type': device_type}, |
| netboot=not pave, |
| service_account='foo@bar.com'),) |
| _ = api.testing_requests.shard_requests( |
| build_results, api.buildbucket.build, test_spec.per_test_timeout_secs, |
| test_spec.pool, shards, test_spec.swarming_expiration_timeout_secs, |
| test_spec.swarming_io_timeout_secs, test_spec.use_runtests, |
| test_spec.default_service_account, test_spec.timeout_secs, |
| test_spec.targets_serial) |
| |
| |
| def GenTests(api): |
| # For coverage |
| api.testing_requests.task_requests_step_data( |
| [api.testing_requests.task_request_jsonish(False)], '') |
| api.testing_requests.default_tests() |
| |
| def test(name): |
| return api.test(name) + api.step_data('read images', |
| api.build.mock_image_manifest()) |
| |
| # Test cases for running Fuchsia tests as a swarming task. |
| yield test('deprecated_qemu') + api.properties( |
| deprecated=True, |
| device_type='QEMU', |
| per_test_timeout_secs=1, |
| test_in_shards=False, |
| variants=['host-asan', 'asan'], |
| ) |
| yield test('deprecated_aemu') + api.properties( |
| deprecated=True, |
| device_type='AEMU', |
| per_test_timeout_secs=1, |
| test_in_shards=False, |
| variants=['host-asan', 'asan'], |
| ) |
| |
| yield test('deprecated_non_emu_pave') + api.properties( |
| deprecated=True, |
| pave=True, |
| device_type='DEVICE TYPE', |
| test_in_shards=False, |
| ) |
| yield test('deprecated_non_emu_netboot') + api.properties( |
| deprecated=True, |
| pave=False, |
| device_type='DEVICE TYPE', |
| test_in_shards=False, |
| ) |
| |
| yield test('not-emu') + api.properties( |
| device_type='DEVICE TYPE', |
| pave=False, |
| use_runtests=True, |
| per_test_timeout_secs=1, |
| variants=['host-asan', 'asan'], |
| ) |
| |
| yield test('qemu') + api.properties(per_test_timeout_secs=1,) |
| |
| yield test('aemu') + api.properties(device_type='AEMU',) |