diff options
| author | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-09-24 09:01:34 +0000 |
|---|---|---|
| committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-09-24 09:01:34 +0000 |
| commit | d8010d6456e856fe5fc0318c2a7bcfd969f06fa7 (patch) | |
| tree | f21acbfec8ca277868e160abaf1f6284f0e82b79 | |
| parent | 5d28c8428fded7d52e3d24abb98c54966a361771 (diff) | |
| download | bcm5719-llvm-d8010d6456e856fe5fc0318c2a7bcfd969f06fa7.tar.gz bcm5719-llvm-d8010d6456e856fe5fc0318c2a7bcfd969f06fa7.zip | |
unittests: Support Windows.
llvm-svn: 114727
| -rw-r--r-- | llvm/unittests/Support/System.cpp | 2 | ||||
| -rw-r--r-- | llvm/utils/unittest/UnitTestMain/TestMain.cpp | 27 |
2 files changed, 28 insertions, 1 deletions
diff --git a/llvm/unittests/Support/System.cpp b/llvm/unittests/Support/System.cpp index b3dd17d380d..94f1978b598 100644 --- a/llvm/unittests/Support/System.cpp +++ b/llvm/unittests/Support/System.cpp @@ -11,6 +11,6 @@ class SystemTest : public ::testing::Test { TEST_F(SystemTest, TimeValue) { sys::TimeValue now = sys::TimeValue::now(); time_t now_t = time(NULL); - EXPECT_TRUE(abs(now_t - now.toEpochTime()) < 2); + EXPECT_TRUE(abs(static_cast<time_t>(now_t - now.toEpochTime())) < 2); } } diff --git a/llvm/utils/unittest/UnitTestMain/TestMain.cpp b/llvm/utils/unittest/UnitTestMain/TestMain.cpp index d97dca872ad..ed42c227c8c 100644 --- a/llvm/utils/unittest/UnitTestMain/TestMain.cpp +++ b/llvm/utils/unittest/UnitTestMain/TestMain.cpp @@ -7,9 +7,36 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Config/config.h" +#include "llvm/System/Signals.h" #include "gtest/gtest.h" + +#if defined(LLVM_ON_WIN32) +# include <Windows.h> +# if defined(_MSC_VER) +# include <crtdbg.h> +# endif +#endif + int main(int argc, char **argv) { + llvm::sys::PrintStackTraceOnErrorSignal(); testing::InitGoogleTest(&argc, argv); + +# if defined(LLVM_ON_WIN32) + // Disable all of the possible ways Windows conspires to make automated + // testing impossible. + ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); +# if defined(_MSC_VER) + ::_set_error_mode(_OUT_TO_STDERR); + ::_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
+ ::_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); + ::_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
+ ::_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); + ::_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
+ ::_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); +# endif +# endif + return RUN_ALL_TESTS(); } |

