void WTFInstallReportBacktraceOnCrashHook() { #if HAVE(SIGNAL_H) // Needed otherwise we are going to dump the stack trace twice // in case we hit an assertion. WTFSetCrashHook(&resetSignalHandlersForFatalErrors); installSignalHandlersForFatalErrors(&dumpBacktraceSignalHandler); #endif }
int main(int argc, char* argv[]) { #ifdef Q_OS_WIN _setmode(1, _O_BINARY); _setmode(2, _O_BINARY); #endif // Suppress debug output from Qt if not started with -v bool suppressQtDebugOutput = true; for (int i = 1; i < argc; ++i) { if (!qstrcmp(argv[i], "-v")) { suppressQtDebugOutput = false; break; } } // Has to be done before QApplication is constructed in case // QApplication itself produces debug output. if (suppressQtDebugOutput) qInstallMsgHandler(messageHandler); WebKit::initializeTestFonts(); QApplication::setGraphicsSystem("raster"); QApplication::setStyle(new QWindowsStyle); QApplication app(argc, argv); app.setQuitOnLastWindowClosed(false); #if HAVE(QT5) QCoreApplication::setAttribute(Qt::AA_Use96Dpi, true); #else #ifdef Q_WS_X11 QX11Info::setAppDpiY(0, 96); QX11Info::setAppDpiX(0, 96); #endif /* * QApplication will initialize the default application font based * on the application DPI at construction time, which might be * different from the DPI we explicitly set using QX11Info above. * See: https://bugreports.qt.nokia.com/browse/QTBUG-21603 * * To ensure that the application font DPI matches the application * DPI, we override the application font using the font we get from * a QWidget, which has already been resolved against the existing * default font, but with the correct paint-device DPI. */ QApplication::setFont(QWidget().font()); #endif #if HAVE(SIGNAL_H) setupSignalHandlers(&crashHandler); WTFSetCrashHook(&WTFCrashHook); #endif QStringList args = app.arguments(); if (args.count() < (!suppressQtDebugOutput ? 3 : 2)) { printUsage(); exit(1); } // Remove the first arguments, it is application name itself args.removeAt(0); WebCore::DumpRenderTree dumper; int index = args.indexOf(QLatin1String("--pixel-tests")); if (index != -1) { dumper.setDumpPixels(true); args.removeAt(index); } index = args.indexOf(QLatin1String("--stdout")); if (index != -1) { QString fileName = takeOptionValue(args, index); dumper.setRedirectOutputFileName(fileName); if (fileName.isEmpty() || !freopen(qPrintable(fileName), "w", stdout)) { fprintf(stderr, "STDOUT redirection failed."); exit(1); } } index = args.indexOf(QLatin1String("--stderr")); if (index != -1) { QString fileName = takeOptionValue(args, index); dumper.setRedirectErrorFileName(fileName); if (!freopen(qPrintable(fileName), "w", stderr)) { fprintf(stderr, "STDERR redirection failed."); exit(1); } } QWebDatabase::removeAllDatabases(); index = args.indexOf(QLatin1String("--timeout")); if (index != -1) { int timeout = takeOptionValue(args, index).toInt(); dumper.setTimeout(timeout); args.removeAt(index); } index = args.indexOf(QLatin1String("--no-timeout")); if (index != -1) { dumper.setShouldTimeout(false); args.removeAt(index); } index = args.indexOf(QLatin1String("-")); if (index != -1) { args.removeAt(index); // Continue waiting in STDIN for more test case after process one test case QObject::connect(&dumper, SIGNAL(ready()), &dumper, SLOT(readLine()), Qt::QueuedConnection); // Read and only read the first test case, ignore the others if (args.size() > 0) { // Process the argument first dumper.processLine(args[0]); } else QTimer::singleShot(0, &dumper, SLOT(readLine())); } else { // Go into standalone mode // Standalone mode need at least one test case if (args.count() < 1) { printUsage(); exit(1); } dumper.processArgsLine(args); } return app.exec(); }