@@ -141,14 +141,14 @@ var serverKey = loadPEM('agent2-key');
141141var serverCert = loadPEM ( 'agent2-cert' ) ;
142142
143143
144- function runClient ( options , cb ) {
144+ function runClient ( port , options , cb ) {
145145
146146 // Client can connect in three ways:
147147 // - Self-signed cert
148148 // - Certificate, but not signed by CA.
149149 // - Certificate signed by CA.
150150
151- var args = [ 's_client' , '-connect' , '127.0.0.1:' + common . PORT ] ;
151+ var args = [ 's_client' , '-connect' , '127.0.0.1:' + port ] ;
152152
153153
154154 console . log ( ' connecting with' , options . name ) ;
@@ -246,7 +246,7 @@ function runClient(options, cb) {
246246
247247// Run the tests
248248var successfulTests = 0 ;
249- function runTest ( testIndex ) {
249+ function runTest ( port , testIndex ) {
250250 var tcase = testCases [ testIndex ] ;
251251 if ( ! tcase ) return ;
252252
@@ -309,31 +309,31 @@ function runTest(testIndex) {
309309 function runNextClient ( clientIndex ) {
310310 var options = tcase . clients [ clientIndex ] ;
311311 if ( options ) {
312- runClient ( options , function ( ) {
312+ runClient ( port , options , function ( ) {
313313 runNextClient ( clientIndex + 1 ) ;
314314 } ) ;
315315 } else {
316316 server . close ( ) ;
317317 successfulTests ++ ;
318- runTest ( testIndex + 1 ) ;
318+ runTest ( port , nextTest ++ ) ;
319319 }
320320 }
321321
322- server . listen ( common . PORT , function ( ) {
322+ server . listen ( port , function ( ) {
323323 if ( tcase . debug ) {
324- console . error ( 'TLS server running on port ' + common . PORT ) ;
324+ console . error ( 'TLS server running on port ' + port ) ;
325325 } else {
326326 if ( tcase . renegotiate ) {
327327 runNextClient ( 0 ) ;
328328 } else {
329329 var clientsCompleted = 0 ;
330330 for ( var i = 0 ; i < tcase . clients . length ; i ++ ) {
331- runClient ( tcase . clients [ i ] , function ( ) {
331+ runClient ( port , tcase . clients [ i ] , function ( ) {
332332 clientsCompleted ++ ;
333333 if ( clientsCompleted === tcase . clients . length ) {
334334 server . close ( ) ;
335335 successfulTests ++ ;
336- runTest ( testIndex + 1 ) ;
336+ runTest ( port , nextTest ++ ) ;
337337 }
338338 } ) ;
339339 }
@@ -343,7 +343,9 @@ function runTest(testIndex) {
343343}
344344
345345
346- runTest ( 0 ) ;
346+ var nextTest = 0 ;
347+ runTest ( common . PORT , nextTest ++ ) ;
348+ runTest ( common . PORT + 1 , nextTest ++ ) ;
347349
348350
349351process . on ( 'exit' , function ( ) {
0 commit comments