summaryrefslogtreecommitdiffstats
path: root/tests/auto/concurrent
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/concurrent')
-rw-r--r--tests/auto/concurrent/CMakeLists.txt3
-rw-r--r--tests/auto/concurrent/qtconcurrentfilter/CMakeLists.txt11
-rw-r--r--tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp83
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/CMakeLists.txt11
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/generation_helpers.h34
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/function_signature.py27
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_excel.py27
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_gui.py27
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_testcase.py27
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generator_main.py27
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/helpers.py27
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/option_management.py27
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrent_selected_tests.cpp29
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.cpp29
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.h29
-rw-r--r--tests/auto/concurrent/qtconcurrentiteratekernel/CMakeLists.txt11
-rw-r--r--tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp34
-rw-r--r--tests/auto/concurrent/qtconcurrentmap/CMakeLists.txt11
-rw-r--r--tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp118
-rw-r--r--tests/auto/concurrent/qtconcurrentmedian/CMakeLists.txt11
-rw-r--r--tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp34
-rw-r--r--tests/auto/concurrent/qtconcurrentrun/CMakeLists.txt12
-rw-r--r--tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp127
-rw-r--r--tests/auto/concurrent/qtconcurrenttask/CMakeLists.txt11
-rw-r--r--tests/auto/concurrent/qtconcurrenttask/tst_qtconcurrenttask.cpp31
-rw-r--r--tests/auto/concurrent/qtconcurrentthreadengine/CMakeLists.txt11
-rw-r--r--tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp39
-rw-r--r--tests/auto/concurrent/testhelper_functions.h29
28 files changed, 341 insertions, 556 deletions
diff --git a/tests/auto/concurrent/CMakeLists.txt b/tests/auto/concurrent/CMakeLists.txt
index 1d7b8cefb4..0088ebfcf6 100644
--- a/tests/auto/concurrent/CMakeLists.txt
+++ b/tests/auto/concurrent/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from concurrent.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(qtconcurrentfilter)
add_subdirectory(qtconcurrentiteratekernel)
diff --git a/tests/auto/concurrent/qtconcurrentfilter/CMakeLists.txt b/tests/auto/concurrent/qtconcurrentfilter/CMakeLists.txt
index f81bed27d6..3c00393d39 100644
--- a/tests/auto/concurrent/qtconcurrentfilter/CMakeLists.txt
+++ b/tests/auto/concurrent/qtconcurrentfilter/CMakeLists.txt
@@ -1,12 +1,19 @@
-# Generated from qtconcurrentfilter.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtconcurrentfilter Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtconcurrentfilter LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtconcurrentfilter
SOURCES
tst_qtconcurrentfilter.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Concurrent
)
diff --git a/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp b/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp
index f9e68bd5f6..e19a596d5d 100644
--- a/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp
+++ b/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp
@@ -1,34 +1,10 @@
-/****************************************************************************
-**
-** 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 <qtconcurrentfilter.h>
#include <QCoreApplication>
#include <QList>
#include <QTest>
+#include <QSet>
#include "../testhelper_functions.h"
@@ -51,6 +27,7 @@ private slots:
void filteredReducedInitialValueThreadPool();
void filteredReducedInitialValueWithMoveOnlyCallables();
void filteredReducedDifferentTypeInitialValue();
+ void filteredReduceOptionConvertableToResultType();
void resultAt();
void incrementalResults();
void noDetach();
@@ -1362,6 +1339,56 @@ void tst_QtConcurrentFilter::filteredReducedDifferentTypeInitialValue()
CHECK_FAIL("lambda-lambda");
}
+void tst_QtConcurrentFilter::filteredReduceOptionConvertableToResultType()
+{
+ const QList<int> intList { 1, 2, 3 };
+ const int sum = 4;
+ QThreadPool p;
+ ReduceOption ro = OrderedReduce;
+
+ // With container
+ QCOMPARE(QtConcurrent::filteredReduced(intList, keepOddIntegers, intSumReduce, ro).result(),
+ sum);
+ QCOMPARE(QtConcurrent::blockingFilteredReduced(intList, keepOddIntegers, intSumReduce, ro),
+ sum);
+
+ // With iterators
+ QCOMPARE(QtConcurrent::filteredReduced(intList.begin(), intList.end(), keepOddIntegers,
+ intSumReduce, ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingFilteredReduced(intList.begin(), intList.end(), keepOddIntegers,
+ intSumReduce, ro), sum);
+
+ // With custom QThreadPool;
+ QCOMPARE(QtConcurrent::filteredReduced(&p, intList, keepOddIntegers, intSumReduce, ro).result(),
+ sum);
+ QCOMPARE(QtConcurrent::blockingFilteredReduced(&p, intList, keepOddIntegers, intSumReduce, ro),
+ sum);
+ QCOMPARE(QtConcurrent::filteredReduced(&p, intList.begin(), intList.end(), keepOddIntegers,
+ intSumReduce, ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingFilteredReduced(&p, intList.begin(), intList.end(),
+ keepOddIntegers, intSumReduce, ro), sum);
+
+ // The same as above, but specify the result type explicitly (this invokes different overloads)
+ QCOMPARE(QtConcurrent::filteredReduced<int>(intList, keepOddIntegers, intSumReduce,
+ ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingFilteredReduced<int>(intList, keepOddIntegers, intSumReduce, ro),
+ sum);
+
+ QCOMPARE(QtConcurrent::filteredReduced<int>(intList.begin(), intList.end(), keepOddIntegers,
+ intSumReduce, ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingFilteredReduced<int>(intList.begin(), intList.end(),
+ keepOddIntegers, intSumReduce, ro), sum);
+
+ QCOMPARE(QtConcurrent::filteredReduced<int>(&p, intList, keepOddIntegers, intSumReduce,
+ ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingFilteredReduced<int>(&p, intList, keepOddIntegers, intSumReduce,
+ ro), sum);
+ QCOMPARE(QtConcurrent::filteredReduced<int>(&p, intList.begin(), intList.end(), keepOddIntegers,
+ intSumReduce, ro).result(),sum);
+ QCOMPARE(QtConcurrent::blockingFilteredReduced<int>(&p, intList.begin(), intList.end(),
+ keepOddIntegers, intSumReduce, ro), sum);
+}
+
bool filterfn(int i)
{
return (i % 2);
@@ -1407,7 +1434,7 @@ void tst_QtConcurrentFilter::incrementalResults()
QCOMPARE(future.isFinished(), true);
QCOMPARE(future.resultCount(), count / 2);
- QCOMPARE(future.results().count(), count / 2);
+ QCOMPARE(future.results().size(), count / 2);
}
void tst_QtConcurrentFilter::noDetach()
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/CMakeLists.txt b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/CMakeLists.txt
index 1933365e86..12545702eb 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/CMakeLists.txt
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qtconcurrentfiltermapgenerated.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtconcurrentfiltermapgenerated Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtconcurrentfiltermapgenerated LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtconcurrentfiltermapgenerated
SOURCES
tst_qtconcurrent_selected_tests.cpp
tst_qtconcurrentfiltermapgenerated.cpp tst_qtconcurrentfiltermapgenerated.h
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Concurrent
)
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generation_helpers.h b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generation_helpers.h
index ab8385b30b..aaa0d85002 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generation_helpers.h
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generation_helpers.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 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) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QTBASE_GENERATION_HELPERS_H
#define QTBASE_GENERATION_HELPERS_H
@@ -156,10 +131,7 @@ public:
bool operator()(const T &el)
{
- if (!movedFrom)
- return el.isOdd();
- else
- return -1;
+ return movedFrom || el.isOdd();
}
};
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/function_signature.py b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/function_signature.py
index 049eea8d43..d87c8a2e9b 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/function_signature.py
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/function_signature.py
@@ -1,30 +1,5 @@
-#############################################################################
-#
# Copyright (C) 2020 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$
-#
-#############################################################################
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
from option_management import need_separate_output_sequence
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_excel.py b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_excel.py
index b9aad29e5a..d05e31fc21 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_excel.py
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_excel.py
@@ -1,30 +1,5 @@
-#############################################################################
-#
# Copyright (C) 2020 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$
-#
-#############################################################################
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
import pandas as pd
from option_management import function_describing_options
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_gui.py b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_gui.py
index 050ccb5839..54c1285e74 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_gui.py
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_gui.py
@@ -1,30 +1,5 @@
-#############################################################################
-#
# Copyright (C) 2020 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$
-#
-#############################################################################
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
import importlib
import sys
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_testcase.py b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_testcase.py
index 9ba03a31a0..d35a7e9065 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_testcase.py
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_testcase.py
@@ -1,30 +1,5 @@
-#############################################################################
-#
# Copyright (C) 2020 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$
-#
-#############################################################################
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
import textwrap
import time
from subprocess import Popen, PIPE
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generator_main.py b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generator_main.py
index 399488bb59..87cb4c7bc4 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generator_main.py
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generator_main.py
@@ -1,30 +1,5 @@
-#############################################################################
-#
# Copyright (C) 2020 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$
-#
-#############################################################################
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
from option_management import function_describing_options, skip_function_description, testcase_describing_options
from generate_testcase import generate_testcase
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/helpers.py b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/helpers.py
index ed485ac3da..fbe969789c 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/helpers.py
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/helpers.py
@@ -1,30 +1,5 @@
-#############################################################################
-#
# Copyright (C) 2020 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$
-#
-#############################################################################
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
def insert_testcases_into_file(filename, testcases):
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/option_management.py b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/option_management.py
index bac2a8d368..6a1fc87f9f 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/option_management.py
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/option_management.py
@@ -1,30 +1,5 @@
-#############################################################################
-#
# Copyright (C) 2020 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$
-#
-#############################################################################
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
import itertools
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrent_selected_tests.cpp b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrent_selected_tests.cpp
index 6b72648720..edb7cce4c9 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrent_selected_tests.cpp
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrent_selected_tests.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 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) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "tst_qtconcurrentfiltermapgenerated.h"
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.cpp b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.cpp
index 5983d6cf76..089ca3f867 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.cpp
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 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) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qtconcurrentfilter.h>
#include <qtconcurrentmap.h>
#include <QCoreApplication>
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.h b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.h
index 1b49a523f8..31b62ac4fd 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.h
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 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) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qtconcurrentfilter.h>
#include <qtconcurrentmap.h>
#include <QTest>
diff --git a/tests/auto/concurrent/qtconcurrentiteratekernel/CMakeLists.txt b/tests/auto/concurrent/qtconcurrentiteratekernel/CMakeLists.txt
index 2c74f6542e..2eea340795 100644
--- a/tests/auto/concurrent/qtconcurrentiteratekernel/CMakeLists.txt
+++ b/tests/auto/concurrent/qtconcurrentiteratekernel/CMakeLists.txt
@@ -1,12 +1,19 @@
-# Generated from qtconcurrentiteratekernel.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtconcurrentiteratekernel Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtconcurrentiteratekernel LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtconcurrentiteratekernel
SOURCES
tst_qtconcurrentiteratekernel.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Concurrent
)
diff --git a/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
index 4163883a5b..27113ad8b7 100644
--- a/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+++ b/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
@@ -1,31 +1,7 @@
-/****************************************************************************
-**
-** 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 <QThread>
+#include <QSet>
struct TestIterator
{
@@ -245,7 +221,7 @@ void tst_QtConcurrentIterateKernel::throttling()
QCOMPARE(iterations.loadRelaxed(), totalIterations);
- QCOMPARE(threads.count(), 1);
+ QCOMPARE(threads.size(), 1);
}
class MultipleResultsFor : public IterateKernel<TestIterator, int>
@@ -263,7 +239,7 @@ public:
void tst_QtConcurrentIterateKernel::multipleResults()
{
QFuture<int> f = startThreadEngine(new MultipleResultsFor(0, 10)).startAsynchronously();
- QCOMPARE(f.results().count() , 10);
+ QCOMPARE(f.results().size() , 10);
QCOMPARE(f.resultAt(0), 0);
QCOMPARE(f.resultAt(5), 5);
QCOMPARE(f.resultAt(9), 9);
diff --git a/tests/auto/concurrent/qtconcurrentmap/CMakeLists.txt b/tests/auto/concurrent/qtconcurrentmap/CMakeLists.txt
index 20ccbdf374..62b434a25f 100644
--- a/tests/auto/concurrent/qtconcurrentmap/CMakeLists.txt
+++ b/tests/auto/concurrent/qtconcurrentmap/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qtconcurrentmap.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtconcurrentmap Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtconcurrentmap LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtconcurrentmap
SOURCES
tst_qtconcurrentmap.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Concurrent
)
diff --git a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp
index 973a9b4fa5..3e3165013f 100644
--- a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp
+++ b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.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 <qtconcurrentmap.h>
#include <qexception.h>
#include <qdebug.h>
@@ -32,6 +7,7 @@
#include <QThread>
#include <QMutex>
#include <QTest>
+#include <QSet>
#include <QRandomGenerator>
#include "../testhelper_functions.h"
@@ -54,6 +30,7 @@ private slots:
void mappedReducedInitialValueThreadPool();
void mappedReducedInitialValueWithMoveOnlyCallable();
void mappedReducedDifferentTypeInitialValue();
+ void mappedReduceOptionConvertableToResultType();
void assignResult();
void functionOverloads();
void noExceptFunctionOverloads();
@@ -73,7 +50,7 @@ public slots:
using namespace QtConcurrent;
-void multiplyBy2Immutable(int x)
+void multiplyBy2Immutable([[maybe_unused]] int x)
{
x *= 2;
}
@@ -81,7 +58,7 @@ void multiplyBy2Immutable(int x)
class MultiplyBy2Immutable
{
public:
- void operator()(int x)
+ void operator()([[maybe_unused]] int x)
{
x *= 2;
}
@@ -186,9 +163,9 @@ void tst_QtConcurrentMap::map()
QCOMPARE(list, QList<int>() << 1 << 2 << 3);
// lambda
- QtConcurrent::map(list, [](int x){x *= 2;}).waitForFinished();
+ QtConcurrent::map(list, []([[maybe_unused]] int x){x *= 2;}).waitForFinished();
QCOMPARE(list, QList<int>() << 1 << 2 << 3);
- QtConcurrent::map(list.begin(), list.end(), [](int x){x *= 2;}).waitForFinished();
+ QtConcurrent::map(list.begin(), list.end(), []([[maybe_unused]] int x){x *= 2;}).waitForFinished();
QCOMPARE(list, QList<int>() << 1 << 2 << 3);
}
@@ -208,6 +185,17 @@ void tst_QtConcurrentMap::map()
QCOMPARE(list, NonTemplateSequence({ 2, 4, 6 }));
}
+ // custom pool with invalid number of threads
+ {
+ QList<int> list;
+ list << 1 << 2 << 3;
+ QThreadPool pool;
+ pool.setMaxThreadCount(0); // explicitly set incorrect value
+ // This should not crash
+ QtConcurrent::map(&pool, list, MultiplyBy2InPlace()).waitForFinished();
+ QCOMPARE(list, QList<int>() << 2 << 4 << 6);
+ }
+
#if 0
// not allowed: map() with immutable sequences makes no sense
{
@@ -238,7 +226,7 @@ void tst_QtConcurrentMap::map()
#if 0
// not allowed: map() on a const list, where functors try to modify the items in the list
{
- const QList<int> list = QList<int>() << 1 << 2 << 3;;
+ const QList<int> list = QList<int>() << 1 << 2 << 3;
QtConcurrent::map(list, MultiplyBy2InPlace());
QtConcurrent::map(list, multiplyBy2InPlace);
@@ -332,9 +320,9 @@ void tst_QtConcurrentMap::blockingMap()
QCOMPARE(list, QList<int>() << 1 << 2 << 3);
// lambda
- QtConcurrent::blockingMap(list, [](int x) { x *= 2; });
+ QtConcurrent::blockingMap(list, []([[maybe_unused]] int x) { x *= 2; });
QCOMPARE(list, QList<int>() << 1 << 2 << 3);
- QtConcurrent::blockingMap(list.begin(), list.end(), [](int x) { x *= 2; });
+ QtConcurrent::blockingMap(list.begin(), list.end(), []([[maybe_unused]] int x) { x *= 2; });
QCOMPARE(list, QList<int>() << 1 << 2 << 3);
}
@@ -375,7 +363,7 @@ void tst_QtConcurrentMap::blockingMap()
#if 0
// not allowed: map() on a const list, where functors try to modify the items in the list
{
- const QList<int> list = QList<int>() << 1 << 2 << 3;;
+ const QList<int> list = QList<int>() << 1 << 2 << 3;
QtConcurrent::blockingMap(list, MultiplyBy2InPlace());
QtConcurrent::blockingMap(list, multiplyBy2InPlace);
@@ -1098,6 +1086,17 @@ void tst_QtConcurrentMap::mappedReducedThreadPool()
intCube, intSumReduce);
QCOMPARE(result, sumOfCubes);
}
+
+ {
+ // pool with invalid number of threads
+ QThreadPool pool;
+ pool.setMaxThreadCount(0); // explicitly set incorrect value
+
+ // This should not crash
+ NonTemplateSequence list { 1, 2, 3 };
+ auto future = QtConcurrent::mappedReduced(&pool, list, multiplyBy2, intSumReduce);
+ QCOMPARE(future.result(), 12);
+ }
}
void tst_QtConcurrentMap::mappedReducedWithMoveOnlyCallable()
@@ -1629,6 +1628,51 @@ void tst_QtConcurrentMap::mappedReducedDifferentTypeInitialValue()
CHECK_FAIL("lambda-lambda");
}
+void tst_QtConcurrentMap::mappedReduceOptionConvertableToResultType()
+{
+ const QList<int> intList { 1, 2, 3 };
+ const int sum = 12;
+ QThreadPool p;
+ ReduceOption ro = OrderedReduce;
+
+ // With container
+ QCOMPARE(QtConcurrent::mappedReduced(intList, multiplyBy2, intSumReduce, ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingMappedReduced(intList, multiplyBy2, intSumReduce, ro), sum);
+
+ // With iterators
+ QCOMPARE(QtConcurrent::mappedReduced(intList.begin(), intList.end(), multiplyBy2, intSumReduce,
+ ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingMappedReduced(intList.begin(), intList.end(), multiplyBy2,
+ intSumReduce, ro), sum);
+
+ // With custom QThreadPool;
+ QCOMPARE(QtConcurrent::mappedReduced(&p, intList, multiplyBy2, intSumReduce, ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingMappedReduced(&p, intList, multiplyBy2, intSumReduce, ro), sum);
+ QCOMPARE(QtConcurrent::mappedReduced(&p, intList.begin(), intList.end(), multiplyBy2,
+ intSumReduce, ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingMappedReduced(&p, intList.begin(), intList.end(), multiplyBy2,
+ intSumReduce, ro), sum);
+
+ // The same as above, but specify the result type explicitly (this invokes different overloads)
+ QCOMPARE(QtConcurrent::mappedReduced<int>(intList, multiplyBy2, intSumReduce, ro).result(),
+ sum);
+ QCOMPARE(QtConcurrent::blockingMappedReduced<int>(intList, multiplyBy2, intSumReduce, ro), sum);
+
+ QCOMPARE(QtConcurrent::mappedReduced<int>(intList.begin(), intList.end(), multiplyBy2,
+ intSumReduce, ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingMappedReduced<int>(intList.begin(), intList.end(), multiplyBy2,
+ intSumReduce, ro), sum);
+
+ QCOMPARE(QtConcurrent::mappedReduced<int>(&p, intList, multiplyBy2, intSumReduce, ro).result(),
+ sum);
+ QCOMPARE(QtConcurrent::blockingMappedReduced<int>(&p, intList, multiplyBy2, intSumReduce, ro),
+ sum);
+ QCOMPARE(QtConcurrent::mappedReduced<int>(&p, intList.begin(), intList.end(), multiplyBy2,
+ intSumReduce, ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingMappedReduced<int>(&p, intList.begin(), intList.end(),
+ multiplyBy2, intSumReduce, ro), sum);
+}
+
int sleeper(int val)
{
QTest::qSleep(100);
@@ -1934,7 +1978,7 @@ void tst_QtConcurrentMap::incrementalResults()
QCOMPARE(future.isFinished(), true);
QCOMPARE(future.resultCount(), count);
- QCOMPARE(future.results().count(), count);
+ QCOMPARE(future.results().size(), count);
}
/*
@@ -2025,7 +2069,7 @@ void tst_QtConcurrentMap::stlContainersLambda()
QtConcurrent::mapped(list, [](const int &i) { return mapper(i); }).waitForFinished();
- QtConcurrent::blockingMap(list, [](int x) { x *= 2; });
+ QtConcurrent::blockingMap(list, []([[maybe_unused]] int x) { x *= 2; });
}
InstanceCounter ic_fn(const InstanceCounter & ic)
diff --git a/tests/auto/concurrent/qtconcurrentmedian/CMakeLists.txt b/tests/auto/concurrent/qtconcurrentmedian/CMakeLists.txt
index cbae4d1fb1..63f0135467 100644
--- a/tests/auto/concurrent/qtconcurrentmedian/CMakeLists.txt
+++ b/tests/auto/concurrent/qtconcurrentmedian/CMakeLists.txt
@@ -1,12 +1,19 @@
-# Generated from qtconcurrentmedian.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtconcurrentmedian Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtconcurrentmedian LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtconcurrentmedian
SOURCES
tst_qtconcurrentmedian.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Concurrent
)
diff --git a/tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp b/tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp
index 8a797447bb..7eea013c8b 100644
--- a/tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp
+++ b/tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp
@@ -1,30 +1,6 @@
-/****************************************************************************
-**
-** 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 <qtconcurrentmedian.h>
#include <QTest>
@@ -73,11 +49,11 @@ void tst_QtConcurrentMedian::median_data()
void tst_QtConcurrentMedian::median()
{
- QFETCH(QList<double> , values);
+ QFETCH(const QList<double> , values);
QFETCH(double, expectedMedian);
QtConcurrent::Median m;
- foreach (double value, values)
+ for (double value : values)
m.addValue(value);
QCOMPARE(m.median(), expectedMedian);
}
diff --git a/tests/auto/concurrent/qtconcurrentrun/CMakeLists.txt b/tests/auto/concurrent/qtconcurrentrun/CMakeLists.txt
index 9f3b60481d..a8b6792570 100644
--- a/tests/auto/concurrent/qtconcurrentrun/CMakeLists.txt
+++ b/tests/auto/concurrent/qtconcurrentrun/CMakeLists.txt
@@ -1,14 +1,22 @@
-# Generated from qtconcurrentrun.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtconcurrentrun Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtconcurrentrun LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtconcurrentrun
SOURCES
tst_qtconcurrentrun.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Concurrent
+ Qt::TestPrivate
)
## Scopes:
diff --git a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
index 235ffca0fc..0bc2961903 100644
--- a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
+++ b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.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 <qtconcurrentrun.h>
#include <QFuture>
#include <QMutex>
@@ -35,12 +10,15 @@
#include <QTimer>
#include <QFutureSynchronizer>
+#include <QtTest/private/qemulationdetector_p.h>
+
using namespace QtConcurrent;
class tst_QtConcurrentRun: public QObject
{
Q_OBJECT
private slots:
+ void initTestCase();
void runLightFunction();
void runHeavyFunction();
void returnValue();
@@ -65,6 +43,8 @@ private slots:
void crefFunction();
void customPromise();
void nonDefaultConstructibleValue();
+ void nullThreadPool();
+ void nullThreadPoolNoLeak();
};
void light()
@@ -106,6 +86,13 @@ void heavy()
qDebug("done function");
}
+void tst_QtConcurrentRun::initTestCase()
+{
+ // proxy check for QEMU; catches slightly more though
+ if (QTestPrivate::isRunningArmOnX86())
+ QSKIP("Runs into spurious crashes on QEMU -- QTBUG-106906");
+}
+
void tst_QtConcurrentRun::runLightFunction()
{
qDebug("starting function");
@@ -679,10 +666,10 @@ void tst_QtConcurrentRun::implicitConvertibleTypes()
{
QThreadPool pool;
- double d;
+ double d = 0.0;
run(doubleFunction, d).waitForFinished();
run(&pool, doubleFunction, d).waitForFinished();
- int i;
+ int i = 0;
run(doubleFunction, d).waitForFinished();
run(&pool, doubleFunction, d).waitForFinished();
run(doubleFunction, i).waitForFinished();
@@ -828,7 +815,7 @@ public:
void run() override {
int iter = 60;
while (--iter && !cancel.loadRelaxed())
- QThread::currentThread()->msleep(25);
+ QThread::currentThread()->sleep(std::chrono::milliseconds{25});
}
};
@@ -1102,12 +1089,25 @@ void report3(QPromise<int> &promise)
promise.addResult(1);
}
+static void staticReport3(QPromise<int> &promise)
+{
+ promise.addResult(0);
+ promise.addResult(2);
+ promise.addResult(1);
+}
+
void reportN(QPromise<double> &promise, int n)
{
for (int i = 0; i < n; ++i)
promise.addResult(0);
}
+static void staticReportN(QPromise<double> &promise, int n)
+{
+ for (int i = 0; i < n; ++i)
+ promise.addResult(0);
+}
+
void reportString1(QPromise<QString> &promise, const QString &s)
{
promise.addResult(s);
@@ -1181,11 +1181,21 @@ void tst_QtConcurrentRun::withPromise()
QCOMPARE(run(report3).results(),
QList<int>({0, 2, 1}));
- QCOMPARE(run(reportN, 4).results(),
- QList<double>({0, 0, 0, 0}));
+ QCOMPARE(run(&staticReport3).results(),
+ QList<int>({0, 2, 1}));
+ QCOMPARE(run(staticReport3).results(),
+ QList<int>({0, 2, 1}));
+
+ QCOMPARE(run(&reportN, 2).results(),
+ QList<double>({0, 0}));
QCOMPARE(run(reportN, 2).results(),
QList<double>({0, 0}));
+ QCOMPARE(run(&staticReportN, 2).results(),
+ QList<double>({0, 0}));
+ QCOMPARE(run(staticReportN, 2).results(),
+ QList<double>({0, 0}));
+
QString s = QLatin1String("string");
const QString &crs = QLatin1String("cr string");
const QString cs = QLatin1String("c string");
@@ -1272,11 +1282,21 @@ void tst_QtConcurrentRun::withPromiseInThreadPool()
QCOMPARE(run(pool.data(), report3).results(),
QList<int>({0, 2, 1}));
- QCOMPARE(run(pool.data(), reportN, 4).results(),
- QList<double>({0, 0, 0, 0}));
+ QCOMPARE(run(pool.data(), &staticReport3).results(),
+ QList<int>({0, 2, 1}));
+ QCOMPARE(run(pool.data(), staticReport3).results(),
+ QList<int>({0, 2, 1}));
+
+ QCOMPARE(run(pool.data(), &reportN, 2).results(),
+ QList<double>({0, 0}));
QCOMPARE(run(pool.data(), reportN, 2).results(),
QList<double>({0, 0}));
+ QCOMPARE(run(pool.data(), &staticReportN, 2).results(),
+ QList<double>({0, 0}));
+ QCOMPARE(run(pool.data(), staticReportN, 2).results(),
+ QList<double>({0, 0}));
+
QString s = QLatin1String("string");
const QString &crs = QLatin1String("cr string");
const QString cs = QLatin1String("c string");
@@ -1406,7 +1426,7 @@ void tst_QtConcurrentRun::withPromiseAndThen()
setFlag(syncEnd);
future.waitForFinished();
- QCOMPARE(future.results().count(), 0);
+ QCOMPARE(future.results().size(), 0);
QVERIFY(runExecuted);
QVERIFY(!cancelReceivedBeforeSync);
QVERIFY(cancelReceivedAfterSync);
@@ -1426,7 +1446,7 @@ void tst_QtConcurrentRun::withPromiseAndThen()
setFlag(syncEnd);
resultFuture.waitForFinished();
- QCOMPARE(future.results().count(), 1);
+ QCOMPARE(future.results().size(), 1);
QCOMPARE(future.result(), 1);
QVERIFY(runExecuted);
QVERIFY(thenExecuted);
@@ -1449,7 +1469,7 @@ void tst_QtConcurrentRun::withPromiseAndThen()
setFlag(syncEnd);
resultFuture.waitForFinished();
- QCOMPARE(future.results().count(), 0);
+ QCOMPARE(future.results().size(), 0);
QVERIFY(runExecuted);
QVERIFY(!thenExecuted);
QVERIFY(cancelExecuted);
@@ -1577,5 +1597,38 @@ void tst_QtConcurrentRun::nonDefaultConstructibleValue()
QCOMPARE(future.result().value, 42);
}
+// QTBUG-98901
+void tst_QtConcurrentRun::nullThreadPool()
+{
+ QThreadPool *pool = nullptr;
+ std::atomic<bool> isInvoked = false;
+ auto future = run(pool, [&] { isInvoked = true; });
+ future.waitForFinished();
+ QVERIFY(future.isCanceled());
+ QVERIFY(!isInvoked);
+}
+
+struct LifetimeChecker
+{
+ LifetimeChecker() { ++count; }
+ LifetimeChecker(const LifetimeChecker &) { ++count; }
+ ~LifetimeChecker() { --count; }
+
+ void operator()() { }
+
+ static std::atomic<int> count;
+};
+std::atomic<int> LifetimeChecker::count = 0;
+
+void tst_QtConcurrentRun::nullThreadPoolNoLeak()
+{
+ {
+ QThreadPool *pool = nullptr;
+ auto future = run(pool, LifetimeChecker());
+ future.waitForFinished();
+ }
+ QCOMPARE(LifetimeChecker::count, 0);
+}
+
QTEST_MAIN(tst_QtConcurrentRun)
#include "tst_qtconcurrentrun.moc"
diff --git a/tests/auto/concurrent/qtconcurrenttask/CMakeLists.txt b/tests/auto/concurrent/qtconcurrenttask/CMakeLists.txt
index 60f5cb47e3..89226eaacc 100644
--- a/tests/auto/concurrent/qtconcurrenttask/CMakeLists.txt
+++ b/tests/auto/concurrent/qtconcurrenttask/CMakeLists.txt
@@ -1,12 +1,19 @@
-# Generated from qtconcurrenttask.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtconcurrenttask Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtconcurrenttask LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtconcurrenttask
SOURCES
tst_qtconcurrenttask.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Concurrent
)
diff --git a/tests/auto/concurrent/qtconcurrenttask/tst_qtconcurrenttask.cpp b/tests/auto/concurrent/qtconcurrenttask/tst_qtconcurrenttask.cpp
index a95f424d0b..d570b0f974 100644
--- a/tests/auto/concurrent/qtconcurrenttask/tst_qtconcurrenttask.cpp
+++ b/tests/auto/concurrent/qtconcurrenttask/tst_qtconcurrenttask.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 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) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qtconcurrenttask.h>
@@ -57,7 +32,7 @@ void tst_QtConcurrentTask::taskWithFreeFunction()
{
QVariant value(42);
- auto result = task(&qvariant_cast<int>)
+ auto result = task([](const QVariant &var){ return qvariant_cast<int>(var); })
.withArguments(value)
.spawn()
.result();
diff --git a/tests/auto/concurrent/qtconcurrentthreadengine/CMakeLists.txt b/tests/auto/concurrent/qtconcurrentthreadengine/CMakeLists.txt
index 8a7f006674..c3c8c9ea59 100644
--- a/tests/auto/concurrent/qtconcurrentthreadengine/CMakeLists.txt
+++ b/tests/auto/concurrent/qtconcurrentthreadengine/CMakeLists.txt
@@ -1,12 +1,19 @@
-# Generated from qtconcurrentthreadengine.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtconcurrentthreadengine Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtconcurrentthreadengine LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtconcurrentthreadengine
SOURCES
tst_qtconcurrentthreadengine.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Concurrent
)
diff --git a/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
index 12a7aa4bf0..0151b13693 100644
--- a/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+++ b/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
@@ -1,35 +1,14 @@
-/****************************************************************************
-**
-** 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
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <qtconcurrentthreadengine.h>
#include <qexception.h>
#include <QThread>
#include <QElapsedTimer>
#include <QTest>
+#include <QSet>
using namespace QtConcurrent;
@@ -258,7 +237,7 @@ void tst_QtConcurrentThreadEngine::threadCount()
const int repeats = 10;
for (int i = 0; i < repeats; ++i) {
(new ThreadCountUser())->startAsynchronously().waitForFinished();
- const auto count = threads.count();
+ const auto count = threads.size();
const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
QVERIFY(count <= maxThreadCount);
QVERIFY(!threads.contains(QThread::currentThread()));
@@ -267,7 +246,7 @@ void tst_QtConcurrentThreadEngine::threadCount()
// Set the finish flag immediately, this should give us one thread only.
for (int i = 0; i < repeats; ++i) {
(new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
- const auto count = threads.count();
+ const auto count = threads.size();
QCOMPARE(count, 1);
QVERIFY(!threads.contains(QThread::currentThread()));
}
@@ -295,7 +274,7 @@ void tst_QtConcurrentThreadEngine::multipleResults()
{
MultipleResultsUser *engine = new MultipleResultsUser();
QFuture<int> f = engine->startAsynchronously();
- QCOMPARE(f.results().count() , 10);
+ QCOMPARE(f.results().size() , 10);
QCOMPARE(f.resultAt(0), 0);
QCOMPARE(f.resultAt(5), 5);
QCOMPARE(f.resultAt(9), 9);
diff --git a/tests/auto/concurrent/testhelper_functions.h b/tests/auto/concurrent/testhelper_functions.h
index a34e0f4ce9..88c2e28910 100644
--- a/tests/auto/concurrent/testhelper_functions.h
+++ b/tests/auto/concurrent/testhelper_functions.h
@@ -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
#ifndef FUNCTIONS_H
#define FUNCTIONS_H