| Jingwen Chen | 537242c | 2022-08-24 11:53:27 +0000 | [diff] [blame] | 1 | // Copyright 2022 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 bp2build | 
|  | 16 |  | 
|  | 17 | import ( | 
|  | 18 | "fmt" | 
|  | 19 | "testing" | 
|  | 20 |  | 
|  | 21 | "android/soong/android" | 
|  | 22 | "android/soong/cc" | 
|  | 23 | "android/soong/genrule" | 
|  | 24 | ) | 
|  | 25 |  | 
|  | 26 | type ccTestBp2buildTestCase struct { | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 27 | description             string | 
|  | 28 | blueprint               string | 
|  | 29 | filesystem              map[string]string | 
|  | 30 | targets                 []testBazelTarget | 
|  | 31 | stubbedBuildDefinitions []string | 
| Jingwen Chen | 537242c | 2022-08-24 11:53:27 +0000 | [diff] [blame] | 32 | } | 
|  | 33 |  | 
|  | 34 | func registerCcTestModuleTypes(ctx android.RegistrationContext) { | 
|  | 35 | cc.RegisterCCBuildComponents(ctx) | 
|  | 36 | ctx.RegisterModuleType("cc_binary", cc.BinaryFactory) | 
|  | 37 | ctx.RegisterModuleType("cc_library_static", cc.LibraryStaticFactory) | 
|  | 38 | ctx.RegisterModuleType("cc_library", cc.LibraryFactory) | 
|  | 39 | ctx.RegisterModuleType("cc_test_library", cc.TestLibraryFactory) | 
|  | 40 | ctx.RegisterModuleType("genrule", genrule.GenRuleFactory) | 
|  | 41 | } | 
|  | 42 |  | 
|  | 43 | func runCcTestTestCase(t *testing.T, testCase ccTestBp2buildTestCase) { | 
|  | 44 | t.Helper() | 
|  | 45 | moduleTypeUnderTest := "cc_test" | 
| Jingwen Chen | 537242c | 2022-08-24 11:53:27 +0000 | [diff] [blame] | 46 | description := fmt.Sprintf("%s %s", moduleTypeUnderTest, testCase.description) | 
|  | 47 | t.Run(description, func(t *testing.T) { | 
|  | 48 | t.Helper() | 
|  | 49 | RunBp2BuildTestCase(t, registerCcTestModuleTypes, Bp2buildTestCase{ | 
|  | 50 | ExpectedBazelTargets:       generateBazelTargetsForTest(testCase.targets, android.HostAndDeviceSupported), | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 51 | Filesystem:                 testCase.filesystem, | 
| Jingwen Chen | 537242c | 2022-08-24 11:53:27 +0000 | [diff] [blame] | 52 | ModuleTypeUnderTest:        moduleTypeUnderTest, | 
|  | 53 | ModuleTypeUnderTestFactory: cc.TestFactory, | 
|  | 54 | Description:                description, | 
|  | 55 | Blueprint:                  testCase.blueprint, | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 56 | StubbedBuildDefinitions:    testCase.stubbedBuildDefinitions, | 
| Jingwen Chen | 537242c | 2022-08-24 11:53:27 +0000 | [diff] [blame] | 57 | }) | 
|  | 58 | }) | 
|  | 59 | } | 
|  | 60 |  | 
|  | 61 | func TestBasicCcTest(t *testing.T) { | 
|  | 62 | runCcTestTestCase(t, ccTestBp2buildTestCase{ | 
|  | 63 | description: "basic cc_test with commonly used attributes", | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 64 | stubbedBuildDefinitions: []string{"libbuildversion", "libprotobuf-cpp-lite", "libprotobuf-cpp-full", | 
|  | 65 | "foolib", "hostlib", "data_mod", "cc_bin", "cc_lib", "cc_test_lib2", "libgtest_main", "libgtest"}, | 
| Jingwen Chen | 537242c | 2022-08-24 11:53:27 +0000 | [diff] [blame] | 66 | blueprint: ` | 
|  | 67 | cc_test { | 
|  | 68 | name: "mytest", | 
|  | 69 | host_supported: true, | 
|  | 70 | srcs: ["test.cpp"], | 
|  | 71 | target: { | 
|  | 72 | android: { | 
|  | 73 | srcs: ["android.cpp"], | 
|  | 74 | shared_libs: ["foolib"], | 
|  | 75 | }, | 
|  | 76 | linux: { | 
|  | 77 | srcs: ["linux.cpp"], | 
|  | 78 | }, | 
|  | 79 | host: { | 
|  | 80 | static_libs: ["hostlib"], | 
|  | 81 | }, | 
|  | 82 | }, | 
| Liz Kammer | efc51d9 | 2023-04-21 15:11:25 -0400 | [diff] [blame] | 83 | static_libs: ["cc_test_lib1"], | 
|  | 84 | shared_libs: ["cc_test_lib2"], | 
| Jingwen Chen | 537242c | 2022-08-24 11:53:27 +0000 | [diff] [blame] | 85 | data: [":data_mod", "file.txt"], | 
|  | 86 | data_bins: [":cc_bin"], | 
|  | 87 | data_libs: [":cc_lib"], | 
|  | 88 | cflags: ["-Wall"], | 
|  | 89 | } | 
| Liz Kammer | efc51d9 | 2023-04-21 15:11:25 -0400 | [diff] [blame] | 90 |  | 
|  | 91 | cc_test_library { | 
|  | 92 | name: "cc_test_lib1", | 
|  | 93 | host_supported: true, | 
|  | 94 | include_build_directory: false, | 
|  | 95 | } | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 96 | ` + simpleModule("cc_library", "foolib") + | 
|  | 97 | simpleModule("cc_library_static", "hostlib") + | 
|  | 98 | simpleModule("genrule", "data_mod") + | 
|  | 99 | simpleModule("cc_binary", "cc_bin") + | 
|  | 100 | simpleModule("cc_library", "cc_lib") + | 
|  | 101 | simpleModule("cc_test_library", "cc_test_lib2") + | 
|  | 102 | simpleModule("cc_library_static", "libgtest_main") + | 
|  | 103 | simpleModule("cc_library_static", "libgtest"), | 
| Jingwen Chen | 537242c | 2022-08-24 11:53:27 +0000 | [diff] [blame] | 104 | targets: []testBazelTarget{ | 
| Liz Kammer | efc51d9 | 2023-04-21 15:11:25 -0400 | [diff] [blame] | 105 | {"cc_library_shared", "cc_test_lib1", AttrNameToString{}}, | 
|  | 106 | {"cc_library_static", "cc_test_lib1_bp2build_cc_library_static", AttrNameToString{}}, | 
| Jingwen Chen | 537242c | 2022-08-24 11:53:27 +0000 | [diff] [blame] | 107 | {"cc_test", "mytest", AttrNameToString{ | 
|  | 108 | "copts": `["-Wall"]`, | 
|  | 109 | "data": `[ | 
|  | 110 | ":data_mod", | 
|  | 111 | "file.txt", | 
|  | 112 | ":cc_bin", | 
|  | 113 | ":cc_lib", | 
|  | 114 | ]`, | 
| Spandan Das | 651203d | 2023-07-21 22:55:32 +0000 | [diff] [blame] | 115 | "deps": `[ | 
|  | 116 | ":cc_test_lib1_bp2build_cc_library_static", | 
|  | 117 | ":libgtest_main", | 
|  | 118 | ":libgtest", | 
|  | 119 | ] + select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 120 | "//build/bazel_common_rules/platforms/os:darwin": [":hostlib"], | 
|  | 121 | "//build/bazel_common_rules/platforms/os:linux_bionic": [":hostlib"], | 
|  | 122 | "//build/bazel_common_rules/platforms/os:linux_glibc": [":hostlib"], | 
|  | 123 | "//build/bazel_common_rules/platforms/os:linux_musl": [":hostlib"], | 
|  | 124 | "//build/bazel_common_rules/platforms/os:windows": [":hostlib"], | 
| Jingwen Chen | 537242c | 2022-08-24 11:53:27 +0000 | [diff] [blame] | 125 | "//conditions:default": [], | 
|  | 126 | })`, | 
| Jingwen Chen | 537242c | 2022-08-24 11:53:27 +0000 | [diff] [blame] | 127 | "local_includes": `["."]`, | 
| Liz Kammer | efc51d9 | 2023-04-21 15:11:25 -0400 | [diff] [blame] | 128 | "dynamic_deps": `[":cc_test_lib2"] + select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 129 | "//build/bazel_common_rules/platforms/os:android": [":foolib"], | 
| Jingwen Chen | 537242c | 2022-08-24 11:53:27 +0000 | [diff] [blame] | 130 | "//conditions:default": [], | 
|  | 131 | })`, | 
|  | 132 | "srcs": `["test.cpp"] + select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 133 | "//build/bazel_common_rules/platforms/os:android": [ | 
| Jingwen Chen | 537242c | 2022-08-24 11:53:27 +0000 | [diff] [blame] | 134 | "linux.cpp", | 
|  | 135 | "android.cpp", | 
|  | 136 | ], | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 137 | "//build/bazel_common_rules/platforms/os:linux_bionic": ["linux.cpp"], | 
|  | 138 | "//build/bazel_common_rules/platforms/os:linux_glibc": ["linux.cpp"], | 
|  | 139 | "//build/bazel_common_rules/platforms/os:linux_musl": ["linux.cpp"], | 
| Jingwen Chen | 537242c | 2022-08-24 11:53:27 +0000 | [diff] [blame] | 140 | "//conditions:default": [], | 
|  | 141 | })`, | 
| yike | fdca7fe | 2023-08-17 01:03:37 +0000 | [diff] [blame] | 142 | "runs_on": `[ | 
|  | 143 | "host_without_device", | 
|  | 144 | "device", | 
|  | 145 | ]`, | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 146 | "features": `select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 147 | "//build/bazel_common_rules/platforms/os_arch:android_arm64": [ | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 148 | "memtag_heap", | 
|  | 149 | "diag_memtag_heap", | 
|  | 150 | ], | 
|  | 151 | "//conditions:default": [], | 
|  | 152 | })`, | 
| Jingwen Chen | 537242c | 2022-08-24 11:53:27 +0000 | [diff] [blame] | 153 | }, | 
|  | 154 | }, | 
|  | 155 | }, | 
|  | 156 | }) | 
|  | 157 | } | 
|  | 158 |  | 
|  | 159 | func TestBasicCcTestGtestIsolatedDisabled(t *testing.T) { | 
|  | 160 | runCcTestTestCase(t, ccTestBp2buildTestCase{ | 
|  | 161 | description: "cc test with disabled gtest and isolated props", | 
|  | 162 | blueprint: ` | 
|  | 163 | cc_test { | 
|  | 164 | name: "mytest", | 
|  | 165 | host_supported: true, | 
|  | 166 | srcs: ["test.cpp"], | 
|  | 167 | gtest: false, | 
|  | 168 | isolated: false, | 
|  | 169 | } | 
|  | 170 | `, | 
|  | 171 | targets: []testBazelTarget{ | 
|  | 172 | {"cc_test", "mytest", AttrNameToString{ | 
|  | 173 | "gtest":          "False", | 
| Jingwen Chen | 537242c | 2022-08-24 11:53:27 +0000 | [diff] [blame] | 174 | "local_includes": `["."]`, | 
|  | 175 | "srcs":           `["test.cpp"]`, | 
| yike | fdca7fe | 2023-08-17 01:03:37 +0000 | [diff] [blame] | 176 | "runs_on": `[ | 
|  | 177 | "host_without_device", | 
|  | 178 | "device", | 
|  | 179 | ]`, | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 180 | "features": `select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 181 | "//build/bazel_common_rules/platforms/os_arch:android_arm64": [ | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 182 | "memtag_heap", | 
|  | 183 | "diag_memtag_heap", | 
|  | 184 | ], | 
|  | 185 | "//conditions:default": [], | 
|  | 186 | })`, | 
| Jingwen Chen | 537242c | 2022-08-24 11:53:27 +0000 | [diff] [blame] | 187 | }, | 
|  | 188 | }, | 
|  | 189 | }, | 
|  | 190 | }) | 
|  | 191 | } | 
| Jingwen Chen | fbff97a | 2022-09-16 02:32:03 +0000 | [diff] [blame] | 192 |  | 
|  | 193 | func TestCcTest_TestOptions_Tags(t *testing.T) { | 
|  | 194 | runCcTestTestCase(t, ccTestBp2buildTestCase{ | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 195 | description:             "cc test with test_options.tags converted to tags", | 
|  | 196 | stubbedBuildDefinitions: []string{"libgtest_main", "libgtest"}, | 
| Jingwen Chen | fbff97a | 2022-09-16 02:32:03 +0000 | [diff] [blame] | 197 | blueprint: ` | 
|  | 198 | cc_test { | 
|  | 199 | name: "mytest", | 
|  | 200 | host_supported: true, | 
|  | 201 | srcs: ["test.cpp"], | 
|  | 202 | test_options: { tags: ["no-remote"] }, | 
|  | 203 | } | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 204 | ` + simpleModule("cc_library_static", "libgtest_main") + | 
|  | 205 | simpleModule("cc_library_static", "libgtest"), | 
| Jingwen Chen | fbff97a | 2022-09-16 02:32:03 +0000 | [diff] [blame] | 206 | targets: []testBazelTarget{ | 
|  | 207 | {"cc_test", "mytest", AttrNameToString{ | 
|  | 208 | "tags":           `["no-remote"]`, | 
|  | 209 | "local_includes": `["."]`, | 
|  | 210 | "srcs":           `["test.cpp"]`, | 
| Spandan Das | 651203d | 2023-07-21 22:55:32 +0000 | [diff] [blame] | 211 | "deps": `[ | 
|  | 212 | ":libgtest_main", | 
|  | 213 | ":libgtest", | 
|  | 214 | ]`, | 
| yike | fdca7fe | 2023-08-17 01:03:37 +0000 | [diff] [blame] | 215 | "runs_on": `[ | 
|  | 216 | "host_without_device", | 
|  | 217 | "device", | 
|  | 218 | ]`, | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 219 | "features": `select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 220 | "//build/bazel_common_rules/platforms/os_arch:android_arm64": [ | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 221 | "memtag_heap", | 
|  | 222 | "diag_memtag_heap", | 
|  | 223 | ], | 
|  | 224 | "//conditions:default": [], | 
|  | 225 | })`, | 
| Jingwen Chen | fbff97a | 2022-09-16 02:32:03 +0000 | [diff] [blame] | 226 | }, | 
|  | 227 | }, | 
|  | 228 | }, | 
|  | 229 | }) | 
|  | 230 | } | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 231 |  | 
|  | 232 | func TestCcTest_TestConfig(t *testing.T) { | 
|  | 233 | runCcTestTestCase(t, ccTestBp2buildTestCase{ | 
|  | 234 | description: "cc test that sets a test_config", | 
|  | 235 | filesystem: map[string]string{ | 
|  | 236 | "test_config.xml": "", | 
|  | 237 | }, | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 238 | stubbedBuildDefinitions: []string{"libgtest_main", "libgtest"}, | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 239 | blueprint: ` | 
|  | 240 | cc_test { | 
|  | 241 | name: "mytest", | 
|  | 242 | srcs: ["test.cpp"], | 
|  | 243 | test_config: "test_config.xml", | 
|  | 244 | } | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 245 | ` + simpleModule("cc_library_static", "libgtest_main") + | 
|  | 246 | simpleModule("cc_library_static", "libgtest"), | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 247 | targets: []testBazelTarget{ | 
|  | 248 | {"cc_test", "mytest", AttrNameToString{ | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 249 | "local_includes":         `["."]`, | 
|  | 250 | "srcs":                   `["test.cpp"]`, | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 251 | "target_compatible_with": `["//build/bazel_common_rules/platforms/os:android"]`, | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 252 | "test_config":            `"test_config.xml"`, | 
| Spandan Das | 651203d | 2023-07-21 22:55:32 +0000 | [diff] [blame] | 253 | "deps": `[ | 
|  | 254 | ":libgtest_main", | 
|  | 255 | ":libgtest", | 
|  | 256 | ]`, | 
| yike | fdca7fe | 2023-08-17 01:03:37 +0000 | [diff] [blame] | 257 | "runs_on": `["device"]`, | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 258 | "features": `select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 259 | "//build/bazel_common_rules/platforms/os_arch:android_arm64": [ | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 260 | "memtag_heap", | 
|  | 261 | "diag_memtag_heap", | 
|  | 262 | ], | 
|  | 263 | "//conditions:default": [], | 
|  | 264 | })`, | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 265 | }, | 
|  | 266 | }, | 
|  | 267 | }, | 
|  | 268 | }) | 
|  | 269 | } | 
|  | 270 |  | 
|  | 271 | func TestCcTest_TestConfigAndroidTestXML(t *testing.T) { | 
|  | 272 | runCcTestTestCase(t, ccTestBp2buildTestCase{ | 
|  | 273 | description: "cc test that defaults to test config AndroidTest.xml", | 
|  | 274 | filesystem: map[string]string{ | 
| Yu Liu | d136a6a | 2023-08-21 21:23:04 +0000 | [diff] [blame] | 275 | "AndroidTest.xml":   "", | 
|  | 276 | "DynamicConfig.xml": "", | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 277 | }, | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 278 | stubbedBuildDefinitions: []string{"libgtest_main", "libgtest"}, | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 279 | blueprint: ` | 
|  | 280 | cc_test { | 
|  | 281 | name: "mytest", | 
|  | 282 | srcs: ["test.cpp"], | 
|  | 283 | } | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 284 | ` + simpleModule("cc_library_static", "libgtest_main") + | 
|  | 285 | simpleModule("cc_library_static", "libgtest"), | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 286 | targets: []testBazelTarget{ | 
|  | 287 | {"cc_test", "mytest", AttrNameToString{ | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 288 | "local_includes":         `["."]`, | 
|  | 289 | "srcs":                   `["test.cpp"]`, | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 290 | "target_compatible_with": `["//build/bazel_common_rules/platforms/os:android"]`, | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 291 | "test_config":            `"AndroidTest.xml"`, | 
| Yu Liu | d136a6a | 2023-08-21 21:23:04 +0000 | [diff] [blame] | 292 | "dynamic_config":         `"DynamicConfig.xml"`, | 
| Spandan Das | 651203d | 2023-07-21 22:55:32 +0000 | [diff] [blame] | 293 | "deps": `[ | 
|  | 294 | ":libgtest_main", | 
|  | 295 | ":libgtest", | 
|  | 296 | ]`, | 
| yike | fdca7fe | 2023-08-17 01:03:37 +0000 | [diff] [blame] | 297 | "runs_on": `["device"]`, | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 298 | "features": `select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 299 | "//build/bazel_common_rules/platforms/os_arch:android_arm64": [ | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 300 | "memtag_heap", | 
|  | 301 | "diag_memtag_heap", | 
|  | 302 | ], | 
|  | 303 | "//conditions:default": [], | 
|  | 304 | })`, | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 305 | }, | 
|  | 306 | }, | 
|  | 307 | }, | 
|  | 308 | }) | 
|  | 309 | } | 
|  | 310 |  | 
|  | 311 | func TestCcTest_TestConfigTemplateOptions(t *testing.T) { | 
|  | 312 | runCcTestTestCase(t, ccTestBp2buildTestCase{ | 
|  | 313 | description: "cc test that sets test config template attributes", | 
|  | 314 | filesystem: map[string]string{ | 
|  | 315 | "test_config_template.xml": "", | 
|  | 316 | }, | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 317 | stubbedBuildDefinitions: []string{"libgtest_isolated_main", "liblog"}, | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 318 | blueprint: ` | 
|  | 319 | cc_test { | 
|  | 320 | name: "mytest", | 
|  | 321 | srcs: ["test.cpp"], | 
|  | 322 | test_config_template: "test_config_template.xml", | 
|  | 323 | auto_gen_config: true, | 
| Spandan Das | f5a8655 | 2023-07-22 03:16:53 +0000 | [diff] [blame] | 324 | isolated: true, | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 325 | } | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 326 | ` + simpleModule("cc_library_static", "libgtest_isolated_main") + | 
|  | 327 | simpleModule("cc_library", "liblog"), | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 328 | targets: []testBazelTarget{ | 
|  | 329 | {"cc_test", "mytest", AttrNameToString{ | 
|  | 330 | "auto_generate_test_config": "True", | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 331 | "local_includes":            `["."]`, | 
|  | 332 | "srcs":                      `["test.cpp"]`, | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 333 | "target_compatible_with":    `["//build/bazel_common_rules/platforms/os:android"]`, | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 334 | "template_configs": `[ | 
|  | 335 | "'<target_preparer class=\"com.android.tradefed.targetprep.RootTargetPreparer\">\\n        <option name=\"force-root\" value=\"false\" />\\n    </target_preparer>'", | 
|  | 336 | "'<option name=\"not-shardable\" value=\"true\" />'", | 
|  | 337 | ]`, | 
|  | 338 | "template_install_base": `"/data/local/tmp"`, | 
|  | 339 | "template_test_config":  `"test_config_template.xml"`, | 
| Spandan Das | d1cd351 | 2023-07-22 02:19:42 +0000 | [diff] [blame] | 340 | "deps":                  `[":libgtest_isolated_main"]`, | 
|  | 341 | "dynamic_deps":          `[":liblog"]`, | 
| yike | fdca7fe | 2023-08-17 01:03:37 +0000 | [diff] [blame] | 342 | "runs_on":               `["device"]`, | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 343 | "features": `select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 344 | "//build/bazel_common_rules/platforms/os_arch:android_arm64": [ | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 345 | "memtag_heap", | 
|  | 346 | "diag_memtag_heap", | 
|  | 347 | ], | 
|  | 348 | "//conditions:default": [], | 
|  | 349 | })`, | 
| Kevin Dagostino | 32edd1a | 2022-12-04 11:16:42 +0000 | [diff] [blame] | 350 | }, | 
|  | 351 | }, | 
|  | 352 | }, | 
|  | 353 | }) | 
|  | 354 | } | 
| Spandan Das | 651203d | 2023-07-21 22:55:32 +0000 | [diff] [blame] | 355 |  | 
|  | 356 | func TestCcTest_WithExplicitGTestDepInAndroidBp(t *testing.T) { | 
|  | 357 | runCcTestTestCase(t, ccTestBp2buildTestCase{ | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 358 | description:             "cc test that lists libgtest in Android.bp should not have dups of libgtest in BUILD file", | 
|  | 359 | stubbedBuildDefinitions: []string{"libgtest_main", "libgtest"}, | 
| Spandan Das | 651203d | 2023-07-21 22:55:32 +0000 | [diff] [blame] | 360 | blueprint: ` | 
|  | 361 | cc_test { | 
|  | 362 | name: "mytest", | 
|  | 363 | srcs: ["test.cpp"], | 
|  | 364 | static_libs: ["libgtest"], | 
|  | 365 | } | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 366 | ` + simpleModule("cc_library_static", "libgtest_main") + | 
|  | 367 | simpleModule("cc_library_static", "libgtest"), | 
| Spandan Das | 651203d | 2023-07-21 22:55:32 +0000 | [diff] [blame] | 368 | targets: []testBazelTarget{ | 
|  | 369 | {"cc_test", "mytest", AttrNameToString{ | 
| Spandan Das | 651203d | 2023-07-21 22:55:32 +0000 | [diff] [blame] | 370 | "local_includes":         `["."]`, | 
|  | 371 | "srcs":                   `["test.cpp"]`, | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 372 | "target_compatible_with": `["//build/bazel_common_rules/platforms/os:android"]`, | 
| Spandan Das | 651203d | 2023-07-21 22:55:32 +0000 | [diff] [blame] | 373 | "deps": `[ | 
|  | 374 | ":libgtest", | 
|  | 375 | ":libgtest_main", | 
|  | 376 | ]`, | 
| yike | fdca7fe | 2023-08-17 01:03:37 +0000 | [diff] [blame] | 377 | "runs_on": `["device"]`, | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 378 | "features": `select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 379 | "//build/bazel_common_rules/platforms/os_arch:android_arm64": [ | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 380 | "memtag_heap", | 
|  | 381 | "diag_memtag_heap", | 
|  | 382 | ], | 
|  | 383 | "//conditions:default": [], | 
|  | 384 | })`, | 
| Spandan Das | 651203d | 2023-07-21 22:55:32 +0000 | [diff] [blame] | 385 | }, | 
|  | 386 | }, | 
|  | 387 | }, | 
|  | 388 | }) | 
|  | 389 |  | 
|  | 390 | } | 
| Spandan Das | d1cd351 | 2023-07-22 02:19:42 +0000 | [diff] [blame] | 391 |  | 
|  | 392 | func TestCcTest_WithIsolatedTurnedOn(t *testing.T) { | 
|  | 393 | runCcTestTestCase(t, ccTestBp2buildTestCase{ | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 394 | description:             "cc test that sets `isolated: true` should run with ligtest_isolated_main instead of libgtest_main", | 
|  | 395 | stubbedBuildDefinitions: []string{"libgtest_isolated_main", "liblog"}, | 
| Spandan Das | d1cd351 | 2023-07-22 02:19:42 +0000 | [diff] [blame] | 396 | blueprint: ` | 
|  | 397 | cc_test { | 
|  | 398 | name: "mytest", | 
|  | 399 | srcs: ["test.cpp"], | 
|  | 400 | isolated: true, | 
|  | 401 | } | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 402 | ` + simpleModule("cc_library_static", "libgtest_isolated_main") + | 
|  | 403 | simpleModule("cc_library", "liblog"), | 
| Spandan Das | d1cd351 | 2023-07-22 02:19:42 +0000 | [diff] [blame] | 404 | targets: []testBazelTarget{ | 
|  | 405 | {"cc_test", "mytest", AttrNameToString{ | 
| Spandan Das | d1cd351 | 2023-07-22 02:19:42 +0000 | [diff] [blame] | 406 | "local_includes":         `["."]`, | 
|  | 407 | "srcs":                   `["test.cpp"]`, | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 408 | "target_compatible_with": `["//build/bazel_common_rules/platforms/os:android"]`, | 
| Spandan Das | d1cd351 | 2023-07-22 02:19:42 +0000 | [diff] [blame] | 409 | "deps":                   `[":libgtest_isolated_main"]`, | 
|  | 410 | "dynamic_deps":           `[":liblog"]`, | 
| yike | fdca7fe | 2023-08-17 01:03:37 +0000 | [diff] [blame] | 411 | "runs_on":                `["device"]`, | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 412 | "features": `select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 413 | "//build/bazel_common_rules/platforms/os_arch:android_arm64": [ | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 414 | "memtag_heap", | 
|  | 415 | "diag_memtag_heap", | 
|  | 416 | ], | 
|  | 417 | "//conditions:default": [], | 
|  | 418 | })`, | 
| Spandan Das | d1cd351 | 2023-07-22 02:19:42 +0000 | [diff] [blame] | 419 | }, | 
|  | 420 | }, | 
|  | 421 | }, | 
|  | 422 | }) | 
|  | 423 |  | 
|  | 424 | } | 
| Spandan Das | e50fd11 | 2023-07-26 17:35:20 +0000 | [diff] [blame] | 425 |  | 
|  | 426 | func TestCcTest_GtestExplicitlySpecifiedInAndroidBp(t *testing.T) { | 
|  | 427 | runCcTestTestCase(t, ccTestBp2buildTestCase{ | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 428 | description:             "If `gtest` is explicit in Android.bp, it should be explicit in BUILD files as well", | 
|  | 429 | stubbedBuildDefinitions: []string{"libgtest_main", "libgtest"}, | 
| Spandan Das | e50fd11 | 2023-07-26 17:35:20 +0000 | [diff] [blame] | 430 | blueprint: ` | 
|  | 431 | cc_test { | 
|  | 432 | name: "mytest_with_gtest", | 
|  | 433 | gtest: true, | 
|  | 434 | } | 
|  | 435 | cc_test { | 
|  | 436 | name: "mytest_with_no_gtest", | 
|  | 437 | gtest: false, | 
|  | 438 | } | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 439 | ` + simpleModule("cc_library_static", "libgtest_main") + | 
|  | 440 | simpleModule("cc_library_static", "libgtest"), | 
| Spandan Das | e50fd11 | 2023-07-26 17:35:20 +0000 | [diff] [blame] | 441 | targets: []testBazelTarget{ | 
|  | 442 | {"cc_test", "mytest_with_gtest", AttrNameToString{ | 
|  | 443 | "local_includes": `["."]`, | 
|  | 444 | "deps": `[ | 
|  | 445 | ":libgtest_main", | 
|  | 446 | ":libgtest", | 
|  | 447 | ]`, | 
|  | 448 | "gtest":                  "True", | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 449 | "target_compatible_with": `["//build/bazel_common_rules/platforms/os:android"]`, | 
| yike | fdca7fe | 2023-08-17 01:03:37 +0000 | [diff] [blame] | 450 | "runs_on":                `["device"]`, | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 451 | "features": `select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 452 | "//build/bazel_common_rules/platforms/os_arch:android_arm64": [ | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 453 | "memtag_heap", | 
|  | 454 | "diag_memtag_heap", | 
|  | 455 | ], | 
|  | 456 | "//conditions:default": [], | 
|  | 457 | })`, | 
| Spandan Das | e50fd11 | 2023-07-26 17:35:20 +0000 | [diff] [blame] | 458 | }, | 
|  | 459 | }, | 
|  | 460 | {"cc_test", "mytest_with_no_gtest", AttrNameToString{ | 
|  | 461 | "local_includes":         `["."]`, | 
|  | 462 | "gtest":                  "False", | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 463 | "target_compatible_with": `["//build/bazel_common_rules/platforms/os:android"]`, | 
| yike | fdca7fe | 2023-08-17 01:03:37 +0000 | [diff] [blame] | 464 | "runs_on":                `["device"]`, | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 465 | "features": `select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 466 | "//build/bazel_common_rules/platforms/os_arch:android_arm64": [ | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 467 | "memtag_heap", | 
|  | 468 | "diag_memtag_heap", | 
|  | 469 | ], | 
|  | 470 | "//conditions:default": [], | 
|  | 471 | })`, | 
|  | 472 | }, | 
|  | 473 | }, | 
|  | 474 | }, | 
|  | 475 | }) | 
|  | 476 | } | 
|  | 477 |  | 
|  | 478 | func TestCcTest_DisableMemtagHeap(t *testing.T) { | 
|  | 479 | runCcTestTestCase(t, ccTestBp2buildTestCase{ | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 480 | description:             "cc test that disable memtag_heap", | 
|  | 481 | stubbedBuildDefinitions: []string{"libgtest_isolated_main", "liblog"}, | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 482 | blueprint: ` | 
|  | 483 | cc_test { | 
|  | 484 | name: "mytest", | 
|  | 485 | srcs: ["test.cpp"], | 
|  | 486 | isolated: true, | 
|  | 487 | sanitize: { | 
|  | 488 | cfi: true, | 
|  | 489 | memtag_heap: false, | 
|  | 490 | }, | 
|  | 491 | } | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 492 | ` + simpleModule("cc_library_static", "libgtest_isolated_main") + | 
|  | 493 | simpleModule("cc_library", "liblog"), | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 494 | targets: []testBazelTarget{ | 
|  | 495 | {"cc_test", "mytest", AttrNameToString{ | 
|  | 496 | "local_includes":         `["."]`, | 
|  | 497 | "srcs":                   `["test.cpp"]`, | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 498 | "target_compatible_with": `["//build/bazel_common_rules/platforms/os:android"]`, | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 499 | "deps":                   `[":libgtest_isolated_main"]`, | 
|  | 500 | "dynamic_deps":           `[":liblog"]`, | 
|  | 501 | "runs_on":                `["device"]`, | 
|  | 502 | "features": `["android_cfi"] + select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 503 | "//build/bazel_common_rules/platforms/os_arch:android_arm64": ["-memtag_heap"], | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 504 | "//conditions:default": [], | 
|  | 505 | })`, | 
|  | 506 | }, | 
|  | 507 | }, | 
|  | 508 | }, | 
|  | 509 | }) | 
|  | 510 | } | 
|  | 511 |  | 
|  | 512 | func TestCcTest_RespectArm64MemtagHeap(t *testing.T) { | 
|  | 513 | runCcTestTestCase(t, ccTestBp2buildTestCase{ | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 514 | description:             "cc test that disable memtag_heap", | 
|  | 515 | stubbedBuildDefinitions: []string{"libgtest_isolated_main", "liblog"}, | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 516 | blueprint: ` | 
|  | 517 | cc_test { | 
|  | 518 | name: "mytest", | 
|  | 519 | srcs: ["test.cpp"], | 
|  | 520 | isolated: true, | 
|  | 521 | target: { | 
|  | 522 | android_arm64: { | 
|  | 523 | sanitize: { | 
|  | 524 | memtag_heap: false, | 
|  | 525 | } | 
|  | 526 | } | 
|  | 527 | }, | 
|  | 528 | } | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 529 | ` + simpleModule("cc_library_static", "libgtest_isolated_main") + | 
|  | 530 | simpleModule("cc_library", "liblog"), | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 531 | targets: []testBazelTarget{ | 
|  | 532 | {"cc_test", "mytest", AttrNameToString{ | 
|  | 533 | "local_includes":         `["."]`, | 
|  | 534 | "srcs":                   `["test.cpp"]`, | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 535 | "target_compatible_with": `["//build/bazel_common_rules/platforms/os:android"]`, | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 536 | "deps":                   `[":libgtest_isolated_main"]`, | 
|  | 537 | "dynamic_deps":           `[":liblog"]`, | 
|  | 538 | "runs_on":                `["device"]`, | 
|  | 539 | "features": `select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 540 | "//build/bazel_common_rules/platforms/os_arch:android_arm64": ["-memtag_heap"], | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 541 | "//conditions:default": [], | 
|  | 542 | })`, | 
|  | 543 | }, | 
|  | 544 | }, | 
|  | 545 | }, | 
|  | 546 | }) | 
|  | 547 | } | 
|  | 548 |  | 
|  | 549 | func TestCcTest_IgnoreNoneArm64MemtagHeap(t *testing.T) { | 
|  | 550 | runCcTestTestCase(t, ccTestBp2buildTestCase{ | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 551 | description:             "cc test that disable memtag_heap", | 
|  | 552 | stubbedBuildDefinitions: []string{"libgtest_isolated_main", "liblog"}, | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 553 | blueprint: ` | 
|  | 554 | cc_test { | 
|  | 555 | name: "mytest", | 
|  | 556 | srcs: ["test.cpp"], | 
|  | 557 | isolated: true, | 
|  | 558 | arch: { | 
|  | 559 | x86: { | 
|  | 560 | sanitize: { | 
|  | 561 | memtag_heap: false, | 
|  | 562 | } | 
|  | 563 | } | 
|  | 564 | }, | 
|  | 565 | } | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 566 | ` + simpleModule("cc_library_static", "libgtest_isolated_main") + | 
|  | 567 | simpleModule("cc_library", "liblog"), | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 568 | targets: []testBazelTarget{ | 
|  | 569 | {"cc_test", "mytest", AttrNameToString{ | 
|  | 570 | "local_includes":         `["."]`, | 
|  | 571 | "srcs":                   `["test.cpp"]`, | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 572 | "target_compatible_with": `["//build/bazel_common_rules/platforms/os:android"]`, | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 573 | "deps":                   `[":libgtest_isolated_main"]`, | 
|  | 574 | "dynamic_deps":           `[":liblog"]`, | 
|  | 575 | "runs_on":                `["device"]`, | 
|  | 576 | "features": `select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 577 | "//build/bazel_common_rules/platforms/os_arch:android_arm64": [ | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 578 | "memtag_heap", | 
|  | 579 | "diag_memtag_heap", | 
|  | 580 | ], | 
|  | 581 | "//conditions:default": [], | 
|  | 582 | })`, | 
|  | 583 | }, | 
|  | 584 | }, | 
|  | 585 | }, | 
|  | 586 | }) | 
|  | 587 | } | 
|  | 588 |  | 
|  | 589 | func TestCcTest_Arm64MemtagHeapOverrideNoConfigOne(t *testing.T) { | 
|  | 590 | runCcTestTestCase(t, ccTestBp2buildTestCase{ | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 591 | description:             "cc test that disable memtag_heap", | 
|  | 592 | stubbedBuildDefinitions: []string{"libgtest_isolated_main", "liblog"}, | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 593 | blueprint: ` | 
|  | 594 | cc_test { | 
|  | 595 | name: "mytest", | 
|  | 596 | srcs: ["test.cpp"], | 
|  | 597 | isolated: true, | 
|  | 598 | sanitize: { | 
|  | 599 | memtag_heap: true, | 
|  | 600 | }, | 
|  | 601 | target: { | 
|  | 602 | android_arm64: { | 
|  | 603 | sanitize: { | 
|  | 604 | memtag_heap: false, | 
|  | 605 | diag: { | 
|  | 606 | memtag_heap: false, | 
|  | 607 | }, | 
|  | 608 | } | 
|  | 609 | } | 
|  | 610 | }, | 
|  | 611 | } | 
| Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 612 | ` + simpleModule("cc_library_static", "libgtest_isolated_main") + | 
|  | 613 | simpleModule("cc_library", "liblog"), | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 614 | targets: []testBazelTarget{ | 
|  | 615 | {"cc_test", "mytest", AttrNameToString{ | 
|  | 616 | "local_includes":         `["."]`, | 
|  | 617 | "srcs":                   `["test.cpp"]`, | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 618 | "target_compatible_with": `["//build/bazel_common_rules/platforms/os:android"]`, | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 619 | "deps":                   `[":libgtest_isolated_main"]`, | 
|  | 620 | "dynamic_deps":           `[":liblog"]`, | 
|  | 621 | "runs_on":                `["device"]`, | 
|  | 622 | "features": `select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 623 | "//build/bazel_common_rules/platforms/os_arch:android_arm64": [ | 
| Yu Liu | 7ece4aa | 2023-08-25 16:56:33 -0700 | [diff] [blame] | 624 | "-memtag_heap", | 
|  | 625 | "-diag_memtag_heap", | 
|  | 626 | ], | 
|  | 627 | "//conditions:default": [], | 
|  | 628 | })`, | 
| Spandan Das | e50fd11 | 2023-07-26 17:35:20 +0000 | [diff] [blame] | 629 | }, | 
|  | 630 | }, | 
|  | 631 | }, | 
|  | 632 | }) | 
|  | 633 | } |