summaryrefslogtreecommitdiffstats
path: root/tests/packagecreator/tst_packagecreator.cpp
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@pelagicore.com>2017-02-22 12:35:10 +0100
committerRobert Griebl <robert.griebl@pelagicore.com>2017-02-22 13:43:59 +0000
commit498b587fde90f7ee1433dfc3876c0fa02dde67ea (patch)
tree85e020ca7df7fbec8c0fd9b409f4586cf3a29de5 /tests/packagecreator/tst_packagecreator.cpp
parenta48dcbd041666875309154161b465e09a6217893 (diff)
Make it possible to slow down all tests that wait at some point
Each of those tests now checks the $TIMEOUT_FACTOR environment variable and adjusts its wait timeouts accordingly. Change-Id: I54086f83b0b3b3e3bcfacf4f15b1ea6b959b7703 Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
Diffstat (limited to 'tests/packagecreator/tst_packagecreator.cpp')
-rw-r--r--tests/packagecreator/tst_packagecreator.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/packagecreator/tst_packagecreator.cpp b/tests/packagecreator/tst_packagecreator.cpp
index 49a41473..4699f9f5 100644
--- a/tests/packagecreator/tst_packagecreator.cpp
+++ b/tests/packagecreator/tst_packagecreator.cpp
@@ -37,6 +37,9 @@
QT_USE_NAMESPACE_AM
+static int timeoutFactor = 1; // useful to increase timeouts when running in valgrind
+static int processTimeout = 3000;
+
class tst_PackageCreator : public QObject
{
Q_OBJECT
@@ -65,11 +68,15 @@ tst_PackageCreator::tst_PackageCreator()
void tst_PackageCreator::initTestCase()
{
+ timeoutFactor = qMax(1, qEnvironmentVariableIntValue("TIMEOUT_FACTOR"));
+ processTimeout *= timeoutFactor;
+ qInfo() << "Timeouts are multiplied by" << timeoutFactor << "(changed by (un)setting $TIMEOUT_FACTOR)";
+
// check if tar command is available at all
QProcess tar;
tar.start(qSL("tar"), { qSL("--version") });
- m_tarAvailable = tar.waitForStarted(3000)
- && tar.waitForFinished(3000)
+ m_tarAvailable = tar.waitForStarted(processTimeout)
+ && tar.waitForFinished(processTimeout)
&& (tar.exitStatus() == QProcess::NormalExit);
m_isCygwin = tar.readAllStandardOutput().contains("Cygwin");
@@ -120,8 +127,8 @@ void tst_PackageCreator::createAndVerify()
QProcess tar;
tar.start(qSL("tar"), { qSL("-tzf"), escapeFilename(output.fileName()) });
- QVERIFY2(tar.waitForStarted(3000) &&
- tar.waitForFinished(3000) &&
+ QVERIFY2(tar.waitForStarted(processTimeout) &&
+ tar.waitForFinished(processTimeout) &&
(tar.exitStatus() == QProcess::NormalExit) &&
(tar.exitCode() == 0), qPrintable(tar.errorString()));
@@ -141,8 +148,8 @@ void tst_PackageCreator::createAndVerify()
QByteArray data = src.readAll();
tar.start(qSL("tar"), { qSL("-xzOf"), escapeFilename(output.fileName()), file });
- QVERIFY2(tar.waitForStarted(3000) &&
- tar.waitForFinished(3000) &&
+ QVERIFY2(tar.waitForStarted(processTimeout) &&
+ tar.waitForFinished(processTimeout) &&
(tar.exitStatus() == QProcess::NormalExit) &&
(tar.exitCode() == 0), qPrintable(tar.errorString()));