Daniel Dunbar | f845c74 | 2009-09-13 21:31:21 +0000 | [diff] [blame] | 1 | //===--- utils/unittest/UnitTestMain/TestMain.cpp - unittest driver -------===// |
Misha Brukman | 8fb520e | 2009-01-01 02:24:48 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Michael J. Spencer | ddfce8f | 2010-09-24 09:01:34 +0000 | [diff] [blame] | 10 | #include "llvm/Config/config.h" |
| 11 | #include "llvm/System/Signals.h" |
Misha Brukman | 8fb520e | 2009-01-01 02:24:48 +0000 | [diff] [blame] | 12 | #include "gtest/gtest.h" |
| 13 | |
Michael J. Spencer | ddfce8f | 2010-09-24 09:01:34 +0000 | [diff] [blame] | 14 | |
| 15 | #if defined(LLVM_ON_WIN32) |
| 16 | # include <Windows.h> |
| 17 | # if defined(_MSC_VER) |
| 18 | # include <crtdbg.h> |
| 19 | # endif |
| 20 | #endif |
| 21 | |
Misha Brukman | 8fb520e | 2009-01-01 02:24:48 +0000 | [diff] [blame] | 22 | int main(int argc, char **argv) { |
Michael J. Spencer | ddfce8f | 2010-09-24 09:01:34 +0000 | [diff] [blame] | 23 | llvm::sys::PrintStackTraceOnErrorSignal(); |
Misha Brukman | 8fb520e | 2009-01-01 02:24:48 +0000 | [diff] [blame] | 24 | testing::InitGoogleTest(&argc, argv); |
Michael J. Spencer | ddfce8f | 2010-09-24 09:01:34 +0000 | [diff] [blame] | 25 | |
| 26 | # if defined(LLVM_ON_WIN32) |
| 27 | // Disable all of the possible ways Windows conspires to make automated |
| 28 | // testing impossible. |
| 29 | ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); |
| 30 | # if defined(_MSC_VER) |
| 31 | ::_set_error_mode(_OUT_TO_STDERR); |
Michael J. Spencer | 6b096c3 | 2010-09-24 09:10:21 +0000 | [diff] [blame] | 32 | ::_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); |
Michael J. Spencer | ddfce8f | 2010-09-24 09:01:34 +0000 | [diff] [blame] | 33 | ::_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); |
Michael J. Spencer | 6b096c3 | 2010-09-24 09:10:21 +0000 | [diff] [blame] | 34 | ::_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); |
Michael J. Spencer | ddfce8f | 2010-09-24 09:01:34 +0000 | [diff] [blame] | 35 | ::_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); |
Michael J. Spencer | 6b096c3 | 2010-09-24 09:10:21 +0000 | [diff] [blame] | 36 | ::_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); |
Michael J. Spencer | ddfce8f | 2010-09-24 09:01:34 +0000 | [diff] [blame] | 37 | ::_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); |
| 38 | # endif |
| 39 | # endif |
| 40 | |
Misha Brukman | 8fb520e | 2009-01-01 02:24:48 +0000 | [diff] [blame] | 41 | return RUN_ALL_TESTS(); |
| 42 | } |