Skip to content

Commit 9dce5fb

Browse files
committed
fix tst_callgraphgenerator calling perf
this doesn't work inside a docker container so I added a perfparser dump of the data to process
1 parent 5716bb2 commit 9dce5fb

File tree

3 files changed

+7
-45
lines changed

3 files changed

+7
-45
lines changed

tests/modeltests/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ set_target_properties(
5252
ecm_add_test(
5353
tst_callgraphgenerator.cpp
5454
../../src/parsers/perf/perfparser.cpp
55-
../../src/initiallystoppedprocess.cpp
56-
../../src/perfcontrolfifowrapper.cpp
57-
../../src/perfrecord.cpp
58-
../../src/recordhost.cpp
5955
../../src/callgraphgenerator.cpp
6056
../../src/errnoutil.cpp
6157
LINK_LIBRARIES
7.73 KB
Binary file not shown.

tests/modeltests/tst_callgraphgenerator.cpp

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,18 @@
77
#include <QTest>
88

99
#include "../../src/parsers/perf/perfparser.h"
10-
#include "../../src/perfrecord.h"
11-
#include "../../src/recordhost.h"
1210
#include "../testutils.h"
1311
#include "data.h"
1412

1513
class TestCallgraphGenerator : public QObject
1614
{
1715
Q_OBJECT
1816
private slots:
19-
void initTestCase()
20-
{
21-
const QStringList perfOptions = {QStringLiteral("--call-graph"), QStringLiteral("dwarf")};
22-
QStringList exeOptions;
23-
24-
const QString exePath = findExe(QStringLiteral("callgraph"));
25-
m_file.open();
26-
27-
perfRecord(perfOptions, exePath, exeOptions, m_file.fileName());
28-
}
29-
3017
void testParent()
3118
{
32-
auto results = callerCalleeResults(m_file.fileName());
19+
auto results = callerCalleeResults(s_fileName);
3320

34-
QVERIFY(callerCalleeResults(m_file.fileName()).entries.size() > 0);
21+
QVERIFY(!callerCalleeResults(s_fileName).entries.empty());
3522

3623
auto key = Data::Symbol();
3724
for (auto it = results.entries.cbegin(); it != results.entries.cend(); it++) {
@@ -51,14 +38,15 @@ private slots:
5138
int parent1Pos = test.indexOf(QLatin1String("parent1"));
5239

5340
QVERIFY(parent3Pos < parent2Pos);
41+
5442
QVERIFY(parent2Pos < parent1Pos);
5543
}
5644

5745
void testChild()
5846
{
59-
auto results = callerCalleeResults(m_file.fileName());
47+
auto results = callerCalleeResults(s_fileName);
6048

61-
QVERIFY(callerCalleeResults(m_file.fileName()).entries.size() > 0);
49+
QVERIFY(!callerCalleeResults(s_fileName).entries.empty());
6250

6351
auto key = Data::Symbol();
6452
for (auto it = results.entries.cbegin(); it != results.entries.cend(); it++) {
@@ -85,40 +73,18 @@ private slots:
8573
qputenv("HOTSPOT_PERFPARSER",
8674
QCoreApplication::applicationDirPath().toUtf8() + QByteArrayLiteral("/perfparser"));
8775
PerfParser parser(this);
88-
8976
QSignalSpy parsingFinishedSpy(&parser, &PerfParser::parsingFinished);
9077
QSignalSpy parsingFailedSpy(&parser, &PerfParser::parsingFailed);
9178

9279
parser.startParseFile(filename);
9380

94-
VERIFY_OR_THROW(parsingFinishedSpy.wait(6000));
81+
VERIFY_OR_THROW(parsingFinishedSpy.wait(60000));
9582
COMPARE_OR_THROW(parsingFailedSpy.count(), 0);
9683

9784
return parser.callerCalleeResults();
9885
}
9986

100-
void perfRecord(const QStringList& perfOptions, const QString& exePath, const QStringList& exeOptions,
101-
const QString& fileName)
102-
{
103-
RecordHost host;
104-
PerfRecord perf(&host);
105-
QSignalSpy recordingFinishedSpy(&perf, &PerfRecord::recordingFinished);
106-
QSignalSpy recordingFailedSpy(&perf, &PerfRecord::recordingFailed);
107-
108-
// always add `-c 1000000`, as perf's frequency mode is too unreliable for testing purposes
109-
perf.record(
110-
perfOptions
111-
+ QStringList {QStringLiteral("-c"), QStringLiteral("1000000"), QStringLiteral("--no-buildid-cache")},
112-
fileName, false, exePath, exeOptions);
113-
114-
VERIFY_OR_THROW(recordingFinishedSpy.wait(10000));
115-
116-
COMPARE_OR_THROW(recordingFailedSpy.count(), 0);
117-
COMPARE_OR_THROW(recordingFinishedSpy.count(), 1);
118-
COMPARE_OR_THROW(QFileInfo::exists(fileName), true);
119-
}
120-
121-
QTemporaryFile m_file;
87+
const QString s_fileName = QFINDTESTDATA("callgraph.perfparser");
12288
};
12389

12490
QTEST_GUILESS_MAIN(TestCallgraphGenerator)

0 commit comments

Comments
 (0)