blob: 9c276b81a100d7c025284bf6adb858df019fe532 [file] [log] [blame]
Colin Cross4d9c2d12016-07-29 12:48:20 -07001// Copyright 2016 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package cc
16
17import (
18 "path/filepath"
nelsonli0d7111e2019-09-17 16:35:23 +080019 "strconv"
Julien Desprez3b933d32021-01-14 11:49:15 -080020
Yifeng Zeng1876f5b2025-02-05 17:00:56 -080021 "github.com/google/blueprint/depset"
Cole Faust65cb40a2024-10-21 15:41:42 -070022 "github.com/google/blueprint/proptools"
23
Colin Cross4d9c2d12016-07-29 12:48:20 -070024 "android/soong/android"
Colin Cross303e21f2018-08-07 16:49:25 -070025 "android/soong/tradefed"
Colin Cross4d9c2d12016-07-29 12:48:20 -070026)
27
Trevor Radcliffef389cb42022-03-24 21:06:14 +000028// TestLinkerProperties properties to be registered via the linker
29type TestLinkerProperties struct {
Colin Cross4d9c2d12016-07-29 12:48:20 -070030 // if set, build against the gtest library. Defaults to true.
Colin Cross600c9df2016-09-13 12:26:16 -070031 Gtest *bool
Christopher Ferris9df92d62018-08-21 12:40:08 -070032
Elliott Hughes90e76f12025-01-16 13:48:31 -080033 // if set, use the isolated gtest runner. Defaults to false.
34 // Isolation is not supported on Windows.
Christopher Ferris9df92d62018-08-21 12:40:08 -070035 Isolated *bool
Colin Crossb916a382016-07-29 17:28:03 -070036}
Colin Cross4d9c2d12016-07-29 12:48:20 -070037
Trevor Radcliffef389cb42022-03-24 21:06:14 +000038// TestInstallerProperties properties to be registered via the installer
39type TestInstallerProperties struct {
40 // list of compatibility suites (for example "cts", "vts") that the module should be installed into.
41 Test_suites []string `android:"arch_variant"`
42}
43
yelinhsieh9fc60402018-10-01 19:23:14 +080044// Test option struct.
45type TestOptions struct {
Zhenhuang Wang0ac5a432022-08-12 18:49:20 +080046 android.CommonTestOptions
47
yelinhsieh9fc60402018-10-01 19:23:14 +080048 // The UID that you want to run the test as on a device.
49 Run_test_as *string
Dan Shi95d19422020-08-15 12:24:26 -070050
David Srbecky519db272020-06-18 18:07:00 +010051 // A list of free-formed strings without spaces that categorize the test.
52 Test_suite_tag []string
Dan Shi95d19422020-08-15 12:24:26 -070053
54 // a list of extra test configuration files that should be installed with the module.
55 Extra_test_configs []string `android:"path,arch_variant"`
Dan Shid79572f2020-11-13 14:33:46 -080056
Justin Yun46f66052021-05-04 18:42:24 +090057 // Add ShippingApiLevelModuleController to auto generated test config. If the device properties
Justin Yuna364cfb2021-05-13 12:39:42 +090058 // for the shipping api level is less than the min_shipping_api_level, skip this module.
59 Min_shipping_api_level *int64
60
61 // Add ShippingApiLevelModuleController to auto generated test config. If any of the device
62 // shipping api level and vendor api level properties are less than the
63 // vsr_min_shipping_api_level, skip this module.
64 // As this includes the shipping api level check, it is not allowed to define
65 // min_shipping_api_level at the same time with this property.
66 Vsr_min_shipping_api_level *int64
Justin Yun46f66052021-05-04 18:42:24 +090067
68 // Add MinApiLevelModuleController with ro.vndk.version property. If ro.vndk.version has an
Justin Yuna364cfb2021-05-13 12:39:42 +090069 // integer value and the value is less than the min_vndk_version, skip this module.
70 Min_vndk_version *int64
Dan Shiec731432023-05-26 04:21:44 +000071
72 // Extra <option> tags to add to the auto generated test xml file under the test runner, e.g., GTest.
73 // The "key" is optional in each of these.
74 Test_runner_options []tradefed.Option
yelinhsieh9fc60402018-10-01 19:23:14 +080075}
76
Colin Crossb916a382016-07-29 17:28:03 -070077type TestBinaryProperties struct {
Dan Willemsen3340d602016-12-27 14:40:40 -080078 // Disables the creation of a test-specific directory when used with
79 // relative_install_path. Useful if several tests need to be in the same
Colin Cross3a02c7b2024-05-21 13:46:22 -070080 // directory.
Dan Willemsen3340d602016-12-27 14:40:40 -080081 No_named_install_directory *bool
Colin Crossfaeb7aa2017-02-01 14:12:44 -080082
83 // list of files or filegroup modules that provide data that should be installed alongside
84 // the test
Dan Shi67a88342020-02-25 16:34:39 -080085 Data []string `android:"path,arch_variant"`
Colin Crossa929db02017-03-27 16:27:50 -070086
Cole Faustc3489f42024-12-06 13:07:18 -080087 // Same as data, but adds dependencies on modules using the device's os variant, and common
Cole Faust65cb40a2024-10-21 15:41:42 -070088 // architecture's variant. Can be useful to add device-built apps to the data of a host
89 // test.
90 Device_common_data []string `android:"path_device_common"`
91
Cole Faustc3489f42024-12-06 13:07:18 -080092 // Same as data, but adds dependencies on modules using the device's os variant, and the
93 // device's first architecture's variant. Can be useful to add device-built apps to the data
94 // of a host test.
Cole Faust65cb40a2024-10-21 15:41:42 -070095 Device_first_data []string `android:"path_device_first"`
96
Colin Crossb3614422025-02-18 15:18:18 -080097 // Same as data, but will add dependencies on modules using the host's os variation and
98 // the common arch variation. Useful for a device test that wants to depend on a host
99 // module, for example to include a custom Tradefed test runner.
100 Host_common_data []string `android:"path_host_common"`
101
Chris Parsons79d66a52020-06-05 17:26:16 -0400102 // list of shared library modules that should be installed alongside the test
103 Data_libs []string `android:"arch_variant"`
104
Colin Crossc8caa062021-09-24 16:50:14 -0700105 // list of binary modules that should be installed alongside the test
106 Data_bins []string `android:"arch_variant"`
107
Julien Despreze146e392018-08-02 15:00:46 -0700108 // the name of the test configuration (for example "AndroidTest.xml") that should be
109 // installed with the module.
Colin Cross27b922f2019-03-04 22:35:41 -0800110 Test_config *string `android:"path,arch_variant"`
Jack He33338892018-09-19 02:21:28 -0700111
112 // the name of the test configuration template (for example "AndroidTestTemplate.xml") that
113 // should be installed with the module.
Colin Cross27b922f2019-03-04 22:35:41 -0800114 Test_config_template *string `android:"path,arch_variant"`
yelinhsieh9fc60402018-10-01 19:23:14 +0800115
116 // Test options.
117 Test_options TestOptions
Dan Shi37ee3b82019-06-06 16:23:32 -0700118
119 // Add RootTargetPreparer to auto generated test config. This guarantees the test to run
120 // with root permission.
121 Require_root *bool
Dan Shi20ccd212019-08-27 10:37:24 -0700122
123 // Add RunCommandTargetPreparer to stop framework before the test and start it after the test.
124 Disable_framework *bool
nelsonli0d7111e2019-09-17 16:35:23 +0800125
Dan Shi6ffaaa82019-09-26 11:41:36 -0700126 // Flag to indicate whether or not to create test config automatically. If AndroidTest.xml
127 // doesn't exist next to the Android.bp, this attribute doesn't need to be set to true
128 // explicitly.
129 Auto_gen_config *bool
easoncylee1e3fdcd2020-04-30 10:08:33 +0800130
131 // Add parameterized mainline modules to auto generated test config. The options will be
132 // handled by TradeFed to download and install the specified modules on the device.
133 Test_mainline_modules []string
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700134
135 // Install the test into a folder named for the module in all test suites.
136 Per_testcase_directory *bool
Yifeng Zeng1876f5b2025-02-05 17:00:56 -0800137
138 // Install the test's dependencies into a folder named standalone-libs relative to the
139 // test's installation path. ld-library-path will be set to this path in the test's
140 // auto-generated config. This way the dependencies can be used by the test without having
141 // to manually install them to the device. See more details in
142 // go/standalone-native-device-tests.
143 Standalone_test *bool
Colin Cross4d9c2d12016-07-29 12:48:20 -0700144}
145
146func init() {
Steven Moreland87c9d7b2017-11-02 21:38:28 -0700147 android.RegisterModuleType("cc_test", TestFactory)
148 android.RegisterModuleType("cc_test_library", TestLibraryFactory)
149 android.RegisterModuleType("cc_benchmark", BenchmarkFactory)
150 android.RegisterModuleType("cc_test_host", TestHostFactory)
151 android.RegisterModuleType("cc_benchmark_host", BenchmarkHostFactory)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700152}
153
Patrice Arrudac249c712019-03-19 17:00:29 -0700154// cc_test generates a test config file and an executable binary file to test
155// specific functionality on a device. The executable binary gets an implicit
156// static_libs dependency on libgtests unless the gtest flag is set to false.
Steven Moreland87c9d7b2017-11-02 21:38:28 -0700157func TestFactory() android.Module {
Colin Cross8ff10582023-12-07 13:10:56 -0800158 module := NewTest(android.HostAndDeviceSupported)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700159 return module.Init()
160}
161
Patrice Arrudac249c712019-03-19 17:00:29 -0700162// cc_test_library creates an archive of files (i.e. .o files) which is later
163// referenced by another module (such as cc_test, cc_defaults or cc_test_library)
164// for archiving or linking.
Steven Moreland87c9d7b2017-11-02 21:38:28 -0700165func TestLibraryFactory() android.Module {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700166 module := NewTestLibrary(android.HostAndDeviceSupported)
167 return module.Init()
168}
169
Patrice Arrudac249c712019-03-19 17:00:29 -0700170// cc_benchmark compiles an executable binary that performs benchmark testing
171// of a specific component in a device. Additional files such as test suites
172// and test configuration are installed on the side of the compiled executed
173// binary.
Steven Moreland87c9d7b2017-11-02 21:38:28 -0700174func BenchmarkFactory() android.Module {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700175 module := NewBenchmark(android.HostAndDeviceSupported)
Aditya Choudhary87b2ab22023-11-17 15:27:06 +0000176 module.testModule = true
Colin Cross4d9c2d12016-07-29 12:48:20 -0700177 return module.Init()
178}
179
Patrice Arrudac249c712019-03-19 17:00:29 -0700180// cc_test_host compiles a test host binary.
Steven Moreland87c9d7b2017-11-02 21:38:28 -0700181func TestHostFactory() android.Module {
Colin Cross8ff10582023-12-07 13:10:56 -0800182 module := NewTest(android.HostSupported)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700183 return module.Init()
184}
185
Patrice Arrudac249c712019-03-19 17:00:29 -0700186// cc_benchmark_host compiles an executable binary that performs benchmark
187// testing of a specific component in the host. Additional files such as
188// test suites and test configuration are installed on the side of the
189// compiled executed binary.
Steven Moreland87c9d7b2017-11-02 21:38:28 -0700190func BenchmarkHostFactory() android.Module {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700191 module := NewBenchmark(android.HostSupported)
192 return module.Init()
193}
194
Chris Parsons216e10a2020-07-09 17:12:52 -0400195func (test *testBinary) dataPaths() []android.DataPath {
Liz Kammer1c14a212020-05-12 15:26:55 -0700196 return test.data
197}
198
Jingwen Chen537242c2022-08-24 11:53:27 +0000199func (test *testBinary) testBinary() bool {
200 return true
201}
202
Colin Crossb916a382016-07-29 17:28:03 -0700203type testDecorator struct {
Trevor Radcliffef389cb42022-03-24 21:06:14 +0000204 LinkerProperties TestLinkerProperties
205 InstallerProperties TestInstallerProperties
206 installer *baseInstaller
207 linker *baseLinker
Colin Cross4d9c2d12016-07-29 12:48:20 -0700208}
209
Colin Cross600c9df2016-09-13 12:26:16 -0700210func (test *testDecorator) gtest() bool {
Trevor Radcliffef389cb42022-03-24 21:06:14 +0000211 return BoolDefault(test.LinkerProperties.Gtest, true)
Colin Cross600c9df2016-09-13 12:26:16 -0700212}
213
Elliott Hughes90e76f12025-01-16 13:48:31 -0800214func (test *testDecorator) isolated(ctx android.BaseModuleContext) bool {
215 return BoolDefault(test.LinkerProperties.Isolated, false) && !ctx.Windows()
Trevor Radcliffecd8fd672022-05-03 14:51:16 +0000216}
217
Jingwen Chen537242c2022-08-24 11:53:27 +0000218// NOTE: Keep this in sync with cc/cc_test.bzl#gtest_copts
Colin Crossb916a382016-07-29 17:28:03 -0700219func (test *testDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
Colin Cross600c9df2016-09-13 12:26:16 -0700220 if !test.gtest() {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700221 return flags
222 }
223
Colin Cross4af21ed2019-11-04 09:37:55 -0800224 flags.Local.CFlags = append(flags.Local.CFlags, "-DGTEST_HAS_STD_STRING")
Colin Cross4d9c2d12016-07-29 12:48:20 -0700225 if ctx.Host() {
Liana Kazanovab88279f2024-07-15 18:45:23 +0000226 flags.Local.CFlags = append(flags.Local.CFlags, "-O0", "-g")
Colin Cross4d9c2d12016-07-29 12:48:20 -0700227
228 switch ctx.Os() {
229 case android.Windows:
Colin Cross4af21ed2019-11-04 09:37:55 -0800230 flags.Local.CFlags = append(flags.Local.CFlags, "-DGTEST_OS_WINDOWS")
Colin Cross4d9c2d12016-07-29 12:48:20 -0700231 case android.Linux:
Colin Cross4af21ed2019-11-04 09:37:55 -0800232 flags.Local.CFlags = append(flags.Local.CFlags, "-DGTEST_OS_LINUX")
Colin Cross4d9c2d12016-07-29 12:48:20 -0700233 case android.Darwin:
Colin Cross4af21ed2019-11-04 09:37:55 -0800234 flags.Local.CFlags = append(flags.Local.CFlags, "-DGTEST_OS_MAC")
Colin Cross4d9c2d12016-07-29 12:48:20 -0700235 }
236 } else {
Colin Cross4af21ed2019-11-04 09:37:55 -0800237 flags.Local.CFlags = append(flags.Local.CFlags, "-DGTEST_OS_LINUX_ANDROID")
Colin Cross4d9c2d12016-07-29 12:48:20 -0700238 }
239
240 return flags
241}
242
Colin Crossb916a382016-07-29 17:28:03 -0700243func (test *testDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
Colin Cross600c9df2016-09-13 12:26:16 -0700244 if test.gtest() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700245 if ctx.useSdk() && ctx.Device() {
Dan Albert7dd58992018-02-09 15:22:59 -0800246 deps.StaticLibs = append(deps.StaticLibs, "libgtest_main_ndk_c++", "libgtest_ndk_c++")
Trevor Radcliffecd8fd672022-05-03 14:51:16 +0000247 } else if test.isolated(ctx) {
Christopher Ferris9df92d62018-08-21 12:40:08 -0700248 deps.StaticLibs = append(deps.StaticLibs, "libgtest_isolated_main")
Christopher Ferris34cbba62019-07-17 15:46:29 -0700249 // The isolated library requires liblog, but adding it
250 // as a static library means unit tests cannot override
251 // liblog functions. Instead make it a shared library
252 // dependency.
253 deps.SharedLibs = append(deps.SharedLibs, "liblog")
Colin Cross4d9c2d12016-07-29 12:48:20 -0700254 } else {
255 deps.StaticLibs = append(deps.StaticLibs, "libgtest_main", "libgtest")
256 }
257 }
Colin Crossb916a382016-07-29 17:28:03 -0700258
Colin Cross4d9c2d12016-07-29 12:48:20 -0700259 return deps
260}
261
Colin Crossb916a382016-07-29 17:28:03 -0700262func (test *testDecorator) linkerProps() []interface{} {
Trevor Radcliffef389cb42022-03-24 21:06:14 +0000263 return []interface{}{&test.LinkerProperties}
264}
265
266func (test *testDecorator) installerProps() []interface{} {
267 return []interface{}{&test.InstallerProperties}
Colin Cross4d9c2d12016-07-29 12:48:20 -0700268}
269
Colin Cross4a9e6ec2023-12-18 15:29:41 -0800270func (test *testDecorator) moduleInfoJSON(ctx android.ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
271 if android.PrefixInList(moduleInfoJSON.CompatibilitySuites, "mts-") &&
272 !android.InList("mts", moduleInfoJSON.CompatibilitySuites) {
273 moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "mts")
274 }
275}
276
Cole Faust5e1454a2025-03-11 15:55:59 -0700277func (test *testDecorator) testSuiteInfo(ctx ModuleContext) {
278 android.SetProvider(ctx, android.TestSuiteInfoProvider, android.TestSuiteInfo{
279 TestSuites: test.InstallerProperties.Test_suites,
280 })
281}
282
Colin Crossb916a382016-07-29 17:28:03 -0700283func NewTestInstaller() *baseInstaller {
284 return NewBaseInstaller("nativetest", "nativetest64", InstallInData)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700285}
286
Colin Crossb916a382016-07-29 17:28:03 -0700287type testBinary struct {
Trevor Radcliffef389cb42022-03-24 21:06:14 +0000288 *testDecorator
Colin Crossb916a382016-07-29 17:28:03 -0700289 *binaryDecorator
290 *baseCompiler
Dan Shi95d19422020-08-15 12:24:26 -0700291 Properties TestBinaryProperties
292 data []android.DataPath
293 testConfig android.Path
294 extraTestConfigs android.Paths
Colin Crossb916a382016-07-29 17:28:03 -0700295}
296
297func (test *testBinary) linkerProps() []interface{} {
298 props := append(test.testDecorator.linkerProps(), test.binaryDecorator.linkerProps()...)
299 props = append(props, &test.Properties)
300 return props
301}
302
Colin Cross37047f12016-12-13 17:06:13 -0800303func (test *testBinary) linkerDeps(ctx DepsContext, deps Deps) Deps {
Colin Crossb916a382016-07-29 17:28:03 -0700304 deps = test.testDecorator.linkerDeps(ctx, deps)
305 deps = test.binaryDecorator.linkerDeps(ctx, deps)
Chris Parsons79d66a52020-06-05 17:26:16 -0400306 deps.DataLibs = append(deps.DataLibs, test.Properties.Data_libs...)
Colin Crossc8caa062021-09-24 16:50:14 -0700307 deps.DataBins = append(deps.DataBins, test.Properties.Data_bins...)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700308 return deps
309}
310
Colin Crossb916a382016-07-29 17:28:03 -0700311func (test *testBinary) linkerFlags(ctx ModuleContext, flags Flags) Flags {
312 flags = test.binaryDecorator.linkerFlags(ctx, flags)
313 flags = test.testDecorator.linkerFlags(ctx, flags)
Colin Crossb881e322024-05-10 13:24:17 -0700314
315 // Add a default rpath to allow tests to dlopen libraries specified in data_libs.
316 // Host modules already get an rpath specified in linker.go.
317 if !ctx.Host() {
318 flags.Global.LdFlags = append(flags.Global.LdFlags, `-Wl,-rpath,\$$ORIGIN`)
319 }
Colin Cross4d9c2d12016-07-29 12:48:20 -0700320 return flags
321}
322
Colin Cross4a9e6ec2023-12-18 15:29:41 -0800323func (test *testBinary) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
324 if ctx.Host() && Bool(test.Properties.Test_options.Unit_test) {
325 moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "host-unit-tests")
326 }
327 moduleInfoJSON.TestOptionsTags = append(moduleInfoJSON.TestOptionsTags, test.Properties.Test_options.Tags...)
328 moduleInfoJSON.TestMainlineModules = append(moduleInfoJSON.TestMainlineModules, test.Properties.Test_mainline_modules...)
329 if test.testConfig != nil {
330 if _, ok := test.testConfig.(android.WritablePath); ok {
331 moduleInfoJSON.AutoTestConfig = []string{"true"}
332 }
333 moduleInfoJSON.TestConfig = append(moduleInfoJSON.TestConfig, test.testConfig.String())
334 }
335 moduleInfoJSON.TestConfig = append(moduleInfoJSON.TestConfig, test.extraTestConfigs.Strings()...)
336
Colin Cross4a9e6ec2023-12-18 15:29:41 -0800337 moduleInfoJSON.DataDependencies = append(moduleInfoJSON.DataDependencies, test.Properties.Data_bins...)
338
339 if len(test.InstallerProperties.Test_suites) > 0 {
340 moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, test.InstallerProperties.Test_suites...)
341 } else {
342 moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "null-suite")
343 }
344
345 test.binaryDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
346 test.testDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
347 moduleInfoJSON.Class = []string{"NATIVE_TESTS"}
348
349}
350
Cole Faust5e1454a2025-03-11 15:55:59 -0700351func (test *testBinary) testSuiteInfo(ctx ModuleContext) {
352 test.testDecorator.testSuiteInfo(ctx)
353}
354
Trevor Radcliffef389cb42022-03-24 21:06:14 +0000355func (test *testBinary) installerProps() []interface{} {
356 return append(test.baseInstaller.installerProps(), test.testDecorator.installerProps()...)
357}
358
Colin Crossb916a382016-07-29 17:28:03 -0700359func (test *testBinary) install(ctx ModuleContext, file android.Path) {
Chris Parsons216e10a2020-07-09 17:12:52 -0400360 dataSrcPaths := android.PathsForModuleSrc(ctx, test.Properties.Data)
Cole Faust65cb40a2024-10-21 15:41:42 -0700361 dataSrcPaths = append(dataSrcPaths, android.PathsForModuleSrc(ctx, test.Properties.Device_common_data)...)
362 dataSrcPaths = append(dataSrcPaths, android.PathsForModuleSrc(ctx, test.Properties.Device_first_data)...)
Colin Crossb3614422025-02-18 15:18:18 -0800363 dataSrcPaths = append(dataSrcPaths, android.PathsForModuleSrc(ctx, test.Properties.Host_common_data)...)
Chris Parsons216e10a2020-07-09 17:12:52 -0400364
365 for _, dataSrcPath := range dataSrcPaths {
366 test.data = append(test.data, android.DataPath{SrcPath: dataSrcPath})
367 }
Chris Parsons79d66a52020-06-05 17:26:16 -0400368
Yu Liu97880e12025-01-07 19:03:34 +0000369 ctx.VisitDirectDepsProxyWithTag(dataLibDepTag, func(dep android.ModuleProxy) {
Chris Parsons79d66a52020-06-05 17:26:16 -0400370 depName := ctx.OtherModuleName(dep)
Yu Liu97880e12025-01-07 19:03:34 +0000371 linkableDep, ok := android.OtherModuleProvider(ctx, dep, LinkableInfoProvider)
Chris Parsons79d66a52020-06-05 17:26:16 -0400372 if !ok {
Ivan Lozano4e5f07d2021-11-04 14:09:38 -0400373 ctx.ModuleErrorf("data_lib %q is not a LinkableInterface module", depName)
Chris Parsons79d66a52020-06-05 17:26:16 -0400374 }
Yu Liu97880e12025-01-07 19:03:34 +0000375 if linkableDep.OutputFile.Valid() {
Chris Parsons216e10a2020-07-09 17:12:52 -0400376 test.data = append(test.data,
Yu Liu97880e12025-01-07 19:03:34 +0000377 android.DataPath{SrcPath: linkableDep.OutputFile.Path(),
378 RelativeInstallPath: linkableDep.RelativeInstallPath})
Chris Parsons79d66a52020-06-05 17:26:16 -0400379 }
380 })
Yu Liu97880e12025-01-07 19:03:34 +0000381 ctx.VisitDirectDepsProxyWithTag(dataBinDepTag, func(dep android.ModuleProxy) {
Colin Crossc8caa062021-09-24 16:50:14 -0700382 depName := ctx.OtherModuleName(dep)
Yu Liu97880e12025-01-07 19:03:34 +0000383 linkableDep, ok := android.OtherModuleProvider(ctx, dep, LinkableInfoProvider)
Colin Crossc8caa062021-09-24 16:50:14 -0700384 if !ok {
Ivan Lozano4e5f07d2021-11-04 14:09:38 -0400385 ctx.ModuleErrorf("data_bin %q is not a LinkableInterface module", depName)
Colin Crossc8caa062021-09-24 16:50:14 -0700386 }
Yu Liu97880e12025-01-07 19:03:34 +0000387 if linkableDep.OutputFile.Valid() {
Colin Crossc8caa062021-09-24 16:50:14 -0700388 test.data = append(test.data,
Yu Liu97880e12025-01-07 19:03:34 +0000389 android.DataPath{SrcPath: linkableDep.OutputFile.Path(),
390 RelativeInstallPath: linkableDep.RelativeInstallPath})
Colin Crossc8caa062021-09-24 16:50:14 -0700391 }
392 })
Chris Parsons79d66a52020-06-05 17:26:16 -0400393
Kiyoung Kimaa394802024-01-08 12:55:45 +0900394 testInstallBase := getTestInstallBase(ctx.InVendorOrProduct())
Dan Shiad042502023-08-02 13:53:00 -0700395 configs := getTradefedConfigOptions(ctx, &test.Properties, test.isolated(ctx), ctx.Device())
yelinhsieh9fc60402018-10-01 19:23:14 +0800396
Cole Faust21680542022-12-07 18:18:37 -0800397 test.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{
398 TestConfigProp: test.Properties.Test_config,
399 TestConfigTemplateProp: test.Properties.Test_config_template,
400 TestSuites: test.testDecorator.InstallerProperties.Test_suites,
401 Config: configs,
Dan Shiec731432023-05-26 04:21:44 +0000402 TestRunnerOptions: test.Properties.Test_options.Test_runner_options,
Cole Faust21680542022-12-07 18:18:37 -0800403 AutoGenConfig: test.Properties.Auto_gen_config,
404 TestInstallBase: testInstallBase,
405 DeviceTemplate: "${NativeTestConfigTemplate}",
406 HostTemplate: "${NativeHostTestConfigTemplate}",
Yifeng Zeng1876f5b2025-02-05 17:00:56 -0800407 StandaloneTest: test.Properties.Standalone_test,
Cole Faust21680542022-12-07 18:18:37 -0800408 })
Colin Crossfaeb7aa2017-02-01 14:12:44 -0800409
Dan Shi95d19422020-08-15 12:24:26 -0700410 test.extraTestConfigs = android.PathsForModuleSrc(ctx, test.Properties.Test_options.Extra_test_configs)
411
Colin Cross600c9df2016-09-13 12:26:16 -0700412 test.binaryDecorator.baseInstaller.dir = "nativetest"
413 test.binaryDecorator.baseInstaller.dir64 = "nativetest64"
Dan Willemsen3340d602016-12-27 14:40:40 -0800414
415 if !Bool(test.Properties.No_named_install_directory) {
416 test.binaryDecorator.baseInstaller.relative = ctx.ModuleName()
Nan Zhang0007d812017-11-07 10:57:05 -0800417 } else if String(test.binaryDecorator.baseInstaller.Properties.Relative_install_path) == "" {
Dan Willemsen3340d602016-12-27 14:40:40 -0800418 ctx.PropertyErrorf("no_named_install_directory", "Module install directory may only be disabled if relative_install_path is set")
419 }
420
Julien Desprez8908b372021-02-04 10:10:16 -0800421 if ctx.Host() && test.gtest() && test.Properties.Test_options.Unit_test == nil {
Julien Desprez3b933d32021-01-14 11:49:15 -0800422 test.Properties.Test_options.Unit_test = proptools.BoolPtr(true)
423 }
Colin Cross5c1d5fb2023-11-15 12:39:40 -0800424
Spandan Das2f238a92025-01-28 23:39:13 +0000425 if !ctx.Config().KatiEnabled() { // TODO(spandandas): Remove the special case for kati
Spandan Das323631f2025-01-24 21:57:47 +0000426 // Install the test config in testcases/ directory for atest.
Spandan Das323631f2025-01-24 21:57:47 +0000427 c, ok := ctx.Module().(*Module)
428 if !ok {
429 ctx.ModuleErrorf("Not a cc_test module")
430 }
Spandan Das2f238a92025-01-28 23:39:13 +0000431 // Install configs in the root of $PRODUCT_OUT/testcases/$module
Spandan Das323631f2025-01-24 21:57:47 +0000432 testCases := android.PathForModuleInPartitionInstall(ctx, "testcases", ctx.ModuleName()+c.SubName())
Spandan Das2f238a92025-01-28 23:39:13 +0000433 if ctx.PrimaryArch() {
434 if test.testConfig != nil {
435 ctx.InstallFile(testCases, ctx.ModuleName()+".config", test.testConfig)
436 }
Cole Faustec71dfb2025-02-18 13:31:12 -0800437 dynamicConfig := android.ExistentPathForSource(ctx, ctx.ModuleDir(), "DynamicConfig.xml")
438 if dynamicConfig.Valid() {
439 ctx.InstallFile(testCases, ctx.ModuleName()+".dynamic", dynamicConfig.Path())
440 }
Spandan Das2f238a92025-01-28 23:39:13 +0000441 for _, extraTestConfig := range test.extraTestConfigs {
442 ctx.InstallFile(testCases, extraTestConfig.Base(), extraTestConfig)
443 }
Spandan Das323631f2025-01-24 21:57:47 +0000444 }
Spandan Das2f238a92025-01-28 23:39:13 +0000445 // Install tests and data in arch specific subdir $PRODUCT_OUT/testcases/$module/$arch
446 testCases = testCases.Join(ctx, ctx.Target().Arch.ArchType.String())
Spandan Das323631f2025-01-24 21:57:47 +0000447 ctx.InstallTestData(testCases, test.data)
448 ctx.InstallFile(testCases, file.Base(), file)
449 }
450
Colin Cross5c1d5fb2023-11-15 12:39:40 -0800451 test.binaryDecorator.baseInstaller.installTestData(ctx, test.data)
Dan Willemsen1d577e22016-08-29 15:53:15 -0700452 test.binaryDecorator.baseInstaller.install(ctx, file)
Yifeng Zeng1876f5b2025-02-05 17:00:56 -0800453 if Bool(test.Properties.Standalone_test) {
454 packagingSpecsBuilder := depset.NewBuilder[android.PackagingSpec](depset.TOPOLOGICAL)
455
456 ctx.VisitDirectDeps(func(dep android.Module) {
457 deps := android.OtherModuleProviderOrDefault(ctx, dep, android.InstallFilesProvider)
458 packagingSpecsBuilder.Transitive(deps.TransitivePackagingSpecs)
459 })
460
461 for _, standaloneTestDep := range packagingSpecsBuilder.Build().ToList() {
462 if standaloneTestDep.ToGob().SrcPath == nil {
463 continue
464 }
Yifeng Zeng02c56e92025-02-12 13:25:16 -0800465 if standaloneTestDep.SkipInstall() {
466 continue
467 }
Yifeng Zengd0015db2025-03-05 18:16:24 -0800468 if standaloneTestDep.Partition() == "data" {
469 continue
470 }
Yifeng Zeng1876f5b2025-02-05 17:00:56 -0800471 test.binaryDecorator.baseInstaller.installStandaloneTestDep(ctx, standaloneTestDep)
472 }
473 }
Colin Cross4d9c2d12016-07-29 12:48:20 -0700474}
475
Kevin Dagostino32edd1a2022-12-04 11:16:42 +0000476func getTestInstallBase(useVendor bool) string {
477 // TODO: (b/167308193) Switch to /data/local/tests/unrestricted as the default install base.
478 testInstallBase := "/data/local/tmp"
479 if useVendor {
480 testInstallBase = "/data/local/tests/vendor"
481 }
482 return testInstallBase
483}
484
Dan Shiad042502023-08-02 13:53:00 -0700485func getTradefedConfigOptions(ctx android.EarlyModuleContext, properties *TestBinaryProperties, isolated bool, device bool) []tradefed.Config {
Kevin Dagostino32edd1a2022-12-04 11:16:42 +0000486 var configs []tradefed.Config
487
488 for _, module := range properties.Test_mainline_modules {
489 configs = append(configs, tradefed.Option{Name: "config-descriptor:metadata", Key: "mainline-param", Value: module})
490 }
Dan Shiad042502023-08-02 13:53:00 -0700491 if device {
492 if Bool(properties.Require_root) {
493 configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", nil})
494 } else {
495 var options []tradefed.Option
496 options = append(options, tradefed.Option{Name: "force-root", Value: "false"})
497 configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", options})
498 }
499 if Bool(properties.Disable_framework) {
500 var options []tradefed.Option
501 configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.StopServicesSetup", options})
502 }
Kevin Dagostino32edd1a2022-12-04 11:16:42 +0000503 }
504 if isolated {
505 configs = append(configs, tradefed.Option{Name: "not-shardable", Value: "true"})
506 }
507 if properties.Test_options.Run_test_as != nil {
508 configs = append(configs, tradefed.Option{Name: "run-test-as", Value: String(properties.Test_options.Run_test_as)})
509 }
510 for _, tag := range properties.Test_options.Test_suite_tag {
511 configs = append(configs, tradefed.Option{Name: "test-suite-tag", Value: tag})
512 }
513 if properties.Test_options.Min_shipping_api_level != nil {
514 if properties.Test_options.Vsr_min_shipping_api_level != nil {
515 ctx.PropertyErrorf("test_options.min_shipping_api_level", "must not be set at the same time as 'vsr_min_shipping_api_level'.")
516 }
517 var options []tradefed.Option
518 options = append(options, tradefed.Option{Name: "min-api-level", Value: strconv.FormatInt(int64(*properties.Test_options.Min_shipping_api_level), 10)})
519 configs = append(configs, tradefed.Object{"module_controller", "com.android.tradefed.testtype.suite.module.ShippingApiLevelModuleController", options})
520 }
521 if properties.Test_options.Vsr_min_shipping_api_level != nil {
522 var options []tradefed.Option
523 options = append(options, tradefed.Option{Name: "vsr-min-api-level", Value: strconv.FormatInt(int64(*properties.Test_options.Vsr_min_shipping_api_level), 10)})
524 configs = append(configs, tradefed.Object{"module_controller", "com.android.tradefed.testtype.suite.module.ShippingApiLevelModuleController", options})
525 }
526 if properties.Test_options.Min_vndk_version != nil {
527 var options []tradefed.Option
528 options = append(options, tradefed.Option{Name: "min-api-level", Value: strconv.FormatInt(int64(*properties.Test_options.Min_vndk_version), 10)})
529 options = append(options, tradefed.Option{Name: "api-level-prop", Value: "ro.vndk.version"})
530 configs = append(configs, tradefed.Object{"module_controller", "com.android.tradefed.testtype.suite.module.MinApiLevelModuleController", options})
531 }
532 return configs
533}
534
Colin Cross8ff10582023-12-07 13:10:56 -0800535func NewTest(hod android.HostOrDeviceSupported) *Module {
536 module, binary := newBinary(hod)
Colin Crossb916a382016-07-29 17:28:03 -0700537 module.multilib = android.MultilibBoth
Aditya Choudhary4b6eaf42023-11-21 15:38:37 +0000538 module.testModule = true
Dan Willemsen1d577e22016-08-29 15:53:15 -0700539 binary.baseInstaller = NewTestInstaller()
Colin Crossb916a382016-07-29 17:28:03 -0700540
541 test := &testBinary{
Trevor Radcliffef389cb42022-03-24 21:06:14 +0000542 testDecorator: &testDecorator{
543 linker: binary.baseLinker,
544 installer: binary.baseInstaller,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700545 },
Colin Crossb916a382016-07-29 17:28:03 -0700546 binaryDecorator: binary,
547 baseCompiler: NewBaseCompiler(),
Colin Cross4d9c2d12016-07-29 12:48:20 -0700548 }
Colin Crossb916a382016-07-29 17:28:03 -0700549 module.compiler = test
550 module.linker = test
551 module.installer = test
Colin Cross4d9c2d12016-07-29 12:48:20 -0700552 return module
553}
554
Colin Crossb916a382016-07-29 17:28:03 -0700555type testLibrary struct {
Trevor Radcliffef389cb42022-03-24 21:06:14 +0000556 *testDecorator
Colin Crossb916a382016-07-29 17:28:03 -0700557 *libraryDecorator
558}
559
Jingwen Chen537242c2022-08-24 11:53:27 +0000560func (test *testLibrary) testLibrary() bool {
561 return true
562}
563
Colin Crossb916a382016-07-29 17:28:03 -0700564func (test *testLibrary) linkerProps() []interface{} {
Trevor Radcliffef389cb42022-03-24 21:06:14 +0000565 var props []interface{}
566 props = append(props, test.testDecorator.linkerProps()...)
567 return append(props, test.libraryDecorator.linkerProps()...)
Colin Crossb916a382016-07-29 17:28:03 -0700568}
569
Colin Cross37047f12016-12-13 17:06:13 -0800570func (test *testLibrary) linkerDeps(ctx DepsContext, deps Deps) Deps {
Colin Crossb916a382016-07-29 17:28:03 -0700571 deps = test.testDecorator.linkerDeps(ctx, deps)
572 deps = test.libraryDecorator.linkerDeps(ctx, deps)
573 return deps
574}
575
576func (test *testLibrary) linkerFlags(ctx ModuleContext, flags Flags) Flags {
577 flags = test.libraryDecorator.linkerFlags(ctx, flags)
578 flags = test.testDecorator.linkerFlags(ctx, flags)
579 return flags
580}
581
Colin Cross4a9e6ec2023-12-18 15:29:41 -0800582func (test *testLibrary) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
583 if len(test.InstallerProperties.Test_suites) > 0 {
584 moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, test.InstallerProperties.Test_suites...)
585 }
586
587 test.libraryDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
588 test.testDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
589}
590
Cole Faust5e1454a2025-03-11 15:55:59 -0700591func (test *testLibrary) testSuiteInfo(ctx ModuleContext) {
592 test.testDecorator.testSuiteInfo(ctx)
593}
594
Trevor Radcliffef389cb42022-03-24 21:06:14 +0000595func (test *testLibrary) installerProps() []interface{} {
596 return append(test.baseInstaller.installerProps(), test.testDecorator.installerProps()...)
597}
598
Colin Cross4d9c2d12016-07-29 12:48:20 -0700599func NewTestLibrary(hod android.HostOrDeviceSupported) *Module {
Colin Crossab3b7322016-12-09 14:46:15 -0800600 module, library := NewLibrary(android.HostAndDeviceSupported)
Dan Willemsen28bda512016-08-31 16:32:55 -0700601 library.baseInstaller = NewTestInstaller()
Colin Crossb916a382016-07-29 17:28:03 -0700602 test := &testLibrary{
Trevor Radcliffef389cb42022-03-24 21:06:14 +0000603 testDecorator: &testDecorator{
604 linker: library.baseLinker,
605 installer: library.baseInstaller,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700606 },
Colin Crossb916a382016-07-29 17:28:03 -0700607 libraryDecorator: library,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700608 }
Colin Crossb916a382016-07-29 17:28:03 -0700609 module.linker = test
Trevor Radcliffef389cb42022-03-24 21:06:14 +0000610 module.installer = test
Colin Cross4d9c2d12016-07-29 12:48:20 -0700611 return module
612}
613
Colin Crosse28f4e22017-04-24 18:10:29 -0700614type BenchmarkProperties struct {
Anders Lewisb97e8182017-07-14 15:20:13 -0700615 // list of files or filegroup modules that provide data that should be installed alongside
616 // the test
Colin Cross27b922f2019-03-04 22:35:41 -0800617 Data []string `android:"path"`
Anders Lewisb97e8182017-07-14 15:20:13 -0700618
Colin Crosse28f4e22017-04-24 18:10:29 -0700619 // list of compatibility suites (for example "cts", "vts") that the module should be
620 // installed into.
Julien Despreze146e392018-08-02 15:00:46 -0700621 Test_suites []string `android:"arch_variant"`
622
623 // the name of the test configuration (for example "AndroidTest.xml") that should be
624 // installed with the module.
Colin Cross27b922f2019-03-04 22:35:41 -0800625 Test_config *string `android:"path,arch_variant"`
Jack He33338892018-09-19 02:21:28 -0700626
627 // the name of the test configuration template (for example "AndroidTestTemplate.xml") that
628 // should be installed with the module.
Colin Cross27b922f2019-03-04 22:35:41 -0800629 Test_config_template *string `android:"path,arch_variant"`
Dan Shi37ee3b82019-06-06 16:23:32 -0700630
631 // Add RootTargetPreparer to auto generated test config. This guarantees the test to run
632 // with root permission.
633 Require_root *bool
Dan Shi6ffaaa82019-09-26 11:41:36 -0700634
635 // Flag to indicate whether or not to create test config automatically. If AndroidTest.xml
636 // doesn't exist next to the Android.bp, this attribute doesn't need to be set to true
637 // explicitly.
638 Auto_gen_config *bool
Colin Crosse28f4e22017-04-24 18:10:29 -0700639}
640
Colin Crossb916a382016-07-29 17:28:03 -0700641type benchmarkDecorator struct {
642 *binaryDecorator
Colin Crosse28f4e22017-04-24 18:10:29 -0700643 Properties BenchmarkProperties
Colin Cross5c1d5fb2023-11-15 12:39:40 -0800644 data []android.DataPath
Colin Cross303e21f2018-08-07 16:49:25 -0700645 testConfig android.Path
Colin Cross4d9c2d12016-07-29 12:48:20 -0700646}
647
Liz Kammerbe46fcc2021-11-01 15:32:43 -0400648func (benchmark *benchmarkDecorator) benchmarkBinary() bool {
649 return true
650}
651
Colin Crosse28f4e22017-04-24 18:10:29 -0700652func (benchmark *benchmarkDecorator) linkerProps() []interface{} {
653 props := benchmark.binaryDecorator.linkerProps()
654 props = append(props, &benchmark.Properties)
655 return props
656}
657
Colin Cross37047f12016-12-13 17:06:13 -0800658func (benchmark *benchmarkDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
Colin Crossb916a382016-07-29 17:28:03 -0700659 deps = benchmark.binaryDecorator.linkerDeps(ctx, deps)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700660 deps.StaticLibs = append(deps.StaticLibs, "libgoogle-benchmark")
661 return deps
662}
663
Colin Crossb916a382016-07-29 17:28:03 -0700664func (benchmark *benchmarkDecorator) install(ctx ModuleContext, file android.Path) {
Colin Cross5c1d5fb2023-11-15 12:39:40 -0800665 for _, d := range android.PathsForModuleSrc(ctx, benchmark.Properties.Data) {
666 benchmark.data = append(benchmark.data, android.DataPath{SrcPath: d})
667 }
Chris Parsons79d66a52020-06-05 17:26:16 -0400668
Dan Shi37ee3b82019-06-06 16:23:32 -0700669 var configs []tradefed.Config
670 if Bool(benchmark.Properties.Require_root) {
nelsonli0d7111e2019-09-17 16:35:23 +0800671 configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", nil})
Dan Shi37ee3b82019-06-06 16:23:32 -0700672 }
Cole Faust21680542022-12-07 18:18:37 -0800673 benchmark.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{
674 TestConfigProp: benchmark.Properties.Test_config,
675 TestConfigTemplateProp: benchmark.Properties.Test_config_template,
676 TestSuites: benchmark.Properties.Test_suites,
677 Config: configs,
678 AutoGenConfig: benchmark.Properties.Auto_gen_config,
679 DeviceTemplate: "${NativeBenchmarkTestConfigTemplate}",
680 HostTemplate: "${NativeBenchmarkTestConfigTemplate}",
681 })
Colin Cross303e21f2018-08-07 16:49:25 -0700682
Colin Cross28690e92017-09-08 16:20:30 -0700683 benchmark.binaryDecorator.baseInstaller.dir = filepath.Join("benchmarktest", ctx.ModuleName())
684 benchmark.binaryDecorator.baseInstaller.dir64 = filepath.Join("benchmarktest64", ctx.ModuleName())
Colin Cross5c1d5fb2023-11-15 12:39:40 -0800685 benchmark.binaryDecorator.baseInstaller.installTestData(ctx, benchmark.data)
Dan Willemsen1d577e22016-08-29 15:53:15 -0700686 benchmark.binaryDecorator.baseInstaller.install(ctx, file)
Colin Crossb916a382016-07-29 17:28:03 -0700687}
688
Colin Cross4a9e6ec2023-12-18 15:29:41 -0800689func (benchmark *benchmarkDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
690 benchmark.binaryDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
691
692 moduleInfoJSON.Class = []string{"NATIVE_TESTS"}
693 if len(benchmark.Properties.Test_suites) > 0 {
694 moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, benchmark.Properties.Test_suites...)
695 } else {
696 moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "null-suite")
697 }
698
699 if android.PrefixInList(moduleInfoJSON.CompatibilitySuites, "mts-") &&
700 !android.InList("mts", moduleInfoJSON.CompatibilitySuites) {
701 moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "mts")
702 }
703
704 if benchmark.testConfig != nil {
705 if _, ok := benchmark.testConfig.(android.WritablePath); ok {
706 moduleInfoJSON.AutoTestConfig = []string{"true"}
707 }
708 moduleInfoJSON.TestConfig = []string{benchmark.testConfig.String()}
709 }
710}
711
Cole Faust5e1454a2025-03-11 15:55:59 -0700712func (benchmark *benchmarkDecorator) testSuiteInfo(ctx ModuleContext) {
713 android.SetProvider(ctx, android.TestSuiteInfoProvider, android.TestSuiteInfo{
714 TestSuites: benchmark.Properties.Test_suites,
715 })
716}
717
Colin Cross4d9c2d12016-07-29 12:48:20 -0700718func NewBenchmark(hod android.HostOrDeviceSupported) *Module {
Colin Cross8ff10582023-12-07 13:10:56 -0800719 module, binary := newBinary(hod)
Colin Crossb916a382016-07-29 17:28:03 -0700720 module.multilib = android.MultilibBoth
Colin Cross28690e92017-09-08 16:20:30 -0700721 binary.baseInstaller = NewBaseInstaller("benchmarktest", "benchmarktest64", InstallInData)
Colin Crossb916a382016-07-29 17:28:03 -0700722
723 benchmark := &benchmarkDecorator{
724 binaryDecorator: binary,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700725 }
Colin Crossb916a382016-07-29 17:28:03 -0700726 module.linker = benchmark
727 module.installer = benchmark
Colin Cross4d9c2d12016-07-29 12:48:20 -0700728 return module
729}