Add new types of blocking processes

Change-Id: I7668d0ac94a4e949f7ea67d8a1c0c144af5bd541
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-03-08 00:28:34 +01:00
parent 8c04c2ea55
commit 47bcb63854

View File

@@ -198,6 +198,7 @@ private slots:
void notRunningAfterStartingNonExistingProgram(); void notRunningAfterStartingNonExistingProgram();
void processChannelForwarding_data(); void processChannelForwarding_data();
void processChannelForwarding(); void processChannelForwarding();
void killBlockingProcess_data();
void killBlockingProcess(); void killBlockingProcess();
void flushFinishedWhileWaitingForReadyRead(); void flushFinishedWhileWaitingForReadyRead();
@@ -1223,16 +1224,56 @@ protected:
bool MessageHandler::ok = true; bool MessageHandler::ok = true;
QtMessageHandler MessageHandler::oldMessageHandler = 0; QtMessageHandler MessageHandler::oldMessageHandler = 0;
enum class BlockType {
EndlessLoop,
InfiniteSleep,
MutexDeadlock,
EventLoop
};
void tst_QtcProcess::KillBlockingProcess::main() void tst_QtcProcess::KillBlockingProcess::main()
{ {
std::cout << "Blocking process successfully executed." << std::endl; std::cout << "Blocking process successfully executed." << std::endl;
while (true) const BlockType blockType = BlockType(qEnvironmentVariableIntValue(envVar()));
; switch (blockType) {
case BlockType::EndlessLoop:
while (true)
;
break;
case BlockType::InfiniteSleep:
QThread::sleep(INT_MAX);
break;
case BlockType::MutexDeadlock: {
QMutex mutex;
mutex.lock();
mutex.lock();
break;
}
case BlockType::EventLoop: {
QEventLoop loop;
loop.exec();
break;
}
}
exit(1);
}
void tst_QtcProcess::killBlockingProcess_data()
{
QTest::addColumn<BlockType>("blockType");
QTest::newRow("EndlessLoop") << BlockType::EndlessLoop;
QTest::newRow("InfiniteSleep") << BlockType::InfiniteSleep;
QTest::newRow("MutexDeadlock") << BlockType::MutexDeadlock;
QTest::newRow("EventLoop") << BlockType::EventLoop;
} }
void tst_QtcProcess::killBlockingProcess() void tst_QtcProcess::killBlockingProcess()
{ {
SubCreatorConfig subConfig(KillBlockingProcess::envVar(), {}); QFETCH(BlockType, blockType);
SubCreatorConfig subConfig(KillBlockingProcess::envVar(), QString::number(int(blockType)));
MessageHandler msgHandler; MessageHandler msgHandler;
{ {