Colin Cross | af98f58 | 2021-05-12 17:27:32 -0700 | [diff] [blame] | 1 | // Copyright 2021 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 ( |
Liz Kammer | bb8d84f | 2021-06-21 12:53:03 -0400 | [diff] [blame^] | 18 | "fmt" |
| 19 | "strings" |
Colin Cross | af98f58 | 2021-05-12 17:27:32 -0700 | [diff] [blame] | 20 | "testing" |
| 21 | |
| 22 | "android/soong/android" |
| 23 | ) |
| 24 | |
| 25 | var prepareForAsanTest = android.FixtureAddFile("asan/Android.bp", []byte(` |
| 26 | cc_library_shared { |
| 27 | name: "libclang_rt.asan-aarch64-android", |
| 28 | } |
| 29 | |
| 30 | cc_library_shared { |
| 31 | name: "libclang_rt.asan-arm-android", |
| 32 | } |
| 33 | `)) |
| 34 | |
| 35 | func TestAsan(t *testing.T) { |
| 36 | bp := ` |
| 37 | cc_binary { |
| 38 | name: "bin_with_asan", |
| 39 | host_supported: true, |
| 40 | shared_libs: [ |
| 41 | "libshared", |
| 42 | "libasan", |
| 43 | ], |
| 44 | static_libs: [ |
| 45 | "libstatic", |
| 46 | "libnoasan", |
| 47 | ], |
| 48 | sanitize: { |
| 49 | address: true, |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | cc_binary { |
| 54 | name: "bin_no_asan", |
| 55 | host_supported: true, |
| 56 | shared_libs: [ |
| 57 | "libshared", |
| 58 | "libasan", |
| 59 | ], |
| 60 | static_libs: [ |
| 61 | "libstatic", |
| 62 | "libnoasan", |
| 63 | ], |
| 64 | } |
| 65 | |
| 66 | cc_library_shared { |
| 67 | name: "libshared", |
| 68 | host_supported: true, |
| 69 | shared_libs: ["libtransitive"], |
| 70 | } |
| 71 | |
| 72 | cc_library_shared { |
| 73 | name: "libasan", |
| 74 | host_supported: true, |
| 75 | shared_libs: ["libtransitive"], |
| 76 | sanitize: { |
| 77 | address: true, |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | cc_library_shared { |
| 82 | name: "libtransitive", |
| 83 | host_supported: true, |
| 84 | } |
| 85 | |
| 86 | cc_library_static { |
| 87 | name: "libstatic", |
| 88 | host_supported: true, |
| 89 | } |
| 90 | |
| 91 | cc_library_static { |
| 92 | name: "libnoasan", |
| 93 | host_supported: true, |
| 94 | sanitize: { |
| 95 | address: false, |
| 96 | } |
| 97 | } |
| 98 | ` |
| 99 | |
| 100 | result := android.GroupFixturePreparers( |
| 101 | prepareForCcTest, |
| 102 | prepareForAsanTest, |
| 103 | ).RunTestWithBp(t, bp) |
| 104 | |
| 105 | check := func(t *testing.T, result *android.TestResult, variant string) { |
| 106 | asanVariant := variant + "_asan" |
| 107 | sharedVariant := variant + "_shared" |
| 108 | sharedAsanVariant := sharedVariant + "_asan" |
| 109 | staticVariant := variant + "_static" |
| 110 | staticAsanVariant := staticVariant + "_asan" |
| 111 | |
| 112 | // The binaries, one with asan and one without |
| 113 | binWithAsan := result.ModuleForTests("bin_with_asan", asanVariant) |
| 114 | binNoAsan := result.ModuleForTests("bin_no_asan", variant) |
| 115 | |
| 116 | // Shared libraries that don't request asan |
| 117 | libShared := result.ModuleForTests("libshared", sharedVariant) |
| 118 | libTransitive := result.ModuleForTests("libtransitive", sharedVariant) |
| 119 | |
| 120 | // Shared library that requests asan |
| 121 | libAsan := result.ModuleForTests("libasan", sharedAsanVariant) |
| 122 | |
| 123 | // Static library that uses an asan variant for bin_with_asan and a non-asan variant |
| 124 | // for bin_no_asan. |
| 125 | libStaticAsanVariant := result.ModuleForTests("libstatic", staticAsanVariant) |
| 126 | libStaticNoAsanVariant := result.ModuleForTests("libstatic", staticVariant) |
| 127 | |
| 128 | // Static library that never uses asan. |
| 129 | libNoAsan := result.ModuleForTests("libnoasan", staticVariant) |
| 130 | |
| 131 | // expectSharedLinkDep verifies that the from module links against the to module as a |
| 132 | // shared library. |
| 133 | expectSharedLinkDep := func(from, to android.TestingModule) { |
| 134 | t.Helper() |
| 135 | fromLink := from.Description("link") |
| 136 | toLink := to.Description("strip") |
| 137 | |
| 138 | if g, w := fromLink.OrderOnly.Strings(), toLink.Output.String(); !android.InList(w, g) { |
| 139 | t.Errorf("%s should link against %s, expected %q, got %q", |
| 140 | from.Module(), to.Module(), w, g) |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | // expectStaticLinkDep verifies that the from module links against the to module as a |
| 145 | // static library. |
| 146 | expectStaticLinkDep := func(from, to android.TestingModule) { |
| 147 | t.Helper() |
| 148 | fromLink := from.Description("link") |
| 149 | toLink := to.Description("static link") |
| 150 | |
| 151 | if g, w := fromLink.Implicits.Strings(), toLink.Output.String(); !android.InList(w, g) { |
| 152 | t.Errorf("%s should link against %s, expected %q, got %q", |
| 153 | from.Module(), to.Module(), w, g) |
| 154 | } |
| 155 | |
| 156 | } |
| 157 | |
| 158 | // expectInstallDep verifies that the install rule of the from module depends on the |
| 159 | // install rule of the to module. |
| 160 | expectInstallDep := func(from, to android.TestingModule) { |
| 161 | t.Helper() |
| 162 | fromInstalled := from.Description("install") |
| 163 | toInstalled := to.Description("install") |
| 164 | |
| 165 | // combine implicits and order-only dependencies, host uses implicit but device uses |
| 166 | // order-only. |
| 167 | got := append(fromInstalled.Implicits.Strings(), fromInstalled.OrderOnly.Strings()...) |
| 168 | want := toInstalled.Output.String() |
| 169 | if !android.InList(want, got) { |
| 170 | t.Errorf("%s installation should depend on %s, expected %q, got %q", |
| 171 | from.Module(), to.Module(), want, got) |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | expectSharedLinkDep(binWithAsan, libShared) |
| 176 | expectSharedLinkDep(binWithAsan, libAsan) |
| 177 | expectSharedLinkDep(libShared, libTransitive) |
| 178 | expectSharedLinkDep(libAsan, libTransitive) |
| 179 | |
| 180 | expectStaticLinkDep(binWithAsan, libStaticAsanVariant) |
| 181 | expectStaticLinkDep(binWithAsan, libNoAsan) |
| 182 | |
| 183 | expectInstallDep(binWithAsan, libShared) |
| 184 | expectInstallDep(binWithAsan, libAsan) |
| 185 | expectInstallDep(binWithAsan, libTransitive) |
| 186 | expectInstallDep(libShared, libTransitive) |
| 187 | expectInstallDep(libAsan, libTransitive) |
| 188 | |
| 189 | expectSharedLinkDep(binNoAsan, libShared) |
| 190 | expectSharedLinkDep(binNoAsan, libAsan) |
| 191 | expectSharedLinkDep(libShared, libTransitive) |
| 192 | expectSharedLinkDep(libAsan, libTransitive) |
| 193 | |
| 194 | expectStaticLinkDep(binNoAsan, libStaticNoAsanVariant) |
| 195 | expectStaticLinkDep(binNoAsan, libNoAsan) |
| 196 | |
| 197 | expectInstallDep(binNoAsan, libShared) |
| 198 | expectInstallDep(binNoAsan, libAsan) |
| 199 | expectInstallDep(binNoAsan, libTransitive) |
| 200 | expectInstallDep(libShared, libTransitive) |
| 201 | expectInstallDep(libAsan, libTransitive) |
| 202 | } |
| 203 | |
| 204 | t.Run("host", func(t *testing.T) { check(t, result, result.Config.BuildOSTarget.String()) }) |
| 205 | t.Run("device", func(t *testing.T) { check(t, result, "android_arm64_armv8-a") }) |
| 206 | } |
Liz Kammer | bb8d84f | 2021-06-21 12:53:03 -0400 | [diff] [blame^] | 207 | |
| 208 | type MemtagNoteType int |
| 209 | |
| 210 | const ( |
| 211 | None MemtagNoteType = iota + 1 |
| 212 | Sync |
| 213 | Async |
| 214 | ) |
| 215 | |
| 216 | func (t MemtagNoteType) str() string { |
| 217 | switch t { |
| 218 | case None: |
| 219 | return "none" |
| 220 | case Sync: |
| 221 | return "sync" |
| 222 | case Async: |
| 223 | return "async" |
| 224 | default: |
| 225 | panic("invalid note type") |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | func checkHasMemtagNote(t *testing.T, m android.TestingModule, expected MemtagNoteType) { |
| 230 | note_async := "note_memtag_heap_async" |
| 231 | note_sync := "note_memtag_heap_sync" |
| 232 | |
| 233 | found := None |
| 234 | implicits := m.Rule("ld").Implicits |
| 235 | for _, lib := range implicits { |
| 236 | if strings.Contains(lib.Rel(), note_async) { |
| 237 | found = Async |
| 238 | break |
| 239 | } else if strings.Contains(lib.Rel(), note_sync) { |
| 240 | found = Sync |
| 241 | break |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | if found != expected { |
| 246 | t.Errorf("Wrong Memtag note in target %q: found %q, expected %q", m.Module().(*Module).Name(), found.str(), expected.str()) |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | var prepareForTestWithMemtagHeap = android.GroupFixturePreparers( |
| 251 | android.FixtureModifyMockFS(func(fs android.MockFS) { |
| 252 | templateBp := ` |
| 253 | cc_test { |
| 254 | name: "%[1]s_test", |
| 255 | gtest: false, |
| 256 | } |
| 257 | |
| 258 | cc_test { |
| 259 | name: "%[1]s_test_false", |
| 260 | gtest: false, |
| 261 | sanitize: { memtag_heap: false }, |
| 262 | } |
| 263 | |
| 264 | cc_test { |
| 265 | name: "%[1]s_test_true", |
| 266 | gtest: false, |
| 267 | sanitize: { memtag_heap: true }, |
| 268 | } |
| 269 | |
| 270 | cc_test { |
| 271 | name: "%[1]s_test_true_nodiag", |
| 272 | gtest: false, |
| 273 | sanitize: { memtag_heap: true, diag: { memtag_heap: false } }, |
| 274 | } |
| 275 | |
| 276 | cc_test { |
| 277 | name: "%[1]s_test_true_diag", |
| 278 | gtest: false, |
| 279 | sanitize: { memtag_heap: true, diag: { memtag_heap: true } }, |
| 280 | } |
| 281 | |
| 282 | cc_binary { |
| 283 | name: "%[1]s_binary", |
| 284 | } |
| 285 | |
| 286 | cc_binary { |
| 287 | name: "%[1]s_binary_false", |
| 288 | sanitize: { memtag_heap: false }, |
| 289 | } |
| 290 | |
| 291 | cc_binary { |
| 292 | name: "%[1]s_binary_true", |
| 293 | sanitize: { memtag_heap: true }, |
| 294 | } |
| 295 | |
| 296 | cc_binary { |
| 297 | name: "%[1]s_binary_true_nodiag", |
| 298 | sanitize: { memtag_heap: true, diag: { memtag_heap: false } }, |
| 299 | } |
| 300 | |
| 301 | cc_binary { |
| 302 | name: "%[1]s_binary_true_diag", |
| 303 | sanitize: { memtag_heap: true, diag: { memtag_heap: true } }, |
| 304 | } |
| 305 | ` |
| 306 | subdirDefaultBp := fmt.Sprintf(templateBp, "default") |
| 307 | subdirExcludeBp := fmt.Sprintf(templateBp, "exclude") |
| 308 | subdirSyncBp := fmt.Sprintf(templateBp, "sync") |
| 309 | subdirAsyncBp := fmt.Sprintf(templateBp, "async") |
| 310 | |
| 311 | fs.Merge(android.MockFS{ |
| 312 | "subdir_default/Android.bp": []byte(subdirDefaultBp), |
| 313 | "subdir_exclude/Android.bp": []byte(subdirExcludeBp), |
| 314 | "subdir_sync/Android.bp": []byte(subdirSyncBp), |
| 315 | "subdir_async/Android.bp": []byte(subdirAsyncBp), |
| 316 | }) |
| 317 | }), |
| 318 | android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { |
| 319 | variables.MemtagHeapExcludePaths = []string{"subdir_exclude"} |
| 320 | // "subdir_exclude" is covered by both include and exclude paths. Exclude wins. |
| 321 | variables.MemtagHeapSyncIncludePaths = []string{"subdir_sync", "subdir_exclude"} |
| 322 | variables.MemtagHeapAsyncIncludePaths = []string{"subdir_async", "subdir_exclude"} |
| 323 | }), |
| 324 | ) |
| 325 | |
| 326 | func TestSanitizeMemtagHeap(t *testing.T) { |
| 327 | variant := "android_arm64_armv8-a" |
| 328 | |
| 329 | result := android.GroupFixturePreparers( |
| 330 | prepareForCcTest, |
| 331 | prepareForTestWithMemtagHeap, |
| 332 | ).RunTest(t) |
| 333 | ctx := result.TestContext |
| 334 | |
| 335 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test", variant), Sync) |
| 336 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_false", variant), None) |
| 337 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true", variant), Async) |
| 338 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_nodiag", variant), Async) |
| 339 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_diag", variant), Sync) |
| 340 | |
| 341 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary", variant), None) |
| 342 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_false", variant), None) |
| 343 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true", variant), Async) |
| 344 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_nodiag", variant), Async) |
| 345 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_diag", variant), Sync) |
| 346 | |
| 347 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test", variant), Sync) |
| 348 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_false", variant), None) |
| 349 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true", variant), Async) |
| 350 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_nodiag", variant), Async) |
| 351 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_diag", variant), Sync) |
| 352 | |
| 353 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary", variant), None) |
| 354 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_false", variant), None) |
| 355 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true", variant), Async) |
| 356 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_nodiag", variant), Async) |
| 357 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_diag", variant), Sync) |
| 358 | |
| 359 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test", variant), Sync) |
| 360 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_false", variant), None) |
| 361 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true", variant), Async) |
| 362 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_nodiag", variant), Async) |
| 363 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_diag", variant), Sync) |
| 364 | |
| 365 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary", variant), Async) |
| 366 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_false", variant), None) |
| 367 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true", variant), Async) |
| 368 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_nodiag", variant), Async) |
| 369 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_diag", variant), Sync) |
| 370 | |
| 371 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test", variant), Sync) |
| 372 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_false", variant), None) |
| 373 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true", variant), Sync) |
| 374 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_nodiag", variant), Async) |
| 375 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_diag", variant), Sync) |
| 376 | |
| 377 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary", variant), Sync) |
| 378 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_false", variant), None) |
| 379 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true", variant), Sync) |
| 380 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_nodiag", variant), Async) |
| 381 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_diag", variant), Sync) |
| 382 | } |
| 383 | |
| 384 | func TestSanitizeMemtagHeapWithSanitizeDevice(t *testing.T) { |
| 385 | variant := "android_arm64_armv8-a" |
| 386 | |
| 387 | result := android.GroupFixturePreparers( |
| 388 | prepareForCcTest, |
| 389 | prepareForTestWithMemtagHeap, |
| 390 | android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { |
| 391 | variables.SanitizeDevice = []string{"memtag_heap"} |
| 392 | }), |
| 393 | ).RunTest(t) |
| 394 | ctx := result.TestContext |
| 395 | |
| 396 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test", variant), Sync) |
| 397 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_false", variant), None) |
| 398 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true", variant), Async) |
| 399 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_nodiag", variant), Async) |
| 400 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_diag", variant), Sync) |
| 401 | |
| 402 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary", variant), Async) |
| 403 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_false", variant), None) |
| 404 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true", variant), Async) |
| 405 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_nodiag", variant), Async) |
| 406 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_diag", variant), Sync) |
| 407 | |
| 408 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test", variant), Sync) |
| 409 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_false", variant), None) |
| 410 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true", variant), Async) |
| 411 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_nodiag", variant), Async) |
| 412 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_diag", variant), Sync) |
| 413 | |
| 414 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary", variant), None) |
| 415 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_false", variant), None) |
| 416 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true", variant), Async) |
| 417 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_nodiag", variant), Async) |
| 418 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_diag", variant), Sync) |
| 419 | |
| 420 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test", variant), Sync) |
| 421 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_false", variant), None) |
| 422 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true", variant), Async) |
| 423 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_nodiag", variant), Async) |
| 424 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_diag", variant), Sync) |
| 425 | |
| 426 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary", variant), Async) |
| 427 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_false", variant), None) |
| 428 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true", variant), Async) |
| 429 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_nodiag", variant), Async) |
| 430 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_diag", variant), Sync) |
| 431 | |
| 432 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test", variant), Sync) |
| 433 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_false", variant), None) |
| 434 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true", variant), Sync) |
| 435 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_nodiag", variant), Async) |
| 436 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_diag", variant), Sync) |
| 437 | |
| 438 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary", variant), Sync) |
| 439 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_false", variant), None) |
| 440 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true", variant), Sync) |
| 441 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_nodiag", variant), Async) |
| 442 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_diag", variant), Sync) |
| 443 | } |
| 444 | |
| 445 | func TestSanitizeMemtagHeapWithSanitizeDeviceDiag(t *testing.T) { |
| 446 | variant := "android_arm64_armv8-a" |
| 447 | |
| 448 | result := android.GroupFixturePreparers( |
| 449 | prepareForCcTest, |
| 450 | prepareForTestWithMemtagHeap, |
| 451 | android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { |
| 452 | variables.SanitizeDevice = []string{"memtag_heap"} |
| 453 | variables.SanitizeDeviceDiag = []string{"memtag_heap"} |
| 454 | }), |
| 455 | ).RunTest(t) |
| 456 | ctx := result.TestContext |
| 457 | |
| 458 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test", variant), Sync) |
| 459 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_false", variant), None) |
| 460 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true", variant), Sync) |
| 461 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_nodiag", variant), Async) |
| 462 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_diag", variant), Sync) |
| 463 | |
| 464 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary", variant), Sync) |
| 465 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_false", variant), None) |
| 466 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true", variant), Sync) |
| 467 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_nodiag", variant), Async) |
| 468 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_diag", variant), Sync) |
| 469 | |
| 470 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test", variant), Sync) |
| 471 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_false", variant), None) |
| 472 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true", variant), Sync) |
| 473 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_nodiag", variant), Async) |
| 474 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_diag", variant), Sync) |
| 475 | |
| 476 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary", variant), None) |
| 477 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_false", variant), None) |
| 478 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true", variant), Sync) |
| 479 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_nodiag", variant), Async) |
| 480 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_diag", variant), Sync) |
| 481 | |
| 482 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test", variant), Sync) |
| 483 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_false", variant), None) |
| 484 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true", variant), Sync) |
| 485 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_nodiag", variant), Async) |
| 486 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_diag", variant), Sync) |
| 487 | |
| 488 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary", variant), Sync) |
| 489 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_false", variant), None) |
| 490 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true", variant), Sync) |
| 491 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_nodiag", variant), Async) |
| 492 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_diag", variant), Sync) |
| 493 | |
| 494 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test", variant), Sync) |
| 495 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_false", variant), None) |
| 496 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true", variant), Sync) |
| 497 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_nodiag", variant), Async) |
| 498 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_diag", variant), Sync) |
| 499 | |
| 500 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary", variant), Sync) |
| 501 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_false", variant), None) |
| 502 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true", variant), Sync) |
| 503 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_nodiag", variant), Async) |
| 504 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_diag", variant), Sync) |
| 505 | } |