diff options
Diffstat (limited to 'tests/auto/corelib/global/qlogging')
-rw-r--r-- | tests/auto/corelib/global/qlogging/BLACKLIST | 10 | ||||
-rw-r--r-- | tests/auto/corelib/global/qlogging/CMakeLists.txt | 11 | ||||
-rw-r--r-- | tests/auto/corelib/global/qlogging/app/main.cpp | 2 | ||||
-rw-r--r-- | tests/auto/corelib/global/qlogging/tst_qlogging.cpp | 96 | ||||
-rw-r--r-- | tests/auto/corelib/global/qlogging/tst_qmessagelogger.cpp | 2 |
5 files changed, 100 insertions, 21 deletions
diff --git a/tests/auto/corelib/global/qlogging/BLACKLIST b/tests/auto/corelib/global/qlogging/BLACKLIST index e2d930e37b..6cd7fc045d 100644 --- a/tests/auto/corelib/global/qlogging/BLACKLIST +++ b/tests/auto/corelib/global/qlogging/BLACKLIST @@ -1,9 +1,7 @@ [qMessagePattern:backtrace] -# QTBUG-63915 -b2qt 64bit +# QTBUG-121389 +b2qt 32bit [qMessagePattern:backtrace depth,separator] -# QTBUG-63915 -b2qt 64bit -# QTBUG-85364 -b2qt cmake +# QTBUG-121389 +b2qt 32bit diff --git a/tests/auto/corelib/global/qlogging/CMakeLists.txt b/tests/auto/corelib/global/qlogging/CMakeLists.txt index 00825c5526..f35c9c4192 100644 --- a/tests/auto/corelib/global/qlogging/CMakeLists.txt +++ b/tests/auto/corelib/global/qlogging/CMakeLists.txt @@ -1,9 +1,11 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -# Generated from qlogging.pro. -# This file is almost completely custom written -# special case skip regeneration +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qlogging LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() qt_internal_add_executable(qlogging_helper NO_INSTALL @@ -21,9 +23,10 @@ set_target_properties(qlogging_helper PROPERTIES CXX_VISIBILITY_PRESET default) qt_internal_add_test(tst_qlogging SOURCES tst_qlogging.cpp DEFINES QT_MESSAGELOGCONTEXT - HELPER_BINARY="${CMAKE_CURRENT_BINARY_DIR}/qlogging_helper" ) +add_dependencies(tst_qlogging qlogging_helper) + qt_internal_add_test(tst_qmessagelogger SOURCES tst_qmessagelogger.cpp DEFINES QT_MESSAGELOGCONTEXT diff --git a/tests/auto/corelib/global/qlogging/app/main.cpp b/tests/auto/corelib/global/qlogging/app/main.cpp index 79d2dbcc92..e5b669e14f 100644 --- a/tests/auto/corelib/global/qlogging/app/main.cpp +++ b/tests/auto/corelib/global/qlogging/app/main.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QCoreApplication> #include <QLoggingCategory> diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index 0a43395ac9..defe3ac421 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -1,7 +1,7 @@ // Copyright (C) 2022 The Qt Company Ltd. // Copyright (C) 2022 Intel Corporation. // Copyright (C) 2014 Olivier Goffart <ogoffart@woboq.com> -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <qdebug.h> #include <qglobal.h> @@ -30,6 +30,8 @@ private slots: #ifdef QT_BUILD_INTERNAL void cleanupFuncinfo_data(); void cleanupFuncinfo(); + void cleanupFuncinfoBad_data(); + void cleanupFuncinfoBad(); #endif void qMessagePattern_data(); @@ -166,9 +168,13 @@ public: int operator%(int) { ADD("TestClass1::operator%"); return 0; } int x; int &operator++() { ADD("TestClass1::operator++"); return x; } - int operator++(int) { ADD("TestClass1::operator++"); return 0; } int &operator--() { ADD("TestClass1::operator--"); return x; } - int operator--(int) { ADD("TestClass1::operator--"); return 0; } + + // slightly different to avoid duplicate test rows +#define ADD2(x) QTest::newRow(x ".postfix") << Q_FUNC_INFO << x; + int operator++(int) { ADD2("TestClass1::operator++"); return 0; } + int operator--(int) { ADD2("TestClass1::operator--"); return 0; } +#undef ADD2 int nested_struct() { @@ -530,7 +536,7 @@ void tst_qmessagehandler::cleanupFuncinfo_data() QTest::newRow("msvc_28") << "class std::map<long,void const *,struct std::less<long>,class std::allocator<struct std::pair<long const ,void const *> > > *__thiscall TestClass2<class std::map<long,void const *,struct std::less<long>,class std::allocator<struct std::pair<long const ,void const *> > > >::func_template1<class TestClass2<class std::map<long,void const *,struct std::less<long>,class std::allocator<struct std::pair<long const ,void const *> > > >>(void)" << "TestClass2::func_template1"; - QTest::newRow("gcc_21") + QTest::newRow("gcc_28") << "T* TestClass2<T>::func_template1() [with S = TestClass2<std::map<long int, const void*, std::less<long int>, std::allocator<std::pair<const long int, const void*> > > >, T = std::map<long int, const void*, std::less<long int>, std::allocator<std::pair<const long int, const void*> > >]" << "TestClass2::func_template1"; @@ -599,6 +605,34 @@ void tst_qmessagehandler::cleanupFuncinfo_data() << "int TestClass1::operator>(int)" << "TestClass1::operator>"; + QTest::newRow("gcc_40") + << "Polymorphic<void (*)(int)>::~Polymorphic()" + << "Polymorphic::~Polymorphic"; + + QTest::newRow("gcc_41") + << "function<void (int*)>()::S::f()" + << "function()::S::f"; + + QTest::newRow("msvc_41") + << "void `void function<void __cdecl(int *)>(void)'::`2'::S::f(void)" + << "function(void)'::`2'::S::f"; + + QTest::newRow("gcc_42") + << "function<Polymorphic<void (int*)> >()::S::f(Polymorphic<void (int*)>*)" + << "function()::S::f"; + + QTest::newRow("msvc_42") + << "void `void function<Polymorphic<void __cdecl(int *)> >(void)'::`2'::S::f(Polymorphic<void __cdecl(int *)> *)" + << "function(void)'::`2'::S::f"; + + QTest::newRow("gcc_lambda_1") << "main(int, char**)::<lambda()>" + << "main(int, char**)::<lambda()>"; + + QTest::newRow("gcc_lambda_with_auto_1") + << "SomeClass::someMethod(const QString&, const QString&)::<lambda(auto:57)> [with " + "auto:57 = QNetworkReply::NetworkError]" + << "SomeClass::someMethod(const QString&, const QString&)::<lambda(auto:57)>"; + QTest::newRow("objc_1") << "-[SomeClass someMethod:withArguments:]" << "-[SomeClass someMethod:withArguments:]"; @@ -614,6 +648,14 @@ void tst_qmessagehandler::cleanupFuncinfo_data() QTest::newRow("objc_4") << "__31-[SomeClass someMethodSchedulingBlock]_block_invoke" << "__31-[SomeClass someMethodSchedulingBlock]_block_invoke"; + + QTest::newRow("thunk-1") + << "non-virtual thunk to QFutureWatcherBasePrivate::postCallOutEvent(QFutureCallOutEvent const&)" + << "QFutureWatcherBasePrivate::postCallOutEvent"; + + QTest::newRow("thunk-2") + << "virtual thunk to std::basic_iostream<char, std::char_traits<char> >::~basic_iostream()" + << "std::basic_iostream::~basic_iostream"; } #endif @@ -634,6 +676,41 @@ void tst_qmessagehandler::cleanupFuncinfo() QEXPECT_FAIL("TestClass1::nested_struct_const", "Nested function processing is broken", Continue); QTEST(QString::fromLatin1(result), "expected"); } + +void tst_qmessagehandler::cleanupFuncinfoBad_data() +{ + QTest::addColumn<QByteArray>("funcinfo"); + + auto addBadFrame = [i = 0](const char *symbol) mutable { + QTest::addRow("%d", ++i) << QByteArray(symbol); + }; + addBadFrame("typeinfo for QEventLoop"); + addBadFrame("typeinfo name for QtPrivate::ResultStoreBase"); + addBadFrame("typeinfo name for ._anon_476"); + addBadFrame("typeinfo name for std::__1::__function::__base<bool (void*, void*)>"); + addBadFrame("vtable for BezierEase"); + addBadFrame("vtable for Polymorphic<void ()>"); + addBadFrame("vtable for Polymorphic<void (*)(int)>"); + addBadFrame("TLS wrapper function for (anonymous namespace)::jitStacks"); + addBadFrame("lcCheckIndex()::category"); + addBadFrame("guard variable for lcEPDetach()::category"); + addBadFrame("guard variable for QImageReader::read(QImage*)::disableNxImageLoading"); + addBadFrame("VTT for std::__1::ostrstream"); + addBadFrame("qIsRelocatable<(anonymous namespace)::Data>"); + addBadFrame("qt_incomplete_metaTypeArray<(anonymous namespace)::qt_meta_stringdata_CLASSQNonContiguousByteDeviceIoDeviceImplENDCLASS_t, QtPrivate::TypeAndForceComplete<void, std::integral_constant<bool, true> > >"); + addBadFrame("f()::i"); +} + +void tst_qmessagehandler::cleanupFuncinfoBad() +{ + QFETCH(QByteArray, funcinfo); + + // A corrupted stack trace may find non-sensical symbols that aren't + // functions. The result doesn't matter, so long as we don't crash or hang. + + QByteArray result = qCleanupFuncinfo(funcinfo); + qDebug() << "Decode of" << funcinfo << "produced" << result; +} #endif void tst_qmessagehandler::qMessagePattern_data() @@ -725,6 +802,10 @@ void tst_qmessagehandler::qMessagePattern_data() #ifdef __GLIBC__ # if QT_CONFIG(static) // These test cases don't work with static Qt builds +# elif !defined(Q_PROCESSOR_X86) + // On most RISC platforms, call frames do not have to be stored to the + // stack (the return pointer may be saved in any callee-saved register), so + // this test isn't reliable. # elif defined(QT_ASAN_ENABLED) // These tests produce far more call frames under ASan # else @@ -735,10 +816,9 @@ void tst_qmessagehandler::qMessagePattern_data() "[MyClass::myFunction|MyClass::mySlot1|?" BACKTRACE_HELPER_NAME "?|", // QMetaObject::invokeMethodImpl calls internal function - // (QMetaMethodPrivate::invokeImpl, at the tims of this writing), which + // (QMetaMethodPrivate::invokeImpl, at the time of this writing), which // will usually show only as ?libQt6Core.so? or equivalent, so we skip - // end of backtrace, actual message "|" QT_NAMESPACE_STR "QMetaObject::invokeMethodImpl] from_a_function 34" }; QTest::newRow("backtrace") << "[%{backtrace}] %{message}" << true << expectedBacktrace; @@ -906,11 +986,9 @@ QString tst_qmessagehandler::backtraceHelperPath() #ifdef Q_OS_ANDROID QString appExe(QCoreApplication::applicationDirPath() + QLatin1String("/lib" BACKTRACE_HELPER_NAME ".so")); -#elif defined(Q_OS_WEBOS) +#else QString appExe(QCoreApplication::applicationDirPath() + QLatin1String("/" BACKTRACE_HELPER_NAME)); -#else - QString appExe(QLatin1String(HELPER_BINARY)); #endif return appExe; } diff --git a/tests/auto/corelib/global/qlogging/tst_qmessagelogger.cpp b/tests/auto/corelib/global/qlogging/tst_qmessagelogger.cpp index 4466c1b36b..9c6b9e275d 100644 --- a/tests/auto/corelib/global/qlogging/tst_qmessagelogger.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qmessagelogger.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <qlogging.h> #include <qloggingcategory.h> |