From f4a630588f9c2947e28f65f07b9f4beb69330602 Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Thu, 9 Jan 2020 17:03:49 +0100 Subject: Fix tst_qlogging Pass in the QT_CMAKE_BUILD define to change the expected executable name in the tests. Add special cases for missing compile flags that cause the collection of backtraces to fail otherwise. Change-Id: I53c44f7e4c6d597f941e4dd8173b3a39a615339c Reviewed-by: Qt CMake Build Bot Reviewed-by: Simon Hausmann --- tests/auto/corelib/global/qlogging/CMakeLists.txt | 10 ++++++++++ tests/auto/corelib/global/qlogging/tst_qlogging.cpp | 11 +++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/global/qlogging/CMakeLists.txt b/tests/auto/corelib/global/qlogging/CMakeLists.txt index a83ebab98a..bd0ab6aeca 100644 --- a/tests/auto/corelib/global/qlogging/CMakeLists.txt +++ b/tests/auto/corelib/global/qlogging/CMakeLists.txt @@ -5,6 +5,14 @@ if(NOT WINRT) SOURCES app/main.cpp DEFINES QT_MESSAGELOGCONTEXT LIBRARIES Qt::Core) + + #special case begin + # Fixes required for the backtrace stack to be correct + if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + target_link_options(qlogging_helper PRIVATE -rdynamic) + endif() + set_target_properties(qlogging_helper PROPERTIES CXX_VISIBILITY_PRESET default) + # special case end endif() add_qt_test(tst_qlogging SOURCES tst_qlogging.cpp @@ -13,3 +21,5 @@ add_qt_test(tst_qlogging SOURCES tst_qlogging.cpp QT_DISABLE_DEPRECATED_BEFORE=0 HELPER_BINARY="${CMAKE_CURRENT_BINARY_DIR}/qlogging_helper" # special case ) + +target_compile_definitions(tst_qlogging PRIVATE QT_CMAKE_BUILD) # special case # to fix the binary name diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index 84e5ccce49..6c0470c8fe 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -792,10 +792,17 @@ void tst_qmessagehandler::qMessagePattern_data() #define QT_NAMESPACE_STR "" #endif + +#ifdef QT_CMAKE_BUILD +#define BACKTRACE_HELPER_NAME "qlogging_helper" +#else +#define BACKTRACE_HELPER_NAME "helper" +#endif + #ifndef QT_NO_DEBUG QTest::newRow("backtrace") << "[%{backtrace}] %{message}" << true << (QList() // MyClass::qt_static_metacall is explicitly marked as hidden in the Q_OBJECT macro - << "[MyClass::myFunction|MyClass::mySlot1|?helper?|" QT_NAMESPACE_STR "QMetaMethod::invoke|" QT_NAMESPACE_STR "QMetaObject::invokeMethod] from_a_function 34"); + << "[MyClass::myFunction|MyClass::mySlot1|?" BACKTRACE_HELPER_NAME "?|" QT_NAMESPACE_STR "QMetaMethod::invoke|" QT_NAMESPACE_STR "QMetaObject::invokeMethod] from_a_function 34"); #endif QTest::newRow("backtrace depth,separator") << "[%{backtrace depth=2 separator=\"\n\"}] %{message}" << true << (QList() @@ -822,7 +829,7 @@ void tst_qmessagehandler::qMessagePattern() #ifndef Q_OS_ANDROID const QString appExe(QLatin1String(HELPER_BINARY)); #else - const QString appExe(QCoreApplication::applicationDirPath() + QLatin1String("/libhelper.so")); + const QString appExe(QCoreApplication::applicationDirPath() + QLatin1String("/lib" BACKTRACE_HELPER_NAME ".so")); #endif // -- cgit v1.2.3