7
7
#include < QTest>
8
8
9
9
#include " ../../src/parsers/perf/perfparser.h"
10
- #include " ../../src/perfrecord.h"
11
- #include " ../../src/recordhost.h"
12
10
#include " ../testutils.h"
13
11
#include " data.h"
14
12
15
13
class TestCallgraphGenerator : public QObject
16
14
{
17
15
Q_OBJECT
18
16
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
-
30
17
void testParent ()
31
18
{
32
- auto results = callerCalleeResults (m_file. fileName () );
19
+ auto results = callerCalleeResults (s_fileName );
33
20
34
- QVERIFY (callerCalleeResults (m_file. fileName ()) .entries .size () > 0 );
21
+ QVERIFY (! callerCalleeResults (s_fileName) .entries .empty () );
35
22
36
23
auto key = Data::Symbol ();
37
24
for (auto it = results.entries .cbegin (); it != results.entries .cend (); it++) {
@@ -51,14 +38,15 @@ private slots:
51
38
int parent1Pos = test.indexOf (QLatin1String (" parent1" ));
52
39
53
40
QVERIFY (parent3Pos < parent2Pos);
41
+
54
42
QVERIFY (parent2Pos < parent1Pos);
55
43
}
56
44
57
45
void testChild ()
58
46
{
59
- auto results = callerCalleeResults (m_file. fileName () );
47
+ auto results = callerCalleeResults (s_fileName );
60
48
61
- QVERIFY (callerCalleeResults (m_file. fileName ()) .entries .size () > 0 );
49
+ QVERIFY (! callerCalleeResults (s_fileName) .entries .empty () );
62
50
63
51
auto key = Data::Symbol ();
64
52
for (auto it = results.entries .cbegin (); it != results.entries .cend (); it++) {
@@ -85,40 +73,18 @@ private slots:
85
73
qputenv (" HOTSPOT_PERFPARSER" ,
86
74
QCoreApplication::applicationDirPath ().toUtf8 () + QByteArrayLiteral (" /perfparser" ));
87
75
PerfParser parser (this );
88
-
89
76
QSignalSpy parsingFinishedSpy (&parser, &PerfParser::parsingFinished);
90
77
QSignalSpy parsingFailedSpy (&parser, &PerfParser::parsingFailed);
91
78
92
79
parser.startParseFile (filename);
93
80
94
- VERIFY_OR_THROW (parsingFinishedSpy.wait (6000 ));
81
+ VERIFY_OR_THROW (parsingFinishedSpy.wait (60000 ));
95
82
COMPARE_OR_THROW (parsingFailedSpy.count (), 0 );
96
83
97
84
return parser.callerCalleeResults ();
98
85
}
99
86
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" );
122
88
};
123
89
124
90
QTEST_GUILESS_MAIN (TestCallgraphGenerator)
0 commit comments