IOSAD-141 Test for "hammering" the engine. IOSAD-141
authorDirk Zimmermann <dz@pep.security>
Fri, 20 Sep 2019 10:01:48 +0200
branchIOSAD-141
changeset 1250b6a4d30abd26
parent 1247 ec96c9c3248e
child 1433 2bf1d496e310
IOSAD-141 Test for "hammering" the engine.
pEpObjCTests/PEPSessionTest.m
     1.1 --- a/pEpObjCTests/PEPSessionTest.m	Fri Sep 13 06:48:58 2019 +0200
     1.2 +++ b/pEpObjCTests/PEPSessionTest.m	Fri Sep 20 10:01:48 2019 +0200
     1.3 @@ -1473,8 +1473,13 @@
     1.4  
     1.5      NSInteger loopCount = 200;
     1.6  
     1.7 +    NSMutableArray *expectationsToWaitFor = [NSMutableArray new];
     1.8 +
     1.9      for (NSUInteger iOuter = 0; iOuter < 100; ++iOuter) {
    1.10 -        XCTestExpectation *expThread1Finished = [self expectationWithDescription:@"Thread1 finished"];
    1.11 +        NSString *threadName1 = [NSString stringWithFormat:@"Thread_%lu_1", (unsigned long) iOuter];
    1.12 +        NSString *threadName1Finished = [NSString stringWithFormat:@"%@ finished", threadName1];
    1.13 +        XCTestExpectation *expThread1Finished = [self expectationWithDescription:threadName1Finished];
    1.14 +        [expectationsToWaitFor addObject:expThread1Finished];
    1.15          NSThread *thread1 = [[NSThread alloc] initWithBlock:^{
    1.16              PEPSession *session1 = [PEPSession new];
    1.17              NSError *error1 = nil;
    1.18 @@ -1489,9 +1494,12 @@
    1.19              }
    1.20              [expThread1Finished fulfill];
    1.21          }];
    1.22 -        [thread1 setName:@"Thread 1"];
    1.23 +        [thread1 setName:threadName1];
    1.24  
    1.25 -        XCTestExpectation *expThread2Finished = [self expectationWithDescription:@"Thread2 finished"];
    1.26 +        NSString *threadName2 = [NSString stringWithFormat:@"Thread_%lu_2", (unsigned long) iOuter];
    1.27 +        NSString *threadName2Finished = [NSString stringWithFormat:@"%@ finished", threadName1];
    1.28 +        XCTestExpectation *expThread2Finished = [self expectationWithDescription:threadName2Finished];
    1.29 +        [expectationsToWaitFor addObject:expThread2Finished];
    1.30          NSThread *thread2 = [[NSThread alloc] initWithBlock:^{
    1.31              PEPSession *session2 = [PEPSession new];
    1.32              NSError *error2 = nil;
    1.33 @@ -1511,13 +1519,13 @@
    1.34              }
    1.35              [expThread2Finished fulfill];
    1.36          }];
    1.37 -        [thread2 setName:@"Thread 2"];
    1.38 +        [thread2 setName:threadName2];
    1.39  
    1.40          [thread1 start];
    1.41          [thread2 start];
    1.42 +    }
    1.43  
    1.44 -        [self waitForExpectations:@[expThread1Finished, expThread2Finished] timeout:20];
    1.45 -    }
    1.46 +    [self waitForExpectations:expectationsToWaitFor timeout:DBL_MAX];
    1.47  }
    1.48  
    1.49  #pragma mark - Helpers