tst_qlogging: use correct qlogging_helper path on webOS

Switched to use runtime path instead of compile time path for the
helper executable. Some tests cases were failing on webOS because of
wrong path.

Fixes: QTBUG-99846
Pick-to: 6.3
Change-Id: I566bc04bdb96ac6e7dd0a875eadb50685aef8282
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Janne Juntunen 2022-01-14 10:01:20 +02:00
parent 06942138d6
commit 5170574532

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2020 The Qt Company Ltd. ** Copyright (C) 2022 The Qt Company Ltd.
** Copyright (C) 2014 Olivier Goffart <ogoffart@woboq.com> ** Copyright (C) 2014 Olivier Goffart <ogoffart@woboq.com>
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
@ -62,6 +62,7 @@ private slots:
void formatLogMessage(); void formatLogMessage();
private: private:
QString backtraceHelperPath();
QStringList m_baseEnvironment; QStringList m_baseEnvironment;
}; };
@ -777,11 +778,7 @@ void tst_qmessagehandler::qMessagePattern()
QFETCH(QList<QByteArray>, expected); QFETCH(QList<QByteArray>, expected);
QProcess process; QProcess process;
#ifndef Q_OS_ANDROID const QString appExe(backtraceHelperPath());
const QString appExe(QLatin1String(HELPER_BINARY));
#else
const QString appExe(QCoreApplication::applicationDirPath() + QLatin1String("/lib" BACKTRACE_HELPER_NAME ".so"));
#endif
// //
// test QT_MESSAGE_PATTERN // test QT_MESSAGE_PATTERN
@ -827,11 +824,7 @@ void tst_qmessagehandler::setMessagePattern()
// //
QProcess process; QProcess process;
#ifndef Q_OS_ANDROID const QString appExe(backtraceHelperPath());
const QString appExe(QLatin1String(HELPER_BINARY));
#else
const QString appExe(QCoreApplication::applicationDirPath() + QLatin1String("/libhelper.so"));
#endif
// make sure there is no QT_MESSAGE_PATTERN in the environment // make sure there is no QT_MESSAGE_PATTERN in the environment
QStringList environment; QStringList environment;
@ -928,6 +921,19 @@ void tst_qmessagehandler::formatLogMessage()
QCOMPARE(r, result); QCOMPARE(r, result);
} }
QString tst_qmessagehandler::backtraceHelperPath()
{
#ifdef Q_OS_ANDROID
QString appExe(QCoreApplication::applicationDirPath()
+ QLatin1String("/lib" BACKTRACE_HELPER_NAME ".so"));
#elif defined(Q_OS_WEBOS)
QString appExe(QCoreApplication::applicationDirPath()
+ QLatin1String("/" BACKTRACE_HELPER_NAME));
#else
QString appExe(QLatin1String(HELPER_BINARY));
#endif
return appExe;
}
QTEST_MAIN(tst_qmessagehandler) QTEST_MAIN(tst_qmessagehandler)
#include "tst_qlogging.moc" #include "tst_qlogging.moc"