diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-12-17 21:14:06 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2014-12-19 01:54:41 +0100 |
commit | 7fad14f4e23a5e4852f76e4493bab15c83a9e22f (patch) | |
tree | 3c3b1757c603ec2702f06984ee68d52676174afb | |
parent | 0cd1ed0883e067edab24006b23fb1c663ba62041 (diff) |
tst_qlogging: add tests for %{pid} and %{threadid}
Since those are unpredictable, there's little we can match, besides the
"0x" for the QThread pointer. For the PID, at least we can compare it to
the value from QProcess.
Change-Id: I89420306863b95c82be761baabd733a7f17eba5e
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
-rw-r--r-- | tests/auto/corelib/global/qlogging/tst_qlogging.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index 68b1fef71d..140b349c64 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -765,6 +765,12 @@ void tst_qmessagehandler::qMessagePattern_data() << "A DEBUG qDebug " << "A qWarning "); + QTest::newRow("pid") << "%{pid}: %{message}" + << true << QList<QByteArray>(); // can't match anything, just test validity + QTest::newRow("threadid") << "ThreadId:%{threadid}: %{message}" + << true << (QList<QByteArray>() + << "ThreadId:0x"); + // This test won't work when midnight is too close... wait a bit while (QTime::currentTime() > QTime(23, 59, 30)) QTest::qWait(10000); @@ -820,6 +826,7 @@ void tst_qmessagehandler::qMessagePattern() process.start(appExe); QVERIFY2(process.waitForStarted(), qPrintable( QString::fromLatin1("Could not start %1: %2").arg(appExe, process.errorString()))); + QByteArray pid = QByteArray::number(process.processId()); process.waitForFinished(); QByteArray output = process.readAllStandardError(); @@ -834,6 +841,8 @@ void tst_qmessagehandler::qMessagePattern() QVERIFY(output.contains(e)); } } + if (pattern.startsWith("%{pid}")) + QVERIFY2(output.startsWith('"' + pid), "PID: " + pid + "\noutput:\n" + output); #endif } |