Skip to content

Commit

Permalink
speedup perfparser test by clearing DEBUGINFOD_URLS
Browse files Browse the repository at this point in the history
reduce and drop the unneeded wait time parameter (for full speed on
Debian/Ubuntu this additionally needs KDAB/perfparser#34 to be applied)
  • Loading branch information
GitMensch committed Jan 10, 2024
1 parent 58f4950 commit 16ddec6
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions tests/integrationtests/tst_perfparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class TestPerfParser : public QObject
private slots:
void initTestCase()
{
qputenv("DEBUGINFOD_URLS", {});
RecordHost host;
QSignalSpy capabilitiesSpy(&host, &RecordHost::perfCapabilitiesChanged);
QSignalSpy installedSpy(&host, &RecordHost::isPerfInstalledChanged);
Expand Down Expand Up @@ -230,22 +231,19 @@ private slots:
{
QTest::addColumn<QString>("perfFile");
QTest::addColumn<QString>("errorMessagePart");
QTest::addColumn<int>("waitTime");

const auto perfData = QFINDTESTDATA("file_content/true.perfparser");
QTest::addRow("pre-exported perfparser") << perfData << QString() << 2000;
QTest::addRow("pre-exported perfparser") << perfData << QString();
const auto perfDataSomeName = QStringLiteral("fruitper");
QFile::copy(perfData, perfDataSomeName); // we can ignore errors (file exist) here
QTest::addRow("pre-exported perfparser \"bad extension\"") << perfDataSomeName << QString() << 2000;
QTest::addRow("pre-exported perfparser \"bad extension\"") << perfDataSomeName << QString();
QTest::addRow("no expected magic header")
<< QFINDTESTDATA("tst_perfparser.cpp") << QStringLiteral("File format unknown") << 1000;
QTest::addRow("PERF v1") << QFINDTESTDATA("file_content/perf.data.true.v1") << QStringLiteral("V1 perf data")
<< 1000;
<< QFINDTESTDATA("tst_perfparser.cpp") << QStringLiteral("File format unknown");
QTest::addRow("PERF v1") << QFINDTESTDATA("file_content/perf.data.true.v1") << QStringLiteral("V1 perf data");

// TODO: check why we need this long waittime
QTest::addRow("PERF v2") << QFINDTESTDATA("file_content/perf.data.true.v2") << QString() << 9000;
QTest::addRow("PERF v2") << QFINDTESTDATA("file_content/perf.data.true.v2") << QString();
#if KFArchive_FOUND
QTest::addRow("PERF v2, gzipped") << QFINDTESTDATA("file_content/perf.data.true.v2.gz") << QString() << 10000;
QTest::addRow("PERF v2, gzipped") << QFINDTESTDATA("file_content/perf.data.true.v2.gz") << QString();
#endif
}

Expand All @@ -265,20 +263,19 @@ private slots:

QFETCH(QString, perfFile);
QFETCH(QString, errorMessagePart);
QFETCH(int, waitTime);

QVERIFY(!perfFile.isEmpty() && QFile::exists(perfFile));
parser.startParseFile(perfFile);

if (errorMessagePart.isEmpty()) {
// if we don't expect an error message (Null String created by `QString()`)
// then expect a finish within the given time frame
QTRY_COMPARE_WITH_TIMEOUT(parsingFinishedSpy.count(), 1, waitTime);
QTRY_COMPARE_WITH_TIMEOUT(parsingFinishedSpy.count(), 1, 2000);
QCOMPARE(parsingFailedSpy.count(), 0);
} else {
// otherwise wait for failed parsing, the check for if the required part is
// found in the error message (we only check a part to allow adjustments later)
QTRY_COMPARE_WITH_TIMEOUT(parsingFailedSpy.count(), 1, waitTime);
QTRY_COMPARE_WITH_TIMEOUT(parsingFailedSpy.count(), 1, 2000);
QCOMPARE(parsingFinishedSpy.count(), 0);
const auto message = parsingFailedSpy.takeFirst().at(0).toString();
QVERIFY(message.contains(errorMessagePart));
Expand Down

0 comments on commit 16ddec6

Please sign in to comment.