src/testlib/qtestcase.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
    52 #include <QtCore/qfile.h>
    52 #include <QtCore/qfile.h>
    53 #include <QtCore/qfileinfo.h>
    53 #include <QtCore/qfileinfo.h>
    54 #include <QtCore/qdir.h>
    54 #include <QtCore/qdir.h>
    55 #include <QtCore/qprocess.h>
    55 #include <QtCore/qprocess.h>
    56 #include <QtCore/qdebug.h>
    56 #include <QtCore/qdebug.h>
    57 #include <QtCore/qlibraryinfo.h>
       
    58 
    57 
    59 #include "QtTest/private/qtestlog_p.h"
    58 #include "QtTest/private/qtestlog_p.h"
    60 #include "QtTest/private/qtesttable_p.h"
    59 #include "QtTest/private/qtesttable_p.h"
    61 #include "QtTest/qtestdata.h"
    60 #include "QtTest/qtestdata.h"
    62 #include "QtTest/private/qtestresult_p.h"
    61 #include "QtTest/private/qtestresult_p.h"
  1006         " -eventcounter   : Counts events received during benchmarks\n"
  1005         " -eventcounter   : Counts events received during benchmarks\n"
  1007         " -minimumvalue n : Sets the minimum acceptable measurement value\n"
  1006         " -minimumvalue n : Sets the minimum acceptable measurement value\n"
  1008         " -iterations  n  : Sets the number of accumulation iterations.\n"
  1007         " -iterations  n  : Sets the number of accumulation iterations.\n"
  1009         " -median  n      : Sets the number of median iterations.\n"
  1008         " -median  n      : Sets the number of median iterations.\n"
  1010         " -vb             : Print out verbose benchmarking information.\n"
  1009         " -vb             : Print out verbose benchmarking information.\n"
  1011 #if !defined(QT_NO_PROCESS) && !defined(QT_NO_SETTINGS)
       
  1012         " -chart          : Create chart based on the benchmark result.\n"
       
  1013 #endif
       
  1014          "\n"
  1010          "\n"
  1015         " -help      : This help\n";
  1011         " -help      : This help\n";
  1016 
  1012 
  1017     for (int i = 1; i < argc; ++i) {
  1013     for (int i = 1; i < argc; ++i) {
  1018         if (strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "--help") == 0
  1014         if (strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "--help") == 0
  1126                 QBenchmarkGlobalData::current->medianIterationCount = qToInt(argv[++i]);
  1122                 QBenchmarkGlobalData::current->medianIterationCount = qToInt(argv[++i]);
  1127             }
  1123             }
  1128 
  1124 
  1129         } else if (strcmp(argv[i], "-vb") == 0) {
  1125         } else if (strcmp(argv[i], "-vb") == 0) {
  1130             QBenchmarkGlobalData::current->verboseOutput = true;
  1126             QBenchmarkGlobalData::current->verboseOutput = true;
  1131 #if !defined(QT_NO_PROCESS) && !defined(QT_NO_SETTINGS)
       
  1132         } else if (strcmp(argv[i], "-chart") == 0) {
  1127         } else if (strcmp(argv[i], "-chart") == 0) {
  1133             QBenchmarkGlobalData::current->createChart = true;
  1128             fprintf(stderr, "Warning: `-chart' option is not available\n");
  1134             QTestLog::setLogMode(QTestLog::XML);
       
  1135             QTestLog::redirectOutput("results.xml");
       
  1136 #endif
       
  1137         } else if (strcmp(argv[i], "-qws") == 0) {
  1129         } else if (strcmp(argv[i], "-qws") == 0) {
  1138             // do nothing
  1130             // do nothing
  1139         } else if (strcmp(argv[i], "-graphicssystem") == 0) {
  1131         } else if (strcmp(argv[i], "-graphicssystem") == 0) {
  1140             // do nothing
  1132             // do nothing
  1141             if (i + 1 >= argc) {
  1133             if (i + 1 >= argc) {
  1741      if (macNeedsActivate) {
  1733      if (macNeedsActivate) {
  1742          IOPMAssertionRelease(powerID);
  1734          IOPMAssertionRelease(powerID);
  1743      }
  1735      }
  1744 #endif
  1736 #endif
  1745 
  1737 
  1746 
       
  1747 #if !defined(QT_NO_PROCESS) && !defined(QT_NO_SETTINGS)
       
  1748     if (QBenchmarkGlobalData::current->createChart) {
       
  1749         QString chartLocation = QLibraryInfo::location(QLibraryInfo::BinariesPath);
       
  1750 #ifdef Q_OS_WIN
       
  1751         chartLocation += QLatin1String("/../tools/qtestlib/chart/release/chart.exe");
       
  1752 #else
       
  1753         chartLocation += QLatin1String("/../tools/qtestlib/chart/chart");
       
  1754 #endif
       
  1755         if (QFile::exists(chartLocation)) {
       
  1756             QProcess p;
       
  1757             p.setProcessChannelMode(QProcess::ForwardedChannels);
       
  1758             p.start(chartLocation, QStringList() << QLatin1String("results.xml"));
       
  1759             p.waitForFinished(-1);
       
  1760         } else {
       
  1761             qDebug() << QLatin1String("Could not find the chart tool in ") + chartLocation + QLatin1String(", please make sure it is compiled.");
       
  1762         }
       
  1763     }
       
  1764 #endif
       
  1765 
       
  1766 #if defined(QTEST_NOEXITCODE)
  1738 #if defined(QTEST_NOEXITCODE)
  1767     return 0;
  1739     return 0;
  1768 #else
  1740 #else
  1769 
  1741 
  1770 #ifdef QTESTLIB_USE_VALGRIND
  1742 #ifdef QTESTLIB_USE_VALGRIND