diff options
author | Magne Pettersen Zachrisen <magne.zachrisen@tandberg.com> | 2010-08-10 19:52:06 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-08-11 14:22:09 (GMT) |
commit | 56396b4b2b66da3133aff1b3864c550ce892d233 (patch) | |
tree | d783766e74ef9914e60a350921745ceef63069b5 /src/testlib/qtestlogger.cpp | |
parent | ef0d191e3d138f695a39128b6040d0884821f5b5 (diff) | |
download | Qt-56396b4b2b66da3133aff1b3864c550ce892d233.zip Qt-56396b4b2b66da3133aff1b3864c550ce892d233.tar.gz Qt-56396b4b2b66da3133aff1b3864c550ce892d233.tar.bz2 |
Added -random option to tests, making the test cases within a test execute in arbitrary order. Very useful for avoiding test cases being dependent on the running order.
Added -seed option -random to make it possible to reroduce
test results. The seed is printed out when -random is specified
Added selftests for -random and -seed options
Changed int parsing into strtol and QTime->QDateTime as suggested by Mr Macieira, fixed selftests
Merge-request: 2362
Reviewed-by: Thiago Macieira <thiago.macieira@nokia.com>
Diffstat (limited to 'src/testlib/qtestlogger.cpp')
-rw-r--r-- | src/testlib/qtestlogger.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/testlib/qtestlogger.cpp b/src/testlib/qtestlogger.cpp index f0be6be..cab97d1 100644 --- a/src/testlib/qtestlogger.cpp +++ b/src/testlib/qtestlogger.cpp @@ -62,7 +62,8 @@ QTestLogger::QTestLogger(int fm) warningCounter(0), skipCounter(0), systemCounter(0), qdebugCounter(0), qwarnCounter(0), qfatalCounter(0), - infoCounter(0) + infoCounter(0), randomSeed_(0), + hasRandomSeed_(false) { } @@ -133,6 +134,14 @@ void QTestLogger::stopLogging() property->addAttribute(QTest::AI_PropertyValue, qVersion()); properties->addLogElement(property); + if (hasRandomSeed()) { + property = new QTestElement(QTest::LET_Property); + property->addAttribute(QTest::AI_Name, "RandomSeed"); + QTest::qt_snprintf(buf, sizeof(buf), "%i", randomSeed()); + property->addAttribute(QTest::AI_PropertyValue, buf); + properties->addLogElement(property); + } + currentLogElement->addLogElement(properties); currentLogElement->addLogElement(iterator); @@ -420,5 +429,21 @@ int QTestLogger::infoCount() const return infoCounter; } +void QTestLogger::registerRandomSeed(unsigned int seed) +{ + randomSeed_ = seed; + hasRandomSeed_ = true; +} + +unsigned int QTestLogger::randomSeed() const +{ + return randomSeed_; +} + +bool QTestLogger::hasRandomSeed() const +{ + return hasRandomSeed_; +} + QT_END_NAMESPACE |