diff --git a/src/main.cc b/src/main.cc index 3fa649377c45f4b9af6819a415f0721a99c1da1f..1bd88b74de8a7b8c8ac9f18b53ec7085fd914187 100644 --- a/src/main.cc +++ b/src/main.cc @@ -151,6 +151,7 @@ int main(int argc, char *argv[]) Q_IMPORT_PLUGIN(QGeoServiceProviderFactoryQGC) bool runUnitTests = false; // Run unit tests + bool stressUnitTests = false; // Stress test unit tests #ifdef QT_DEBUG // We parse a small set of command line options here prior to QGCApplication in order to handle the ones @@ -161,11 +162,15 @@ int main(int argc, char *argv[]) QString unitTestOptions; CmdLineOpt_t rgCmdLineOptions[] = { { "--unittest", &runUnitTests, &unitTestOptions }, + { "--unittest-stress", &stressUnitTests, &unitTestOptions }, { "--no-windows-assert-ui", &quietWindowsAsserts, NULL }, // Add additional command line option flags here }; ParseCmdLineOptions(argc, argv, rgCmdLineOptions, sizeof(rgCmdLineOptions)/sizeof(rgCmdLineOptions[0]), false); + if (stressUnitTests) { + runUnitTests = true; + } if (quietWindowsAsserts) { #ifdef Q_OS_WIN @@ -195,23 +200,27 @@ int main(int argc, char *argv[]) app->_initCommon(); - int exitCode; + int exitCode = 0; #ifndef __mobile__ #ifdef QT_DEBUG if (runUnitTests) { - if (!app->_initForUnitTests()) { - return -1; - } - - // Run the test - int failures = UnitTest::run(unitTestOptions); - if (failures == 0) { - qDebug() << "ALL TESTS PASSED"; - } else { - qDebug() << failures << " TESTS FAILED!"; + for (int i=0; i < (stressUnitTests ? 20 : 1); i++) { + if (!app->_initForUnitTests()) { + return -1; + } + + // Run the test + int failures = UnitTest::run(unitTestOptions); + if (failures == 0) { + qDebug() << "ALL TESTS PASSED"; + exitCode = 0; + } else { + qDebug() << failures << " TESTS FAILED!"; + exitCode = -failures; + break; + } } - exitCode = -failures; } else #endif #endif