ios: Simplify testBadAccess by removing optimizations.

The badAccess test may return different mach exception codes depending
on optimization levels. Simplify by this by turning off optimization
for this particular test.

Also removes testSegv, which was duplicative and not really testing
SIGSEGV.

Change-Id: Idb92731da6a86545ed83c2bbdd200a0b792c579f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3403040
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
This commit is contained in:
Justin Cohen 2022-01-20 12:16:41 -05:00 committed by Crashpad LUCI CQ
parent 50531fc68f
commit b25b523d30
3 changed files with 8 additions and 32 deletions

View File

@ -16,6 +16,7 @@
#include <objc/runtime.h>
#import "Service/Sources/EDOClientService.h"
#include "build/build_config.h"
#import "test/ios/host/cptest_shared_object.h"
#include "util/mach/exception_types.h"
#include "util/mach/mach_extensions.h"
@ -85,19 +86,6 @@
XCTAssertEqualObjects(result, @"crashpad");
}
- (void)testSegv {
[rootObject_ crashSegv];
#if defined(NDEBUG)
#if TARGET_OS_SIMULATOR
[self verifyCrashReportException:EXC_BAD_INSTRUCTION];
#else
[self verifyCrashReportException:EXC_BREAKPOINT];
#endif
#else
[self verifyCrashReportException:EXC_BAD_ACCESS];
#endif
}
- (void)testKillAbort {
[rootObject_ crashKillAbort];
[self verifyCrashReportException:EXC_SOFT_SIGNAL];
@ -108,10 +96,12 @@
- (void)testTrap {
[rootObject_ crashTrap];
#if TARGET_OS_SIMULATOR
#if defined(ARCH_CPU_X86_64)
[self verifyCrashReportException:EXC_BAD_INSTRUCTION];
#else
#elif defined(ARCH_CPU_ARM64)
[self verifyCrashReportException:EXC_BREAKPOINT];
#else
#error Port to your CPU architecture
#endif
}
@ -125,15 +115,7 @@
- (void)testBadAccess {
[rootObject_ crashBadAccess];
#if defined(NDEBUG)
#if TARGET_OS_SIMULATOR
[self verifyCrashReportException:EXC_BAD_INSTRUCTION];
#else
[self verifyCrashReportException:EXC_BREAKPOINT];
#endif
#else
[self verifyCrashReportException:EXC_BAD_ACCESS];
#endif
}
- (void)testException {

View File

@ -241,7 +241,9 @@ GetProcessSnapshotMinidumpFromSinglePending() {
return [dict passByValue];
}
- (void)crashBadAccess {
// Use [[clang::optnone]] here to get consistent exception codes, otherwise the
// exception can change depending on optimization level.
- (void)crashBadAccess [[clang::optnone]] {
strcpy(nullptr, "bla");
}
@ -249,11 +251,6 @@ GetProcessSnapshotMinidumpFromSinglePending() {
kill(getpid(), SIGABRT);
}
- (void)crashSegv {
long* zero = nullptr;
*zero = 0xc045004d;
}
- (void)crashTrap {
__builtin_trap();
}

View File

@ -58,9 +58,6 @@
// Triggers a crash with a call to kill(SIGABRT).
- (void)crashKillAbort;
// Triggers a segfault crash.
- (void)crashSegv;
// Trigger a crash with a __builtin_trap.
- (void)crashTrap;