summaryrefslogtreecommitdiffstats
path: root/src/testlib
Commit message (Collapse)AuthorAgeFilesLines
* Doc: add missing "see also"Volker Hilsheimer2022-07-041-0/+1
| | | | | | Pick-to: 6.4 Change-Id: Ibeb7d48a8c4c3e0e2000280bd85db943fc73c1c7 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QCOMPARE: Fix a typo in the documentationLaszlo Papp2022-07-011-1/+1
| | | | | Change-Id: If21359397ef7873592b94838647aee121b84b33a Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* qtestlib: exit with error if a test is invoked with unknown data tagDimitrios Apostolou2022-06-281-21/+22
| | | | | | | | | | | | | | Previously trying to execute a test function with an unknown data tag would print an error message but exit with 0. This patch stores a test failure, and continues trying to execute the rest of the command line arguments, if any. In the end the process exits with the usual exit code (number of failed tests) which is now !=0. Pick-to: 6.4 6.3 6.2 Fixes: QTBUG-24240 Change-Id: Id4d422035f173e01e77ca88028dfd94dc0f9085c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* FatalSignalHandler: print some more information from siginfo_tThiago Macieira2022-06-281-6/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | The siginfo_t parameter allows us to show what process sent a signal or the crashing address. Additionally, it allows us to determine if the crashing signal was indeed sent due to a crash. The selftest tst_crashes produces now: $ QTEST_DISABLE_STACK_DUMP=1 ./crashes ********* Start testing of tst_Crashes ********* Config: Using QtTest library 6.4.0, Qt 6.4.0 (x86_64-little_endian-lp64 shared (dynamic) debug build; by GCC 11.2.1 20220420 [revision 691af15031e00227ba6d5935c1d737026cda4129]), opensuse-tumbleweed 20220428 PASS : tst_Crashes::initTestCase() Received signal 11 (SIGSEGV), code 1, for address 0x0000000000000004 Function time: 0ms, total time: 0ms [1] 201995 segmentation fault (core dumped) QTEST_DISABLE_STACK_DUMP=1 ./crashes The last line comes from the shell. The code isn't decoded, but on Linux it's a SEGV_MAPERR. macOS prints exactly the same thing. I've updated one of the expected_crashes_*.txt output that doesn't seem possible (the "Received a fatal error" message does not appear in Qt anywhere). Pick-to: 6.4 Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16ebc8391234f0e2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTest: switch some text-conversion functions to use qsizetypeMårten Nordheim2022-06-282-12/+10
| | | | | | | | | To avoid potential narrowing. Pick-to: 6.4 Task-number: QTBUG-104125 Change-Id: I37bfc5c49e7c919f5204a76a905758a92527d864 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Doc: Revise Qt Test Module landing pageAndreas Eliasson2022-06-271-21/+24
| | | | | | | | | | | | Most of the module landing pages now follow a certain content structure. In this case, the reference section should be placed before the licenses and attributions section. Also, to make the wording consistent across all module landing pages, use the globally available word snippets. Pick-to: 6.4 Change-Id: I2b2164eb1b8a0eb91db0f1efea8390956d54b29e Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Add the qt_class pragma to file listed in sync.profile classnames mapAlexey Edelev2022-06-221-0/+4
| | | | | | | | | This makes header files self-contained and reduces the number of 'sources of truth' for syncqt procedure. Change-Id: I7f5865abc69934603139d23e1b5452da46ccb110 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Revise Qt Test tutorialAndreas Eliasson2022-06-214-34/+177
| | | | | | | | | | | - Make it explicit that each chapter can be run as a stand-alone test application - Add a CMake section on how to build the executable Task-number: QTBUG-103730 Pick-to: 6.4 6.3 Change-Id: Id4c87c454521f698dcf16cfdc176318dd3e16786 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Fix typos in docs and commentsKai Köhne2022-06-154-5/+5
| | | | | | | | | Found by codespell Pick-to: 6.4 Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Don't exit(1) on unrecognised test function name, just report a failureEdward Welbourne2022-06-151-9/+23
| | | | | | | | | | This way, if you name several test functions on the command-line, you'll at least get the ones that do exist run (and you'll be told all of the ones that don't exist, rather than only the first). Pick-to: 6.4 6.3 6.2 Change-Id: I14a515fcfacb6ca49e0470b236c05475b25db4f2 Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
* FatalSignalHandler: print the signal name on crashThiago Macieira2022-06-081-2/+34
| | | | | | | | | | | | | It's easier to remember what "SIGSEGV" means instead of "11". GNU libc has offered sigabbrev_np() (non-portable) since 2.32; for older libcs, we'll be happy with a hardcoded list. Selftest updated to match... though it didn't seem to be necessary. Pick-to: 6.4 Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16ebc66ecf6e9465 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QTest: Remove pre-Qt6 codeMårten Nordheim2022-06-081-10/+0
| | | | | | | | | It's disabled now, so can be deleted Pick-to: 6.4 6.3 6.2 Change-Id: I0d548327e7ef42bbca9ed88556bf9f8456038cc7 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Define out unused functions on WASM buildMikolaj Boc2022-06-081-5/+7
| | | | | | | | | | | | | | | The struct iovec conversion functions that are needed on Unix are unused on WASM build. This makes the build fail with -Werror on Mac since the WASM build is treated as a variant of Unix. Cross-compilation with clang: Apple clang version 13.0.0 (clang-1300.0.27.3) Target: arm64-apple-darwin21.3.0 Fixes: QTBUG-103974 Pick-to: 6.3 6.4 Change-Id: I34c65a18832ceedb9064a98f5729e45667749461 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTestLib: improve documentationIvan Solovev2022-06-082-0/+14
| | | | | | | | | | | | Add missing '\since' version numbers. This commit amends cc6d984390dc937b9d8440b6ba7d4f578e22ac0d and 0681a2dd5a8095baddb5905fb21a58ce19b958c5 Pick-to: 6.4 Change-Id: Ia10b991c996fb58f08a17e485c4dfcbfbe8eba0a Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* qtestcase.cpp: create a common function to print the test runtimeThiago Macieira2022-06-031-12/+28
| | | | | | | | | | | The time was getting printed twice for the stack trace, but zero for the watch dog if the stack trace was disabled. Selftest appears to pass (though I thought it shouldn't). Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16ebc4ec99e7fc5a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QCOMPARE/QVERIFY: fix huge pessimisation in QTestResult::reportResultMarc Mutz2022-06-031-1/+2
| | | | | | | | | | | | | | | | The old code allocated a stack buffer, but asked the runtime to zero-initialize it. That's 1KiB of writes to the stack on every QCOMPARE and QVERIFY before any actual work is done. Fixing this little laissez-faire to just initialize the first character in the buffer results in nice little speedups of ~40%. This fixes the issue in reportResult(), a Cut'n'paste from compare() and verify(), which have since been fixed by a previous commit. Change-Id: I5cad57299490925b88e768dc751304699274db2e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QTestLib: rework QTest::compare_helper()Ivan Solovev2022-06-036-28/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ChangeLog][QTestLib] QCOMPARE now evaluates toString() on its arguments lazily, speeding up the general case where the comparison doesn't fail. This is true for the QCOMPARE functionality provided by Qt. If you specialized qCompare() for your own types, then you need to change its implementation in line with Qt's own qCompare() specializations in order to enable this feature. [ChangeLog][QTestLib] QCOMPARE calls with nullptr argument(s) will now print the actual and expected values upon failure. Previously it was not like that because of the compareHelper() overload in qtestresult.cpp that treated the presence of nullptr-arguments as a reason to ignore formatFailMessage() call. New implementation does not have this check, and correctly executes formatFailMessage() for all arguments. Note that the qCompare() overloads that call QTestResult::compare() internally were not affected by this patch, because they already defer toString() invocation until the comparison fails. Some numbers, collected against shared release developer build. I checked how this change affects the test execution. The idea was to pick some tests for types that do not have a specific QTestResult::compare overload, so I picked a couple of QByteArray tests. The comparison is done by running a test 10 times and taking the average execution duration, as reported in the log. tst_qbytearrayapisymmetry: Before: 15.6 ms After: 14.2 ms tst_qbytearray: Before: 41 ms After: 36 ms The benefit is around 9% and 12% respectively. Fixes: QTBUG-98874 Change-Id: I7d59ddc760168b15974e7720930f629fb34efa13 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add QTRY_COMPARE_{EQ,NE,LT,LE,GT,GE}_WITH_TIMEOUT()Ivan Solovev2022-06-032-0/+186
| | | | | | | | | | | | [ChangeLog][QTestLib] Add QTRY_COMPARE_{EQ,NE,LT,LE,GT,GE}_WITH_TIMEOUT macros that repeatedly execute QCOMPARE_{EQ,NE,LT,LE,GT,GE} until either the comparison returns true or the timeout expires. Also add QTRY_COMPARE_{EQ,NE,LT,LE,GT,GE} macros that simply invoke the *_WITH_TIMEOUT versions with the usual timeout of five seconds. Task-number: QTBUG-98873 Change-Id: Ib0d7d1c8c997f442b46acd85da738a8f512cc875 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add QCOMPARE_{EQ,NE,LT,LE,GT,GE}()Ivan Solovev2022-06-036-18/+306
| | | | | | | | | | | | | | | | | | | | | [ChangeLog][QTestLib] Add QCOMPARE_{EQ,NE,LT,LE,GT,GE}() macros. These new macros behave similarly to QVERIFY(a op b), where 'op' is ==, !=, <, <=, >, >= respectively, but print a formatted error message with argument values in case of failure. The formatting is done lazily, which means that the strings will be generated only when the comparison fails. Also add a new test for tst_selftest and generate expected output for it. Fixes: QTBUG-98873 Task-number: QTBUG-98874 Change-Id: Ic8074798901d7a469b1f58d5cd28bbf49a3da1db Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Testlib: teach TAP test logger to support new QCOMPARE_* operatorsIvan Solovev2022-06-031-10/+67
| | | | | | | | | | | | | | | | | | | | | | The TAP test logger will now correctly print comparison types such as QCOMPARE_NE or QCOMPARE_LT, and also provide a proper expected/wanted value (by adding proper arithmetical operators in front of the value). Sample output: type: QCOMPARE_GE message: Left value is expected to be greater than or equal to right value, but is not wanted: >= 1 (rhs) found: 0 (lhs) expected: >= 1 (rhs) actual: 0 (lhs) at: tst_ExtendedCompare::compareUnregistereEnum() (tst_extendedcompare.cpp:232) file: tst_extendedcompare.cpp line: 232 As a drive-by: make some variables const. Task-number: QTBUG-98873 Change-Id: Idb54eaabcb937b42d3fc844f30041aab82d73f69 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QCOMPARE/QVERIFY: fix huge pessimisation in QTestResultMarc Mutz2022-06-031-2/+4
| | | | | | | | | | | | | | | | | | | | | | | The old code allocated a stack buffer, but asked the runtime to zero-initialize it. That's 1KiB of writes to the stack on every QCOMPARE and QVERIFY before any actual work is done. Fixing this little laissez-faire to just initialize the first character in the buffer results in nice little speedups of up to or exceeding 2x. Amends d946507727b363326d05f48da93c2af04bdda76d. [ChangeLog][QtTestLib] Optimized successful QCOMPARE and QVERIFY for an up to 2x speedup. This has the potential to meaningfully reduce the load on the CI, so picking all the way to 5.15. Pick-to: 6.3 6.2 5.15 Change-Id: Ib93d69282ec87cbd26a60e4ac14413e8cef8ff78 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QtTest: move the disabling of core dumps from load-time to qInit()Thiago Macieira2022-06-011-2/+2
| | | | | | | | | | | | | There's no reason it has to be done THAT early. It was added in commit aec85a53df3dbe3047c6db0f6eb39cb161cd3e6b to have the selftests (which do crash) not leave lots of core files around. I could replace it with a QProcess::setChildProcessModifier() function, but the variable is now documented in the QtTest manual, so it would be no gain. Function renamed to reflect its implementation. Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16ebc25df97a98e3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Use a precise timer in QTestEventLoop if timeout is sub-secondVolker Hilsheimer2022-05-311-1/+2
| | | | | | | | | | | | QTestEventLoop is used by QSignalSpy::wait. If tests want to verify that a signal gets emitted within a second or less, we should use a precise timer to reduce the chance of timer imprecision breaking the test. Change-Id: I2a2ca3bbdcaf032288f1fdc2aecc6afd05a6c76c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* FatalSignalHandler: handle SIGABRT tooThiago Macieira2022-05-301-1/+1
| | | | | | | Pick-to: 6.3 Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb77e9c77d10ba Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* FatalSignalHandler: expand to more Unix OSes than just Linux and macOSThiago Macieira2022-05-301-7/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At least for my FreeBSD this makes sense. The default debugger search is gdb first then lldb on Linux-not-Android and for QNX (qcc is GCC after all), but lldb first everywhere else. With LLVM14 from Ports, I get: $ tests/auto/corelib/tools/qhashseed/tst_qhashseed | head -1 ********* Start testing of tst_QHashSeed ********* Config: Using QtTest library 6.4.0, Qt 6.4.0 (x86_64-little_endian-lp64 shared (dynamic) debug build; by Clang 14.0.0), freebsd 13.0 === Received signal at function time: 1ms, total time: 3ms, dumping stack === (lldb) process attach --pid 1782 Process 1782 stopped Executable module set to "/usr/home/tjmaciei/obj/qt/qt6/qtbase/tests/auto/corelib/tools/qhashseed/tst_qhashseed". Architecture set to: x86_64--freebsd13.0. (lldb) bt all * thread #1, name = 'tst_qhashseed' * frame #0: 0x0000000800f227c8 libc.so.7`_wait4 at _wait4.S:4 frame #1: 0x00000008003243bc libthr.so.3`__thr_wait4(pid=<unavailable>, status=<unavailable>, options=<unavailable>, rusage=<unavailable>) at thr_syscalls.c:581:8 frame #2: 0x00000008002b9c73 libQt6Test.t.so.6`(anonymous namespace)::StackTraceHandler::generate() at qtestcase.cpp:393:9 [...] === End of stack trace === Received signal 13 Function time: 1ms Total time: 3ms Support for Windows left as an exercise for later. The WindowsFaultHandler code doesn't even call generateStackTrace(). Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eba471f58ff3cb Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* FatalSignalHandler: use mmap() to create the alternate stackThiago Macieira2022-05-301-21/+67
| | | | | | | | | | | | So we can mark the bottom page as inaccessible, thus be able to catch a stack overflow in the handler itself. Our code shouldn't cause overflows, but it's possible that a chained handler does more work than expected. Pick-to: 6.3 Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb83a294ab7958 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* StackTraceHandler: call the debugger directly, instead of via /bin/shThiago Macieira2022-05-231-14/+29
| | | | | | | | | | | | | This removes one middle-man and a 512-byte variable in favor of a simple 32-bit enum. This was done in a way so we can extend to use either gdb or lldb in any OS. I've renamed the debuggerPresent() function to make its meaning clearer. Pick-to: 6.3 Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eba561628ff89b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* StackTraceHandler: simplify the gdb and lldb commandsThiago Macieira2022-05-231-11/+2
| | | | | | | | | | Instead of piping stuff via the shell into them, just use batch mode. And also take the opportunity to tell them not to read their user- provided configuration files. Pick-to: 6.3 Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eba21e71afaefa Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* FatalSignalHandler: chain back to the original crash handlerThiago Macieira2022-05-201-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | If a previous handler was already installed, ensure it is called, because there may be a reason why it was there. For example, the Android ART adds a signal action to every fatal signal for logging purposes. We do that by restoring the signal handler we had and re-raising the signal. If our handler was overridden by something else, then that handler was already called, but will get uninstalled after our code runs. It won't be a problem, because the application is exiting anyway. [ChangeLog][QtTest][Behavior Change] On Unix, the QtTest code to handle Unix/POSIX fatal signals will now call back to the original handler that was installed, if there was one. This allows logging frameworks (such as Android ART's), for example, to log the crash too. Additionally, if there was no handler, the application should exit with the correct signal instead of SIGABRT. Fixes: QTBUG-97652 Pick-to: 6.3 Change-Id: Ifc4fca159b490d8d0b614d736e46caefcb903a4c Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* FatalSignalHandler: remember the previous signal's handlerThiago Macieira2022-05-201-41/+23
| | | | | | | | | | | | And only restore those signals, instead of iterating over all possible signals, instead of attempting to restore to SIG_DFL. Also, as a consequence, we will install our handler even if there was already a handler installed for the signal. Pick-to: 6.3 Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb756685f4e8b8 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* FatalSignalHandler: simplify SA_RESETHAND codeThiago Macieira2022-05-201-13/+6
| | | | | | | | | And remove the unreachable code after std::abort() that was meant to mimic that in INTEGRITY. The next commit will fix this properly. Pick-to: 6.3 Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb772018add694 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* FatalSignalHandler: simplify the SA_SIGINFO handlingThiago Macieira2022-05-201-9/+10
| | | | | | | | | The #if around the function declaration was ugly. Pick-to: 6.3 Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb7540f5da080f Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* FatalSignalHandler: use std::optional instead of QScopedPointerThiago Macieira2022-05-201-2/+4
| | | | | | | | We get stack space reserved instead of using the heap. Pick-to: 6.3 Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb73fff0174150 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* FatalSignalHandler: split the Windows and Unix contentsThiago Macieira2022-05-201-57/+58
| | | | | | | | | | | | They're very different, so there's no point in having them even in the same class body. I've renamed the Windows one because Windows does not report crashes via signals anyway. If you have an IDE that can scan both branches of the #if, it will help you find the Windows-specific code too. Pick-to: 6.3 Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb73ba196cfb74 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Put DebugSymbolResolver and FatalSignalHandler in an unnamed namespaceThiago Macieira2022-05-201-1/+4
| | | | | | | Pick-to: 6.3 Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb735315b337b6 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* FatalSignalHandler: remove call to qEnvironmentXxx from handler codeThiago Macieira2022-05-201-1/+6
| | | | | | | | | | | | | | The Qt environment handling functions lock a mutex. That's a big no-no in signal handlers. [ChangeLog][QtTest][Behavior Change] QtTest will now check the value of the environment variable QTEST_PAUSE_ON_CRASH in QTest::qRun(), so if a test wants to modify this variable, it must do so from the main() or initMain() functions, not in the test itself (including initTestCase()). Pick-to: 6.3 Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb78867cd8f54e Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* qtestcase: make the stack trace generation more signal-safeThiago Macieira2022-05-201-25/+44
| | | | | | | | | | This should work so long as there's no async-unsafe pthread_atfork()- registered callback. Pick-to: 6.3 Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb72e4e313bc19 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* qtestcase.cpp: fix warning about ignoring the result of writev()Thiago Macieira2022-05-191-2/+2
| | | | | | | | I don't get it on openSUSE Tumbleweed, but this is not the only place I don't get a warn_unused_result warning and it happens elsewhere. Change-Id: I7e305799c8594ebab255fffd16ee12ff30df6d4d Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Use QAbstractItemModelTester or QFileSystemModelAndreas Buhr2022-05-182-4/+21
| | | | | | | | | | | | This patch enables usage of QAbstractItemModelTester on QFileSystemModel. QAbstractItemModelTester called fetchMore() on all items. QFileSystemModel represents the whole file system. This led to very long test runs. To avoid this, this patch introduces a new feature in QAbstractItemModelTester, namely to disable calling of fetchMore(). Change-Id: Ie5d2e22fa4c143be7c080d9f79632cd2cbe07aac Reviewed-by: David Faure <david.faure@kdab.com>
* Use SPDX license identifiersLucie Gérard2022-05-16100-3808/+207
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add missing header files to the module sourcesAlexey Edelev2022-05-121-0/+3
| | | | | | | | | All module header files should be listed in the corresponding sections of modules SOURCEs to be accessible in CMake routines. Task-number: QTBUG-103196 Change-Id: Ieb77ae70557e35e546a5b00387e1e0aa40338239 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* qtestcase/Unix: remove fprintf from signal handlerThiago Macieira2022-05-051-8/+100
| | | | | | | | | | | It's not async-signal-safe, so don't use it. Instead, let's use writev() (which should write atomically and we won't need to have a buffer) and std::to_chars to format numbers where available (where not, we roll out our own implementation with divisions). Pick-to: 6.3 Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb70a158f44864 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* De-pessimize QBenchmarkValgrindUtils::extractResult()Marc Mutz2022-05-051-8/+12
| | | | | | | | | | | | | | As if QIODevice::readLine() and QIODevice::Text open-mode aren't slow enough, the old code took the line QByteArray, converted it to a QString so it could apply a trivial regex to it: '^summary: (\d+)'. We can, of course, use QByteArray::startsWith("summary: ") followed by std::from_chars(), these days, to get the same effect, without having to JIT-compile an RX and convert every line into UTF-16 first. Change-Id: I20d80ffb469329d3c3efd08c71fcf5abf9f486d3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* qtestcase.cpp: use #ifdef RLIMIT_CORE to guard RLIMIT_CORE usageThiago Macieira2022-05-041-2/+2
| | | | | | | Instead of trying to guess which OSes have this functionality. Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16ebc20fe7eca346 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QTeamCityLogger: fix .arg() placeholder injectionMarc Mutz2022-05-041-3/+2
| | | | | | | | | | | | | | Since each .arg() call starts from scratch, a file name containing a suitable %n would mess up the formatting of the following .arg() call. Fix by using multiArg(), which requires to pre-format the line into a QString, but which performs only a single-pass, so doesn't suffer from the placeholder injection problem that plagues .arg()-chaining. Pick-to: 6.3 6.2 5.15 Change-Id: I549527643da657fca0bea63d5e3becadac529d4b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QBenchmarkValgrindUtils::extractResult(): use std::optionalMarc Mutz2022-05-031-5/+5
| | | | | | | | | | ... instead of a pair of val and valSeen variables. More elegant. Pick-to: 6.3 Change-Id: I0fcf9a3b5611e30fb81d92619993a7828496cd1b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QAbstractTestLogger: disable copyingMarc Mutz2022-05-031-0/+1
| | | | | | | | | Fixes clazy-copyable-polymorphic. Pick-to: 6.3 6.2 5.15 Change-Id: I31a68da6e402ada91099b09540b29a1d56f9cc56 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QTestLog: simplify construction of a log messageSona Kurazyan2022-05-021-2/+5
| | | | | Change-Id: I055efa45ec468cae43a38a9746a47af0382ca8c1 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QtTestLib: replace remaining uses of QL1String with QL1StringViewSona Kurazyan2022-05-028-35/+36
| | | | | | | | | Remove unneeded \fn qdoc lines as a drive-by. Task-number: QTBUG-98434 Change-Id: Id93ddbb38b97a8f5a6734bfbc82686ccb3a87aa6 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QtTestLib: replace QLatin1String uses with _L1/_s/QStringLiteralSona Kurazyan2022-05-027-82/+88
| | | | | | | Task-number: QTBUG-98434 Change-Id: Ie327fd4af1880002e5a1e09b43384f2b709625e7 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>