summaryrefslogtreecommitdiffstats
path: root/tests/auto/addresscache/tst_addresscache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/addresscache/tst_addresscache.cpp')
-rw-r--r--tests/auto/addresscache/tst_addresscache.cpp41
1 files changed, 35 insertions, 6 deletions
diff --git a/tests/auto/addresscache/tst_addresscache.cpp b/tests/auto/addresscache/tst_addresscache.cpp
index 2086410..951d2bb 100644
--- a/tests/auto/addresscache/tst_addresscache.cpp
+++ b/tests/auto/addresscache/tst_addresscache.cpp
@@ -37,24 +37,53 @@ private slots:
info_b.addr = 0x200;
PerfAddressCache cache;
+ PerfAddressCache::OffsetAddressCache invalidAddressCache;
PerfAddressCache::AddressCacheEntry entry{42, true};
- cache.cache(info_a, 0x110, entry);
- QCOMPARE(cache.find(info_a, 0x110).locationId, entry.locationId);
- QCOMPARE(cache.find(info_b, 0x210).locationId, entry.locationId);
+ cache.cache(info_a, 0x110, entry, &invalidAddressCache);
+ QCOMPARE(cache.find(info_a, 0x110, &invalidAddressCache).locationId, entry.locationId);
+ QCOMPARE(cache.find(info_b, 0x210, &invalidAddressCache).locationId, entry.locationId);
}
void testInvalid()
{
PerfAddressCache cache;
+ PerfAddressCache::OffsetAddressCache invalidAddressCache_a;
+ PerfAddressCache::OffsetAddressCache invalidAddressCache_b;
PerfAddressCache::AddressCacheEntry entry{42, true};
- cache.cache(PerfElfMap::ElfInfo{}, 0x110, entry);
- QCOMPARE(cache.find(PerfElfMap::ElfInfo{}, 0x110).locationId, entry.locationId);
+ cache.cache(PerfElfMap::ElfInfo{}, 0x110, entry, &invalidAddressCache_a);
+ QCOMPARE(cache.find(PerfElfMap::ElfInfo{}, 0x110, &invalidAddressCache_a).locationId, entry.locationId);
+ QCOMPARE(cache.find(PerfElfMap::ElfInfo{}, 0x110, &invalidAddressCache_b).locationId, -1);
}
void testEmpty()
{
PerfAddressCache cache;
- QCOMPARE(cache.find(PerfElfMap::ElfInfo{}, 0x123).locationId, -1);
+ PerfAddressCache::OffsetAddressCache invalidAddressCache;
+ QCOMPARE(cache.find(PerfElfMap::ElfInfo{}, 0x123, &invalidAddressCache).locationId, -1);
+ }
+
+ void testSymbolCache()
+ {
+ const auto libfoo_a = QByteArrayLiteral("/usr/lib/libfoo_a.so");
+ const auto libfoo_b = QByteArrayLiteral("/usr/lib/libfoo_b.so");
+
+ PerfAddressCache cache;
+
+ QVERIFY(!cache.findSymbol(libfoo_a, 0).isValid());
+ QVERIFY(!cache.findSymbol(libfoo_b, 0).isValid());
+
+ cache.setSymbolCache(libfoo_a, {{0x100, 0x100, 10, "Foo"}, {0x11a, 0x11a, 0, "FooZ"}, {0x12a, 0x12a, 10, "FooN"}});
+ for (auto addr : {0x100, 0x100 + 9}) {
+ const auto cached = cache.findSymbol(libfoo_a, addr);
+ QVERIFY(cached.isValid());
+ QCOMPARE(cached.offset, quint64(0x100));
+ QCOMPARE(cached.size, quint64(10));
+ QCOMPARE(cached.symname, "Foo");
+ }
+ QVERIFY(!cache.findSymbol(libfoo_a, 0x100 + 10).isValid());
+ QVERIFY(!cache.findSymbol(libfoo_b, 0x100).isValid());
+ QVERIFY(!cache.findSymbol(libfoo_b, 0x100 + 9).isValid());
+ QVERIFY(cache.findSymbol(libfoo_a, 0x11a + 1).isValid());
}
};