Fixes compatibility with Windows CE and Symbian (By Tim Baverstock and Mika).

This commit is contained in:
zhanyong.wan
2009-06-19 17:23:54 +00:00
parent ae3247986b
commit 4853a50337
11 changed files with 70 additions and 20 deletions

View File

@@ -45,7 +45,9 @@
#error "It must not be included except by Google Test itself."
#endif // GTEST_IMPLEMENTATION_
#ifndef _WIN32_WCE
#include <errno.h>
#endif // !_WIN32_WCE
#include <stddef.h>
#include <stdlib.h> // For strtoll/_strtoul64.
@@ -1072,7 +1074,7 @@ class UnitTestImpl {
original_working_dir_.Set(FilePath::GetCurrentDir());
if (original_working_dir_.IsEmpty()) {
printf("%s\n", "Failed to get the current working directory.");
abort();
posix::Abort();
}
}

View File

@@ -36,8 +36,10 @@
#include <stdio.h>
#if GTEST_OS_WINDOWS
#ifndef _WIN32_WCE
#include <io.h>
#include <sys/stat.h>
#endif // _WIN32_WCE
#else
#include <unistd.h>
#endif // GTEST_OS_WINDOWS
@@ -425,7 +427,7 @@ void GTestLog(GTestLogSeverity severity, const char* file,
fprintf(stderr, "\n%s %s:%d: %s\n", marker, file, line, msg);
if (severity == GTEST_FATAL) {
fflush(NULL); // abort() is not guaranteed to flush open file streams.
abort();
posix::Abort();
}
}
@@ -444,6 +446,10 @@ class CapturedStderr {
public:
// The ctor redirects stderr to a temporary file.
CapturedStderr() {
#ifdef _WIN32_WCE
// Not supported on Windows CE.
posix::Abort();
#else
uncaptured_fd_ = dup(kStdErrFileno);
#if GTEST_OS_WINDOWS
@@ -465,19 +471,24 @@ class CapturedStderr {
fflush(NULL);
dup2(captured_fd, kStdErrFileno);
close(captured_fd);
#endif // _WIN32_WCE
}
~CapturedStderr() {
#ifndef _WIN32_WCE
remove(filename_.c_str());
#endif // _WIN32_WCE
}
// Stops redirecting stderr.
void StopCapture() {
#ifndef _WIN32_WCE
// Restores the original stream.
fflush(NULL);
dup2(uncaptured_fd_, kStdErrFileno);
close(uncaptured_fd_);
uncaptured_fd_ = -1;
#endif // !_WIN32_WCE
}
// Returns the name of the temporary file holding the stderr output.

View File

@@ -86,7 +86,7 @@ const char* TypedTestCasePState::VerifyRegisteredTestNames(
fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
errors_str.c_str());
fflush(stderr);
abort();
posix::Abort();
}
return registered_tests;

View File

@@ -3364,14 +3364,14 @@ int UnitTest::Run() {
SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
#endif // _WIN32_WCE
#if defined(_MSC_VER) || defined(__MINGW32__)
#if (defined(_MSC_VER) || defined(__MINGW32__)) && !defined(_WIN32_WCE)
// Death test children can be terminated with _abort(). On Windows,
// _abort() can show a dialog with a warning message. This forces the
// abort message to go to stderr instead.
_set_error_mode(_OUT_TO_STDERR);
#endif
#if _MSC_VER >= 1400
#if _MSC_VER >= 1400 && !defined(_WIN32_WCE)
// In the debug version, Visual Studio pops up a separate dialog
// offering a choice to debug the aborted program. We need to suppress
// this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement
@@ -3387,7 +3387,7 @@ int UnitTest::Run() {
_set_abort_behavior(
0x0, // Clear the following flags:
_WRITE_ABORT_MSG | _CALL_REPORTFAULT); // pop-up window, core dump.
#endif // _MSC_VER >= 1400
#endif
}
__try {