| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 1 | // 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 |  | 
|  | 15 | package cc | 
|  | 16 |  | 
|  | 17 | import ( | 
|  | 18 | "path/filepath" | 
| nelsonli | 0d7111e | 2019-09-17 16:35:23 +0800 | [diff] [blame] | 19 | "strconv" | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 20 | "strings" | 
|  | 21 |  | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 22 | "android/soong/android" | 
| Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 23 | "android/soong/tradefed" | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 24 | ) | 
|  | 25 |  | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 26 | type TestProperties struct { | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 27 | // if set, build against the gtest library. Defaults to true. | 
| Colin Cross | 600c9df | 2016-09-13 12:26:16 -0700 | [diff] [blame] | 28 | Gtest *bool | 
| Christopher Ferris | 9df92d6 | 2018-08-21 12:40:08 -0700 | [diff] [blame] | 29 |  | 
|  | 30 | // if set, use the isolated gtest runner. Defaults to false. | 
|  | 31 | Isolated *bool | 
| Jiyong Park | 62304bb | 2020-04-13 16:19:48 +0900 | [diff] [blame] | 32 |  | 
|  | 33 | // List of APEXes that this module tests. The module has access to | 
|  | 34 | // the private part of the listed APEXes even when it is not included in the | 
|  | 35 | // APEXes. | 
|  | 36 | Test_for []string | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 37 | } | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 38 |  | 
| yelinhsieh | 9fc6040 | 2018-10-01 19:23:14 +0800 | [diff] [blame] | 39 | // Test option struct. | 
|  | 40 | type TestOptions struct { | 
|  | 41 | // The UID that you want to run the test as on a device. | 
|  | 42 | Run_test_as *string | 
|  | 43 | } | 
|  | 44 |  | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 45 | type TestBinaryProperties struct { | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 46 | // Create a separate binary for each source file.  Useful when there is | 
|  | 47 | // global state that can not be torn down and reset between each test suite. | 
|  | 48 | Test_per_src *bool | 
| Dan Willemsen | 3340d60 | 2016-12-27 14:40:40 -0800 | [diff] [blame] | 49 |  | 
|  | 50 | // Disables the creation of a test-specific directory when used with | 
|  | 51 | // relative_install_path. Useful if several tests need to be in the same | 
|  | 52 | // directory, but test_per_src doesn't work. | 
|  | 53 | No_named_install_directory *bool | 
| Colin Cross | faeb7aa | 2017-02-01 14:12:44 -0800 | [diff] [blame] | 54 |  | 
|  | 55 | // list of files or filegroup modules that provide data that should be installed alongside | 
|  | 56 | // the test | 
| Dan Shi | 67a8834 | 2020-02-25 16:34:39 -0800 | [diff] [blame] | 57 | Data []string `android:"path,arch_variant"` | 
| Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 58 |  | 
|  | 59 | // list of compatibility suites (for example "cts", "vts") that the module should be | 
|  | 60 | // installed into. | 
| Dan Willemsen | 15d54d5 | 2017-09-18 16:49:28 -0700 | [diff] [blame] | 61 | Test_suites []string `android:"arch_variant"` | 
| Julien Desprez | e146e39 | 2018-08-02 15:00:46 -0700 | [diff] [blame] | 62 |  | 
|  | 63 | // the name of the test configuration (for example "AndroidTest.xml") that should be | 
|  | 64 | // installed with the module. | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 65 | Test_config *string `android:"path,arch_variant"` | 
| Jack He | 3333889 | 2018-09-19 02:21:28 -0700 | [diff] [blame] | 66 |  | 
|  | 67 | // the name of the test configuration template (for example "AndroidTestTemplate.xml") that | 
|  | 68 | // should be installed with the module. | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 69 | Test_config_template *string `android:"path,arch_variant"` | 
| yelinhsieh | 9fc6040 | 2018-10-01 19:23:14 +0800 | [diff] [blame] | 70 |  | 
|  | 71 | // Test options. | 
|  | 72 | Test_options TestOptions | 
| Dan Shi | 37ee3b8 | 2019-06-06 16:23:32 -0700 | [diff] [blame] | 73 |  | 
|  | 74 | // Add RootTargetPreparer to auto generated test config. This guarantees the test to run | 
|  | 75 | // with root permission. | 
|  | 76 | Require_root *bool | 
| Dan Shi | 20ccd21 | 2019-08-27 10:37:24 -0700 | [diff] [blame] | 77 |  | 
|  | 78 | // Add RunCommandTargetPreparer to stop framework before the test and start it after the test. | 
|  | 79 | Disable_framework *bool | 
| nelsonli | 0d7111e | 2019-09-17 16:35:23 +0800 | [diff] [blame] | 80 |  | 
|  | 81 | // Add MinApiLevelModuleController to auto generated test config. If the device property of | 
|  | 82 | // "ro.product.first_api_level" < Test_min_api_level, then skip this module. | 
|  | 83 | Test_min_api_level *int64 | 
|  | 84 |  | 
|  | 85 | // Add MinApiLevelModuleController to auto generated test config. If the device property of | 
|  | 86 | // "ro.build.version.sdk" < Test_min_sdk_version, then skip this module. | 
|  | 87 | Test_min_sdk_version *int64 | 
| Dan Shi | 6ffaaa8 | 2019-09-26 11:41:36 -0700 | [diff] [blame] | 88 |  | 
|  | 89 | // Flag to indicate whether or not to create test config automatically. If AndroidTest.xml | 
|  | 90 | // doesn't exist next to the Android.bp, this attribute doesn't need to be set to true | 
|  | 91 | // explicitly. | 
|  | 92 | Auto_gen_config *bool | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 93 | } | 
|  | 94 |  | 
|  | 95 | func init() { | 
| Steven Moreland | 87c9d7b | 2017-11-02 21:38:28 -0700 | [diff] [blame] | 96 | android.RegisterModuleType("cc_test", TestFactory) | 
|  | 97 | android.RegisterModuleType("cc_test_library", TestLibraryFactory) | 
|  | 98 | android.RegisterModuleType("cc_benchmark", BenchmarkFactory) | 
|  | 99 | android.RegisterModuleType("cc_test_host", TestHostFactory) | 
|  | 100 | android.RegisterModuleType("cc_benchmark_host", BenchmarkHostFactory) | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 101 | } | 
|  | 102 |  | 
| Patrice Arruda | c249c71 | 2019-03-19 17:00:29 -0700 | [diff] [blame] | 103 | // cc_test generates a test config file and an executable binary file to test | 
|  | 104 | // specific functionality on a device. The executable binary gets an implicit | 
|  | 105 | // static_libs dependency on libgtests unless the gtest flag is set to false. | 
| Steven Moreland | 87c9d7b | 2017-11-02 21:38:28 -0700 | [diff] [blame] | 106 | func TestFactory() android.Module { | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 107 | module := NewTest(android.HostAndDeviceSupported) | 
|  | 108 | return module.Init() | 
|  | 109 | } | 
|  | 110 |  | 
| Patrice Arruda | c249c71 | 2019-03-19 17:00:29 -0700 | [diff] [blame] | 111 | // cc_test_library creates an archive of files (i.e. .o files) which is later | 
|  | 112 | // referenced by another module (such as cc_test, cc_defaults or cc_test_library) | 
|  | 113 | // for archiving or linking. | 
| Steven Moreland | 87c9d7b | 2017-11-02 21:38:28 -0700 | [diff] [blame] | 114 | func TestLibraryFactory() android.Module { | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 115 | module := NewTestLibrary(android.HostAndDeviceSupported) | 
|  | 116 | return module.Init() | 
|  | 117 | } | 
|  | 118 |  | 
| Patrice Arruda | c249c71 | 2019-03-19 17:00:29 -0700 | [diff] [blame] | 119 | // cc_benchmark compiles an executable binary that performs benchmark testing | 
|  | 120 | // of a specific component in a device. Additional files such as test suites | 
|  | 121 | // and test configuration are installed on the side of the compiled executed | 
|  | 122 | // binary. | 
| Steven Moreland | 87c9d7b | 2017-11-02 21:38:28 -0700 | [diff] [blame] | 123 | func BenchmarkFactory() android.Module { | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 124 | module := NewBenchmark(android.HostAndDeviceSupported) | 
|  | 125 | return module.Init() | 
|  | 126 | } | 
|  | 127 |  | 
| Patrice Arruda | c249c71 | 2019-03-19 17:00:29 -0700 | [diff] [blame] | 128 | // cc_test_host compiles a test host binary. | 
| Steven Moreland | 87c9d7b | 2017-11-02 21:38:28 -0700 | [diff] [blame] | 129 | func TestHostFactory() android.Module { | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 130 | module := NewTest(android.HostSupported) | 
|  | 131 | return module.Init() | 
|  | 132 | } | 
|  | 133 |  | 
| Patrice Arruda | c249c71 | 2019-03-19 17:00:29 -0700 | [diff] [blame] | 134 | // cc_benchmark_host compiles an executable binary that performs benchmark | 
|  | 135 | // testing of a specific component in the host. Additional files such as | 
|  | 136 | // test suites and test configuration are installed on the side of the | 
|  | 137 | // compiled executed binary. | 
| Steven Moreland | 87c9d7b | 2017-11-02 21:38:28 -0700 | [diff] [blame] | 138 | func BenchmarkHostFactory() android.Module { | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 139 | module := NewBenchmark(android.HostSupported) | 
|  | 140 | return module.Init() | 
|  | 141 | } | 
|  | 142 |  | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 143 | type testPerSrc interface { | 
|  | 144 | testPerSrc() bool | 
|  | 145 | srcs() []string | 
| Roland Levillain | f2fad97 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 146 | isAllTestsVariation() bool | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 147 | setSrc(string, string) | 
| Roland Levillain | f2fad97 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 148 | unsetSrc() | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 149 | } | 
|  | 150 |  | 
|  | 151 | func (test *testBinary) testPerSrc() bool { | 
|  | 152 | return Bool(test.Properties.Test_per_src) | 
|  | 153 | } | 
|  | 154 |  | 
|  | 155 | func (test *testBinary) srcs() []string { | 
|  | 156 | return test.baseCompiler.Properties.Srcs | 
|  | 157 | } | 
|  | 158 |  | 
| Roland Levillain | f2fad97 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 159 | func (test *testBinary) isAllTestsVariation() bool { | 
|  | 160 | stem := test.binaryDecorator.Properties.Stem | 
|  | 161 | return stem != nil && *stem == "" | 
|  | 162 | } | 
|  | 163 |  | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 164 | func (test *testBinary) setSrc(name, src string) { | 
|  | 165 | test.baseCompiler.Properties.Srcs = []string{src} | 
| Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 166 | test.binaryDecorator.Properties.Stem = StringPtr(name) | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 167 | } | 
|  | 168 |  | 
| Roland Levillain | f2fad97 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 169 | func (test *testBinary) unsetSrc() { | 
|  | 170 | test.baseCompiler.Properties.Srcs = nil | 
|  | 171 | test.binaryDecorator.Properties.Stem = StringPtr("") | 
|  | 172 | } | 
|  | 173 |  | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 174 | var _ testPerSrc = (*testBinary)(nil) | 
|  | 175 |  | 
| Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 176 | func TestPerSrcMutator(mctx android.BottomUpMutatorContext) { | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 177 | if m, ok := mctx.Module().(*Module); ok { | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 178 | if test, ok := m.linker.(testPerSrc); ok { | 
| Roland Levillain | f2fad97 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 179 | numTests := len(test.srcs()) | 
|  | 180 | if test.testPerSrc() && numTests > 0 { | 
| Chih-Hung Hsieh | a5f22ed | 2019-10-24 20:47:54 -0700 | [diff] [blame] | 181 | if duplicate, found := android.CheckDuplicate(test.srcs()); found { | 
| Jooyung Han | a61ff2c | 2019-02-28 18:06:34 +0900 | [diff] [blame] | 182 | mctx.PropertyErrorf("srcs", "found a duplicate entry %q", duplicate) | 
|  | 183 | return | 
|  | 184 | } | 
| Roland Levillain | f2fad97 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 185 | testNames := make([]string, numTests) | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 186 | for i, src := range test.srcs() { | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 187 | testNames[i] = strings.TrimSuffix(filepath.Base(src), filepath.Ext(src)) | 
|  | 188 | } | 
| Roland Levillain | f2fad97 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 189 | // In addition to creating one variation per test source file, | 
|  | 190 | // create an additional "all tests" variation named "", and have it | 
|  | 191 | // depends on all other test_per_src variations. This is useful to | 
|  | 192 | // create subsequent dependencies of a given module on all | 
|  | 193 | // test_per_src variations created above: by depending on | 
|  | 194 | // variation "", that module will transitively depend on all the | 
|  | 195 | // other test_per_src variations without the need to know their | 
|  | 196 | // name or even their number. | 
|  | 197 | testNames = append(testNames, "") | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 198 | tests := mctx.CreateLocalVariations(testNames...) | 
| Roland Levillain | f2fad97 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 199 | all_tests := tests[numTests] | 
|  | 200 | all_tests.(*Module).linker.(testPerSrc).unsetSrc() | 
|  | 201 | // Prevent the "all tests" variation from being installable nor | 
|  | 202 | // exporting to Make, as it won't create any output file. | 
|  | 203 | all_tests.(*Module).Properties.PreventInstall = true | 
|  | 204 | all_tests.(*Module).Properties.HideFromMake = true | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 205 | for i, src := range test.srcs() { | 
|  | 206 | tests[i].(*Module).linker.(testPerSrc).setSrc(testNames[i], src) | 
| Roland Levillain | f2fad97 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 207 | mctx.AddInterVariantDependency(testPerSrcDepTag, all_tests, tests[i]) | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 208 | } | 
|  | 209 | } | 
|  | 210 | } | 
|  | 211 | } | 
|  | 212 | } | 
|  | 213 |  | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 214 | type testDecorator struct { | 
|  | 215 | Properties TestProperties | 
|  | 216 | linker     *baseLinker | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 217 | } | 
|  | 218 |  | 
| Colin Cross | 600c9df | 2016-09-13 12:26:16 -0700 | [diff] [blame] | 219 | func (test *testDecorator) gtest() bool { | 
| Colin Cross | 38b40df | 2018-04-10 16:14:46 -0700 | [diff] [blame] | 220 | return BoolDefault(test.Properties.Gtest, true) | 
| Colin Cross | 600c9df | 2016-09-13 12:26:16 -0700 | [diff] [blame] | 221 | } | 
|  | 222 |  | 
| Jiyong Park | 62304bb | 2020-04-13 16:19:48 +0900 | [diff] [blame] | 223 | func (test *testDecorator) testFor() []string { | 
|  | 224 | return test.Properties.Test_for | 
|  | 225 | } | 
|  | 226 |  | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 227 | func (test *testDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags { | 
| Colin Cross | 600c9df | 2016-09-13 12:26:16 -0700 | [diff] [blame] | 228 | if !test.gtest() { | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 229 | return flags | 
|  | 230 | } | 
|  | 231 |  | 
| Colin Cross | 4af21ed | 2019-11-04 09:37:55 -0800 | [diff] [blame] | 232 | flags.Local.CFlags = append(flags.Local.CFlags, "-DGTEST_HAS_STD_STRING") | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 233 | if ctx.Host() { | 
| Colin Cross | 4af21ed | 2019-11-04 09:37:55 -0800 | [diff] [blame] | 234 | flags.Local.CFlags = append(flags.Local.CFlags, "-O0", "-g") | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 235 |  | 
|  | 236 | switch ctx.Os() { | 
|  | 237 | case android.Windows: | 
| Colin Cross | 4af21ed | 2019-11-04 09:37:55 -0800 | [diff] [blame] | 238 | flags.Local.CFlags = append(flags.Local.CFlags, "-DGTEST_OS_WINDOWS") | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 239 | case android.Linux: | 
| Colin Cross | 4af21ed | 2019-11-04 09:37:55 -0800 | [diff] [blame] | 240 | flags.Local.CFlags = append(flags.Local.CFlags, "-DGTEST_OS_LINUX") | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 241 | case android.Darwin: | 
| Colin Cross | 4af21ed | 2019-11-04 09:37:55 -0800 | [diff] [blame] | 242 | flags.Local.CFlags = append(flags.Local.CFlags, "-DGTEST_OS_MAC") | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 243 | } | 
|  | 244 | } else { | 
| Colin Cross | 4af21ed | 2019-11-04 09:37:55 -0800 | [diff] [blame] | 245 | flags.Local.CFlags = append(flags.Local.CFlags, "-DGTEST_OS_LINUX_ANDROID") | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 246 | } | 
|  | 247 |  | 
|  | 248 | return flags | 
|  | 249 | } | 
|  | 250 |  | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 251 | func (test *testDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) Deps { | 
| Colin Cross | 600c9df | 2016-09-13 12:26:16 -0700 | [diff] [blame] | 252 | if test.gtest() { | 
| Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 253 | if ctx.useSdk() && ctx.Device() { | 
| Dan Albert | 7dd5899 | 2018-02-09 15:22:59 -0800 | [diff] [blame] | 254 | deps.StaticLibs = append(deps.StaticLibs, "libgtest_main_ndk_c++", "libgtest_ndk_c++") | 
| Christopher Ferris | 9df92d6 | 2018-08-21 12:40:08 -0700 | [diff] [blame] | 255 | } else if BoolDefault(test.Properties.Isolated, false) { | 
|  | 256 | deps.StaticLibs = append(deps.StaticLibs, "libgtest_isolated_main") | 
| Christopher Ferris | 34cbba6 | 2019-07-17 15:46:29 -0700 | [diff] [blame] | 257 | // The isolated library requires liblog, but adding it | 
|  | 258 | // as a static library means unit tests cannot override | 
|  | 259 | // liblog functions. Instead make it a shared library | 
|  | 260 | // dependency. | 
|  | 261 | deps.SharedLibs = append(deps.SharedLibs, "liblog") | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 262 | } else { | 
|  | 263 | deps.StaticLibs = append(deps.StaticLibs, "libgtest_main", "libgtest") | 
|  | 264 | } | 
|  | 265 | } | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 266 |  | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 267 | return deps | 
|  | 268 | } | 
|  | 269 |  | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 270 | func (test *testDecorator) linkerInit(ctx BaseModuleContext, linker *baseLinker) { | 
| yangbill | b3174d1 | 2018-05-07 06:41:20 +0000 | [diff] [blame] | 271 | // 1. Add ../../lib[64] to rpath so that out/host/linux-x86/nativetest/<test dir>/<test> can | 
| Colin Cross | bd75e1d | 2017-06-30 17:27:55 -0700 | [diff] [blame] | 272 | // find out/host/linux-x86/lib[64]/library.so | 
| yangbill | b3174d1 | 2018-05-07 06:41:20 +0000 | [diff] [blame] | 273 | // 2. Add ../../../lib[64] to rpath so that out/host/linux-x86/testcases/<test dir>/<CPU>/<test> can | 
|  | 274 | // also find out/host/linux-x86/lib[64]/library.so | 
|  | 275 | runpaths := []string{"../../lib", "../../../lib"} | 
|  | 276 | for _, runpath := range runpaths { | 
|  | 277 | if ctx.toolchain().Is64Bit() { | 
|  | 278 | runpath += "64" | 
|  | 279 | } | 
|  | 280 | linker.dynamicProperties.RunPaths = append(linker.dynamicProperties.RunPaths, runpath) | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 281 | } | 
| Colin Cross | bd75e1d | 2017-06-30 17:27:55 -0700 | [diff] [blame] | 282 |  | 
|  | 283 | // add "" to rpath so that test binaries can find libraries in their own test directory | 
|  | 284 | linker.dynamicProperties.RunPaths = append(linker.dynamicProperties.RunPaths, "") | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 285 | } | 
|  | 286 |  | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 287 | func (test *testDecorator) linkerProps() []interface{} { | 
|  | 288 | return []interface{}{&test.Properties} | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 289 | } | 
|  | 290 |  | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 291 | func NewTestInstaller() *baseInstaller { | 
|  | 292 | return NewBaseInstaller("nativetest", "nativetest64", InstallInData) | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 293 | } | 
|  | 294 |  | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 295 | type testBinary struct { | 
|  | 296 | testDecorator | 
|  | 297 | *binaryDecorator | 
|  | 298 | *baseCompiler | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 299 | Properties TestBinaryProperties | 
| Colin Cross | faeb7aa | 2017-02-01 14:12:44 -0800 | [diff] [blame] | 300 | data       android.Paths | 
| Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 301 | testConfig android.Path | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 302 | } | 
|  | 303 |  | 
|  | 304 | func (test *testBinary) linkerProps() []interface{} { | 
|  | 305 | props := append(test.testDecorator.linkerProps(), test.binaryDecorator.linkerProps()...) | 
|  | 306 | props = append(props, &test.Properties) | 
|  | 307 | return props | 
|  | 308 | } | 
|  | 309 |  | 
|  | 310 | func (test *testBinary) linkerInit(ctx BaseModuleContext) { | 
|  | 311 | test.testDecorator.linkerInit(ctx, test.binaryDecorator.baseLinker) | 
|  | 312 | test.binaryDecorator.linkerInit(ctx) | 
|  | 313 | } | 
|  | 314 |  | 
| Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 315 | func (test *testBinary) linkerDeps(ctx DepsContext, deps Deps) Deps { | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 316 | deps = test.testDecorator.linkerDeps(ctx, deps) | 
|  | 317 | deps = test.binaryDecorator.linkerDeps(ctx, deps) | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 318 | return deps | 
|  | 319 | } | 
|  | 320 |  | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 321 | func (test *testBinary) linkerFlags(ctx ModuleContext, flags Flags) Flags { | 
|  | 322 | flags = test.binaryDecorator.linkerFlags(ctx, flags) | 
|  | 323 | flags = test.testDecorator.linkerFlags(ctx, flags) | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 324 | return flags | 
|  | 325 | } | 
|  | 326 |  | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 327 | func (test *testBinary) install(ctx ModuleContext, file android.Path) { | 
| Colin Cross | 8a49795 | 2019-03-05 22:25:09 -0800 | [diff] [blame] | 328 | test.data = android.PathsForModuleSrc(ctx, test.Properties.Data) | 
| nelsonli | 0d7111e | 2019-09-17 16:35:23 +0800 | [diff] [blame] | 329 | var api_level_prop string | 
| Dan Shi | 37ee3b8 | 2019-06-06 16:23:32 -0700 | [diff] [blame] | 330 | var configs []tradefed.Config | 
| nelsonli | 0d7111e | 2019-09-17 16:35:23 +0800 | [diff] [blame] | 331 | var min_level string | 
| Dan Shi | 37ee3b8 | 2019-06-06 16:23:32 -0700 | [diff] [blame] | 332 | if Bool(test.Properties.Require_root) { | 
| nelsonli | 0d7111e | 2019-09-17 16:35:23 +0800 | [diff] [blame] | 333 | configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", nil}) | 
| Dan Shi | bc0f260 | 2019-09-17 02:43:50 +0000 | [diff] [blame] | 334 | } else { | 
|  | 335 | var options []tradefed.Option | 
|  | 336 | options = append(options, tradefed.Option{"force-root", "false"}) | 
| nelsonli | 0d7111e | 2019-09-17 16:35:23 +0800 | [diff] [blame] | 337 | configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", options}) | 
| Dan Shi | 20ccd21 | 2019-08-27 10:37:24 -0700 | [diff] [blame] | 338 | } | 
|  | 339 | if Bool(test.Properties.Disable_framework) { | 
|  | 340 | var options []tradefed.Option | 
|  | 341 | options = append(options, tradefed.Option{"run-command", "stop"}) | 
|  | 342 | options = append(options, tradefed.Option{"teardown-command", "start"}) | 
| nelsonli | 0d7111e | 2019-09-17 16:35:23 +0800 | [diff] [blame] | 343 | configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RunCommandTargetPreparer", options}) | 
| Julien Desprez | eb7398e | 2019-02-28 08:45:28 -0800 | [diff] [blame] | 344 | } | 
| Dan Shi | 37ee3b8 | 2019-06-06 16:23:32 -0700 | [diff] [blame] | 345 | if Bool(test.testDecorator.Properties.Isolated) { | 
|  | 346 | configs = append(configs, tradefed.Option{"not-shardable", "true"}) | 
|  | 347 | } | 
| yelinhsieh | 9fc6040 | 2018-10-01 19:23:14 +0800 | [diff] [blame] | 348 | if test.Properties.Test_options.Run_test_as != nil { | 
| Dan Shi | 37ee3b8 | 2019-06-06 16:23:32 -0700 | [diff] [blame] | 349 | configs = append(configs, tradefed.Option{"run-test-as", String(test.Properties.Test_options.Run_test_as)}) | 
| yelinhsieh | 9fc6040 | 2018-10-01 19:23:14 +0800 | [diff] [blame] | 350 | } | 
| nelsonli | 0d7111e | 2019-09-17 16:35:23 +0800 | [diff] [blame] | 351 | if test.Properties.Test_min_api_level != nil && test.Properties.Test_min_sdk_version != nil { | 
|  | 352 | ctx.PropertyErrorf("test_min_api_level", "'test_min_api_level' and 'test_min_sdk_version' should not be set at the same time.") | 
|  | 353 | } else if test.Properties.Test_min_api_level != nil { | 
|  | 354 | api_level_prop = "ro.product.first_api_level" | 
|  | 355 | min_level = strconv.FormatInt(int64(*test.Properties.Test_min_api_level), 10) | 
|  | 356 | } else if test.Properties.Test_min_sdk_version != nil { | 
|  | 357 | api_level_prop = "ro.build.version.sdk" | 
|  | 358 | min_level = strconv.FormatInt(int64(*test.Properties.Test_min_sdk_version), 10) | 
|  | 359 | } | 
|  | 360 | if api_level_prop != "" { | 
|  | 361 | var options []tradefed.Option | 
|  | 362 | options = append(options, tradefed.Option{"min-api-level", min_level}) | 
|  | 363 | options = append(options, tradefed.Option{"api-level-prop", api_level_prop}) | 
|  | 364 | configs = append(configs, tradefed.Object{"module_controller", "com.android.tradefed.testtype.suite.module.MinApiLevelModuleController", options}) | 
|  | 365 | } | 
| yelinhsieh | 9fc6040 | 2018-10-01 19:23:14 +0800 | [diff] [blame] | 366 |  | 
| Jack He | 3333889 | 2018-09-19 02:21:28 -0700 | [diff] [blame] | 367 | test.testConfig = tradefed.AutoGenNativeTestConfig(ctx, test.Properties.Test_config, | 
| Dan Shi | 6ffaaa8 | 2019-09-26 11:41:36 -0700 | [diff] [blame] | 368 | test.Properties.Test_config_template, test.Properties.Test_suites, configs, test.Properties.Auto_gen_config) | 
| Colin Cross | faeb7aa | 2017-02-01 14:12:44 -0800 | [diff] [blame] | 369 |  | 
| Colin Cross | 600c9df | 2016-09-13 12:26:16 -0700 | [diff] [blame] | 370 | test.binaryDecorator.baseInstaller.dir = "nativetest" | 
|  | 371 | test.binaryDecorator.baseInstaller.dir64 = "nativetest64" | 
| Dan Willemsen | 3340d60 | 2016-12-27 14:40:40 -0800 | [diff] [blame] | 372 |  | 
|  | 373 | if !Bool(test.Properties.No_named_install_directory) { | 
|  | 374 | test.binaryDecorator.baseInstaller.relative = ctx.ModuleName() | 
| Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 375 | } else if String(test.binaryDecorator.baseInstaller.Properties.Relative_install_path) == "" { | 
| Dan Willemsen | 3340d60 | 2016-12-27 14:40:40 -0800 | [diff] [blame] | 376 | ctx.PropertyErrorf("no_named_install_directory", "Module install directory may only be disabled if relative_install_path is set") | 
|  | 377 | } | 
|  | 378 |  | 
| Dan Willemsen | 1d577e2 | 2016-08-29 15:53:15 -0700 | [diff] [blame] | 379 | test.binaryDecorator.baseInstaller.install(ctx, file) | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 380 | } | 
|  | 381 |  | 
|  | 382 | func NewTest(hod android.HostOrDeviceSupported) *Module { | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 383 | module, binary := NewBinary(hod) | 
|  | 384 | module.multilib = android.MultilibBoth | 
| Dan Willemsen | 1d577e2 | 2016-08-29 15:53:15 -0700 | [diff] [blame] | 385 | binary.baseInstaller = NewTestInstaller() | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 386 |  | 
|  | 387 | test := &testBinary{ | 
|  | 388 | testDecorator: testDecorator{ | 
|  | 389 | linker: binary.baseLinker, | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 390 | }, | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 391 | binaryDecorator: binary, | 
|  | 392 | baseCompiler:    NewBaseCompiler(), | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 393 | } | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 394 | module.compiler = test | 
|  | 395 | module.linker = test | 
|  | 396 | module.installer = test | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 397 | return module | 
|  | 398 | } | 
|  | 399 |  | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 400 | type testLibrary struct { | 
|  | 401 | testDecorator | 
|  | 402 | *libraryDecorator | 
|  | 403 | } | 
|  | 404 |  | 
|  | 405 | func (test *testLibrary) linkerProps() []interface{} { | 
|  | 406 | return append(test.testDecorator.linkerProps(), test.libraryDecorator.linkerProps()...) | 
|  | 407 | } | 
|  | 408 |  | 
|  | 409 | func (test *testLibrary) linkerInit(ctx BaseModuleContext) { | 
|  | 410 | test.testDecorator.linkerInit(ctx, test.libraryDecorator.baseLinker) | 
|  | 411 | test.libraryDecorator.linkerInit(ctx) | 
|  | 412 | } | 
|  | 413 |  | 
| Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 414 | func (test *testLibrary) linkerDeps(ctx DepsContext, deps Deps) Deps { | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 415 | deps = test.testDecorator.linkerDeps(ctx, deps) | 
|  | 416 | deps = test.libraryDecorator.linkerDeps(ctx, deps) | 
|  | 417 | return deps | 
|  | 418 | } | 
|  | 419 |  | 
|  | 420 | func (test *testLibrary) linkerFlags(ctx ModuleContext, flags Flags) Flags { | 
|  | 421 | flags = test.libraryDecorator.linkerFlags(ctx, flags) | 
|  | 422 | flags = test.testDecorator.linkerFlags(ctx, flags) | 
|  | 423 | return flags | 
|  | 424 | } | 
|  | 425 |  | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 426 | func NewTestLibrary(hod android.HostOrDeviceSupported) *Module { | 
| Colin Cross | ab3b732 | 2016-12-09 14:46:15 -0800 | [diff] [blame] | 427 | module, library := NewLibrary(android.HostAndDeviceSupported) | 
| Dan Willemsen | 28bda51 | 2016-08-31 16:32:55 -0700 | [diff] [blame] | 428 | library.baseInstaller = NewTestInstaller() | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 429 | test := &testLibrary{ | 
|  | 430 | testDecorator: testDecorator{ | 
|  | 431 | linker: library.baseLinker, | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 432 | }, | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 433 | libraryDecorator: library, | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 434 | } | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 435 | module.linker = test | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 436 | return module | 
|  | 437 | } | 
|  | 438 |  | 
| Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 439 | type BenchmarkProperties struct { | 
| Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 440 | // list of files or filegroup modules that provide data that should be installed alongside | 
|  | 441 | // the test | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 442 | Data []string `android:"path"` | 
| Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 443 |  | 
| Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 444 | // list of compatibility suites (for example "cts", "vts") that the module should be | 
|  | 445 | // installed into. | 
| Julien Desprez | e146e39 | 2018-08-02 15:00:46 -0700 | [diff] [blame] | 446 | Test_suites []string `android:"arch_variant"` | 
|  | 447 |  | 
|  | 448 | // the name of the test configuration (for example "AndroidTest.xml") that should be | 
|  | 449 | // installed with the module. | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 450 | Test_config *string `android:"path,arch_variant"` | 
| Jack He | 3333889 | 2018-09-19 02:21:28 -0700 | [diff] [blame] | 451 |  | 
|  | 452 | // the name of the test configuration template (for example "AndroidTestTemplate.xml") that | 
|  | 453 | // should be installed with the module. | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 454 | Test_config_template *string `android:"path,arch_variant"` | 
| Dan Shi | 37ee3b8 | 2019-06-06 16:23:32 -0700 | [diff] [blame] | 455 |  | 
|  | 456 | // Add RootTargetPreparer to auto generated test config. This guarantees the test to run | 
|  | 457 | // with root permission. | 
|  | 458 | Require_root *bool | 
| Dan Shi | 6ffaaa8 | 2019-09-26 11:41:36 -0700 | [diff] [blame] | 459 |  | 
|  | 460 | // Flag to indicate whether or not to create test config automatically. If AndroidTest.xml | 
|  | 461 | // doesn't exist next to the Android.bp, this attribute doesn't need to be set to true | 
|  | 462 | // explicitly. | 
|  | 463 | Auto_gen_config *bool | 
| Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 464 | } | 
|  | 465 |  | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 466 | type benchmarkDecorator struct { | 
|  | 467 | *binaryDecorator | 
| Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 468 | Properties BenchmarkProperties | 
| Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 469 | data       android.Paths | 
| Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 470 | testConfig android.Path | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 471 | } | 
|  | 472 |  | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 473 | func (benchmark *benchmarkDecorator) linkerInit(ctx BaseModuleContext) { | 
|  | 474 | runpath := "../../lib" | 
|  | 475 | if ctx.toolchain().Is64Bit() { | 
|  | 476 | runpath += "64" | 
|  | 477 | } | 
|  | 478 | benchmark.baseLinker.dynamicProperties.RunPaths = append(benchmark.baseLinker.dynamicProperties.RunPaths, runpath) | 
|  | 479 | benchmark.binaryDecorator.linkerInit(ctx) | 
|  | 480 | } | 
|  | 481 |  | 
| Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 482 | func (benchmark *benchmarkDecorator) linkerProps() []interface{} { | 
|  | 483 | props := benchmark.binaryDecorator.linkerProps() | 
|  | 484 | props = append(props, &benchmark.Properties) | 
|  | 485 | return props | 
|  | 486 | } | 
|  | 487 |  | 
| Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 488 | func (benchmark *benchmarkDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps { | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 489 | deps = benchmark.binaryDecorator.linkerDeps(ctx, deps) | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 490 | deps.StaticLibs = append(deps.StaticLibs, "libgoogle-benchmark") | 
|  | 491 | return deps | 
|  | 492 | } | 
|  | 493 |  | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 494 | func (benchmark *benchmarkDecorator) install(ctx ModuleContext, file android.Path) { | 
| Colin Cross | 8a49795 | 2019-03-05 22:25:09 -0800 | [diff] [blame] | 495 | benchmark.data = android.PathsForModuleSrc(ctx, benchmark.Properties.Data) | 
| Dan Shi | 37ee3b8 | 2019-06-06 16:23:32 -0700 | [diff] [blame] | 496 | var configs []tradefed.Config | 
|  | 497 | if Bool(benchmark.Properties.Require_root) { | 
| nelsonli | 0d7111e | 2019-09-17 16:35:23 +0800 | [diff] [blame] | 498 | configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", nil}) | 
| Dan Shi | 37ee3b8 | 2019-06-06 16:23:32 -0700 | [diff] [blame] | 499 | } | 
| Jack He | 3333889 | 2018-09-19 02:21:28 -0700 | [diff] [blame] | 500 | benchmark.testConfig = tradefed.AutoGenNativeBenchmarkTestConfig(ctx, benchmark.Properties.Test_config, | 
| Dan Shi | 6ffaaa8 | 2019-09-26 11:41:36 -0700 | [diff] [blame] | 501 | benchmark.Properties.Test_config_template, benchmark.Properties.Test_suites, configs, benchmark.Properties.Auto_gen_config) | 
| Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 502 |  | 
| Colin Cross | 28690e9 | 2017-09-08 16:20:30 -0700 | [diff] [blame] | 503 | benchmark.binaryDecorator.baseInstaller.dir = filepath.Join("benchmarktest", ctx.ModuleName()) | 
|  | 504 | benchmark.binaryDecorator.baseInstaller.dir64 = filepath.Join("benchmarktest64", ctx.ModuleName()) | 
| Dan Willemsen | 1d577e2 | 2016-08-29 15:53:15 -0700 | [diff] [blame] | 505 | benchmark.binaryDecorator.baseInstaller.install(ctx, file) | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 506 | } | 
|  | 507 |  | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 508 | func NewBenchmark(hod android.HostOrDeviceSupported) *Module { | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 509 | module, binary := NewBinary(hod) | 
|  | 510 | module.multilib = android.MultilibBoth | 
| Colin Cross | 28690e9 | 2017-09-08 16:20:30 -0700 | [diff] [blame] | 511 | binary.baseInstaller = NewBaseInstaller("benchmarktest", "benchmarktest64", InstallInData) | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 512 |  | 
|  | 513 | benchmark := &benchmarkDecorator{ | 
|  | 514 | binaryDecorator: binary, | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 515 | } | 
| Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 516 | module.linker = benchmark | 
|  | 517 | module.installer = benchmark | 
| Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 518 | return module | 
|  | 519 | } |