6 #import <XCTest/XCTest.h>
7 #import <OCMock/OCMock.h>
9 #import "mockaksxcbase.h"
10 #import "SecdWatchdog.h"
12 @interface mockaksWatchDog : mockaksxcbase
13 @property (assign) uint64_t diskusage;
16 @implementation mockaksWatchDog
18 - (bool)mockedWatchdogrusage:(rusage_info_current *)rusage
20 memset(rusage, 0, sizeof(*rusage));
21 rusage->ri_diskio_byteswritten = self.diskusage;
22 rusage->ri_logical_writes = self.diskusage;
27 - (void)testWatchDogDiskWrite {
29 id mock = OCMClassMock([SecdWatchdog class]);
30 OCMStub([mock watchdogrusage:[OCMArg anyPointer]]).andCall(self, @selector(mockedWatchdogrusage:));
31 OCMStub([mock triggerOSFaults]).andReturn(FALSE);
33 SecdWatchdog *wd = [SecdWatchdog watchdog];
36 XCTAssertFalse(wd.diskUsageHigh, "diskusage high should not be true");
38 self.diskusage = 2 * 1000 * 1024 * 1024; // 2GiBi
41 XCTAssertTrue(wd.diskUsageHigh, "diskusage high should be true");