Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Unified Diff: base/tools_sanity_unittest.cc

Issue 339893002: Make sure ThreadSanitizer v2 reports a data race in ToolsSanityTest.DataRace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the ifdefs Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/tools_sanity_unittest.cc
diff --git a/base/tools_sanity_unittest.cc b/base/tools_sanity_unittest.cc
index 7d4c96eb5f71c6cb080fa96971233b235724cbba..c03110e24b4965ea89ba117106ef7bf8d48ce9ca 100644
--- a/base/tools_sanity_unittest.cc
+++ b/base/tools_sanity_unittest.cc
@@ -287,16 +287,27 @@ void RunInParallel(PlatformThread::Delegate *d1, PlatformThread::Delegate *d2) {
PlatformThread::Join(b);
}
-} // namespace
-
-// A data race detector should report an error in this test.
-TEST(ToolsSanityTest, DataRace) {
+#if defined(THREAD_SANITIZER)
+void DataRace() {
bool *shared = new bool(false);
TOOLS_SANITY_TEST_CONCURRENT_THREAD thread1(shared), thread2(shared);
RunInParallel(&thread1, &thread2);
EXPECT_TRUE(*shared);
delete shared;
+ // We're in a death test - crash.
+ CHECK(0);
+}
+#endif
+
+} // namespace
+
+#if defined(THREAD_SANITIZER)
+// A data race detector should report an error in this test.
+TEST(ToolsSanityTest, DataRace) {
+ // The suppression regexp must match that in base/debug/tsan_suppressions.cc.
+ EXPECT_DEATH(DataRace(), "1 race:base/tools_sanity_unittest.cc");
}
+#endif
TEST(ToolsSanityTest, AnnotateBenignRace) {
bool shared = false;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698