OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This file contains intentional memory errors, some of which may lead to | 5 // This file contains intentional memory errors, some of which may lead to |
6 // crashes if the test is ran without special memory testing tools. We use these | 6 // crashes if the test is ran without special memory testing tools. We use these |
7 // errors to verify the sanity of the tools. | 7 // errors to verify the sanity of the tools. |
8 | 8 |
9 #include "base/atomicops.h" | 9 #include "base/atomicops.h" |
10 #include "base/debug/asan_invalid_access.h" | 10 #include "base/debug/asan_invalid_access.h" |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 } | 332 } |
333 | 333 |
334 TEST(ToolsSanityTest, AtomicsAreIgnored) { | 334 TEST(ToolsSanityTest, AtomicsAreIgnored) { |
335 base::subtle::Atomic32 shared = 0; | 335 base::subtle::Atomic32 shared = 0; |
336 ReleaseStoreThread thread1(&shared); | 336 ReleaseStoreThread thread1(&shared); |
337 AcquireLoadThread thread2(&shared); | 337 AcquireLoadThread thread2(&shared); |
338 RunInParallel(&thread1, &thread2); | 338 RunInParallel(&thread1, &thread2); |
339 EXPECT_EQ(kMagicValue, shared); | 339 EXPECT_EQ(kMagicValue, shared); |
340 } | 340 } |
341 | 341 |
| 342 #if defined(CFI_ENFORCEMENT) |
| 343 TEST(ToolsSanityTest, BadCast) { |
| 344 class A { |
| 345 virtual void f() {} |
| 346 }; |
| 347 |
| 348 class B { |
| 349 virtual void f() {} |
| 350 }; |
| 351 |
| 352 A a; |
| 353 EXPECT_DEATH((void)(B*)&a, "ILL_ILLOPN"); |
| 354 } |
| 355 #endif |
| 356 |
342 } // namespace base | 357 } // namespace base |
OLD | NEW |