Add cxx11_future in QPromise tests and disable it for VxWorks
cxx11_future flag should be disabled for VxWorks. VxWorks still does have some bugs related to this std features and some parts of code needs to be excluded. At least till the 24.03 VxWorks release as for now this is the expected release that should contain fixes. Task-number: QTBUG-115777 Change-Id: Ic652403697d727f4ae05ae7287ff8285075d3802 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
d4568bcfdb
commit
ac6a9f9bfa
|
|
@ -439,7 +439,7 @@ qt_feature("system-doubleconversion" PRIVATE
|
|||
)
|
||||
qt_feature("cxx11_future" PUBLIC
|
||||
LABEL "C++11 <future>"
|
||||
CONDITION ON
|
||||
CONDITION NOT VXWORKS
|
||||
)
|
||||
qt_feature("cxx17_filesystem" PUBLIC
|
||||
LABEL "C++17 <filesystem>"
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ do { \
|
|||
QFAIL("Test case " #test "(" #__VA_ARGS__ ") failed"); \
|
||||
} while (false)
|
||||
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
// std::thread-like wrapper that ensures that the thread is joined at the end of
|
||||
// a scope to prevent potential std::terminate
|
||||
struct ThreadWrapper
|
||||
|
|
@ -102,6 +103,7 @@ struct ThreadWrapper
|
|||
t->wait();
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
void tst_QPromise::promise()
|
||||
{
|
||||
|
|
@ -342,6 +344,7 @@ void tst_QPromise::progress()
|
|||
|
||||
void tst_QPromise::addInThread()
|
||||
{
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
const auto testAddResult = [] (auto promise, const auto &result) {
|
||||
promise.start();
|
||||
auto f = promise.future();
|
||||
|
|
@ -357,10 +360,12 @@ void tst_QPromise::addInThread()
|
|||
RUN_TEST_FUNC(testAddResult, QPromise<int>(), 42);
|
||||
RUN_TEST_FUNC(testAddResult, QPromise<QString>(), u8"42");
|
||||
RUN_TEST_FUNC(testAddResult, QPromise<CopyOnlyType>(), CopyOnlyType{99});
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QPromise::addInThreadMoveOnlyObject()
|
||||
{
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
QPromise<MoveOnlyType> promise;
|
||||
promise.start();
|
||||
auto f = promise.future();
|
||||
|
|
@ -372,10 +377,12 @@ void tst_QPromise::addInThreadMoveOnlyObject()
|
|||
// Iterators wait for result first
|
||||
for (auto& result : f)
|
||||
QCOMPARE(result, MoveOnlyType{-11});
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QPromise::reportFromMultipleThreads()
|
||||
{
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
QPromise<int> promise;
|
||||
auto f = promise.future();
|
||||
promise.start();
|
||||
|
|
@ -394,10 +401,12 @@ void tst_QPromise::reportFromMultipleThreads()
|
|||
QVERIFY(std::find(expected.begin(), expected.end(), actual) != expected.end());
|
||||
expected.removeOne(actual);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QPromise::reportFromMultipleThreadsByMovedPromise()
|
||||
{
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
QPromise<int> initialPromise;
|
||||
auto f = initialPromise.future();
|
||||
{
|
||||
|
|
@ -424,10 +433,12 @@ void tst_QPromise::reportFromMultipleThreadsByMovedPromise()
|
|||
QVERIFY(std::find(expected.begin(), expected.end(), actual) != expected.end());
|
||||
expected.removeOne(actual);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QPromise::doNotCancelWhenFinished()
|
||||
{
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
const auto testFinishedPromise = [] (auto promise) {
|
||||
auto f = promise.future();
|
||||
promise.start();
|
||||
|
|
@ -446,11 +457,13 @@ void tst_QPromise::doNotCancelWhenFinished()
|
|||
RUN_TEST_FUNC(testFinishedPromise, QPromise<QString>());
|
||||
RUN_TEST_FUNC(testFinishedPromise, QPromise<CopyOnlyType>());
|
||||
RUN_TEST_FUNC(testFinishedPromise, QPromise<MoveOnlyType>());
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef QT_NO_EXCEPTIONS
|
||||
void tst_QPromise::cancelWhenDestroyed()
|
||||
{
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
QPromise<int> initialPromise;
|
||||
auto f = initialPromise.future();
|
||||
|
||||
|
|
@ -478,11 +491,13 @@ void tst_QPromise::cancelWhenDestroyed()
|
|||
QVERIFY(std::find(expected.begin(), expected.end(), actual) != expected.end());
|
||||
expected.removeOne(actual);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void tst_QPromise::cancelWhenReassigned()
|
||||
{
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
QPromise<int> promise;
|
||||
auto f = promise.future();
|
||||
promise.start();
|
||||
|
|
@ -496,6 +511,7 @@ void tst_QPromise::cancelWhenReassigned()
|
|||
|
||||
QCOMPARE(f.isFinished(), true);
|
||||
QCOMPARE(f.isCanceled(), true);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
@ -614,6 +630,7 @@ void tst_QPromise::continuationsRunWhenFinished()
|
|||
|
||||
void tst_QPromise::finishWhenSwapped()
|
||||
{
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
QPromise<int> promise1;
|
||||
auto f1 = promise1.future();
|
||||
promise1.start();
|
||||
|
|
@ -648,11 +665,13 @@ void tst_QPromise::finishWhenSwapped()
|
|||
|
||||
QCOMPARE(f2.resultAt(0), 1);
|
||||
QCOMPARE(f2.resultAt(1), 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void testCancelWhenMoved()
|
||||
{
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
QPromise<T> promise1;
|
||||
auto f1 = promise1.future();
|
||||
promise1.start();
|
||||
|
|
@ -678,6 +697,7 @@ void testCancelWhenMoved()
|
|||
// Future #2 is explicitly finished inside thread
|
||||
QCOMPARE(f2.isFinished(), true);
|
||||
QCOMPARE(f2.isCanceled(), false);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QPromise::cancelWhenMoved()
|
||||
|
|
@ -719,6 +739,7 @@ void tst_QPromise::waitUntilResumed()
|
|||
|
||||
void tst_QPromise::waitUntilCanceled()
|
||||
{
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
QPromise<int> promise;
|
||||
promise.start();
|
||||
auto f = promise.future();
|
||||
|
|
@ -739,6 +760,7 @@ void tst_QPromise::waitUntilCanceled()
|
|||
f.waitForFinished();
|
||||
|
||||
QCOMPARE(f.resultCount(), 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Below is a quick and dirty hack to make snippets a part of a test suite
|
||||
|
|
|
|||
Loading…
Reference in New Issue