Remove Q_ASSERT's from QMetaType autotest.
Instead of asserting in debug mode and doing nothing in release mode, put specific warnings in the test output and fail the test gracefully. Change-Id: I453a0ab7ddef5b2acf55f77f71a59a940d93ae54 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern (cherry picked from commit a3b2fa3f1beffa7709c11522d4e2db9ec8f952e0)
This commit is contained in:
parent
4bf7ac3968
commit
d0d393d86f
@ -113,17 +113,35 @@ protected:
|
||||
#ifdef Q_OS_LINUX
|
||||
pthread_yield();
|
||||
#endif
|
||||
Q_ASSERT(QMetaType::isRegistered(tp));
|
||||
Q_ASSERT(QMetaType::type(nm) == tp);
|
||||
Q_ASSERT(QMetaType::typeName(tp) == name);
|
||||
if (!QMetaType::isRegistered(tp)) {
|
||||
++failureCount;
|
||||
qWarning() << name << "is not a registered metatype";
|
||||
}
|
||||
if (QMetaType::type(nm) != tp) {
|
||||
++failureCount;
|
||||
qWarning() << "Wrong metatype returned for" << name;
|
||||
}
|
||||
if (QMetaType::typeName(tp) != name) {
|
||||
++failureCount;
|
||||
qWarning() << "Wrong typeName returned for" << tp;
|
||||
}
|
||||
void *buf = QMetaType::construct(tp, 0);
|
||||
void *buf2 = QMetaType::construct(tp, buf);
|
||||
Q_ASSERT(buf);
|
||||
Q_ASSERT(buf2);
|
||||
if (!buf) {
|
||||
++failureCount;
|
||||
qWarning() << "Null buffer returned by QMetaType::construct(tp, 0)";
|
||||
}
|
||||
if (!buf2) {
|
||||
++failureCount;
|
||||
qWarning() << "Null buffer returned by QMetaType::construct(tp, buf)";
|
||||
}
|
||||
QMetaType::destroy(tp, buf);
|
||||
QMetaType::destroy(tp, buf2);
|
||||
}
|
||||
}
|
||||
public:
|
||||
MetaTypeTorturer() : failureCount(0) { }
|
||||
int failureCount;
|
||||
};
|
||||
|
||||
void tst_QMetaType::threadSafety()
|
||||
@ -139,6 +157,10 @@ void tst_QMetaType::threadSafety()
|
||||
QVERIFY(t1.wait());
|
||||
QVERIFY(t2.wait());
|
||||
QVERIFY(t3.wait());
|
||||
|
||||
QCOMPARE(t1.failureCount, 0);
|
||||
QCOMPARE(t2.failureCount, 0);
|
||||
QCOMPARE(t3.failureCount, 0);
|
||||
}
|
||||
|
||||
namespace TestSpace
|
||||
|
Loading…
Reference in New Issue
Block a user