@@ -140,6 +140,31 @@ - (void)testTwoWayAndMultiplexInvocation {
140
140
[service invalidate ];
141
141
}
142
142
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
+
143
168
- (void )testDispatchAsyncEarlyReturn {
144
169
[self launchApplicationWithPort: EDOTEST_APP_SERVICE_PORT initValue: 5 ];
145
170
EDOHostService *service =
0 commit comments