Bug 1237447 - Disable the crashreporter when crashing intentionally in TestPLDHash. r=njn
authorChris Manchester <cmanchester@mozilla.com>
Thu, 07 Jan 2016 12:27:10 -0800
changeset 279060 39220ff4899b5614e2da063687efd6c8147a0e97
parent 279059 c2b1901fba11e5dc36ea070f9179d7676a85221d
child 279061 9d0643d45a74538f6b703d665fa03917d1605bbb
push id29867
push usercbook@mozilla.com
push dateFri, 08 Jan 2016 11:00:43 +0000
treeherdermozilla-central@1424cdfc075d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1237447
milestone46.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1237447 - Disable the crashreporter when crashing intentionally in TestPLDHash. r=njn
xpcom/tests/gtest/TestPLDHash.cpp
--- a/xpcom/tests/gtest/TestPLDHash.cpp
+++ b/xpcom/tests/gtest/TestPLDHash.cpp
@@ -14,16 +14,20 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 
 // This global variable is defined in toolkit/xre/nsSigHandlers.cpp.
 extern unsigned int _gdb_sleep_duration;
 #endif
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsICrashReporter.h"
+#endif
+
 // We can test that certain operations cause expected aborts by forking
 // and then checking that the child aborted in the expected way (i.e. via
 // MOZ_CRASH). We skip this for the following configurations.
 // - On Windows, because it doesn't have fork().
 // - On non-DEBUG builds, because the crashes cause the crash reporter to pop
 //   up when running this test locally, which is surprising and annoying.
 // - On ASAN builds, because ASAN alters the way a MOZ_CRASHing process
 //   terminates, which makes it harder to test if the right thing has occurred.
@@ -35,16 +39,25 @@ TestCrashyOperation(void (*aCrashyOperat
   // to be attached.
   unsigned int old_gdb_sleep_duration = _gdb_sleep_duration;
   _gdb_sleep_duration = 0;
 
   int pid = fork();
   ASSERT_NE(pid, -1);
 
   if (pid == 0) {
+    // Disable the crashreporter -- writing a crash dump in the child will
+    // prevent the parent from writing a subsequent dump. Crashes here are
+    // expected, so we don't want their stacks to show up in the log anyway.
+#ifdef MOZ_CRASHREPORTER
+    nsCOMPtr<nsICrashReporter> crashreporter =
+      do_GetService("@mozilla.org/toolkit/crash-reporter;1");
+    crashreporter->SetEnabled(false);
+#endif
+
     // Child: perform the crashy operation.
     aCrashyOperation();
     fprintf(stderr, "TestCrashyOperation: didn't crash?!\n");
     ASSERT_TRUE(false);   // shouldn't reach here
   }
 
   // Parent: check that child crashed as expected.
   int status;