Skip to content

Commit efa5ebf

Browse files
committed
Add test for local symbols in symbol cache
- Implement `testLocalSymbolsInSymbolCache` method in both test classes - Validate retrieval of local symbols for Mach-O files
1 parent 4547989 commit efa5ebf

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

Tests/MachOKitTests/DyldCachePrintTests.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,28 @@ final class DyldCachePrintTests: XCTestCase {
152152
}
153153
}
154154

155+
func testLocalSymbolsInSymbolCache() throws {
156+
guard let symbolCache = try cache.symbolCache else {
157+
return
158+
}
159+
guard let info = symbolCache.localSymbolsInfo else {
160+
return
161+
}
162+
let machO = cache.machOFiles().first(
163+
where: {
164+
$0.imagePath.contains("/SwiftUICore")
165+
}
166+
)!
167+
guard let entry = info.entry(for: machO, in: symbolCache) else {
168+
XCTFail("No entry found")
169+
return
170+
}
171+
let symbols = Array(info.symbols(in: symbolCache))[entry.nlistRange]
172+
for symbol in symbols.prefix(100) {
173+
print(symbol.name)
174+
}
175+
}
176+
155177
func testMachOFiles() throws {
156178
let machOs = cache.machOFiles()
157179
for machO in machOs {

Tests/MachOKitTests/FullDyldCachePrintTests.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,28 @@ final class FullDyldCachePrintTests: XCTestCase {
148148
}
149149
}
150150

151+
func testLocalSymbolsInSymbolCache() throws {
152+
guard let symbolCache = try cache.symbolCache else {
153+
return
154+
}
155+
guard let info = symbolCache.localSymbolsInfo else {
156+
return
157+
}
158+
let machO = cache.machOFiles().first(
159+
where: {
160+
$0.imagePath.contains("/SwiftUICore")
161+
}
162+
)!
163+
guard let entry = info.entry(for: machO, in: symbolCache) else {
164+
XCTFail("No entry found")
165+
return
166+
}
167+
let symbols = Array(info.symbols(in: symbolCache))[entry.nlistRange]
168+
for symbol in symbols.prefix(100) {
169+
print(symbol.name)
170+
}
171+
}
172+
151173
func testMachOFiles() throws {
152174
let machOs = cache.machOFiles()
153175
for machO in machOs {

0 commit comments

Comments
 (0)