mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
Improved killing of old processes.
This commit is contained in:
parent
b881d342d5
commit
1f99917069
2 changed files with 47 additions and 10 deletions
|
@ -16,6 +16,11 @@
|
||||||
#include "ui/AutoTester.h"
|
#include "ui/AutoTester.h"
|
||||||
extern AutoTester* autoTester;
|
extern AutoTester* autoTester;
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
#include <windows.h>
|
||||||
|
#include <tlhelp32.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
TestRunner::TestRunner(QObject* parent) : QObject(parent) {
|
TestRunner::TestRunner(QObject* parent) : QObject(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,15 +143,48 @@ void TestRunner::createSnapshotFolder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestRunner::killProcesses() {
|
void TestRunner::killProcesses() {
|
||||||
killProcessByName("assignment-client.exe");
|
|
||||||
killProcessByName("domain-server.exe");
|
|
||||||
killProcessByName("server-console.exe");
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestRunner::killProcessByName(QString processName) {
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
QString commandLine = "taskkill /im " + processName + " /f >nul";
|
try {
|
||||||
system(commandLine.toStdString().c_str());
|
QStringList processesToKill = QStringList() << "interface.exe" << "assignment-client.exe" << "domain-server.exe" << "server-console.exe";
|
||||||
|
|
||||||
|
// Loop until all pending processes to kill have actually died
|
||||||
|
QStringList pendingProcessesToKill;
|
||||||
|
do {
|
||||||
|
pendingProcessesToKill.clear();
|
||||||
|
|
||||||
|
// Get list of running tasks
|
||||||
|
HANDLE processSnapHandle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||||
|
if (processSnapHandle == INVALID_HANDLE_VALUE) {
|
||||||
|
throw("Process snapshot creation failure");
|
||||||
|
}
|
||||||
|
|
||||||
|
PROCESSENTRY32 processEntry32;
|
||||||
|
processEntry32.dwSize = sizeof(PROCESSENTRY32);
|
||||||
|
if (!Process32First(processSnapHandle, &processEntry32)) {
|
||||||
|
CloseHandle(processSnapHandle);
|
||||||
|
throw("Process32First failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kill any task in the list
|
||||||
|
do {
|
||||||
|
foreach (QString process, processesToKill)
|
||||||
|
if (QString(processEntry32.szExeFile) == process) {
|
||||||
|
QString commandLine = "taskkill /im " + process + " /f >nul";
|
||||||
|
system(commandLine.toStdString().c_str());
|
||||||
|
pendingProcessesToKill << process;
|
||||||
|
}
|
||||||
|
} while (Process32Next(processSnapHandle, &processEntry32));
|
||||||
|
|
||||||
|
QThread::sleep(2);
|
||||||
|
} while (!pendingProcessesToKill.isEmpty());
|
||||||
|
|
||||||
|
} catch (QString errorMessage) {
|
||||||
|
QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), errorMessage);
|
||||||
|
exit(-1);
|
||||||
|
} catch (...) {
|
||||||
|
QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "unknown error");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +277,7 @@ void TestRunner::addBuildNumberToResults(QString zippedFolderName) {
|
||||||
// Add the build number to the end of the filename
|
// Add the build number to the end of the filename
|
||||||
QString build = element.text();
|
QString build = element.text();
|
||||||
QStringList filenameParts = zippedFolderName.split(".");
|
QStringList filenameParts = zippedFolderName.split(".");
|
||||||
QString augmentedFilename = filenameParts[0] + "_" + build + "." + filenameParts[1];
|
QString augmentedFilename = filenameParts[0] + "(" + build + ")." + filenameParts[1];
|
||||||
QFile::rename(zippedFolderName, augmentedFilename);
|
QFile::rename(zippedFolderName, augmentedFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ public:
|
||||||
void selectTemporaryFolder();
|
void selectTemporaryFolder();
|
||||||
void createSnapshotFolder();
|
void createSnapshotFolder();
|
||||||
void killProcesses();
|
void killProcesses();
|
||||||
void killProcessByName(QString processName);
|
|
||||||
void startLocalServerProcesses();
|
void startLocalServerProcesses();
|
||||||
void runInterfaceWithTestScript();
|
void runInterfaceWithTestScript();
|
||||||
void evaluateResults();
|
void evaluateResults();
|
||||||
|
|
Loading…
Reference in a new issue