diff --git a/src/darwin/Framework/CHIPTests/MTRAsyncWorkQueueTests.m b/src/darwin/Framework/CHIPTests/MTRAsyncWorkQueueTests.m index 1b0b3d6ff8ed2a..3207a851b2e9ac 100644 --- a/src/darwin/Framework/CHIPTests/MTRAsyncWorkQueueTests.m +++ b/src/darwin/Framework/CHIPTests/MTRAsyncWorkQueueTests.m @@ -544,13 +544,17 @@ - (void)testItemsConcurrently [self waitForExpectations:@[ first3WorkItemsExecutedExpectation ] timeout:2]; // the before-sleep counter should have reached 3 immediately as they all run concurrently. + os_unfair_lock_lock(&counterLock); XCTAssertEqual(afterSleepCounter, 0); + os_unfair_lock_unlock(&counterLock); [self waitForExpectations:@[ lastWorkItemWaitedExpectation, first3WorkItemsSleptExpectation ] timeout:2]; // see that all 3 first items ran and slept + os_unfair_lock_lock(&counterLock); XCTAssertEqual(beforeSleepCounter, 3); XCTAssertEqual(afterSleepCounter, 3); + os_unfair_lock_unlock(&counterLock); } @end