forked from qt-creator/qt-creator
Valgrind test: Use Utils::Process instead of QProcess
Change-Id: Id7a0611fd7d36adc22993f50cce87cd30c6a336c Reviewed-by: hjk <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -14,7 +14,6 @@
|
|||||||
#include <projectexplorer/runcontrol.h>
|
#include <projectexplorer/runcontrol.h>
|
||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QProcess>
|
|
||||||
#include <QTcpServer>
|
#include <QTcpServer>
|
||||||
#include <QTest>
|
#include <QTest>
|
||||||
|
|
||||||
@@ -148,17 +147,17 @@ void ValgrindMemcheckParserTest::initTest(const QString &testfile, const QString
|
|||||||
{
|
{
|
||||||
QVERIFY(!m_server->hasPendingConnections());
|
QVERIFY(!m_server->hasPendingConnections());
|
||||||
|
|
||||||
m_process = new QProcess(m_server);
|
m_process.reset(new Process);
|
||||||
m_process->setProcessChannelMode(QProcess::ForwardedChannels);
|
m_process->setProcessChannelMode(QProcess::ForwardedChannels);
|
||||||
const QString fakeValgrind = fakeValgrindExecutable();
|
const QString fakeValgrind = fakeValgrindExecutable();
|
||||||
const QFileInfo fileInfo(fakeValgrind);
|
const QFileInfo fileInfo(fakeValgrind);
|
||||||
QVERIFY2(fileInfo.isExecutable(), qPrintable(fakeValgrind));
|
QVERIFY2(fileInfo.isExecutable(), qPrintable(fakeValgrind));
|
||||||
QVERIFY2(!fileInfo.isDir(), qPrintable(fakeValgrind));
|
QVERIFY2(!fileInfo.isDir(), qPrintable(fakeValgrind));
|
||||||
|
|
||||||
m_process->start(
|
const QStringList args = {QString("--xml-socket=127.0.0.1:%1").arg(m_server->serverPort()),
|
||||||
fakeValgrind,
|
"-i", testfile};
|
||||||
QStringList({QString("--xml-socket=127.0.0.1:%1").arg(m_server->serverPort()), "-i",
|
m_process->setCommand({FilePath::fromString(fakeValgrind), args + otherArgs});
|
||||||
testfile}) << otherArgs);
|
m_process->start();
|
||||||
|
|
||||||
QVERIFY(m_process->waitForStarted(5000));
|
QVERIFY(m_process->waitForStarted(5000));
|
||||||
QCOMPARE(m_process->state(), QProcess::Running);
|
QCOMPARE(m_process->state(), QProcess::Running);
|
||||||
@@ -171,10 +170,7 @@ void ValgrindMemcheckParserTest::initTest(const QString &testfile, const QString
|
|||||||
void ValgrindMemcheckParserTest::cleanup()
|
void ValgrindMemcheckParserTest::cleanup()
|
||||||
{
|
{
|
||||||
m_socket.reset();
|
m_socket.reset();
|
||||||
if (m_process) {
|
m_process.reset();
|
||||||
delete m_process;
|
|
||||||
m_process = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValgrindMemcheckParserTest::testHelgrindSample1()
|
void ValgrindMemcheckParserTest::testHelgrindSample1()
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
#include <utils/process.h>
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QProcess;
|
|
||||||
class QTcpServer;
|
class QTcpServer;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ private:
|
|||||||
void initTest(const QString &testfile, const QStringList &otherArgs = {});
|
void initTest(const QString &testfile, const QStringList &otherArgs = {});
|
||||||
|
|
||||||
QTcpServer *m_server = nullptr;
|
QTcpServer *m_server = nullptr;
|
||||||
QProcess *m_process = nullptr;
|
std::unique_ptr<Utils::Process> m_process;
|
||||||
std::unique_ptr<QTcpSocket> m_socket;
|
std::unique_ptr<QTcpSocket> m_socket;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user