Skip to content

Commit 372b62f

Browse files
Update testTwoWayAndMultiplexInvocation.
PiperOrigin-RevId: 276769286
1 parent f872075 commit 372b62f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Service/Tests/FunctionalTests/EDOServiceUITest.m

+25
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,31 @@ - (void)testTwoWayAndMultiplexInvocation {
140140
[service invalidate];
141141
}
142142

143+
- (void)testMultiplexInvocationStressfully {
144+
[self launchApplicationWithPort:EDOTEST_APP_SERVICE_PORT initValue:5];
145+
146+
EDOTestDummy *remoteDummy = [EDOClientService rootObjectWithPort:EDOTEST_APP_SERVICE_PORT];
147+
XCTAssertEqualObjects([remoteDummy class], NSClassFromString(@"EDOObject"));
148+
149+
const int kStressTestAttempts = 5;
150+
const int kConcurrentNumber = 15;
151+
EDOTestDummyInTest *dummy = [[EDOTestDummyInTest alloc] initWithValue:8];
152+
153+
for (int i = 0; i < kStressTestAttempts; ++i) {
154+
XCTestExpectation *nestedCallExpectation =
155+
[self expectationWithDescription:@"nested invocation completed."];
156+
// The inner dispatch_apply performs actual stressful execution, and the test considers deadlock
157+
// will happen if dispatch_apply cannot complete within the timeout.
158+
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
159+
dispatch_apply(kConcurrentNumber, DISPATCH_APPLY_AUTO, ^(size_t iteration) {
160+
[remoteDummy callBackToTest:dummy withValue:7];
161+
});
162+
[nestedCallExpectation fulfill];
163+
});
164+
[self waitForExpectations:@[ nestedCallExpectation ] timeout:5.f];
165+
}
166+
}
167+
143168
- (void)testDispatchAsyncEarlyReturn {
144169
[self launchApplicationWithPort:EDOTEST_APP_SERVICE_PORT initValue:5];
145170
EDOHostService *service =

0 commit comments

Comments
 (0)