forked from qt-creator/qt-creator
Process test: Prevent empty loop from being optimized out
This should fix the macOS "Run tests" on GitHub Build Bot. Change-Id: Iae185d47fa33c97c63480b10d5a25a1d4c13f532 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -161,10 +161,16 @@ int ProcessTestApp::BlockingProcess::main()
|
|||||||
{
|
{
|
||||||
std::cout << "Blocking process successfully executed." << std::endl;
|
std::cout << "Blocking process successfully executed." << std::endl;
|
||||||
const BlockType blockType = BlockType(qEnvironmentVariableIntValue(envVar()));
|
const BlockType blockType = BlockType(qEnvironmentVariableIntValue(envVar()));
|
||||||
|
bool dummy = true;
|
||||||
switch (blockType) {
|
switch (blockType) {
|
||||||
case BlockType::EndlessLoop:
|
case BlockType::EndlessLoop:
|
||||||
while (true)
|
while (true) {
|
||||||
;
|
if (dummy) {
|
||||||
|
// Note: Keep these lines, otherwise the compiler may optimize out the empty loop.
|
||||||
|
std::cout << "EndlessLoop started" << std::endl;
|
||||||
|
dummy = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BlockType::InfiniteSleep:
|
case BlockType::InfiniteSleep:
|
||||||
QThread::sleep(INT_MAX);
|
QThread::sleep(INT_MAX);
|
||||||
|
@@ -1216,7 +1216,6 @@ void tst_Process::mergedChannels_data()
|
|||||||
<< false << false << false << true;
|
<< false << false << false << true;
|
||||||
QTest::newRow("ForwardedErrorChannel") << QProcess::ForwardedErrorChannel
|
QTest::newRow("ForwardedErrorChannel") << QProcess::ForwardedErrorChannel
|
||||||
<< true << false << false << false;
|
<< true << false << false << false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_Process::mergedChannels()
|
void tst_Process::mergedChannels()
|
||||||
@@ -1265,6 +1264,7 @@ void tst_Process::destroyBlockingProcess()
|
|||||||
subConfig.setupSubProcess(&process);
|
subConfig.setupSubProcess(&process);
|
||||||
process.start();
|
process.start();
|
||||||
QVERIFY(process.waitForStarted());
|
QVERIFY(process.waitForStarted());
|
||||||
|
QVERIFY(process.isRunning());
|
||||||
QVERIFY(!process.waitForFinished(1000));
|
QVERIFY(!process.waitForFinished(1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user