summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-30 17:27:55 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-30 17:27:55 +0000
commite940d48dd33a1ed32184c4c7342fcf80eee46789 (patch)
tree7be4a7bae1fc3b9175be8d6b9f224dbc80de6306 /chrome
parent195e8db95593f4b96dae03e18033d3575029c5c1 (diff)
downloadchromium_src-e940d48dd33a1ed32184c4c7342fcf80eee46789.zip
chromium_src-e940d48dd33a1ed32184c4c7342fcf80eee46789.tar.gz
chromium_src-e940d48dd33a1ed32184c4c7342fcf80eee46789.tar.bz2
Moving the work done in WinMain to another method called explictly,
as WinMain hold the loader lock and may be causing dead-locks. BUG=None TEST=Run the browser tests. R=darin Review URL: http://codereview.chromium.org/242067 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27624 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/test/test_launcher/in_proc_test_runner.cc16
-rw-r--r--chrome/test/test_launcher/run_all_unittests.cc39
2 files changed, 34 insertions, 21 deletions
diff --git a/chrome/test/test_launcher/in_proc_test_runner.cc b/chrome/test/test_launcher/in_proc_test_runner.cc
index 379d4e5..fb818e1 100644
--- a/chrome/test/test_launcher/in_proc_test_runner.cc
+++ b/chrome/test/test_launcher/in_proc_test_runner.cc
@@ -31,12 +31,17 @@ class InProcTestRunner : public tests::TestRunner {
explicit InProcTestRunner(const std::wstring& lib_name)
: lib_name_(lib_name),
dynamic_lib_(NULL),
- run_test_proc_(NULL) {
+ run_test_proc_(NULL),
+ uninitialize_proc_(NULL) {
}
~InProcTestRunner() {
if (!dynamic_lib_)
return;
+ if (uninitialize_proc_ && (uninitialize_proc_)()) {
+ LOG(ERROR) << "Uninitialization of " <<
+ base::GetNativeLibraryName(lib_name_) << " failed.";
+ }
base::UnloadNativeLibrary(dynamic_lib_);
LOG(INFO) << "Unloaded " << base::GetNativeLibraryName(lib_name_);
}
@@ -62,6 +67,10 @@ class InProcTestRunner : public tests::TestRunner {
return false;
}
+ uninitialize_proc_ = reinterpret_cast<UninitializeProc>(
+ base::GetFunctionPointerFromNativeLibrary(dynamic_lib_,
+ "UninitializeTest"));
+
return true;
}
@@ -85,11 +94,16 @@ class InProcTestRunner : public tests::TestRunner {
private:
typedef int (CDECL *RunTestProc)(int, char**);
+ typedef int (CDECL *UninitializeProc)();
std::wstring lib_name_;
base::NativeLibrary dynamic_lib_;
RunTestProc run_test_proc_;
+ // An optional UnitializeTest method called before the library containing the
+ // test is unloaded.
+ UninitializeProc uninitialize_proc_;
+
DISALLOW_COPY_AND_ASSIGN(InProcTestRunner);
};
diff --git a/chrome/test/test_launcher/run_all_unittests.cc b/chrome/test/test_launcher/run_all_unittests.cc
index e4eb431..c56b505 100644
--- a/chrome/test/test_launcher/run_all_unittests.cc
+++ b/chrome/test/test_launcher/run_all_unittests.cc
@@ -17,30 +17,29 @@ extern "C" {
DLLEXPORT int CDECL RunTests(int argc, char **argv) {
return ChromeTestSuite(argc, argv).Run();
}
-}
#if defined(OS_WIN)
-BOOL WINAPI DllMain(HINSTANCE dll_module, DWORD reason, LPVOID reserved) {
- if (reason == DLL_PROCESS_DETACH) {
- // The CRichEditCtrl (used by the omnibox) calls OleInitialize, but somehow
- // does not always calls OleUninitialize, causing an unbalanced Ole
- // initialization that triggers a DCHECK in ScopedOleInitializer the next
- // time we run a test.
- // This behavior has been seen on some Vista boxes, but not all of them.
- // There is a flag to prevent Ole initialization in CRichEditCtrl (see
- // http://support.microsoft.com/kb/238989), but it is set to 0 in recent
- // Windows versions.
- // This is a dirty hack to make sure the OleCount is back to 0 in all cases,
- // so the next test will have Ole unitialized, as expected.
+DLLEXPORT int CDECL UninitializeTest() {
+ // The CRichEditCtrl (used by the omnibox) calls OleInitialize, but somehow
+ // does not always calls OleUninitialize, causing an unbalanced Ole
+ // initialization that triggers a DCHECK in ScopedOleInitializer the next
+ // time we run a test.
+ // This behavior has been seen on some Vista boxes, but not all of them.
+ // There is a flag to prevent Ole initialization in CRichEditCtrl (see
+ // http://support.microsoft.com/kb/238989), but it is set to 0 in recent
+ // Windows versions.
+ // This is a dirty hack to make sure the OleCount is back to 0 in all cases,
+ // so the next test will have Ole unitialized, as expected.
- if (OleInitialize(NULL) == S_FALSE) {
- // We were already initialized, balance that extra-initialization.
- OleUninitialize();
- }
- // Balance the OleInitialize from the above test.
+ if (OleInitialize(NULL) == S_FALSE) {
+ // We were already initialized, balance that extra-initialization.
OleUninitialize();
}
- return TRUE;
-}
+ // Balance the OleInitialize from the above test.
+ OleUninitialize();
+ return 0; // 0 means uninitialization OK.
+}
#endif
+
+}