From 7fad14f4e23a5e4852f76e4493bab15c83a9e22f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 17 Dec 2014 21:14:06 -0800 Subject: 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 Reviewed-by: Kai Koehne --- tests/auto/corelib/global/qlogging/tst_qlogging.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/auto/corelib/global/qlogging/tst_qlogging.cpp') 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(); // can't match anything, just test validity + QTest::newRow("threadid") << "ThreadId:%{threadid}: %{message}" + << true << (QList() + << "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 } -- cgit v1.2.3