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>bb10
parent
0cd1ed0883
commit
7fad14f4e2
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue