summaryrefslogtreecommitdiff
path: root/src/gtest-port.cc
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-09-24 21:15:59 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-09-24 21:15:59 +0000
commitfff033497b70e96a5dcadb6ba9570c12b5921d74 (patch)
treeceb0f9819c41f511d74cf72066ec48620dea8caa /src/gtest-port.cc
parent9c54fe88bc2b5d03bb9594b0c8f5ad1e0b905996 (diff)
downloadgtest-fff033497b70e96a5dcadb6ba9570c12b5921d74.tar.gz
gtest-fff033497b70e96a5dcadb6ba9570c12b5921d74.tar.bz2
gtest-fff033497b70e96a5dcadb6ba9570c12b5921d74.tar.xz
Publishes the even listener API (by Vlad Losev); adds OS-indicating macros to simplify gtest code (by Zhanyong Wan).
git-svn-id: http://googletest.googlecode.com/svn/trunk@320 861a406c-534a-0410-8894-cb66d6ee9925
Diffstat (limited to 'src/gtest-port.cc')
-rw-r--r--src/gtest-port.cc28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/gtest-port.cc b/src/gtest-port.cc
index ba9a9a2..de169e2 100644
--- a/src/gtest-port.cc
+++ b/src/gtest-port.cc
@@ -35,14 +35,14 @@
#include <stdlib.h>
#include <stdio.h>
-#if GTEST_OS_WINDOWS
-#ifndef _WIN32_WCE
+#if GTEST_OS_WINDOWS_MOBILE
+#include <windows.h> // For TerminateProcess()
+#elif GTEST_OS_WINDOWS
#include <io.h>
#include <sys/stat.h>
-#endif // _WIN32_WCE
#else
#include <unistd.h>
-#endif // GTEST_OS_WINDOWS
+#endif // GTEST_OS_WINDOWS_MOBILE
#if GTEST_OS_MAC
#include <mach/mach_init.h>
@@ -50,10 +50,6 @@
#include <mach/vm_map.h>
#endif // GTEST_OS_MAC
-#ifdef _WIN32_WCE
-#include <windows.h> // For TerminateProcess()
-#endif // _WIN32_WCE
-
#include <gtest/gtest-spi.h>
#include <gtest/gtest-message.h>
#include <gtest/internal/gtest-string.h>
@@ -449,7 +445,7 @@ class CapturedStderr {
public:
// The ctor redirects stderr to a temporary file.
CapturedStderr() {
-#ifdef _WIN32_WCE
+#if GTEST_OS_WINDOWS_MOBILE
// Not supported on Windows CE.
posix::Abort();
#else
@@ -474,24 +470,24 @@ class CapturedStderr {
fflush(NULL);
dup2(captured_fd, kStdErrFileno);
close(captured_fd);
-#endif // _WIN32_WCE
+#endif // GTEST_OS_WINDOWS_MOBILE
}
~CapturedStderr() {
-#ifndef _WIN32_WCE
+#if !GTEST_OS_WINDOWS_MOBILE
remove(filename_.c_str());
-#endif // _WIN32_WCE
+#endif // !GTEST_OS_WINDOWS_MOBILE
}
// Stops redirecting stderr.
void StopCapture() {
-#ifndef _WIN32_WCE
+#if !GTEST_OS_WINDOWS_MOBILE
// Restores the original stream.
fflush(NULL);
dup2(uncaptured_fd_, kStdErrFileno);
close(uncaptured_fd_);
uncaptured_fd_ = -1;
-#endif // !_WIN32_WCE
+#endif // !GTEST_OS_WINDOWS_MOBILE
}
// Returns the name of the temporary file holding the stderr output.
@@ -573,14 +569,14 @@ const ::std::vector<String>& GetArgvs() { return g_argvs; }
#endif // GTEST_HAS_DEATH_TEST
-#ifdef _WIN32_WCE
+#if GTEST_OS_WINDOWS_MOBILE
namespace posix {
void Abort() {
DebugBreak();
TerminateProcess(GetCurrentProcess(), 1);
}
} // namespace posix
-#endif // _WIN32_WCE
+#endif // GTEST_OS_WINDOWS_MOBILE
// Returns the name of the environment variable corresponding to the
// given flag. For example, FlagToEnvVar("foo") will return