datacommsserver/esockserver/test/TE_Socket/SocketTestSection1.cpp
branchRCL_3
changeset 84 486e9e9c45a7
parent 76 576874e13a2c
equal deleted inserted replaced
76:576874e13a2c 84:486e9e9c45a7
   311 
   311 
   312 enum TVerdict CSocketTest1_7::InternalDoTestStepL( void )
   312 enum TVerdict CSocketTest1_7::InternalDoTestStepL( void )
   313 	{
   313 	{
   314 	TVerdict verdict = EPass;
   314 	TVerdict verdict = EPass;
   315 
   315 
   316 	TInt numExhaustiveSockets = iNormalTest ? KNumExhaustiveSockets : 10;	
   316 	TInt numExhaustiveSockets = iNormalTest ? KNumExhaustiveSockets : 10;
   317 	iNormalTest = EFalse; // normal test is only run once, the rest are OOM tests
   317 	iNormalTest = EFalse; // normal test is only run once, the rest are OOM tests
   318 
   318 
   319 	Logger().WriteFormat(_L("Test Purpose: Exhaustive Socket Open"));
   319 	Logger().WriteFormat(_L("Test Purpose: Exhaustive Socket Open"));
   320 
   320 
   321 	// connect to esock
   321 	// connect to esock
   368 		}
   368 		}
   369 
   369 
   370 
   370 
   371 #if defined (_DEBUG_SOCKET_FUNCTIONS)
   371 #if defined (_DEBUG_SOCKET_FUNCTIONS)
   372 
   372 
       
   373 	numExhaustiveSockets = KNumExhaustiveSocketsWithoutSocketCleanup;
   373 	Logger().WriteFormat(_L("Attempting to Open %d sockets"), numExhaustiveSockets);
   374 	Logger().WriteFormat(_L("Attempting to Open %d sockets"), numExhaustiveSockets);
   374 	TInt sockCount1 = sockNum;
   375 	TInt sockCount1 = sockNum;
   375 	ret = KErrNone;
   376 	ret = KErrNone;
   376 	sockNum = 0;
   377 	sockNum = 0;	
   377 	while (ret==KErrNone && sockNum<numExhaustiveSockets)
   378 	while (ret==KErrNone && sockNum<numExhaustiveSockets)
   378 		{
   379 		{
   379 		ret=socks[sockNum].Open(ss, protoInfo.iAddrFamily,
   380 		ret=socks[sockNum].Open(ss, protoInfo.iAddrFamily,
   380 								protoInfo.iSockType,protoInfo.iProtocol);
   381 								protoInfo.iSockType,protoInfo.iProtocol);
   381 		sockNum++;
   382 		sockNum++;
   382 		}
   383 		}
   383 	if (ret != KErrNone)
   384 	if (ret != KErrNone)
   384 		{
   385 		{
   385 		sockNum--;
   386 		sockNum--;
   386 		}
   387 		}
   387 	Logger().WriteFormat(_L("Created %d sockets, expected at least %d sockets"), sockNum, sockCount1);
   388 		Logger().WriteFormat(_L("Created %d sockets"), sockNum);
   388 	
   389 	
       
   390 	// Not sure what use it is to test whether we can open at least as many sockets as previously.
       
   391 	// We can't assume that once we've freed all the sockets first time around that the ESock heap will
       
   392 	// go back exactly to where it was before - this makes assumptions about the ESock algorithms.  Why
       
   393 	// wouldn't ESock legitimately cache objects, for example?
       
   394 	//
   389 	//TESTL(sockNum >= sockCount1);
   395 	//TESTL(sockNum >= sockCount1);
       
   396 	//
       
   397 
       
   398 	//
       
   399 	// NOTE:
       
   400 	// We do *not* free up the sockets but just close the session.  This is to exercise the subsession
       
   401 	// cleanup behaviour in ESock with a large number of sockets.  We test that this cleanup operation
       
   402 	// does not overflow the transport queue, as each subsession cleanup results in a message being sent.
   390 	//
   403 	//
   391 	//Logger().WriteFormat(_L("Freeing sockets in creation order"));
   404 	//Logger().WriteFormat(_L("Freeing sockets in creation order"));
   392 	//for (i=0; i<sockNum; i++)
   405 	//for (i=0; i<sockNum; i++)
   393 	//	{
   406 	//	{
   394 	//	socks[i].Close();
   407 	//	socks[i].Close();
   395 	//	}
   408 	//	}
       
   409 	//
   396 
   410 
   397 #endif	// (_DEBUG) }
   411 #endif	// (_DEBUG) }
   398 
   412 
   399 	CleanupStack::PopAndDestroy(socks);
   413 	CleanupStack::PopAndDestroy(socks);
   400 
   414 
   401 	CleanupStack::Pop(&ss);
   415 	CleanupStack::Pop(&ss);
   402 	Logger().WriteFormat(_L("Now closing socket server session without closing %d opened sockets"), sockNum);
       
   403 	ss.Close();
   416 	ss.Close();
   404 	SetTestStepResult(verdict);
   417 	SetTestStepResult(verdict);
   405 	return verdict;
   418 	return verdict;
   406 	}
   419 	}
   407 
   420