Commit c68faf27 authored by Don Gagne's avatar Don Gagne

Add --unittest-stress support

parent 2cd9ce2d
...@@ -151,6 +151,7 @@ int main(int argc, char *argv[]) ...@@ -151,6 +151,7 @@ int main(int argc, char *argv[])
Q_IMPORT_PLUGIN(QGeoServiceProviderFactoryQGC) Q_IMPORT_PLUGIN(QGeoServiceProviderFactoryQGC)
bool runUnitTests = false; // Run unit tests bool runUnitTests = false; // Run unit tests
bool stressUnitTests = false; // Stress test unit tests
#ifdef QT_DEBUG #ifdef QT_DEBUG
// We parse a small set of command line options here prior to QGCApplication in order to handle the ones // 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[]) ...@@ -161,11 +162,15 @@ int main(int argc, char *argv[])
QString unitTestOptions; QString unitTestOptions;
CmdLineOpt_t rgCmdLineOptions[] = { CmdLineOpt_t rgCmdLineOptions[] = {
{ "--unittest", &runUnitTests, &unitTestOptions }, { "--unittest", &runUnitTests, &unitTestOptions },
{ "--unittest-stress", &stressUnitTests, &unitTestOptions },
{ "--no-windows-assert-ui", &quietWindowsAsserts, NULL }, { "--no-windows-assert-ui", &quietWindowsAsserts, NULL },
// Add additional command line option flags here // Add additional command line option flags here
}; };
ParseCmdLineOptions(argc, argv, rgCmdLineOptions, sizeof(rgCmdLineOptions)/sizeof(rgCmdLineOptions[0]), false); ParseCmdLineOptions(argc, argv, rgCmdLineOptions, sizeof(rgCmdLineOptions)/sizeof(rgCmdLineOptions[0]), false);
if (stressUnitTests) {
runUnitTests = true;
}
if (quietWindowsAsserts) { if (quietWindowsAsserts) {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
...@@ -195,23 +200,27 @@ int main(int argc, char *argv[]) ...@@ -195,23 +200,27 @@ int main(int argc, char *argv[])
app->_initCommon(); app->_initCommon();
int exitCode; int exitCode = 0;
#ifndef __mobile__ #ifndef __mobile__
#ifdef QT_DEBUG #ifdef QT_DEBUG
if (runUnitTests) { if (runUnitTests) {
if (!app->_initForUnitTests()) { for (int i=0; i < (stressUnitTests ? 20 : 1); i++) {
return -1; if (!app->_initForUnitTests()) {
} return -1;
}
// Run the test
int failures = UnitTest::run(unitTestOptions); // Run the test
if (failures == 0) { int failures = UnitTest::run(unitTestOptions);
qDebug() << "ALL TESTS PASSED"; if (failures == 0) {
} else { qDebug() << "ALL TESTS PASSED";
qDebug() << failures << " TESTS FAILED!"; exitCode = 0;
} else {
qDebug() << failures << " TESTS FAILED!";
exitCode = -failures;
break;
}
} }
exitCode = -failures;
} else } else
#endif #endif
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment