forked from qt-creator/qt-creator
Valgrind: Use external test data if available
External data files will be tried to search inside a path that is specified by the environment variable QTC_TEST_EXTRADATALOCATION and need to be present inside a subdirectory called 'valgrind'. Change-Id: I8f192b2862e4c269ed17b7a81000eb3dabfc2efb Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -111,6 +111,18 @@ static QString dataFile(const QString &file)
|
|||||||
return QString(PARSERTESTS_DATA_DIR) + '/' + file;
|
return QString(PARSERTESTS_DATA_DIR) + '/' + file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QString extraDataFile(const QString &file)
|
||||||
|
{
|
||||||
|
static QString prefix = QString::fromLocal8Bit(qgetenv("QTC_TEST_EXTRADATALOCATION"));
|
||||||
|
if (prefix.isEmpty())
|
||||||
|
return QString();
|
||||||
|
|
||||||
|
QFileInfo fi(QString(prefix + "/valgrind"), file);
|
||||||
|
if (fi.exists())
|
||||||
|
return fi.canonicalFilePath();
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
void ValgrindMemcheckParserTest::initTestCase()
|
void ValgrindMemcheckParserTest::initTestCase()
|
||||||
{
|
{
|
||||||
m_server = new QTcpServer(this);
|
m_server = new QTcpServer(this);
|
||||||
@@ -131,7 +143,7 @@ void ValgrindMemcheckParserTest::initTest(const QString &testfile, const QString
|
|||||||
m_process->start(
|
m_process->start(
|
||||||
fakeValgrind,
|
fakeValgrind,
|
||||||
QStringList({QString("--xml-socket=127.0.0.1:%1").arg(m_server->serverPort()), "-i",
|
QStringList({QString("--xml-socket=127.0.0.1:%1").arg(m_server->serverPort()), "-i",
|
||||||
dataFile(testfile)}) << otherArgs);
|
testfile}) << otherArgs);
|
||||||
|
|
||||||
QVERIFY(m_process->waitForStarted(5000));
|
QVERIFY(m_process->waitForStarted(5000));
|
||||||
QCOMPARE(m_process->state(), QProcess::Running);
|
QCOMPARE(m_process->state(), QProcess::Running);
|
||||||
@@ -155,9 +167,11 @@ void ValgrindMemcheckParserTest::cleanup()
|
|||||||
|
|
||||||
void ValgrindMemcheckParserTest::testHelgrindSample1()
|
void ValgrindMemcheckParserTest::testHelgrindSample1()
|
||||||
{
|
{
|
||||||
|
const QString file = extraDataFile("helgrind-output-sample1.xml");
|
||||||
|
if (file.isEmpty())
|
||||||
QSKIP("test file does not exist");
|
QSKIP("test file does not exist");
|
||||||
|
|
||||||
initTest("helgrind-output-sample1.xml");
|
initTest(file);
|
||||||
|
|
||||||
QList<Error> expectedErrors;
|
QList<Error> expectedErrors;
|
||||||
{
|
{
|
||||||
@@ -251,7 +265,7 @@ void ValgrindMemcheckParserTest::testHelgrindSample1()
|
|||||||
|
|
||||||
void ValgrindMemcheckParserTest::testMemcheckSample1()
|
void ValgrindMemcheckParserTest::testMemcheckSample1()
|
||||||
{
|
{
|
||||||
initTest("memcheck-output-sample1.xml");
|
initTest(dataFile("memcheck-output-sample1.xml"));
|
||||||
|
|
||||||
QList<Error> expectedErrors;
|
QList<Error> expectedErrors;
|
||||||
{
|
{
|
||||||
@@ -327,9 +341,11 @@ void ValgrindMemcheckParserTest::testMemcheckSample1()
|
|||||||
|
|
||||||
void ValgrindMemcheckParserTest::testMemcheckSample2()
|
void ValgrindMemcheckParserTest::testMemcheckSample2()
|
||||||
{
|
{
|
||||||
|
const QString file = extraDataFile("memcheck-output-sample2.xml");
|
||||||
|
if (file.isEmpty())
|
||||||
QSKIP("test file does not exist");
|
QSKIP("test file does not exist");
|
||||||
|
|
||||||
initTest("memcheck-output-sample2.xml");
|
initTest(file);
|
||||||
|
|
||||||
Parser parser;
|
Parser parser;
|
||||||
Recorder rec(&parser);
|
Recorder rec(&parser);
|
||||||
@@ -353,9 +369,11 @@ void ValgrindMemcheckParserTest::testMemcheckSample2()
|
|||||||
|
|
||||||
void ValgrindMemcheckParserTest::testMemcheckSample3()
|
void ValgrindMemcheckParserTest::testMemcheckSample3()
|
||||||
{
|
{
|
||||||
|
const QString file = extraDataFile("memcheck-output-sample3.xml");
|
||||||
|
if (file.isEmpty())
|
||||||
QSKIP("test file does not exist");
|
QSKIP("test file does not exist");
|
||||||
|
|
||||||
initTest("memcheck-output-sample3.xml");
|
initTest(file);
|
||||||
|
|
||||||
Parser parser;
|
Parser parser;
|
||||||
Recorder rec(&parser);
|
Recorder rec(&parser);
|
||||||
@@ -405,10 +423,12 @@ void ValgrindMemcheckParserTest::testMemcheckSample3()
|
|||||||
|
|
||||||
void ValgrindMemcheckParserTest::testMemcheckCharm()
|
void ValgrindMemcheckParserTest::testMemcheckCharm()
|
||||||
{
|
{
|
||||||
|
// a somewhat larger file, to make sure buffering and partial I/O works ok
|
||||||
|
const QString file = extraDataFile("memcheck-output-charm.xml");
|
||||||
|
if (file.isEmpty())
|
||||||
QSKIP("test file does not exist");
|
QSKIP("test file does not exist");
|
||||||
|
|
||||||
// a somewhat larger file, to make sure buffering and partial I/O works ok
|
initTest(file);
|
||||||
initTest("memcheck-output-untitled.xml");
|
|
||||||
|
|
||||||
Parser parser;
|
Parser parser;
|
||||||
Recorder rec(&parser);
|
Recorder rec(&parser);
|
||||||
@@ -426,7 +446,7 @@ void ValgrindMemcheckParserTest::testMemcheckCharm()
|
|||||||
|
|
||||||
void ValgrindMemcheckParserTest::testValgrindCrash()
|
void ValgrindMemcheckParserTest::testValgrindCrash()
|
||||||
{
|
{
|
||||||
initTest("memcheck-output-sample1.xml", QStringList("--crash"));
|
initTest(dataFile("memcheck-output-sample1.xml"), QStringList("--crash"));
|
||||||
|
|
||||||
Parser parser;
|
Parser parser;
|
||||||
parser.parse(m_socket);
|
parser.parse(m_socket);
|
||||||
@@ -441,7 +461,7 @@ void ValgrindMemcheckParserTest::testValgrindCrash()
|
|||||||
|
|
||||||
void ValgrindMemcheckParserTest::testValgrindGarbage()
|
void ValgrindMemcheckParserTest::testValgrindGarbage()
|
||||||
{
|
{
|
||||||
initTest("memcheck-output-sample1.xml", QStringList("--garbage"));
|
initTest(dataFile("memcheck-output-sample1.xml"), QStringList("--garbage"));
|
||||||
|
|
||||||
Parser parser;
|
Parser parser;
|
||||||
parser.parse(m_socket);
|
parser.parse(m_socket);
|
||||||
|
Reference in New Issue
Block a user