Skip to content

Commit

Permalink
Fix tests on watchOS
Browse files Browse the repository at this point in the history
  • Loading branch information
bamx23 committed May 6, 2024
1 parent 19f0f0e commit e691528
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
19 changes: 17 additions & 2 deletions Sources/KSCrashRecording/Monitors/KSCrashMonitor_Signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,32 @@ static void addContextualInfoToEvent(struct KSCrash_MonitorContext* eventContext
}
}

#else

static void setEnabled(bool isEnabled)
{
// Not supported
}

static bool isEnabled(void)
{
return false;
}

static void addContextualInfoToEvent(struct KSCrash_MonitorContext* eventContext)
{
// Not supported
}

#endif

KSCrashMonitorAPI* kscm_signal_getAPI(void)
{
static KSCrashMonitorAPI api =
{
#if KSCRASH_HAS_SIGNAL
.setEnabled = setEnabled,
.isEnabled = isEnabled,
.addContextualInfoToEvent = addContextualInfoToEvent
#endif
};
return &api;
}
4 changes: 4 additions & 0 deletions Tests/KSCrashRecordingCoreTests/KSCPU_Tests.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@

#import <XCTest/XCTest.h>

#import "KSSystemCapabilities.h"
#import "KSCPU.h"
#import "KSMachineContext.h"
#import "TestThread.h"

#import <mach/mach.h>

#if KSCRASH_HAS_THREADS_API

@interface KSCPU_Tests : XCTestCase @end

Expand Down Expand Up @@ -97,3 +99,5 @@ - (void) testStackGrowDirection
}

@end

#endif
21 changes: 20 additions & 1 deletion Tests/KSCrashRecordingTests/KSCrashMonitor_Signal_Tests.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@

#import <XCTest/XCTest.h>

#import "KSSystemCapabilities.h"
#import "KSCrashMonitorContext.h"
#import "KSCrashMonitor_Signal.h"


@interface KSCrashMonitor_Signal_Tests : XCTestCase @end


@implementation KSCrashMonitor_Signal_Tests

#if KSCRASH_HAS_SIGNAL

- (void) testInstallAndRemove
{
KSCrashMonitorAPI* api = kscm_signal_getAPI();
Expand All @@ -61,4 +63,21 @@ - (void) testDoubleInstallAndRemove
XCTAssertFalse(api->isEnabled());
}

#else

- (void) testNoImplementation
{
KSCrashMonitorAPI* api = kscm_signal_getAPI();

KSCrash_MonitorContext context;
api->addContextualInfoToEvent(&context);

api->setEnabled(true);
XCTAssertFalse(api->isEnabled());
api->setEnabled(false);
XCTAssertFalse(api->isEnabled());
}

#endif

@end

0 comments on commit e691528

Please sign in to comment.