summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2017-04-11 11:10:05 +0200
committerMilian Wolff <milian.wolff@kdab.com>2017-04-12 13:32:33 +0000
commit74a1fa8cf0e3e2050aa155591d6a23f08d9ecce6 (patch)
tree483fb8a974f770a9ffdad0c2f9478b589848434e /tests
parent60377d85e4a6542aca090716c0079af09a79cd9e (diff)
Report an error when the kallsyms file could not be parsed
When a wrong kallsym path is given, or the file could not be parsed correctly, e.g. when it was empty, then we want to notify the user about this. Otherwise, it may not be clear why symbol resolution for kernel addresses is broken. Change-Id: Icf51fa3038810e69a91d332a33495e7678b3977a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/kallsyms/tst_kallsyms.cpp44
1 files changed, 40 insertions, 4 deletions
diff --git a/tests/auto/kallsyms/tst_kallsyms.cpp b/tests/auto/kallsyms/tst_kallsyms.cpp
index 4d8d756..d9f7c31 100644
--- a/tests/auto/kallsyms/tst_kallsyms.cpp
+++ b/tests/auto/kallsyms/tst_kallsyms.cpp
@@ -86,7 +86,9 @@ private slots:
file.write(kallsymsContents);
file.flush();
- PerfKallsyms kallsyms(file.fileName());
+ PerfKallsyms kallsyms;
+ QVERIFY(kallsyms.parseMapping(file.fileName()));
+ QVERIFY(kallsyms.errorString().isEmpty());
const auto entry = kallsyms.findEntry(address);
QCOMPARE(entry.address, expectedAddress);
@@ -100,7 +102,9 @@ private slots:
if (!QFile::exists(path))
QSKIP("/proc/kallsysms not available");
- PerfKallsyms kallsyms(path);
+ PerfKallsyms kallsyms;
+ QVERIFY(kallsyms.parseMapping(path));
+ QVERIFY(kallsyms.errorString().isEmpty());
// just check that we find any entry
const auto addr = std::numeric_limits<quint64>::max();
@@ -108,6 +112,37 @@ private slots:
QVERIFY(!entry.symbol.isEmpty());
}
+ void testParseErrors()
+ {
+ QTemporaryFile file;
+ QVERIFY(file.open());
+ const auto fileName = file.fileName();
+
+ {
+ PerfKallsyms kallsyms;
+ QVERIFY(!kallsyms.parseMapping(fileName));
+ qDebug() << kallsyms.errorString(); // file is empty
+ QVERIFY(!kallsyms.errorString().isEmpty());
+ }
+
+ file.write("this is garbage and not a valid mapping\n");
+ file.flush();
+ {
+ PerfKallsyms kallsyms;
+ QVERIFY(!kallsyms.parseMapping(fileName));
+ qDebug() << kallsyms.errorString(); // invalid address
+ QVERIFY(!kallsyms.errorString().isEmpty());
+ }
+
+ QVERIFY(file.remove());
+ {
+ PerfKallsyms kallsyms;
+ QVERIFY(!kallsyms.parseMapping(fileName));
+ qDebug() << kallsyms.errorString(); // file not found
+ QVERIFY(!kallsyms.errorString().isEmpty());
+ }
+ }
+
void benchmarkProc()
{
const auto path = QStringLiteral("/proc/kallsyms");
@@ -115,8 +150,9 @@ private slots:
QSKIP("/proc/kallsysms not available");
QBENCHMARK {
- PerfKallsyms kallsyms(path);
- Q_UNUSED(kallsyms);
+ PerfKallsyms kallsyms;
+ bool parsed = kallsyms.parseMapping(path);
+ Q_UNUSED(parsed);
}
}
};