1 //===--- utils/unittest/UnitTestMain/TestMain.cpp - unittest driver -------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/Support/CommandLine.h"
11 #include "llvm/Support/Signals.h"
12 #include "gmock/gmock.h"
13 #include "gtest/gtest.h"
17 # if defined(_MSC_VER)
22 const char *TestMainArgv0
;
24 int main(int argc
, char **argv
) {
25 llvm::sys::PrintStackTraceOnErrorSignal(argv
[0],
26 true /* Disable crash reporting */);
28 // Initialize both gmock and gtest.
29 testing::InitGoogleMock(&argc
, argv
);
31 llvm::cl::ParseCommandLineOptions(argc
, argv
);
33 // Make it easy for a test to re-execute itself by saving argv[0].
34 TestMainArgv0
= argv
[0];
37 // Disable all of the possible ways Windows conspires to make automated
38 // testing impossible.
39 ::SetErrorMode(SEM_FAILCRITICALERRORS
| SEM_NOGPFAULTERRORBOX
);
40 # if defined(_MSC_VER)
41 ::_set_error_mode(_OUT_TO_STDERR
);
42 _CrtSetReportMode(_CRT_WARN
, _CRTDBG_MODE_FILE
| _CRTDBG_MODE_DEBUG
);
43 _CrtSetReportFile(_CRT_WARN
, _CRTDBG_FILE_STDERR
);
44 _CrtSetReportMode(_CRT_ERROR
, _CRTDBG_MODE_FILE
| _CRTDBG_MODE_DEBUG
);
45 _CrtSetReportFile(_CRT_ERROR
, _CRTDBG_FILE_STDERR
);
46 _CrtSetReportMode(_CRT_ASSERT
, _CRTDBG_MODE_FILE
| _CRTDBG_MODE_DEBUG
);
47 _CrtSetReportFile(_CRT_ASSERT
, _CRTDBG_FILE_STDERR
);
51 return RUN_ALL_TESTS();