1 # Copyright 2013 The Chromium 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.
5 """Setup for linker tests."""
11 from pylib
import constants
12 from pylib
.linker
import test_case
13 from pylib
.linker
import test_runner
16 os
.path
.join(constants
.DIR_SOURCE_ROOT
, 'build', 'util', 'lib',
18 import unittest_util
# pylint: disable=F0401
20 # ModernLinker requires Android M (API level 23) or later.
21 _VERSION_SDK_PROPERTY
= 'ro.build.version.sdk'
22 _MODERN_LINKER_MINIMUM_SDK_INT
= 23
24 def Setup(args
, devices
):
25 """Creates a list of test cases and a runner factory.
28 args: an argparse.Namespace object.
29 devices: an iterable of available devices.
31 A tuple of (TestRunnerFactory, tests).
33 legacy_linker_tests
= [
34 test_case
.LinkerSharedRelroTest(is_modern_linker
=False,
36 test_case
.LinkerSharedRelroTest(is_modern_linker
=False,
39 modern_linker_tests
= [
40 test_case
.LinkerSharedRelroTest(is_modern_linker
=True),
44 for device
in devices
:
45 min_sdk_int
= min(min_sdk_int
, device
.build_version_sdk
)
47 if min_sdk_int
>= _MODERN_LINKER_MINIMUM_SDK_INT
:
48 all_tests
= legacy_linker_tests
+ modern_linker_tests
50 all_tests
= legacy_linker_tests
51 logging
.warn('Not running LinkerModern tests (requires API %d, found %d)',
52 _MODERN_LINKER_MINIMUM_SDK_INT
, min_sdk_int
)
55 all_test_names
= [test
.qualified_name
for test
in all_tests
]
56 filtered_test_names
= unittest_util
.FilterTestNames(all_test_names
,
58 all_tests
= [t
for t
in all_tests \
59 if t
.qualified_name
in filtered_test_names
]
61 def TestRunnerFactory(device
, _shard_index
):
62 return test_runner
.LinkerTestRunner(device
, args
.tool
)
64 return (TestRunnerFactory
, all_tests
)