blob: dae2a3774b5a8e8c66af9dd9e1cdf53c52c3e173 [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"
19 "strings"
20
Colin Cross4d9c2d12016-07-29 12:48:20 -070021 "android/soong/android"
Colin Cross303e21f2018-08-07 16:49:25 -070022 "android/soong/tradefed"
Colin Cross4d9c2d12016-07-29 12:48:20 -070023)
24
Colin Crossb916a382016-07-29 17:28:03 -070025type TestProperties struct {
Colin Cross4d9c2d12016-07-29 12:48:20 -070026 // if set, build against the gtest library. Defaults to true.
Colin Cross600c9df2016-09-13 12:26:16 -070027 Gtest *bool
Christopher Ferris9df92d62018-08-21 12:40:08 -070028
29 // if set, use the isolated gtest runner. Defaults to false.
30 Isolated *bool
Colin Crossb916a382016-07-29 17:28:03 -070031}
Colin Cross4d9c2d12016-07-29 12:48:20 -070032
yelinhsieh9fc60402018-10-01 19:23:14 +080033// Test option struct.
34type TestOptions struct {
35 // The UID that you want to run the test as on a device.
36 Run_test_as *string
37}
38
Colin Crossb916a382016-07-29 17:28:03 -070039type TestBinaryProperties struct {
Colin Cross4d9c2d12016-07-29 12:48:20 -070040 // Create a separate binary for each source file. Useful when there is
41 // global state that can not be torn down and reset between each test suite.
42 Test_per_src *bool
Dan Willemsen3340d602016-12-27 14:40:40 -080043
44 // Disables the creation of a test-specific directory when used with
45 // relative_install_path. Useful if several tests need to be in the same
46 // directory, but test_per_src doesn't work.
47 No_named_install_directory *bool
Colin Crossfaeb7aa2017-02-01 14:12:44 -080048
49 // list of files or filegroup modules that provide data that should be installed alongside
50 // the test
Colin Cross27b922f2019-03-04 22:35:41 -080051 Data []string `android:"path"`
Colin Crossa929db02017-03-27 16:27:50 -070052
53 // list of compatibility suites (for example "cts", "vts") that the module should be
54 // installed into.
Dan Willemsen15d54d52017-09-18 16:49:28 -070055 Test_suites []string `android:"arch_variant"`
Julien Despreze146e392018-08-02 15:00:46 -070056
57 // the name of the test configuration (for example "AndroidTest.xml") that should be
58 // installed with the module.
Colin Cross27b922f2019-03-04 22:35:41 -080059 Test_config *string `android:"path,arch_variant"`
Jack He33338892018-09-19 02:21:28 -070060
61 // the name of the test configuration template (for example "AndroidTestTemplate.xml") that
62 // should be installed with the module.
Colin Cross27b922f2019-03-04 22:35:41 -080063 Test_config_template *string `android:"path,arch_variant"`
yelinhsieh9fc60402018-10-01 19:23:14 +080064
65 // Test options.
66 Test_options TestOptions
Colin Cross4d9c2d12016-07-29 12:48:20 -070067}
68
69func init() {
Steven Moreland87c9d7b2017-11-02 21:38:28 -070070 android.RegisterModuleType("cc_test", TestFactory)
71 android.RegisterModuleType("cc_test_library", TestLibraryFactory)
72 android.RegisterModuleType("cc_benchmark", BenchmarkFactory)
73 android.RegisterModuleType("cc_test_host", TestHostFactory)
74 android.RegisterModuleType("cc_benchmark_host", BenchmarkHostFactory)
Colin Cross4d9c2d12016-07-29 12:48:20 -070075}
76
Patrice Arrudac249c712019-03-19 17:00:29 -070077// cc_test generates a test config file and an executable binary file to test
78// specific functionality on a device. The executable binary gets an implicit
79// static_libs dependency on libgtests unless the gtest flag is set to false.
Steven Moreland87c9d7b2017-11-02 21:38:28 -070080func TestFactory() android.Module {
Colin Cross4d9c2d12016-07-29 12:48:20 -070081 module := NewTest(android.HostAndDeviceSupported)
82 return module.Init()
83}
84
Patrice Arrudac249c712019-03-19 17:00:29 -070085// cc_test_library creates an archive of files (i.e. .o files) which is later
86// referenced by another module (such as cc_test, cc_defaults or cc_test_library)
87// for archiving or linking.
Steven Moreland87c9d7b2017-11-02 21:38:28 -070088func TestLibraryFactory() android.Module {
Colin Cross4d9c2d12016-07-29 12:48:20 -070089 module := NewTestLibrary(android.HostAndDeviceSupported)
90 return module.Init()
91}
92
Patrice Arrudac249c712019-03-19 17:00:29 -070093// cc_benchmark compiles an executable binary that performs benchmark testing
94// of a specific component in a device. Additional files such as test suites
95// and test configuration are installed on the side of the compiled executed
96// binary.
Steven Moreland87c9d7b2017-11-02 21:38:28 -070097func BenchmarkFactory() android.Module {
Colin Cross4d9c2d12016-07-29 12:48:20 -070098 module := NewBenchmark(android.HostAndDeviceSupported)
99 return module.Init()
100}
101
Patrice Arrudac249c712019-03-19 17:00:29 -0700102// cc_test_host compiles a test host binary.
Steven Moreland87c9d7b2017-11-02 21:38:28 -0700103func TestHostFactory() android.Module {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700104 module := NewTest(android.HostSupported)
105 return module.Init()
106}
107
Patrice Arrudac249c712019-03-19 17:00:29 -0700108// cc_benchmark_host compiles an executable binary that performs benchmark
109// testing of a specific component in the host. Additional files such as
110// test suites and test configuration are installed on the side of the
111// compiled executed binary.
Steven Moreland87c9d7b2017-11-02 21:38:28 -0700112func BenchmarkHostFactory() android.Module {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700113 module := NewBenchmark(android.HostSupported)
114 return module.Init()
115}
116
Colin Crossb916a382016-07-29 17:28:03 -0700117type testPerSrc interface {
118 testPerSrc() bool
119 srcs() []string
120 setSrc(string, string)
121}
122
123func (test *testBinary) testPerSrc() bool {
124 return Bool(test.Properties.Test_per_src)
125}
126
127func (test *testBinary) srcs() []string {
128 return test.baseCompiler.Properties.Srcs
129}
130
131func (test *testBinary) setSrc(name, src string) {
132 test.baseCompiler.Properties.Srcs = []string{src}
Nan Zhang0007d812017-11-07 10:57:05 -0800133 test.binaryDecorator.Properties.Stem = StringPtr(name)
Colin Crossb916a382016-07-29 17:28:03 -0700134}
135
136var _ testPerSrc = (*testBinary)(nil)
137
Colin Cross4d9c2d12016-07-29 12:48:20 -0700138func testPerSrcMutator(mctx android.BottomUpMutatorContext) {
139 if m, ok := mctx.Module().(*Module); ok {
Colin Crossb916a382016-07-29 17:28:03 -0700140 if test, ok := m.linker.(testPerSrc); ok {
141 if test.testPerSrc() && len(test.srcs()) > 0 {
Jooyung Hana61ff2c2019-02-28 18:06:34 +0900142 if duplicate, found := checkDuplicate(test.srcs()); found {
143 mctx.PropertyErrorf("srcs", "found a duplicate entry %q", duplicate)
144 return
145 }
Colin Crossb916a382016-07-29 17:28:03 -0700146 testNames := make([]string, len(test.srcs()))
147 for i, src := range test.srcs() {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700148 testNames[i] = strings.TrimSuffix(filepath.Base(src), filepath.Ext(src))
149 }
150 tests := mctx.CreateLocalVariations(testNames...)
Colin Crossb916a382016-07-29 17:28:03 -0700151 for i, src := range test.srcs() {
152 tests[i].(*Module).linker.(testPerSrc).setSrc(testNames[i], src)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700153 }
154 }
155 }
156 }
157}
158
Jooyung Hana61ff2c2019-02-28 18:06:34 +0900159func checkDuplicate(values []string) (duplicate string, found bool) {
160 seen := make(map[string]string)
161 for _, v := range values {
162 if duplicate, found = seen[v]; found {
163 return
164 }
165 seen[v] = v
166 }
167 return
168}
169
Colin Crossb916a382016-07-29 17:28:03 -0700170type testDecorator struct {
171 Properties TestProperties
172 linker *baseLinker
Colin Cross4d9c2d12016-07-29 12:48:20 -0700173}
174
Colin Cross600c9df2016-09-13 12:26:16 -0700175func (test *testDecorator) gtest() bool {
Colin Cross38b40df2018-04-10 16:14:46 -0700176 return BoolDefault(test.Properties.Gtest, true)
Colin Cross600c9df2016-09-13 12:26:16 -0700177}
178
Colin Crossb916a382016-07-29 17:28:03 -0700179func (test *testDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
Colin Cross600c9df2016-09-13 12:26:16 -0700180 if !test.gtest() {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700181 return flags
182 }
183
184 flags.CFlags = append(flags.CFlags, "-DGTEST_HAS_STD_STRING")
185 if ctx.Host() {
186 flags.CFlags = append(flags.CFlags, "-O0", "-g")
187
188 switch ctx.Os() {
189 case android.Windows:
190 flags.CFlags = append(flags.CFlags, "-DGTEST_OS_WINDOWS")
191 case android.Linux:
192 flags.CFlags = append(flags.CFlags, "-DGTEST_OS_LINUX")
Colin Cross4d9c2d12016-07-29 12:48:20 -0700193 case android.Darwin:
194 flags.CFlags = append(flags.CFlags, "-DGTEST_OS_MAC")
Colin Cross4d9c2d12016-07-29 12:48:20 -0700195 }
196 } else {
197 flags.CFlags = append(flags.CFlags, "-DGTEST_OS_LINUX_ANDROID")
198 }
199
200 return flags
201}
202
Colin Crossb916a382016-07-29 17:28:03 -0700203func (test *testDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
Colin Cross600c9df2016-09-13 12:26:16 -0700204 if test.gtest() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700205 if ctx.useSdk() && ctx.Device() {
Dan Albert7dd58992018-02-09 15:22:59 -0800206 deps.StaticLibs = append(deps.StaticLibs, "libgtest_main_ndk_c++", "libgtest_ndk_c++")
Christopher Ferris9df92d62018-08-21 12:40:08 -0700207 } else if BoolDefault(test.Properties.Isolated, false) {
208 deps.StaticLibs = append(deps.StaticLibs, "libgtest_isolated_main")
Colin Cross4d9c2d12016-07-29 12:48:20 -0700209 } else {
210 deps.StaticLibs = append(deps.StaticLibs, "libgtest_main", "libgtest")
211 }
212 }
Colin Crossb916a382016-07-29 17:28:03 -0700213
Colin Cross4d9c2d12016-07-29 12:48:20 -0700214 return deps
215}
216
Colin Crossb916a382016-07-29 17:28:03 -0700217func (test *testDecorator) linkerInit(ctx BaseModuleContext, linker *baseLinker) {
yangbillb3174d12018-05-07 06:41:20 +0000218 // 1. Add ../../lib[64] to rpath so that out/host/linux-x86/nativetest/<test dir>/<test> can
Colin Crossbd75e1d2017-06-30 17:27:55 -0700219 // find out/host/linux-x86/lib[64]/library.so
yangbillb3174d12018-05-07 06:41:20 +0000220 // 2. Add ../../../lib[64] to rpath so that out/host/linux-x86/testcases/<test dir>/<CPU>/<test> can
221 // also find out/host/linux-x86/lib[64]/library.so
222 runpaths := []string{"../../lib", "../../../lib"}
223 for _, runpath := range runpaths {
224 if ctx.toolchain().Is64Bit() {
225 runpath += "64"
226 }
227 linker.dynamicProperties.RunPaths = append(linker.dynamicProperties.RunPaths, runpath)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700228 }
Colin Crossbd75e1d2017-06-30 17:27:55 -0700229
230 // add "" to rpath so that test binaries can find libraries in their own test directory
231 linker.dynamicProperties.RunPaths = append(linker.dynamicProperties.RunPaths, "")
Colin Cross4d9c2d12016-07-29 12:48:20 -0700232}
233
Colin Crossb916a382016-07-29 17:28:03 -0700234func (test *testDecorator) linkerProps() []interface{} {
235 return []interface{}{&test.Properties}
Colin Cross4d9c2d12016-07-29 12:48:20 -0700236}
237
Colin Crossb916a382016-07-29 17:28:03 -0700238func NewTestInstaller() *baseInstaller {
239 return NewBaseInstaller("nativetest", "nativetest64", InstallInData)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700240}
241
Colin Crossb916a382016-07-29 17:28:03 -0700242type testBinary struct {
243 testDecorator
244 *binaryDecorator
245 *baseCompiler
Colin Crossb916a382016-07-29 17:28:03 -0700246 Properties TestBinaryProperties
Colin Crossfaeb7aa2017-02-01 14:12:44 -0800247 data android.Paths
Colin Cross303e21f2018-08-07 16:49:25 -0700248 testConfig android.Path
Colin Crossb916a382016-07-29 17:28:03 -0700249}
250
251func (test *testBinary) linkerProps() []interface{} {
252 props := append(test.testDecorator.linkerProps(), test.binaryDecorator.linkerProps()...)
253 props = append(props, &test.Properties)
254 return props
255}
256
257func (test *testBinary) linkerInit(ctx BaseModuleContext) {
258 test.testDecorator.linkerInit(ctx, test.binaryDecorator.baseLinker)
259 test.binaryDecorator.linkerInit(ctx)
260}
261
Colin Cross37047f12016-12-13 17:06:13 -0800262func (test *testBinary) linkerDeps(ctx DepsContext, deps Deps) Deps {
Colin Crossb916a382016-07-29 17:28:03 -0700263 deps = test.testDecorator.linkerDeps(ctx, deps)
264 deps = test.binaryDecorator.linkerDeps(ctx, deps)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700265 return deps
266}
267
Colin Crossb916a382016-07-29 17:28:03 -0700268func (test *testBinary) linkerFlags(ctx ModuleContext, flags Flags) Flags {
269 flags = test.binaryDecorator.linkerFlags(ctx, flags)
270 flags = test.testDecorator.linkerFlags(ctx, flags)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700271 return flags
272}
273
Colin Crossb916a382016-07-29 17:28:03 -0700274func (test *testBinary) install(ctx ModuleContext, file android.Path) {
Colin Cross8a497952019-03-05 22:25:09 -0800275 test.data = android.PathsForModuleSrc(ctx, test.Properties.Data)
Julien Desprezeb7398e2019-02-28 08:45:28 -0800276 optionsMap := map[string]string{}
277 if Bool(test.testDecorator.Properties.Isolated) {
278 optionsMap["not-shardable"] = "true"
279 }
yelinhsieh9fc60402018-10-01 19:23:14 +0800280
281 if test.Properties.Test_options.Run_test_as != nil {
282 optionsMap["run-test-as"] = String(test.Properties.Test_options.Run_test_as)
283 }
284
Jack He33338892018-09-19 02:21:28 -0700285 test.testConfig = tradefed.AutoGenNativeTestConfig(ctx, test.Properties.Test_config,
Julien Desprezeb7398e2019-02-28 08:45:28 -0800286 test.Properties.Test_config_template,
287 test.Properties.Test_suites, optionsMap)
Colin Crossfaeb7aa2017-02-01 14:12:44 -0800288
Colin Cross600c9df2016-09-13 12:26:16 -0700289 test.binaryDecorator.baseInstaller.dir = "nativetest"
290 test.binaryDecorator.baseInstaller.dir64 = "nativetest64"
Dan Willemsen3340d602016-12-27 14:40:40 -0800291
292 if !Bool(test.Properties.No_named_install_directory) {
293 test.binaryDecorator.baseInstaller.relative = ctx.ModuleName()
Nan Zhang0007d812017-11-07 10:57:05 -0800294 } else if String(test.binaryDecorator.baseInstaller.Properties.Relative_install_path) == "" {
Dan Willemsen3340d602016-12-27 14:40:40 -0800295 ctx.PropertyErrorf("no_named_install_directory", "Module install directory may only be disabled if relative_install_path is set")
296 }
297
Dan Willemsen1d577e22016-08-29 15:53:15 -0700298 test.binaryDecorator.baseInstaller.install(ctx, file)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700299}
300
301func NewTest(hod android.HostOrDeviceSupported) *Module {
Colin Crossb916a382016-07-29 17:28:03 -0700302 module, binary := NewBinary(hod)
303 module.multilib = android.MultilibBoth
Dan Willemsen1d577e22016-08-29 15:53:15 -0700304 binary.baseInstaller = NewTestInstaller()
Colin Crossb916a382016-07-29 17:28:03 -0700305
306 test := &testBinary{
307 testDecorator: testDecorator{
308 linker: binary.baseLinker,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700309 },
Colin Crossb916a382016-07-29 17:28:03 -0700310 binaryDecorator: binary,
311 baseCompiler: NewBaseCompiler(),
Colin Cross4d9c2d12016-07-29 12:48:20 -0700312 }
Colin Crossb916a382016-07-29 17:28:03 -0700313 module.compiler = test
314 module.linker = test
315 module.installer = test
Colin Cross4d9c2d12016-07-29 12:48:20 -0700316 return module
317}
318
Colin Crossb916a382016-07-29 17:28:03 -0700319type testLibrary struct {
320 testDecorator
321 *libraryDecorator
322}
323
324func (test *testLibrary) linkerProps() []interface{} {
325 return append(test.testDecorator.linkerProps(), test.libraryDecorator.linkerProps()...)
326}
327
328func (test *testLibrary) linkerInit(ctx BaseModuleContext) {
329 test.testDecorator.linkerInit(ctx, test.libraryDecorator.baseLinker)
330 test.libraryDecorator.linkerInit(ctx)
331}
332
Colin Cross37047f12016-12-13 17:06:13 -0800333func (test *testLibrary) linkerDeps(ctx DepsContext, deps Deps) Deps {
Colin Crossb916a382016-07-29 17:28:03 -0700334 deps = test.testDecorator.linkerDeps(ctx, deps)
335 deps = test.libraryDecorator.linkerDeps(ctx, deps)
336 return deps
337}
338
339func (test *testLibrary) linkerFlags(ctx ModuleContext, flags Flags) Flags {
340 flags = test.libraryDecorator.linkerFlags(ctx, flags)
341 flags = test.testDecorator.linkerFlags(ctx, flags)
342 return flags
343}
344
Colin Cross4d9c2d12016-07-29 12:48:20 -0700345func NewTestLibrary(hod android.HostOrDeviceSupported) *Module {
Colin Crossab3b7322016-12-09 14:46:15 -0800346 module, library := NewLibrary(android.HostAndDeviceSupported)
Dan Willemsen28bda512016-08-31 16:32:55 -0700347 library.baseInstaller = NewTestInstaller()
Colin Crossb916a382016-07-29 17:28:03 -0700348 test := &testLibrary{
349 testDecorator: testDecorator{
350 linker: library.baseLinker,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700351 },
Colin Crossb916a382016-07-29 17:28:03 -0700352 libraryDecorator: library,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700353 }
Colin Crossb916a382016-07-29 17:28:03 -0700354 module.linker = test
Colin Cross4d9c2d12016-07-29 12:48:20 -0700355 return module
356}
357
Colin Crosse28f4e22017-04-24 18:10:29 -0700358type BenchmarkProperties struct {
Anders Lewisb97e8182017-07-14 15:20:13 -0700359 // list of files or filegroup modules that provide data that should be installed alongside
360 // the test
Colin Cross27b922f2019-03-04 22:35:41 -0800361 Data []string `android:"path"`
Anders Lewisb97e8182017-07-14 15:20:13 -0700362
Colin Crosse28f4e22017-04-24 18:10:29 -0700363 // list of compatibility suites (for example "cts", "vts") that the module should be
364 // installed into.
Julien Despreze146e392018-08-02 15:00:46 -0700365 Test_suites []string `android:"arch_variant"`
366
367 // the name of the test configuration (for example "AndroidTest.xml") that should be
368 // installed with the module.
Colin Cross27b922f2019-03-04 22:35:41 -0800369 Test_config *string `android:"path,arch_variant"`
Jack He33338892018-09-19 02:21:28 -0700370
371 // the name of the test configuration template (for example "AndroidTestTemplate.xml") that
372 // should be installed with the module.
Colin Cross27b922f2019-03-04 22:35:41 -0800373 Test_config_template *string `android:"path,arch_variant"`
Colin Crosse28f4e22017-04-24 18:10:29 -0700374}
375
Colin Crossb916a382016-07-29 17:28:03 -0700376type benchmarkDecorator struct {
377 *binaryDecorator
Colin Crosse28f4e22017-04-24 18:10:29 -0700378 Properties BenchmarkProperties
Anders Lewisb97e8182017-07-14 15:20:13 -0700379 data android.Paths
Colin Cross303e21f2018-08-07 16:49:25 -0700380 testConfig android.Path
Colin Cross4d9c2d12016-07-29 12:48:20 -0700381}
382
Colin Crossb916a382016-07-29 17:28:03 -0700383func (benchmark *benchmarkDecorator) linkerInit(ctx BaseModuleContext) {
384 runpath := "../../lib"
385 if ctx.toolchain().Is64Bit() {
386 runpath += "64"
387 }
388 benchmark.baseLinker.dynamicProperties.RunPaths = append(benchmark.baseLinker.dynamicProperties.RunPaths, runpath)
389 benchmark.binaryDecorator.linkerInit(ctx)
390}
391
Colin Crosse28f4e22017-04-24 18:10:29 -0700392func (benchmark *benchmarkDecorator) linkerProps() []interface{} {
393 props := benchmark.binaryDecorator.linkerProps()
394 props = append(props, &benchmark.Properties)
395 return props
396}
397
Colin Cross37047f12016-12-13 17:06:13 -0800398func (benchmark *benchmarkDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
Colin Crossb916a382016-07-29 17:28:03 -0700399 deps = benchmark.binaryDecorator.linkerDeps(ctx, deps)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700400 deps.StaticLibs = append(deps.StaticLibs, "libgoogle-benchmark")
401 return deps
402}
403
Colin Crossb916a382016-07-29 17:28:03 -0700404func (benchmark *benchmarkDecorator) install(ctx ModuleContext, file android.Path) {
Colin Cross8a497952019-03-05 22:25:09 -0800405 benchmark.data = android.PathsForModuleSrc(ctx, benchmark.Properties.Data)
Jack He33338892018-09-19 02:21:28 -0700406 benchmark.testConfig = tradefed.AutoGenNativeBenchmarkTestConfig(ctx, benchmark.Properties.Test_config,
yangbill4f41bc22019-02-13 21:45:47 +0800407 benchmark.Properties.Test_config_template, benchmark.Properties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700408
Colin Cross28690e92017-09-08 16:20:30 -0700409 benchmark.binaryDecorator.baseInstaller.dir = filepath.Join("benchmarktest", ctx.ModuleName())
410 benchmark.binaryDecorator.baseInstaller.dir64 = filepath.Join("benchmarktest64", ctx.ModuleName())
Dan Willemsen1d577e22016-08-29 15:53:15 -0700411 benchmark.binaryDecorator.baseInstaller.install(ctx, file)
Colin Crossb916a382016-07-29 17:28:03 -0700412}
413
Colin Cross4d9c2d12016-07-29 12:48:20 -0700414func NewBenchmark(hod android.HostOrDeviceSupported) *Module {
Colin Crossb916a382016-07-29 17:28:03 -0700415 module, binary := NewBinary(hod)
416 module.multilib = android.MultilibBoth
Colin Cross28690e92017-09-08 16:20:30 -0700417 binary.baseInstaller = NewBaseInstaller("benchmarktest", "benchmarktest64", InstallInData)
Colin Crossb916a382016-07-29 17:28:03 -0700418
419 benchmark := &benchmarkDecorator{
420 binaryDecorator: binary,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700421 }
Colin Crossb916a382016-07-29 17:28:03 -0700422 module.linker = benchmark
423 module.installer = benchmark
Colin Cross4d9c2d12016-07-29 12:48:20 -0700424 return module
425}