diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2022-11-11 09:29:17 +0200 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2022-11-11 09:29:17 +0200 |
commit | 4ee4fc18b4067b90efa46ca9baba74f53b54d9ec (patch) | |
tree | cc68622c9b85992d99a8373ab55471ee821a4ebf /src/testlib | |
parent | ab28ff2207e8f33754c79793089dbf943d67736d (diff) | |
parent | ebb49c66aaf22ed55d62ff7bc3690fce00b7d8ba (diff) | |
download | qtbase-4ee4fc18b4067b90efa46ca9baba74f53b54d9ec.tar.gz |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.8' into tqtc/lts-5.15-opensourcev5.15.8-lts-lgpl
Change-Id: I569a2246c9e8d70430e8c5405b9f3df2218078ee
Diffstat (limited to 'src/testlib')
-rw-r--r-- | src/testlib/qabstractitemmodeltester.cpp | 2 | ||||
-rw-r--r-- | src/testlib/qtestcase.cpp | 10 | ||||
-rw-r--r-- | src/testlib/qtestcase.h | 3 | ||||
-rw-r--r-- | src/testlib/qtestcase.qdoc | 27 |
4 files changed, 27 insertions, 15 deletions
diff --git a/src/testlib/qabstractitemmodeltester.cpp b/src/testlib/qabstractitemmodeltester.cpp index a2c643660a..8efb9c53d4 100644 --- a/src/testlib/qabstractitemmodeltester.cpp +++ b/src/testlib/qabstractitemmodeltester.cpp @@ -570,7 +570,7 @@ void QAbstractItemModelTesterPrivate::checkChildren(const QModelIndex &parent, i // recursively go down the children if (model->hasChildren(index) && currentDepth < 10) - checkChildren(index, ++currentDepth); + checkChildren(index, currentDepth + 1); // make sure that after testing the children that the index doesn't change. QModelIndex newerIndex = model->index(r, c, parent); diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 979fd6e1d2..c98bcbec40 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -212,13 +212,13 @@ static void stackTrace() if (debuggerPresent() || hasSystemCrashReporter()) return; -#if defined(Q_OS_LINUX) || defined(Q_OS_MACOS) +#if defined(Q_OS_LINUX) || (defined(Q_OS_MACOS) && !defined(Q_PROCESSOR_ARM_64)) const int msecsFunctionTime = qRound(QTestLog::msecsFunctionTime()); const int msecsTotalTime = qRound(QTestLog::msecsTotalTime()); fprintf(stderr, "\n=== Received signal at function time: %dms, total time: %dms, dumping stack ===\n", msecsFunctionTime, msecsTotalTime); -#endif -#ifdef Q_OS_LINUX + +# ifdef Q_OS_LINUX char cmd[512]; qsnprintf(cmd, 512, "gdb --pid %d 2>/dev/null <<EOF\n" "set prompt\n" @@ -231,7 +231,7 @@ static void stackTrace() if (system(cmd) == -1) fprintf(stderr, "calling gdb failed\n"); fprintf(stderr, "=== End of stack trace ===\n"); -#elif defined(Q_OS_MACOS) +# elif defined(Q_OS_MACOS) char cmd[512]; qsnprintf(cmd, 512, "lldb -p %d 2>/dev/null <<EOF\n" "bt all\n" @@ -241,6 +241,8 @@ static void stackTrace() if (system(cmd) == -1) fprintf(stderr, "calling lldb failed\n"); fprintf(stderr, "=== End of stack trace ===\n"); +# endif + #endif } diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index b5aea46689..6c9d23f649 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -101,6 +101,7 @@ do {\ " but no exception caught", __FILE__, __LINE__);\ return;\ } QT_CATCH (const exceptiontype &) {\ + /* success */\ }\ } QT_CATCH (const std::exception &e) {\ QByteArray msg = QByteArray() + "Expected exception of type " #exceptiontype \ @@ -110,7 +111,7 @@ do {\ } QT_CATCH (...) {\ QTest::qFail("Expected exception of type " #exceptiontype " to be thrown" \ " but unknown exception caught", __FILE__, __LINE__);\ - return;\ + QT_RETHROW;\ }\ } while (false) diff --git a/src/testlib/qtestcase.qdoc b/src/testlib/qtestcase.qdoc index e39b47024f..dd5ec762a7 100644 --- a/src/testlib/qtestcase.qdoc +++ b/src/testlib/qtestcase.qdoc @@ -149,15 +149,24 @@ \relates QTest - The QVERIFY_EXCEPTION_THROWN macro executes an \a expression and tries - to catch an exception thrown from the \a expression. If the \a expression - throws an exception and its type is the same as \a exceptiontype - or \a exceptiontype is substitutable with the type of thrown exception - (i.e. usually the type of thrown exception is publicly derived - from \a exceptiontype) then execution will be continued. If not-substitutable - type of exception is thrown or the \a expression doesn't throw an exception - at all, then a failure will be recorded in the test log and - the test won't be executed further. + The QVERIFY_EXCEPTION_THROWN macro executes \a expression + and tries to catch an exception thrown from \a expression. + + There are several possible outcomes: + + \list + \li If \a expression throws an exception that is either the same as + \a exceptiontype or derived from \a exceptiontype, then execution will continue. + + \li Otherwise, if \a expression throws no exception, or the + exception thrown derives from \c{std::exception}, then a failure + will be recorded in the test log and the macro returns early + (from enclosing function). + + \li If the thrown exception derives neither from \c{std::exception} nor from + \a exceptiontype, a failure will be recorded in the test log, and the exception is + re-thrown. This avoids problems with e.g. pthread cancellation exceptions. + \endlist \note This macro can only be used in a test function that is invoked by the test framework. |