2009-09-14 05:31:21 +08:00
|
|
|
//===--- utils/unittest/UnitTestMain/TestMain.cpp - unittest driver -------===//
|
2009-01-01 10:24:48 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-01-18 18:18:50 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2010-11-30 02:16:10 +08:00
|
|
|
#include "llvm/Support/Signals.h"
|
2009-01-01 10:24:48 +08:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
2010-09-24 17:01:34 +08:00
|
|
|
|
2015-07-07 07:51:40 +08:00
|
|
|
#if defined(_WIN32)
|
2011-02-04 20:53:04 +08:00
|
|
|
# include <windows.h>
|
2010-09-24 17:01:34 +08:00
|
|
|
# if defined(_MSC_VER)
|
|
|
|
# include <crtdbg.h>
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2013-04-30 12:30:41 +08:00
|
|
|
const char *TestMainArgv0;
|
|
|
|
|
2009-01-01 10:24:48 +08:00
|
|
|
int main(int argc, char **argv) {
|
2015-04-08 04:43:23 +08:00
|
|
|
llvm::sys::PrintStackTraceOnErrorSignal(true /* Disable crash reporting */);
|
2009-01-01 10:24:48 +08:00
|
|
|
testing::InitGoogleTest(&argc, argv);
|
2013-01-18 18:18:50 +08:00
|
|
|
llvm::cl::ParseCommandLineOptions(argc, argv);
|
2010-09-24 17:01:34 +08:00
|
|
|
|
2013-04-30 12:30:41 +08:00
|
|
|
// Make it easy for a test to re-execute itself by saving argv[0].
|
|
|
|
TestMainArgv0 = argv[0];
|
|
|
|
|
2015-07-07 07:51:40 +08:00
|
|
|
# if defined(_WIN32)
|
2010-09-24 17:01:34 +08:00
|
|
|
// 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);
|
2010-10-02 11:26:54 +08:00
|
|
|
_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);
|
2010-09-24 17:01:34 +08:00
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
|
2009-01-01 10:24:48 +08:00
|
|
|
return RUN_ALL_TESTS();
|
|
|
|
}
|