summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarcus Tillmanns <marcus.tillmanns@qt.io>2022-07-14 15:05:18 +0200
committerMarcus Tillmanns <marcus.tillmanns@qt.io>2022-07-18 08:06:06 +0000
commit07cb8876db7f2a7856f5fce6cc7854c4e6ff8b7f (patch)
treed2aebd1fa3df1fc408b4c882674e0878f777c279 /tests
parent825a3a5e7e59da467844e4f5ae8a19a929c7f6e1 (diff)
downloadqt-creator-07cb8876db7f2a7856f5fce6cc7854c4e6ff8b7f.tar.gz
deviceshell: Fix racecondition and long running tests
When writing to stdout and stderr from two processes, their output could become interleaved. To work around that, we write stdout and stderr to different files and later combine them together in the shell script. Since tst_deviceshell tests could run for a long time if /usr folder is too big, added a check that first tests the runtime once. Since we currently only support linux containers, limit the tests to only run if the container platform is linux as well. Change-Id: I4b313596cdf9acc839d54d7cc77c66fd53ac23bf Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/utils/deviceshell/tst_deviceshell.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/tests/auto/utils/deviceshell/tst_deviceshell.cpp b/tests/auto/utils/deviceshell/tst_deviceshell.cpp
index 2c209b94a1..399a76e1ca 100644
--- a/tests/auto/utils/deviceshell/tst_deviceshell.cpp
+++ b/tests/auto/utils/deviceshell/tst_deviceshell.cpp
@@ -60,9 +60,10 @@ private:
bool testDocker(const FilePath &executable)
{
QtcProcess p;
- p.setCommand({executable, {"info"}});
+ p.setCommand({executable, {"info", "--format", "{{.OSType}}"}});
p.runBlocking();
- return p.result() == ProcessResult::FinishedWithSuccess;
+ const QString platform = p.cleanedStdOut().trimmed();
+ return p.result() == ProcessResult::FinishedWithSuccess && platform == "linux";
}
class tst_DeviceShell : public QObject
@@ -336,10 +337,25 @@ private slots:
QList<int> runs{1,2,3,4,5,6,7,8,9};
- QList<QByteArray> results = Utils::mapped<QList>(runs, [&shell](const int i) -> QByteArray{
+ int maxDepth = 4;
+ int numMs = 0;
+
+ while (true) {
+ QElapsedTimer t;
+ t.start();
+ DeviceShell::RunResult result = shell.outputForRunInShell({"find", {"/usr", "-maxdepth", QString::number(maxDepth)}});
+ numMs = t.elapsed();
+ qDebug() << "adjusted maxDepth" << maxDepth << "took" << numMs << "ms";
+ if (numMs < 100 || maxDepth == 1) {
+ break;
+ }
+ maxDepth--;
+ }
+
+ QList<QByteArray> results = Utils::mapped<QList>(runs, [&shell, maxDepth](const int i) -> QByteArray{
QElapsedTimer t;
t.start();
- DeviceShell::RunResult result = shell.outputForRunInShell({"find", {"/usr", "-maxdepth", "4"}});
+ DeviceShell::RunResult result = shell.outputForRunInShell({"find", {"/usr", "-maxdepth", QString::number(maxDepth)}});
qDebug() << i << "took" << t.elapsed() << "ms";
return result.stdOut;
});