summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMagne Pettersen Zachrisen <magne.zachrisen@tandberg.com>2010-08-10 19:52:06 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-08-11 14:22:09 (GMT)
commit56396b4b2b66da3133aff1b3864c550ce892d233 (patch)
treed783766e74ef9914e60a350921745ceef63069b5 /tests/auto
parentef0d191e3d138f695a39128b6040d0884821f5b5 (diff)
downloadQt-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 'tests/auto')
-rw-r--r--tests/auto/selftests/expected_random.lightxml20
-rw-r--r--tests/auto/selftests/expected_random.txt9
-rw-r--r--tests/auto/selftests/expected_random.xml23
-rw-r--r--tests/auto/selftests/expected_random.xunitxml14
-rw-r--r--tests/auto/selftests/random/random.pro9
-rw-r--r--tests/auto/selftests/random/tst_random.cpp28
-rw-r--r--tests/auto/selftests/selftests.pro2
-rw-r--r--tests/auto/selftests/selftests.qrc6
-rw-r--r--tests/auto/selftests/tst_selftests.cpp5
9 files changed, 114 insertions, 2 deletions
diff --git a/tests/auto/selftests/expected_random.lightxml b/tests/auto/selftests/expected_random.lightxml
new file mode 100644
index 0000000..15f56a1
--- /dev/null
+++ b/tests/auto/selftests/expected_random.lightxml
@@ -0,0 +1,20 @@
+<Environment>
+ <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
+ <RandomSeed>325</RandomSeed>
+</Environment>
+<TestFunction name="initTestCase">
+<Incident type="pass" file="" line="0"/>
+</TestFunction>
+<TestFunction name="testTwo">
+<Incident type="pass" file="" line="0"/>
+</TestFunction>
+<TestFunction name="testOne">
+<Incident type="pass" file="" line="0"/>
+</TestFunction>
+<TestFunction name="testThree">
+<Incident type="pass" file="" line="0"/>
+</TestFunction>
+<TestFunction name="cleanupTestCase">
+<Incident type="pass" file="" line="0"/>
+</TestFunction>
diff --git a/tests/auto/selftests/expected_random.txt b/tests/auto/selftests/expected_random.txt
new file mode 100644
index 0000000..3f4c11d
--- /dev/null
+++ b/tests/auto/selftests/expected_random.txt
@@ -0,0 +1,9 @@
+********* Start testing of tst_Random *********
+Config: Using QTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@, Random seed 325
+PASS : tst_Random::initTestCase()
+PASS : tst_Random::testTwo()
+PASS : tst_Random::testOne()
+PASS : tst_Random::testThree()
+PASS : tst_Random::cleanupTestCase()
+Totals: 5 passed, 0 failed, 0 skipped
+********* Finished testing of tst_Random *********
diff --git a/tests/auto/selftests/expected_random.xml b/tests/auto/selftests/expected_random.xml
new file mode 100644
index 0000000..3677287
--- /dev/null
+++ b/tests/auto/selftests/expected_random.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<TestCase name="tst_Random">
+<Environment>
+ <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
+ <RandomSeed>325</RandomSeed>
+</Environment>
+<TestFunction name="initTestCase">
+<Incident type="pass" file="" line="0" />
+</TestFunction>
+<TestFunction name="testTwo">
+<Incident type="pass" file="" line="0" />
+</TestFunction>
+<TestFunction name="testOne">
+<Incident type="pass" file="" line="0" />
+</TestFunction>
+<TestFunction name="testThree">
+<Incident type="pass" file="" line="0" />
+</TestFunction>
+<TestFunction name="cleanupTestCase">
+<Incident type="pass" file="" line="0" />
+</TestFunction>
+</TestCase>
diff --git a/tests/auto/selftests/expected_random.xunitxml b/tests/auto/selftests/expected_random.xunitxml
new file mode 100644
index 0000000..262aa0a
--- /dev/null
+++ b/tests/auto/selftests/expected_random.xunitxml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<testsuite errors="0" failures="0" tests="5" name="tst_Random">
+ <properties>
+ <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/>
+ <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/>
+ <property value="325" name="RandomSeed"/>
+ </properties>
+ <testcase result="pass" name="initTestCase"/>
+ <testcase result="pass" name="testTwo"/>
+ <testcase result="pass" name="testOne"/>
+ <testcase result="pass" name="testThree"/>
+ <testcase result="pass" name="cleanupTestCase"/>
+ <system-err/>
+</testsuite>
diff --git a/tests/auto/selftests/random/random.pro b/tests/auto/selftests/random/random.pro
new file mode 100644
index 0000000..19572ad
--- /dev/null
+++ b/tests/auto/selftests/random/random.pro
@@ -0,0 +1,9 @@
+load(qttest_p4)
+SOURCES += tst_random.cpp
+QT = core
+
+mac:CONFIG -= app_bundle
+CONFIG -= debug_and_release_target
+
+
+TARGET = random
diff --git a/tests/auto/selftests/random/tst_random.cpp b/tests/auto/selftests/random/tst_random.cpp
new file mode 100644
index 0000000..1ee922e
--- /dev/null
+++ b/tests/auto/selftests/random/tst_random.cpp
@@ -0,0 +1,28 @@
+#include <QtCore>
+#include <QtTest/QtTest>
+
+class tst_Random: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testOne() const {}
+ void testTwo() const {}
+ void testThree() const {}
+};
+
+/*
+int main(int argc, char * argv[])
+{
+ int failures = 0;
+ tst_Random tst;
+ for (int i = 0; i != 10; i++) {
+ failures += QTest::qExec(&tst, argc, argv);
+ }
+ return failures;
+}
+*/
+QTEST_MAIN(tst_Random)
+
+#include "tst_random.moc"
+
diff --git a/tests/auto/selftests/selftests.pro b/tests/auto/selftests/selftests.pro
index d854b5e..bfbd598 100644
--- a/tests/auto/selftests/selftests.pro
+++ b/tests/auto/selftests/selftests.pro
@@ -5,7 +5,7 @@ SUBDIRS = subtest test warnings maxwarnings cmptest globaldata skipglobal skip \
skipinit skipinitdata datetime singleskip assert waitwithoutgui differentexec \
exceptionthrow qexecstringlist datatable commandlinedata\
benchlibwalltime benchlibcallgrind benchlibeventcounter benchlibtickcounter \
- benchliboptions xunit badxml longstring
+ benchliboptions xunit badxml longstring random
INSTALLS =
diff --git a/tests/auto/selftests/selftests.qrc b/tests/auto/selftests/selftests.qrc
index f82722b..ba7ca4f 100644
--- a/tests/auto/selftests/selftests.qrc
+++ b/tests/auto/selftests/selftests.qrc
@@ -90,6 +90,10 @@
<file>expected_multiexec.xml</file>
<file>expected_multiexec.xunitxml</file>
<file>expected_qexecstringlist.txt</file>
+ <file>expected_random.txt</file>
+ <file>expected_random.lightxml</file>
+ <file>expected_random.xml</file>
+ <file>expected_random.xunitxml</file>
<file>expected_singleskip.lightxml</file>
<file>expected_singleskip.txt</file>
<file>expected_singleskip.xml</file>
@@ -134,5 +138,5 @@
<file>expected_xunit.txt</file>
<file>expected_xunit.xml</file>
<file>expected_xunit.xunitxml</file>
- </qresource>
+ </qresource>
</RCC>
diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp
index 0818b4c..9fb7ce6 100644
--- a/tests/auto/selftests/tst_selftests.cpp
+++ b/tests/auto/selftests/tst_selftests.cpp
@@ -245,6 +245,7 @@ void tst_Selftests::runSubTest_data()
<< "xunit"
<< "longstring"
<< "badxml"
+ << "random"
;
foreach (Logger const& logger, allLoggers()) {
@@ -273,6 +274,9 @@ void tst_Selftests::runSubTest_data()
else if (subtest == "badxml") {
arguments << "-eventcounter";
}
+ else if (subtest == "random") {
+ arguments << QString("-random -seed 325").split(' ');
+ }
// These tests don't work right with loggers other than plain, usually because
// they internally supply arguments to themselves.
@@ -632,3 +636,4 @@ void tst_Selftests::cleanupTestCase()
QTEST_MAIN(tst_Selftests)
#include "tst_selftests.moc"
+