diff --git a/ipc/glue/test/gtest/TestAsyncBlockers.cpp b/ipc/glue/test/gtest/TestAsyncBlockers.cpp index ad066f26c8b7..6f8d298621fe 100644 --- a/ipc/glue/test/gtest/TestAsyncBlockers.cpp +++ b/ipc/glue/test/gtest/TestAsyncBlockers.cpp @@ -7,11 +7,11 @@ #include "mozilla/SpinEventLoopUntil.h" #include "mozilla/ipc/AsyncBlockers.h" +#include "mozilla/gtest/MozHelpers.h" #include "nsCOMPtr.h" #include "nsITimer.h" #include "nsINamed.h" -#include "TestUtils.h" using namespace mozilla; using namespace mozilla::ipc; @@ -19,27 +19,19 @@ using namespace mozilla::ipc; #define PROCESS_EVENTS_UNTIL(_done) \ SpinEventLoopUntil("TestAsyncBlockers"_ns, [&]() { return _done; }); -#if defined(XP_UNIX) -// This global variable is defined in toolkit/xre/nsSigHandlers.cpp. -extern unsigned int _gdb_sleep_duration; -#endif // defined(XP_UNIX) - class TestAsyncBlockers : public ::testing::Test { protected: void SetUp() override { -#if defined(XP_UNIX) - mOldSleepDuration = ::_gdb_sleep_duration; - ::_gdb_sleep_duration = 0; -#endif // defined(XP_UNIX) + SAVE_GDB_SLEEP(mOldSleepDuration); return; } -#if defined(XP_UNIX) - void TearDown() final { ::_gdb_sleep_duration = mOldSleepDuration; } + void TearDown() final { RESTORE_GDB_SLEEP(mOldSleepDuration); } private: +#if defined(HAS_GDB_SLEEP_DURATION) unsigned int mOldSleepDuration = 0; -#endif // defined(XP_UNIX) +#endif // defined(HAS_GDB_SLEEP_DURATION) }; class Blocker {}; @@ -158,7 +150,7 @@ TEST_F(TestAsyncBlockers, Register_WaitUntilClear_0s) { #if defined(MOZ_DIAGNOSTIC_ASSERT_ENABLED) && !defined(ANDROID) && \ !(defined(XP_DARWIN) && !defined(MOZ_DEBUG)) static void DeregisterEmpty_Test() { - DisableCrashReporter(); + mozilla::gtest::DisableCrashReporter(); AsyncBlockers blockers; Blocker* blocker = new Blocker(); diff --git a/ipc/glue/test/gtest/TestUtilityProcess.cpp b/ipc/glue/test/gtest/TestUtilityProcess.cpp index f0c091c21e90..c5d19c992f7e 100644 --- a/ipc/glue/test/gtest/TestUtilityProcess.cpp +++ b/ipc/glue/test/gtest/TestUtilityProcess.cpp @@ -14,7 +14,7 @@ #endif // defined(MOZ_WIDGET_ANDROID) || defined(XP_MACOSX) #if defined(XP_WIN) -# include "TestUtils.h" +# include "mozilla/gtest/MozHelpers.h" # include "mozilla/ipc/UtilityProcessImpl.h" #endif // defined(XP_WIN) @@ -141,7 +141,7 @@ TEST_F(UtilityProcess, DestroyProcess) { #if defined(XP_WIN) static void LoadLibraryCrash_Test() { - DisableCrashReporter(); + mozilla::gtest::DisableCrashReporter(); // Just a uuidgen name to have something random UtilityProcessImpl::LoadLibraryOrCrash( L"2b49036e-6ba3-400c-a297-38fa1f6c5255.dll"); diff --git a/ipc/glue/test/gtest/TestUtils.h b/ipc/glue/test/gtest/TestUtils.h deleted file mode 100644 index 612fdb4a5043..000000000000 --- a/ipc/glue/test/gtest/TestUtils.h +++ /dev/null @@ -1,24 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef GTEST_UTILITY_TEST_UTILS_H -#define GTEST_UTILITY_TEST_UTILS_H - -#include "nsServiceManagerUtils.h" -#include "nsICrashReporter.h" - -#if (defined(MOZ_DIAGNOSTIC_ASSERT_ENABLED) || defined(XP_WIN)) && \ - !defined(ANDROID) && !(defined(XP_DARWIN) && !defined(MOZ_DEBUG)) -static void DisableCrashReporter() { - nsCOMPtr crashreporter = - do_GetService("@mozilla.org/toolkit/crash-reporter;1"); - if (crashreporter) { - crashreporter->SetEnabled(false); - } -} -#endif // defined(MOZ_DIAGNOSTIC_ASSERT_ENABLED) && !defined(ANDROID) && - // !(defined(XP_DARWIN) && !defined(MOZ_DEBUG)) - -#endif // GTEST_UTILITY_TEST_UTILS_H diff --git a/memory/gtest/TestJemalloc.cpp b/memory/gtest/TestJemalloc.cpp index d23b29cc2d42..7f3b3f9cf332 100644 --- a/memory/gtest/TestJemalloc.cpp +++ b/memory/gtest/TestJemalloc.cpp @@ -8,10 +8,9 @@ #include "mozilla/UniquePtr.h" #include "mozilla/Unused.h" #include "mozilla/Vector.h" +#include "mozilla/gtest/MozHelpers.h" #include "mozmemory.h" #include "nsCOMPtr.h" -#include "nsICrashReporter.h" -#include "nsServiceManagerUtils.h" #include "Utils.h" #include "gtest/gtest.h" @@ -20,35 +19,6 @@ # include "replace_malloc_bridge.h" #endif -#if defined(DEBUG) && !defined(XP_WIN) && !defined(ANDROID) -# define HAS_GDB_SLEEP_DURATION 1 -extern unsigned int _gdb_sleep_duration; -#endif - -// Death tests are too slow on OSX because of the system crash reporter. -#ifndef XP_DARWIN -static void DisableCrashReporter() { - nsCOMPtr crashreporter = - do_GetService("@mozilla.org/toolkit/crash-reporter;1"); - if (crashreporter) { - crashreporter->SetEnabled(false); - } -} - -// Wrap ASSERT_DEATH_IF_SUPPORTED to disable the crash reporter -// when entering the subprocess, so that the expected crashes don't -// create a minidump that the gtest harness will interpret as an error. -# define ASSERT_DEATH_WRAP(a, b) \ - ASSERT_DEATH_IF_SUPPORTED( \ - { \ - DisableCrashReporter(); \ - a; \ - }, \ - b) -#else -# define ASSERT_DEATH_WRAP(a, b) -#endif - using namespace mozilla; class AutoDisablePHCOnCurrentThread { @@ -295,11 +265,8 @@ TEST(Jemalloc, Arenas) free(ptr); moz_dispose_arena(arena); -#ifdef HAS_GDB_SLEEP_DURATION // Avoid death tests adding some unnecessary (long) delays. - unsigned int old_gdb_sleep_duration = _gdb_sleep_duration; - _gdb_sleep_duration = 0; -#endif + SAVE_GDB_SLEEP_LOCAL(); // Can't use an arena after it's disposed. // ASSERT_DEATH_WRAP(moz_arena_malloc(arena, 80), ""); @@ -333,9 +300,7 @@ TEST(Jemalloc, Arenas) moz_dispose_arena(arena2); moz_dispose_arena(arena); -#ifdef HAS_GDB_SLEEP_DURATION - _gdb_sleep_duration = old_gdb_sleep_duration; -#endif + RESTORE_GDB_SLEEP_LOCAL(); } // Check that a buffer aPtr is entirely filled with a given character from @@ -464,11 +429,8 @@ TEST(Jemalloc, JunkPoison) jemalloc_stats_t stats; jemalloc_stats(&stats); -# ifdef HAS_GDB_SLEEP_DURATION // Avoid death tests adding some unnecessary (long) delays. - unsigned int old_gdb_sleep_duration = _gdb_sleep_duration; - _gdb_sleep_duration = 0; -# endif + SAVE_GDB_SLEEP_LOCAL(); // Create buffers in a separate arena, for faster comparisons with // bulk_compare. @@ -654,9 +616,7 @@ TEST(Jemalloc, JunkPoison) moz_arena_free(buf_arena, fill_buf); moz_dispose_arena(buf_arena); -# ifdef HAS_GDB_SLEEP_DURATION - _gdb_sleep_duration = old_gdb_sleep_duration; -# endif + RESTORE_GDB_SLEEP_LOCAL(); } #endif // !defined(XP_WIN) || !defined(MOZ_CODE_COVERAGE) @@ -669,11 +629,8 @@ TEST(Jemalloc, TrailingGuard) jemalloc_stats_t stats; jemalloc_stats(&stats); -#ifdef HAS_GDB_SLEEP_DURATION // Avoid death tests adding some unnecessary (long) delays. - unsigned int old_gdb_sleep_duration = _gdb_sleep_duration; - _gdb_sleep_duration = 0; -#endif + SAVE_GDB_SLEEP_LOCAL(); arena_id_t arena = moz_create_arena(); ASSERT_TRUE(arena != 0); @@ -705,9 +662,7 @@ TEST(Jemalloc, TrailingGuard) moz_dispose_arena(arena); -#ifdef HAS_GDB_SLEEP_DURATION - _gdb_sleep_duration = old_gdb_sleep_duration; -#endif + RESTORE_GDB_SLEEP_LOCAL(); } TEST(Jemalloc, LeadingGuard) @@ -719,11 +674,8 @@ TEST(Jemalloc, LeadingGuard) jemalloc_stats_t stats; jemalloc_stats(&stats); -#ifdef HAS_GDB_SLEEP_DURATION // Avoid death tests adding some unnecessary (long) delays. - unsigned int old_gdb_sleep_duration = _gdb_sleep_duration; - _gdb_sleep_duration = 0; -#endif + SAVE_GDB_SLEEP_LOCAL(); arena_id_t arena = moz_create_arena(); ASSERT_TRUE(arena != 0); @@ -755,9 +707,7 @@ TEST(Jemalloc, LeadingGuard) moz_arena_free(arena, ptr); moz_dispose_arena(arena); -#ifdef HAS_GDB_SLEEP_DURATION - _gdb_sleep_duration = old_gdb_sleep_duration; -#endif + RESTORE_GDB_SLEEP_LOCAL(); } TEST(Jemalloc, DisposeArena) @@ -765,11 +715,8 @@ TEST(Jemalloc, DisposeArena) jemalloc_stats_t stats; jemalloc_stats(&stats); -#ifdef HAS_GDB_SLEEP_DURATION // Avoid death tests adding some unnecessary (long) delays. - unsigned int old_gdb_sleep_duration = _gdb_sleep_duration; - _gdb_sleep_duration = 0; -#endif + SAVE_GDB_SLEEP_LOCAL(); arena_id_t arena = moz_create_arena(); void* ptr = moz_arena_malloc(arena, 42); @@ -805,7 +752,5 @@ TEST(Jemalloc, DisposeArena) // Using the arena after it's been disposed of is MOZ_CRASH-worthy. ASSERT_DEATH_WRAP(moz_arena_malloc(arena, 42), ""); -#ifdef HAS_GDB_SLEEP_DURATION - _gdb_sleep_duration = old_gdb_sleep_duration; -#endif + RESTORE_GDB_SLEEP_LOCAL(); } diff --git a/storage/test/gtest/test_deadlock_detector.cpp b/storage/test/gtest/test_deadlock_detector.cpp index 26152ad4740e..4e542d2f7ea6 100644 --- a/storage/test/gtest/test_deadlock_detector.cpp +++ b/storage/test/gtest/test_deadlock_detector.cpp @@ -14,6 +14,9 @@ #include "mozilla/ReentrantMonitor.h" #include "SQLiteMutex.h" +// We need this one so _gdb_sleep_duration is also in "storage" namespace +#include "mozilla/gtest/MozHelpers.h" + #include "gtest/gtest.h" using namespace mozilla; @@ -40,11 +43,6 @@ class TestMutex : public mozilla::storage::SQLiteMutex { sqlite3_mutex* mInner; }; -// This global variable is defined in toolkit/xre/nsSigHandlers.cpp. -// It's declared in xpcom/tests/gtest/TestDeadlockDetector.cpp, but we #include -// that within the |storage| namespace, so we need to declare it again here. -extern unsigned int _gdb_sleep_duration; - // These are the two macros that differentiate this file from the XPCOM one. #define MUTEX TestMutex #define TESTNAME(name) storage_##name diff --git a/testing/gtest/mozilla/MozHelpers.cpp b/testing/gtest/mozilla/MozHelpers.cpp new file mode 100644 index 000000000000..468c6f0ab56c --- /dev/null +++ b/testing/gtest/mozilla/MozHelpers.cpp @@ -0,0 +1,13 @@ +#include "MozHelpers.h" + +namespace mozilla::gtest { + +void DisableCrashReporter() { + nsCOMPtr crashreporter = + do_GetService("@mozilla.org/toolkit/crash-reporter;1"); + if (crashreporter) { + crashreporter->SetEnabled(false); + } +} + +} // namespace mozilla::gtest diff --git a/testing/gtest/mozilla/MozHelpers.h b/testing/gtest/mozilla/MozHelpers.h new file mode 100644 index 000000000000..d55f1dac76a6 --- /dev/null +++ b/testing/gtest/mozilla/MozHelpers.h @@ -0,0 +1,68 @@ +#ifndef TESTING_GTEST_MOZILLA_HELPERS_H_ +#define TESTING_GTEST_MOZILLA_HELPERS_H_ + +#include "gtest/gtest.h" + +#include "nsCOMPtr.h" +#include "nsServiceManagerUtils.h" +#include "nsICrashReporter.h" + +#if defined(DEBUG) && !defined(XP_WIN) && !defined(ANDROID) +# define HAS_GDB_SLEEP_DURATION 1 +extern unsigned int _gdb_sleep_duration; +#endif + +namespace mozilla::gtest { + +#if defined(HAS_GDB_SLEEP_DURATION) +# define ZERO_GDB_SLEEP() _gdb_sleep_duration = 0; + +# define SAVE_GDB_SLEEP(v) \ + v = _gdb_sleep_duration; \ + ZERO_GDB_SLEEP(); +# define RESTORE_GDB_SLEEP(v) _gdb_sleep_duration = v; + +// Some use needs to be in the global namespace +# define SAVE_GDB_SLEEP_GLOBAL(v) \ + v = ::_gdb_sleep_duration; \ + ZERO_GDB_SLEEP(); +# define RESTORE_GDB_SLEEP_GLOBAL(v) ::_gdb_sleep_duration = v; + +# define SAVE_GDB_SLEEP_LOCAL() \ + unsigned int _old_gdb_sleep_duration; \ + SAVE_GDB_SLEEP(_old_gdb_sleep_duration); +# define RESTORE_GDB_SLEEP_LOCAL() RESTORE_GDB_SLEEP(_old_gdb_sleep_duration); + +#else // defined(HAS_GDB_SLEEP_DURATION) + +# define ZERO_GDB_SLEEP() ; + +# define SAVE_GDB_SLEEP(v) +# define SAVE_GDB_SLEEP_GLOBAL(v) +# define SAVE_GDB_SLEEP_LOCAL() +# define RESTORE_GDB_SLEEP(v) +# define RESTORE_GDB_SLEEP_GLOBAL(v) +# define RESTORE_GDB_SLEEP_LOCAL() +#endif // defined(HAS_GDB_SLEEP_DURATION) + +// Death tests are too slow on OSX because of the system crash reporter. +#if !defined(XP_DARWIN) +// Wrap ASSERT_DEATH_IF_SUPPORTED to disable the crash reporter +// when entering the subprocess, so that the expected crashes don't +// create a minidump that the gtest harness will interpret as an error. +# define ASSERT_DEATH_WRAP(a, b) \ + ASSERT_DEATH_IF_SUPPORTED( \ + { \ + mozilla::gtest::DisableCrashReporter(); \ + a; \ + }, \ + b) +#else +# define ASSERT_DEATH_WRAP(a, b) +#endif + +void DisableCrashReporter(); + +} // namespace mozilla::gtest + +#endif // TESTING_GTEST_MOZILLA_HELPERS_H_ diff --git a/testing/gtest/mozilla/moz.build b/testing/gtest/mozilla/moz.build index 919d5ee622f6..570d3775339d 100644 --- a/testing/gtest/mozilla/moz.build +++ b/testing/gtest/mozilla/moz.build @@ -19,12 +19,14 @@ if CONFIG["ENABLE_TESTS"]: EXPORTS.mozilla.gtest += [ "MozAssertions.h", + "MozHelpers.h", ] SOURCES += [ "GTestRunner.cpp", "MozAssertions.cpp", "MozGTestBench.cpp", + "MozHelpers.cpp", "SanityTest.cpp", ] diff --git a/xpcom/tests/gtest/TestDeadlockDetector.cpp b/xpcom/tests/gtest/TestDeadlockDetector.cpp index c6e74ce0c1d9..c02ba13da280 100644 --- a/xpcom/tests/gtest/TestDeadlockDetector.cpp +++ b/xpcom/tests/gtest/TestDeadlockDetector.cpp @@ -9,8 +9,6 @@ #include "prthread.h" #include "nsCOMPtr.h" -#include "nsICrashReporter.h" -#include "nsServiceManagerUtils.h" #include "nsTArray.h" #include "mozilla/CondVar.h" @@ -18,6 +16,8 @@ #include "mozilla/ReentrantMonitor.h" #include "mozilla/Mutex.h" +#include "mozilla/gtest/MozHelpers.h" + #include "gtest/gtest.h" using namespace mozilla; @@ -38,40 +38,28 @@ static PRThread* spawn(void (*run)(void*), void* arg) { PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0); } -// This global variable is defined in toolkit/xre/nsSigHandlers.cpp. -extern unsigned int _gdb_sleep_duration; - /** * Simple test fixture that makes sure the gdb sleep setup in the * ah crap handler is bypassed during the death tests. */ class TESTNAME(DeadlockDetectorTest) : public ::testing::Test { protected: - void SetUp() final { - mOldSleepDuration = ::_gdb_sleep_duration; - ::_gdb_sleep_duration = 0; - } + void SetUp() final { SAVE_GDB_SLEEP_GLOBAL(mOldSleepDuration); } - void TearDown() final { ::_gdb_sleep_duration = mOldSleepDuration; } + void TearDown() final { RESTORE_GDB_SLEEP_GLOBAL(mOldSleepDuration); } private: +#if defined(HAS_GDB_SLEEP_DURATION) unsigned int mOldSleepDuration; +#endif // defined(HAS_GDB_SLEEP_DURATION) }; -static void DisableCrashReporter() { - nsCOMPtr crashreporter = - do_GetService("@mozilla.org/toolkit/crash-reporter;1"); - if (crashreporter) { - crashreporter->SetEnabled(false); - } -} - //----------------------------------------------------------------------------- // Single-threaded sanity tests // Stupidest possible deadlock. static int Sanity_Child() MOZ_NO_THREAD_SAFETY_ANALYSIS { - DisableCrashReporter(); + mozilla::gtest::DisableCrashReporter(); MUTEX m1("dd.sanity.m1"); m1.Lock(); @@ -92,7 +80,7 @@ TEST_F(TESTNAME(DeadlockDetectorTest), TESTNAME(SanityDeathTest)) { // Slightly less stupid deadlock. static int Sanity2_Child() MOZ_NO_THREAD_SAFETY_ANALYSIS { - DisableCrashReporter(); + mozilla::gtest::DisableCrashReporter(); MUTEX m1("dd.sanity2.m1"); MUTEX m2("dd.sanity2.m2"); @@ -119,7 +107,7 @@ TEST_F(TESTNAME(DeadlockDetectorTest), TESTNAME(Sanity2DeathTest)) { int Sanity3_Child() MOZ_NO_THREAD_SAFETY_ANALYSIS { - DisableCrashReporter(); + mozilla::gtest::DisableCrashReporter(); MUTEX m1("dd.sanity3.m1"); MUTEX m2("dd.sanity3.m2"); @@ -156,7 +144,7 @@ TEST_F(TESTNAME(DeadlockDetectorTest), TESTNAME(Sanity3DeathTest)) #endif static int Sanity4_Child() MOZ_NO_THREAD_SAFETY_ANALYSIS { - DisableCrashReporter(); + mozilla::gtest::DisableCrashReporter(); mozilla::ReentrantMonitor m1 MOZ_UNANNOTATED("dd.sanity4.m1"); MUTEX m2("dd.sanity4.m2"); @@ -179,7 +167,7 @@ TEST_F(TESTNAME(DeadlockDetectorTest), TESTNAME(Sanity4DeathTest)) { } static int Sanity5_Child() MOZ_NO_THREAD_SAFETY_ANALYSIS { - DisableCrashReporter(); + mozilla::gtest::DisableCrashReporter(); mozilla::RecursiveMutex m1 MOZ_UNANNOTATED("dd.sanity4.m1"); MUTEX m2("dd.sanity4.m2"); @@ -248,7 +236,7 @@ TwoThreads_thread(void* arg) MOZ_NO_THREAD_SAFETY_ANALYSIS int TwoThreads_Child() MOZ_NO_THREAD_SAFETY_ANALYSIS { - DisableCrashReporter(); + mozilla::gtest::DisableCrashReporter(); nsTArray locks = { new MUTEX("dd.twothreads.m1"), diff --git a/xpcom/tests/gtest/TestPLDHash.cpp b/xpcom/tests/gtest/TestPLDHash.cpp index db7b74e03961..d302e72595cc 100644 --- a/xpcom/tests/gtest/TestPLDHash.cpp +++ b/xpcom/tests/gtest/TestPLDHash.cpp @@ -5,10 +5,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "PLDHashTable.h" -#include "nsCOMPtr.h" -#include "nsICrashReporter.h" -#include "nsServiceManagerUtils.h" #include "gtest/gtest.h" +#include "mozilla/gtest/MozHelpers.h" // This test mostly focuses on edge cases. But more coverage of normal // operations wouldn't be a bad thing. @@ -17,9 +15,6 @@ # include # include # include - -// This global variable is defined in toolkit/xre/nsSigHandlers.cpp. -extern unsigned int _gdb_sleep_duration; #endif // We can test that certain operations cause expected aborts by forking @@ -34,8 +29,7 @@ static void TestCrashyOperation(const char* label, void (*aCrashyOperation)()) { #if defined(XP_UNIX) && defined(DEBUG) && !defined(MOZ_ASAN) // We're about to trigger a crash. When it happens don't pause to allow GDB // to be attached. - unsigned int old_gdb_sleep_duration = _gdb_sleep_duration; - _gdb_sleep_duration = 0; + SAVE_GDB_SLEEP_LOCAL(); int pid = fork(); ASSERT_NE(pid, -1); @@ -44,11 +38,7 @@ static void TestCrashyOperation(const char* label, void (*aCrashyOperation)()) { // 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. - nsCOMPtr crashreporter = - do_GetService("@mozilla.org/toolkit/crash-reporter;1"); - if (crashreporter) { - crashreporter->SetEnabled(false); - } + mozilla::gtest::DisableCrashReporter(); // Child: perform the crashy operation. FILE* stderr_dup = fdopen(dup(fileno(stderr)), "w"); @@ -86,7 +76,7 @@ static void TestCrashyOperation(const char* label, void (*aCrashyOperation)()) { } } - _gdb_sleep_duration = old_gdb_sleep_duration; + RESTORE_GDB_SLEEP_LOCAL(); #endif } diff --git a/xpcom/tests/gtest/TestSTLWrappers.cpp b/xpcom/tests/gtest/TestSTLWrappers.cpp index 313379809f22..c2762247a9db 100644 --- a/xpcom/tests/gtest/TestSTLWrappers.cpp +++ b/xpcom/tests/gtest/TestSTLWrappers.cpp @@ -10,10 +10,6 @@ # error "failed to wrap " #endif -#include "nsCOMPtr.h" -#include "nsICrashReporter.h" -#include "nsServiceManagerUtils.h" - // gcc errors out if we |try ... catch| with -fno-exceptions, but we // can still test on windows #ifdef _MSC_VER @@ -29,20 +25,12 @@ #include "gtest/gtest.h" -#if defined(XP_UNIX) -extern unsigned int _gdb_sleep_duration; -#endif +#include "mozilla/gtest/MozHelpers.h" void ShouldAbort() { -#if defined(XP_UNIX) - _gdb_sleep_duration = 0; -#endif + ZERO_GDB_SLEEP(); - nsCOMPtr crashreporter = - do_GetService("@mozilla.org/toolkit/crash-reporter;1"); - if (crashreporter) { - crashreporter->SetEnabled(false); - } + mozilla::gtest::DisableCrashReporter(); std::vector v;