From 21b48a72aa50dde84149267f6b7402522b846b24 Mon Sep 17 00:00:00 2001 From: Mark Mentovai Date: Fri, 26 Apr 2019 14:00:01 -0400 Subject: Linux breakpad_unittests: fix ThreadSanitizer problems Some tests were failing because they had expectations about the number of threads in a process, but TSan, and in some cases, ASan, introduce their own threads. Where a sanitizer affects this, the expectations are now used as minimum thread counts, not exact thread counts. See https://www.brooklinen.com/blogs/brookliving/best-thread-count-for-sheets. These problems were detected by ThreadSanitizer at https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8915151099544583616/+/steps/breakpad_unittests__with_patch_/0/stdout Bug: chromium:949098 Change-Id: Ie40f1766bea27e9bcb112bf9e0b8b846fb343012 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1585948 Reviewed-by: Robert Sesek --- src/common/linux/elf_core_dump_unittest.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/common/linux') diff --git a/src/common/linux/elf_core_dump_unittest.cc b/src/common/linux/elf_core_dump_unittest.cc index 9b41dcee..2399c12f 100644 --- a/src/common/linux/elf_core_dump_unittest.cc +++ b/src/common/linux/elf_core_dump_unittest.cc @@ -244,9 +244,18 @@ TEST(ElfCoreDumpTest, ValidCoreFile) { note = note.GetNextNote(); } - EXPECT_TRUE(expected_thread_ids == actual_thread_ids); +#if defined(THREAD_SANITIZER) + for (std::set::const_iterator expected = expected_thread_ids.begin(); + expected != expected_thread_ids.end(); + ++expected) { + EXPECT_NE(actual_thread_ids.find(*expected), actual_thread_ids.end()); + } + EXPECT_GE(num_nt_prstatus, kNumOfThreads); +#else + EXPECT_EQ(actual_thread_ids, expected_thread_ids); + EXPECT_EQ(num_nt_prstatus, kNumOfThreads); +#endif EXPECT_EQ(1U, num_nt_prpsinfo); - EXPECT_EQ(kNumOfThreads, num_nt_prstatus); #if defined(__i386__) || defined(__x86_64__) EXPECT_EQ(num_pr_fpvalid, num_nt_fpregset); #endif -- cgit v1.2.1