Skip to content

Commit

Permalink
Additional tuning of unit test timing to avoid timing conditions that…
Browse files Browse the repository at this point in the history
… fails the test when the machine is slow
  • Loading branch information
jtung-apple committed May 23, 2024
1 parent 285b2b1 commit 59bf484
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/darwin/Framework/CHIPTests/MTRDeviceTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -3744,7 +3744,7 @@ - (void)test036_TestStorageBehaviorConfiguration
// Check delay exists
XCTAssertGreaterThan(reportToPersistenceDelay, baseTestDelayTime / 2);
// Check delay is expectd - use base delay plus small fudge in case of CPU slowness with dispatch_after
XCTAssertLessThan(reportToPersistenceDelay, baseTestDelayTime * 1.1);
XCTAssertLessThan(reportToPersistenceDelay, baseTestDelayTime * 1.3);

XCTestExpectation * dataPersisted2 = [self expectationWithDescription:@"data persisted 2"];

Expand Down Expand Up @@ -3791,7 +3791,7 @@ - (void)test036_TestStorageBehaviorConfiguration
os_unfair_lock_unlock(&lock);
// Check delay exists and approximately reportToPersistenceDelayTimeMax, which is base delay times 2
XCTAssertGreaterThan(reportToPersistenceDelay, baseTestDelayTime * 2 * 0.9);
XCTAssertLessThan(reportToPersistenceDelay, baseTestDelayTime * 2 * 1.1);
XCTAssertLessThan(reportToPersistenceDelay, baseTestDelayTime * 2 * 1.3); // larger upper limit in case machine is slow

delegate.onClusterDataPersisted = nil;

Expand Down Expand Up @@ -3834,7 +3834,7 @@ - (void)test036_TestStorageBehaviorConfiguration
os_unfair_lock_unlock(&lock);
// Check delay exists and approximately base delay times 3
XCTAssertGreaterThan(reportToPersistenceDelay, baseTestDelayTime * 3 * 0.9);
XCTAssertLessThan(reportToPersistenceDelay, baseTestDelayTime * 3 * 1.1);
XCTAssertLessThan(reportToPersistenceDelay, baseTestDelayTime * 3 * 1.3); // larger upper limit in case machine is slow

// Test 4: test reporting excessively, and see that persistence does not happen until
// reporting frequency goes back above the threshold
Expand Down

0 comments on commit 59bf484

Please sign in to comment.