Skip to content

Commit

Permalink
Updated tests to check on symbolication for the .ips crashes too
Browse files Browse the repository at this point in the history
  • Loading branch information
inket committed Aug 6, 2022
1 parent 7eff507 commit 702fa44
Showing 1 changed file with 20 additions and 83 deletions.
103 changes: 20 additions & 83 deletions MacSymbolicatorTests/SymbolicatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,16 @@ class TestFile {
}

class SymbolicatorTests: XCTestCase {
func testSingleTargetCrashSymbolication() {
let testBundle = Bundle(for: MacSymbolicatorTests.self)
let testFile = TestFile(path: "Crashes/single-target-crash.crash")
let dsymFile = DSYMFile(
path: testBundle.url(forResource: "dSYMs/CrashingTest", withExtension: "dSYM")!
)!
private var testBundle: Bundle {
return Bundle(for: MacSymbolicatorTests.self)
}

private func testSymbolication(testFile: TestFile, dsymFiles: [DSYMFile]) {
let crashFile = try! CrashFile(path: testFile.originalURL)

var symbolicator = Symbolicator(
crashFile: crashFile,
dsymFiles: [dsymFile],
dsymFiles: dsymFiles,
logController: DefaultLogController()
)

Expand All @@ -63,106 +61,45 @@ class SymbolicatorTests: XCTestCase {
XCTAssertNotEqual(symbolicator.symbolicatedContent, crashFile.content)
}

func testSingleTargetCrashSymbolication() {
let dsymFile = DSYMFile(
path: testBundle.url(forResource: "dSYMs/CrashingTest", withExtension: "dSYM")!
)!

testSymbolication(testFile: TestFile(path: "Crashes/single-target-crash.ips"), dsymFiles: [dsymFile])
testSymbolication(testFile: TestFile(path: "Crashes/single-target-crash.crash"), dsymFiles: [dsymFile])
}

func testMultiTargetCrashSymbolication() {
let testBundle = Bundle(for: MacSymbolicatorTests.self)
let testFile = TestFile(path: "Crashes/multi-target-crash.crash")
let dsymFiles = [
DSYMFile(path: testBundle.url(forResource: "dSYMs/CrashingInAnotherTargetTest", withExtension: "dSYM")!)!,
DSYMFile(path: testBundle.url(forResource: "dSYMs/AnotherTarget.framework", withExtension: "dSYM")!)!
]

let crashFile = try! CrashFile(path: testFile.originalURL)

var symbolicator = Symbolicator(
crashFile: crashFile,
dsymFiles: dsymFiles,
logController: DefaultLogController()
)

XCTAssert(symbolicator.symbolicate())
let result = symbolicator.symbolicatedContent

try! (result ?? "").write(to: testFile.resultURL, atomically: true, encoding: .utf8)

let expectedContent = try! String(contentsOf: testFile.expectationURL)

XCTAssertEqual(result, expectedContent)
XCTAssertNotEqual(symbolicator.symbolicatedContent, crashFile.content)
testSymbolication(testFile: TestFile(path: "Crashes/multi-target-crash.ips"), dsymFiles: dsymFiles)
testSymbolication(testFile: TestFile(path: "Crashes/multi-target-crash.crash"), dsymFiles: dsymFiles)
}

func testSingleThreadSampleSymbolication() {
let testBundle = Bundle(for: MacSymbolicatorTests.self)
let testFile = TestFile(path: "Samples/singlethread-sample.txt")
let dsymFile = DSYMFile(
path: testBundle.url(forResource: "dSYMs/SingleThreadHangingTest", withExtension: "dSYM")!
)!

let crashFile = try! CrashFile(path: testFile.originalURL)

var symbolicator = Symbolicator(
crashFile: crashFile,
dsymFiles: [dsymFile],
logController: DefaultLogController()
)

XCTAssert(symbolicator.symbolicate())
let result = symbolicator.symbolicatedContent

try! (result ?? "").write(to: testFile.resultURL, atomically: true, encoding: .utf8)

let expectedContent = try! String(contentsOf: testFile.expectationURL)

XCTAssertEqual(result, expectedContent)
XCTAssertNotEqual(symbolicator.symbolicatedContent, crashFile.content)
testSymbolication(testFile: TestFile(path: "Samples/singlethread-sample.txt"), dsymFiles: [dsymFile])
}

func testMultiThreadSampleSymbolication() {
let testBundle = Bundle(for: MacSymbolicatorTests.self)
let testFile = TestFile(path: "Samples/multithread-sample.txt")
let dsymFile = DSYMFile(
path: testBundle.url(forResource: "dSYMs/MultiThreadHangingTest", withExtension: "dSYM")!
)!

let crashFile = try! CrashFile(path: testFile.originalURL)

var symbolicator = Symbolicator(
crashFile: crashFile,
dsymFiles: [dsymFile],
logController: DefaultLogController()
)

XCTAssert(symbolicator.symbolicate())
let result = symbolicator.symbolicatedContent

try! (result ?? "").write(to: testFile.resultURL, atomically: true, encoding: .utf8)

let expectedContent = try! String(contentsOf: testFile.expectationURL)

XCTAssertEqual(result, expectedContent)
XCTAssertNotEqual(symbolicator.symbolicatedContent, crashFile.content)
testSymbolication(testFile: TestFile(path: "Samples/multithread-sample.txt"), dsymFiles: [dsymFile])
}

func testiOSSymbolication() {
let testBundle = Bundle(for: MacSymbolicatorTests.self)
let testFile = TestFile(path: "Crashes/ios-crash.crash")
let dsymFile = DSYMFile(path: testBundle.url(forResource: "dSYMs/iOSCrashingTest.app", withExtension: "dSYM")!)!

let crashFile = try! CrashFile(path: testFile.originalURL)

var symbolicator = Symbolicator(
crashFile: crashFile,
dsymFiles: [dsymFile],
logController: DefaultLogController()
)

XCTAssert(symbolicator.symbolicate())
let result = symbolicator.symbolicatedContent

try! (result ?? "").write(to: testFile.resultURL, atomically: true, encoding: .utf8)

let expectedContent = try! String(contentsOf: testFile.expectationURL)

XCTAssertEqual(result, expectedContent)
XCTAssertNotEqual(symbolicator.symbolicatedContent, crashFile.content)
testSymbolication(testFile: TestFile(path: "Crashes/ios-crash.ips"), dsymFiles: [dsymFile])
testSymbolication(testFile: TestFile(path: "Crashes/ios-crash.crash"), dsymFiles: [dsymFile])
}
}

0 comments on commit 702fa44

Please sign in to comment.