summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/thread/qthreadstorage
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/thread/qthreadstorage')
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/CMakeLists.txt27
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/crashonexit/CMakeLists.txt13
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/crashonexit/crashOnExit.cpp29
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro16
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro8
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/test/test.pro16
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp87
7 files changed, 71 insertions, 125 deletions
diff --git a/tests/auto/corelib/thread/qthreadstorage/CMakeLists.txt b/tests/auto/corelib/thread/qthreadstorage/CMakeLists.txt
new file mode 100644
index 0000000000..14d8d7dd40
--- /dev/null
+++ b/tests/auto/corelib/thread/qthreadstorage/CMakeLists.txt
@@ -0,0 +1,27 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## tst_qthreadstorage Test:
+#####################################################################
+
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qthreadstorage LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
+qt_internal_add_test(tst_qthreadstorage
+ SOURCES
+ tst_qthreadstorage.cpp
+)
+
+## Scopes:
+#####################################################################
+
+if(NOT ANDROID)
+ add_subdirectory(crashonexit)
+ if(QT_FEATURE_process)
+ add_dependencies(tst_qthreadstorage crashOnExit_helper)
+ endif()
+endif()
diff --git a/tests/auto/corelib/thread/qthreadstorage/crashonexit/CMakeLists.txt b/tests/auto/corelib/thread/qthreadstorage/crashonexit/CMakeLists.txt
new file mode 100644
index 0000000000..4d62e61a36
--- /dev/null
+++ b/tests/auto/corelib/thread/qthreadstorage/crashonexit/CMakeLists.txt
@@ -0,0 +1,13 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## crashonexit Binary:
+#####################################################################
+
+qt_internal_add_executable(crashOnExit_helper
+ OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.."
+ INSTALL_DIRECTORY "${INSTALL_TESTSDIR}/tst_qthreadstorage/crashOnExit_helper"
+ SOURCES
+ crashOnExit.cpp
+)
diff --git a/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashOnExit.cpp b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashOnExit.cpp
index 5a42156b85..3b3a4d4813 100644
--- a/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashOnExit.cpp
+++ b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashOnExit.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/QCoreApplication>
#include <QtCore/QThreadStorage>
diff --git a/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro
deleted file mode 100644
index 57bd78bcee..0000000000
--- a/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-SOURCES += crashOnExit.cpp
-debug_and_release {
- CONFIG(debug, debug|release) {
- TARGET = ../../debug/crashOnExit_helper
- } else {
- TARGET = ../../release/crashOnExit_helper
- }
-} else {
- TARGET = ../crashOnExit_helper
-}
-QT = core
-CONFIG += cmdline
-
-# This app is testdata for tst_qthreadstorage
-target.path = $$[QT_INSTALL_TESTS]/tst_qthreadstorage/$$TARGET
-INSTALLS += target
diff --git a/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro b/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro
deleted file mode 100644
index 432c564ba1..0000000000
--- a/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-TEMPLATE = subdirs
-
-!android:!winrt {
- test.depends = crashonexit
- SUBDIRS += crashonexit
-}
-
-SUBDIRS += test
diff --git a/tests/auto/corelib/thread/qthreadstorage/test/test.pro b/tests/auto/corelib/thread/qthreadstorage/test/test.pro
deleted file mode 100644
index d2f21f48f0..0000000000
--- a/tests/auto/corelib/thread/qthreadstorage/test/test.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-CONFIG += testcase
-debug_and_release {
- CONFIG(debug, debug|release) {
- TARGET = ../../debug/tst_qthreadstorage
- !android:!winrt: TEST_HELPER_INSTALLS = ../../debug/crashonexit_helper
- } else {
- TARGET = ../../release/tst_qthreadstorage
- !android:!winrt: TEST_HELPER_INSTALLS = ../../release/crashonexit_helper
- }
-} else {
- TARGET = ../tst_qthreadstorage
- !android:!winrt: TEST_HELPER_INSTALLS = ../crashonexit_helper
-}
-CONFIG += console
-QT = core testlib
-SOURCES = ../tst_qthreadstorage.cpp
diff --git a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp
index 3538d90803..ca382cf60c 100644
--- a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp
+++ b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp
@@ -1,32 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QTest>
+#if QT_CONFIG(process)
+#include <QProcess>
+#endif
+#include <QTestEventLoop>
#include <qcoreapplication.h>
#include <qmutex.h>
@@ -76,7 +55,7 @@ void tst_QThreadStorage::hasLocalData()
QVERIFY(!pointers.hasLocalData());
pointers.setLocalData(new Pointer);
QVERIFY(pointers.hasLocalData());
- pointers.setLocalData(0);
+ pointers.setLocalData(nullptr);
QVERIFY(!pointers.hasLocalData());
}
@@ -88,8 +67,8 @@ void tst_QThreadStorage::localData()
pointers.setLocalData(p);
QVERIFY(pointers.hasLocalData());
QCOMPARE(pointers.localData(), p);
- pointers.setLocalData(0);
- QCOMPARE(pointers.localData(), (Pointer *)0);
+ pointers.setLocalData(nullptr);
+ QCOMPARE(pointers.localData(), nullptr);
QVERIFY(!pointers.hasLocalData());
}
@@ -102,8 +81,8 @@ void tst_QThreadStorage::localData_const()
pointers.setLocalData(p);
QVERIFY(pointers.hasLocalData());
QCOMPARE(const_pointers.localData(), p);
- pointers.setLocalData(0);
- QCOMPARE(const_pointers.localData(), (Pointer *)0);
+ pointers.setLocalData(nullptr);
+ QCOMPARE(const_pointers.localData(), nullptr);
QVERIFY(!pointers.hasLocalData());
}
@@ -113,7 +92,7 @@ void tst_QThreadStorage::setLocalData()
QVERIFY(!pointers.hasLocalData());
pointers.setLocalData(new Pointer);
QVERIFY(pointers.hasLocalData());
- pointers.setLocalData(0);
+ pointers.setLocalData(nullptr);
QVERIFY(!pointers.hasLocalData());
}
@@ -129,7 +108,7 @@ public:
: pointers(p)
{ }
- void run()
+ void run() override
{
pointers.setLocalData(new Pointer);
@@ -157,7 +136,7 @@ void tst_QThreadStorage::autoDelete()
QCOMPARE(Pointer::count, c);
}
-bool threadStorageOk;
+static bool threadStorageOk;
void testAdoptedThreadStorageWin(void *p)
{
QThreadStorage<Pointer *> *pointers = reinterpret_cast<QThreadStorage<Pointer *> *>(p);
@@ -180,17 +159,10 @@ void testAdoptedThreadStorageWin(void *p)
}
QObject::connect(QThread::currentThread(), SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
}
-#ifdef Q_OS_WINRT
-unsigned __stdcall testAdoptedThreadStorageWinRT(void *p)
-{
- testAdoptedThreadStorageWin(p);
- return 0;
-}
-#endif
void *testAdoptedThreadStorageUnix(void *pointers)
{
testAdoptedThreadStorageWin(pointers);
- return 0;
+ return nullptr;
}
void tst_QThreadStorage::adoptedThreads()
{
@@ -201,14 +173,9 @@ void tst_QThreadStorage::adoptedThreads()
{
#ifdef Q_OS_UNIX
pthread_t thread;
- const int state = pthread_create(&thread, 0, testAdoptedThreadStorageUnix, &pointers);
+ const int state = pthread_create(&thread, nullptr, testAdoptedThreadStorageUnix, &pointers);
QCOMPARE(state, 0);
- pthread_join(thread, 0);
-#elif defined Q_OS_WINRT
- HANDLE thread;
- thread = (HANDLE) _beginthreadex(NULL, 0, testAdoptedThreadStorageWinRT, &pointers, 0, 0);
- QVERIFY(thread);
- WaitForSingleObjectEx(thread, INFINITE, FALSE);
+ pthread_join(thread, nullptr);
#elif defined Q_OS_WIN
HANDLE thread;
thread = (HANDLE)_beginthread(testAdoptedThreadStorageWin, 0, &pointers);
@@ -224,7 +191,7 @@ void tst_QThreadStorage::adoptedThreads()
QTRY_COMPARE(Pointer::count, c);
}
-QBasicAtomicInt cleanupOrder = Q_BASIC_ATOMIC_INITIALIZER(0);
+static QBasicAtomicInt cleanupOrder = Q_BASIC_ATOMIC_INITIALIZER(0);
class First
{
@@ -261,7 +228,7 @@ void tst_QThreadStorage::ensureCleanupOrder()
: first(first), second(second)
{ }
- void run()
+ void run() override
{
// set in reverse order, but shouldn't matter, the data
// will be deleted in the order the thread storage objects
@@ -305,11 +272,14 @@ static inline bool runCrashOnExit(const QString &binary, QString *errorMessage)
void tst_QThreadStorage::crashOnExit()
{
+#ifdef Q_OS_ANDROID
+ QSKIP("Can't start QProcess to run a custom user binary on Android");
+#endif
#if !QT_CONFIG(process)
QSKIP("No qprocess support", SkipAll);
#else
QString errorMessage;
- QVERIFY2(runCrashOnExit("crashOnExit_helper", &errorMessage),
+ QVERIFY2(runCrashOnExit("./crashOnExit_helper", &errorMessage),
qPrintable(errorMessage));
#endif
}
@@ -352,7 +322,7 @@ void tst_QThreadStorage::leakInDestructor()
Thread(QThreadStorage<ThreadStorageLocalDataTester *> &t) : tls(t) { }
- void run()
+ void run() override
{
QVERIFY(!tls.hasLocalData());
tls.setLocalData(new ThreadStorageLocalDataTester);
@@ -404,7 +374,7 @@ void tst_QThreadStorage::resetInDestructor()
class Thread : public QThread
{
public:
- void run()
+ void run() override
{
QVERIFY(!ThreadStorageResetLocalDataTesterTls()->hasLocalData());
ThreadStorageResetLocalDataTesterTls()->setLocalData(new ThreadStorageResetLocalDataTester);
@@ -440,7 +410,8 @@ void tst_QThreadStorage::valueBased()
Thread(QThreadStorage<SPointer> &t1, QThreadStorage<QString> &t2, QThreadStorage<int> &t3)
: tlsSPointer(t1), tlsString(t2), tlsInt(t3) { }
- void run() {
+ void run() override
+ {
/*QVERIFY(!tlsSPointer.hasLocalData());
QVERIFY(!tlsString.hasLocalData());
QVERIFY(!tlsInt.hasLocalData());*/