Skip to content

Commit 2f90356

Browse files
committed
Add tests for SentryCrashCPU changes
1 parent c46cd91 commit 2f90356

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Tests/SentryTests/SentryCrash/SentryCrashCPU_Tests.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#import "TestThread.h"
3333

3434
#import <mach/mach.h>
35+
#if defined(__arm64__)
36+
# include <sys/_types/_ucontext64.h>
37+
#endif
3538

3639
@interface SentryCrashCPU_Tests : XCTestCase
3740
@end
@@ -81,12 +84,22 @@ - (void)testCPUState
8184
XCTAssertTrue(value == 0, @"");
8285

8386
uintptr_t address;
87+
#if defined(__arm64__)
88+
ucontext64_t userContext;
89+
userContext.uc_mcontext64 = &machineContext->machineContext;
90+
#else
91+
ucontext_t userContext;
92+
userContext.uc_mcontext = &machineContext->machineContext;
93+
#endif
8494
address = sentrycrashcpu_framePointer(machineContext);
8595
XCTAssertTrue(address != 0, @"");
96+
XCTAssertEqual(sentrycrashcpu_framePointerFromUserContext(&userContext), address);
8697
address = sentrycrashcpu_stackPointer(machineContext);
8798
XCTAssertTrue(address != 0, @"");
99+
XCTAssertEqual(sentrycrashcpu_stackPointerFromUserContext(&userContext), address);
88100
address = sentrycrashcpu_instructionAddress(machineContext);
89101
XCTAssertTrue(address != 0, @"");
102+
XCTAssertEqual(sentrycrashcpu_instructionAddressFromUserContext(&userContext), address);
90103

91104
numRegisters = sentrycrashcpu_numExceptionRegisters();
92105
for (int i = 0; i < numRegisters; i++) {

0 commit comments

Comments
 (0)