Revert "Dodge qFatal() so as to get coverage results despite it"
This reverts commit f20adcde30. The
implementation had the right idea, but this is not expected to work
reliably in C++. It's jumping out of several frames without cleaning
them out properly and our ASan-based memory leak-checker has started
complaining (the next commit will move this test elsewhere).
==19313==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 258 byte(s) in 1 object(s) allocated from:
#0 0x7ffa505c8e48 in __interceptor_malloc (/usr/lib64/libasan.so.5+0x109e48)
#1 0x7ffa4f2d7ff9 (/home/qt/work/install/lib/libQt6Core.so.6+0x896ff9)
#2 0x7ffa4f2d834d in QArrayData::allocate(QArrayData**, long long, long long, long long, QArrayData::AllocationOption) (/home/qt/work/install/lib/libQt6Core.so.6+0x89734d)
#3 0x7ffa4f23b700 (/home/qt/work/install/lib/libQt6Core.so.6+0x7fa700)
#4 0x7ffa4f1f6cc8 in QString::reallocData(long long, QArrayData::AllocationOption) (/home/qt/work/install/lib/libQt6Core.so.6+0x7b5cc8)
#5 0x7ffa4f1f68a7 in QString::resize(long long) (/home/qt/work/install/lib/libQt6Core.so.6+0x7b58a7)
#6 0x7ffa4f2092ff (/home/qt/work/install/lib/libQt6Core.so.6+0x7c82ff)
#7 0x7ffa4f209e09 in QString::vasprintf(char const*, __va_list_tag*) (/home/qt/work/install/lib/libQt6Core.so.6+0x7c8e09)
#8 0x7ffa4ed0d83d (/home/qt/work/install/lib/libQt6Core.so.6+0x2cc83d)
#9 0x7ffa4ed114a9 in QMessageLogger::fatal(char const*, ...) const (/home/qt/work/install/lib/libQt6Core.so.6+0x2d04a9)
#10 0x5641d2604c40 in tst_Silent::messages() /home/qt/work/qt/qtbase/tests/auto/testlib/selftests/silent/tst_silent.cpp:77
#11 0x5641d26050fb in tst_Silent::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) tests/auto/testlib/selftests/silent/silent_autogen/include/tst_silent.moc:118
The restoration of the signal handler (which QtTest now has) is also
wrong: this needed to use sigaction() instead.
Change-Id: Ifa1111900d6945ea8e05fffd177f14fbc09a1d7d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
bb10
parent
40e9e42bc6
commit
1c8402dd41
|
|
@ -47,17 +47,6 @@ void tst_Silent::xpass()
|
|||
QVERIFY2(true, "This test should XPASS");
|
||||
}
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
static jmp_buf state;
|
||||
static void abort_handler(int)
|
||||
{
|
||||
longjmp(state, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
void tst_Silent::messages()
|
||||
{
|
||||
qWarning("This is a warning that should not appear in silent test output");
|
||||
|
|
@ -66,15 +55,7 @@ void tst_Silent::messages()
|
|||
qCritical("This is a critical message that should not appear in silent test output");
|
||||
qInfo("This is an info message that should not appear in silent test output");
|
||||
QTestLog::info("This is an internal testlib info message that should not appear in silent test output", __FILE__, __LINE__);
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
// We're testing qFatal, but we don't want to actually std::abort() !
|
||||
auto prior = signal(SIGABRT, abort_handler);
|
||||
if (setjmp(state))
|
||||
signal(SIGABRT, prior);
|
||||
else
|
||||
#endif
|
||||
qFatal("This is a fatal error message that should still appear in silent test output");
|
||||
qFatal("This is a fatal error message that should still appear in silent test output");
|
||||
}
|
||||
|
||||
QTEST_MAIN_WRAPPER(tst_Silent,
|
||||
|
|
|
|||
Loading…
Reference in New Issue