diff options
author | mmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-14 13:50:50 +0000 |
---|---|---|
committer | mmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-14 13:50:50 +0000 |
commit | b7b8f66bba2c9f8253096a92376dfd047b7d0822 (patch) | |
tree | 2aff43551468591fd99e008f5a15342768430859 | |
parent | e9f17ab968e051627b02b6e02305417d5aee6f37 (diff) | |
download | chromium_src-b7b8f66bba2c9f8253096a92376dfd047b7d0822.zip chromium_src-b7b8f66bba2c9f8253096a92376dfd047b7d0822.tar.gz chromium_src-b7b8f66bba2c9f8253096a92376dfd047b7d0822.tar.bz2 |
Fix the flaky atexit test by preventing it from running the global atexit callbacks.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@869 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/at_exit_unittest.cc | 11 | ||||
-rw-r--r-- | base/run_all_unittests.cc | 4 |
2 files changed, 13 insertions, 2 deletions
diff --git a/base/at_exit_unittest.cc b/base/at_exit_unittest.cc index 692ce66..564aabc 100644 --- a/base/at_exit_unittest.cc +++ b/base/at_exit_unittest.cc @@ -33,6 +33,13 @@ namespace { +// Don't test the global AtExitManager, because asking it to process its +// AtExit callbacks can ruin the global state that other tests may depend on. +class ShadowingAtExitManager : public base::AtExitManager { + public: + ShadowingAtExitManager() : AtExitManager(true) {} +}; + int g_test_counter_1 = 0; int g_test_counter_2 = 0; @@ -56,6 +63,8 @@ void ExpectCounter1IsZero() { } // namespace TEST(AtExitTest, Basic) { + ShadowingAtExitManager shadowing_at_exit_manager; + ZeroTestCounters(); base::AtExitManager::RegisterCallback(&IncrementTestCounter1); base::AtExitManager::RegisterCallback(&IncrementTestCounter2); @@ -69,6 +78,8 @@ TEST(AtExitTest, Basic) { } TEST(AtExitTest, LIFOOrder) { + ShadowingAtExitManager shadowing_at_exit_manager; + ZeroTestCounters(); base::AtExitManager::RegisterCallback(&IncrementTestCounter1); base::AtExitManager::RegisterCallback(&ExpectCounter1IsZero); diff --git a/base/run_all_unittests.cc b/base/run_all_unittests.cc index fae6cc6..732e700 100644 --- a/base/run_all_unittests.cc +++ b/base/run_all_unittests.cc @@ -31,8 +31,8 @@ #include "base/test_suite.h" int main(int argc, char** argv) { - // Setup an AtExitManager so Singleton objects will be destructed. - base::AtExitManager at_exit_manager; + // Set up an AtExitManager so Singleton objects will be destroyed. + base::AtExitManager at_exit_manager; CommandLine::SetArgcArgv(argc, argv); |