aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorvladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2010-05-05 13:09:35 +0000
committervladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2010-05-05 13:09:35 +0000
commitc476707e82f8db4974912594fbf419326973cb2a (patch)
tree344548e468d47fa5788cfe7f01e9f65b815b23f6 /src
parent520f623c5940686b0827eff8b608c4b68aa557d6 (diff)
downloadgoogletest-c476707e82f8db4974912594fbf419326973cb2a.tar.gz
googletest-c476707e82f8db4974912594fbf419326973cb2a.tar.bz2
googletest-c476707e82f8db4974912594fbf419326973cb2a.zip
Improves support for building Google Test as Windows DLL.
Diffstat (limited to 'src')
-rw-r--r--src/gtest-death-test.cc9
-rw-r--r--src/gtest-internal-inl.h2
-rw-r--r--src/gtest_main.cc2
3 files changed, 10 insertions, 3 deletions
diff --git a/src/gtest-death-test.cc b/src/gtest-death-test.cc
index 3b73b01d..66bf1898 100644
--- a/src/gtest-death-test.cc
+++ b/src/gtest-death-test.cc
@@ -418,7 +418,14 @@ void DeathTestImpl::Abort(AbortReason reason) {
const char status_ch =
reason == TEST_DID_NOT_DIE ? kDeathTestLived : kDeathTestReturned;
GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Write(write_fd(), &status_ch, 1));
- GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Close(write_fd()));
+ // We are leaking the descriptor here because on some platforms (i.e.,
+ // when built as Windows DLL), destructors of global objects will still
+ // run after calling _exit(). On such systems, write_fd_ will be
+ // indirectly closed from the destructor of UnitTestImpl, causing double
+ // close if it is also closed here. On debug configurations, double close
+ // may assert. As there are no in-process buffers to flush here, we are
+ // relying on the OS to close the descriptor after the process terminates
+ // when the destructors are not run.
_exit(1); // Exits w/o any normal exit hooks (we were supposed to crash)
}
diff --git a/src/gtest-internal-inl.h b/src/gtest-internal-inl.h
index 855b2155..a3cda754 100644
--- a/src/gtest-internal-inl.h
+++ b/src/gtest-internal-inl.h
@@ -977,7 +977,7 @@ GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv);
// Returns the message describing the last system error, regardless of the
// platform.
-String GetLastErrnoDescription();
+GTEST_API_ String GetLastErrnoDescription();
#if GTEST_OS_WINDOWS
// Provides leak-safe Windows kernel handle ownership.
diff --git a/src/gtest_main.cc b/src/gtest_main.cc
index d20c02fd..6d4d22d2 100644
--- a/src/gtest_main.cc
+++ b/src/gtest_main.cc
@@ -31,7 +31,7 @@
#include <gtest/gtest.h>
-int main(int argc, char **argv) {
+GTEST_API_ int main(int argc, char **argv) {
std::cout << "Running main() from gtest_main.cc\n";
testing::InitGoogleTest(&argc, argv);