datacommsserver/esockserver/test/TE_ESock/EsockTestSection7.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This contains ESock Test cases from section 7
       
    15 // 
       
    16 //
       
    17 
       
    18 // EPOC includes
       
    19 #include <e32base.h>
       
    20 #include <in_sock.h>
       
    21 
       
    22 // Test system includes
       
    23 #include "EsockTestSection7.h"
       
    24 
       
    25 
       
    26 // Test step 7.1
       
    27 const TDesC& CEsockTest7_1::GetTestName()
       
    28 	{
       
    29 	// store the name of this test case
       
    30 	_LIT(ret,"Test7.1");
       
    31 	
       
    32 	return ret;
       
    33 	}
       
    34 
       
    35 CEsockTest7_1::~CEsockTest7_1()
       
    36 	{
       
    37 	}
       
    38 
       
    39 enum TVerdict CEsockTest7_1::easyTestStepPreambleL()
       
    40 	{
       
    41 	if (iEsockSuite->GetSocketListCount() != 2)
       
    42 		{
       
    43 		CloseSockets();
       
    44 		
       
    45 		TInt ret = OpenSockets(KAfInet, KSockStream, KProtocolInetTcp);
       
    46 		if (KErrNone != ret)
       
    47 			{
       
    48 			Logger().WriteFormat(_L("Open TCP socket failed, returned %d"), ret);
       
    49 			return EFail;
       
    50 			}
       
    51 		
       
    52 		ret = OpenSockets(KAfInet, KSockDatagram, KProtocolInetUdp);
       
    53 		if (KErrNone != ret)
       
    54 			{
       
    55 			Logger().WriteFormat(_L("Open UDP socket failed, returned %d"), ret);
       
    56 			return EFail;
       
    57 			}
       
    58 		}
       
    59 	return EPass;
       
    60 	}
       
    61 
       
    62 enum TVerdict CEsockTest7_1::easyTestStepL()
       
    63 	{
       
    64 	TInt nSockets = iEsockSuite->GetSocketListCount();
       
    65 	TESTEL(2 == nSockets, nSockets);
       
    66 	
       
    67 	// Test IP options (KSolInetIp)
       
    68 
       
    69 	RSocket &sock1 = iEsockSuite->GetSocketHandle(1);
       
    70 	RSocket &sock2 = iEsockSuite->GetSocketHandle(2);
       
    71 	
       
    72 	// KSoIpTOS option, default value = 0
       
    73 	
       
    74 	TInt nRet;
       
    75 	// get option and check its default value
       
    76 	TInt ret = sock1.GetOpt(KSoIpTOS, KSolInetIp, nRet);
       
    77 	TESTEL(KErrNone == ret, ret);
       
    78 	TESTEL(nRet == 0, nRet);
       
    79 	
       
    80 	// set new value - check it has been set correctly
       
    81 	ret = sock1.SetOpt(KSoIpTOS, KSolInetIp, 60);
       
    82 	TESTEL(KErrNone == ret, ret);
       
    83 	ret = sock1.GetOpt(KSoIpTOS, KSolInetIp, nRet);
       
    84 	TESTEL(KErrNone == ret, ret);
       
    85 	TESTEL(nRet == 60, nRet);
       
    86 	
       
    87 	// restore default
       
    88 	ret = sock1.SetOpt(KSoIpTOS, KSolInetIp, 0);
       
    89 	TESTEL(KErrNone == ret, ret);
       
    90 	
       
    91 	// repeat for UDP socket
       
    92 	ret = sock2.GetOpt(KSoIpTOS, KSolInetIp, nRet);
       
    93 	TESTEL(KErrNone == ret, ret);
       
    94 	TESTEL(nRet == 0, nRet);
       
    95 	
       
    96 	// set new value - check it has been set correctly
       
    97 	ret = sock2.SetOpt(KSoIpTOS, KSolInetIp, 1);
       
    98 	TESTEL(KErrNone == ret, ret);
       
    99 	ret = sock2.GetOpt(KSoIpTOS, KSolInetIp, nRet);
       
   100 	TESTEL(KErrNone == ret, ret);
       
   101 	TESTEL(nRet == 1, nRet);
       
   102 	
       
   103 	// restore default
       
   104 	ret = sock2.SetOpt(KSoIpTOS, KSolInetIp, 0);
       
   105 	TESTEL(KErrNone == ret, ret);
       
   106 	
       
   107 	// KSoIpTTL option - default value = 69
       
   108 	
       
   109 	// get option and check its default value
       
   110 	ret = sock1.GetOpt(KSoIpTTL, KSolInetIp, nRet);
       
   111 	TESTEL(KErrNone == ret, ret);
       
   112 	TESTEL(nRet == 69, nRet);
       
   113 	// set new value - check it has been set correctly
       
   114 	ret = sock1.SetOpt(KSoIpTTL, KSolInetIp, 255);
       
   115 	TESTEL(KErrNone == ret, ret);
       
   116 	ret = sock1.GetOpt(KSoIpTTL, KSolInetIp, nRet);
       
   117 	TESTEL(KErrNone == ret, ret);
       
   118 	TESTEL(nRet == 255, nRet);
       
   119 	
       
   120 	// restore the default
       
   121 	ret = sock1.SetOpt(KSoIpTTL, KSolInetIp, 69);
       
   122 	TESTEL(KErrNone == ret, ret);
       
   123 	
       
   124 	// repeat for UDP socket
       
   125 	ret = sock2.GetOpt(KSoIpTTL, KSolInetIp, nRet);
       
   126 	TESTEL(KErrNone == ret, ret);
       
   127 	TESTEL(nRet == 69, nRet);
       
   128 	
       
   129 	// set new value - check it has been set correctly
       
   130 	ret = sock2.SetOpt(KSoIpTTL, KSolInetIp, 63);
       
   131 	TESTEL(KErrNone == ret, ret);
       
   132 	ret = sock2.GetOpt(KSoIpTTL, KSolInetIp, nRet);
       
   133 	TESTEL(KErrNone == ret, ret);
       
   134 	TESTEL(nRet == 63, nRet);
       
   135 	
       
   136 	// restore the default
       
   137 	ret = sock2.SetOpt(KSoIpTTL, KSolInetIp, 69);
       
   138 	TESTEL(KErrNone == ret, ret);
       
   139 	
       
   140 	// KSoReuseAddr option - default value is disabled (0)
       
   141 	
       
   142 	// get option and check its default value
       
   143 	ret = sock1.GetOpt(KSoReuseAddr, KSolInetIp, nRet);
       
   144 	TESTEL(KErrNone == ret, ret);
       
   145 	TESTEL(nRet == 0, nRet);
       
   146 	
       
   147 	// set new value - check it has been set correctly
       
   148 	ret = sock1.SetOpt(KSoReuseAddr, KSolInetIp, 1);
       
   149 	TESTEL(KErrNone == ret, ret);
       
   150 	ret = sock1.GetOpt(KSoReuseAddr, KSolInetIp, nRet);
       
   151 	TESTEL(KErrNone == ret, ret);
       
   152 	TESTEL(nRet == 1, nRet);
       
   153 	
       
   154 	// restore the default
       
   155 	ret = sock1.SetOpt(KSoReuseAddr, KSolInetIp, 0);
       
   156 	TESTEL(KErrNone == ret, ret);
       
   157 	
       
   158 	// repeat for UDP socket
       
   159 	ret = sock2.GetOpt(KSoReuseAddr, KSolInetIp, nRet);
       
   160 	TESTEL(KErrNone == ret, ret);
       
   161 	TESTEL(nRet == 0, nRet);
       
   162 	
       
   163 	// set new value - check it has been set correctly
       
   164 	ret = sock2.SetOpt(KSoReuseAddr, KSolInetIp, 1);
       
   165 	TESTEL(KErrNone == ret, ret);
       
   166 	ret = sock2.GetOpt(KSoReuseAddr, KSolInetIp, nRet);
       
   167 	TESTEL(KErrNone == ret, ret);
       
   168 	TESTEL(nRet == 1, nRet);
       
   169 	
       
   170 	// restore the default
       
   171 	ret = sock2.SetOpt(KSoReuseAddr, KSolInetIp, 0);
       
   172 	TESTEL(KErrNone == ret, ret);
       
   173 	
       
   174 	// KSoNoInterfaceError option - supported
       
   175 	
       
   176 	// get/set option - sould be successful
       
   177 	ret = sock1.GetOpt(KSoNoInterfaceError, KSolInetIp, nRet);
       
   178 	TESTEL(KErrNone == ret, ret);
       
   179 	ret = sock1.SetOpt(KSoNoInterfaceError, KSolInetIp, 1);
       
   180 	TESTEL(KErrNone == ret, ret);
       
   181 	
       
   182 	// repeat for UDP socket
       
   183 	ret = sock2.GetOpt(KSoNoInterfaceError, KSolInetIp, nRet);
       
   184 	TESTEL(KErrNone == ret, ret);
       
   185 	ret = sock2.SetOpt(KSoNoInterfaceError, KSolInetIp, 1);
       
   186 	TESTEL(KErrNone == ret, ret);
       
   187 	
       
   188 	CloseSockets(2);
       
   189 	
       
   190 	return EPass;
       
   191 	}
       
   192 	
       
   193 	
       
   194 // Test step 7.2
       
   195 const TDesC& CEsockTest7_2::GetTestName()
       
   196 	{
       
   197 	// store the name of this test case
       
   198 	_LIT(ret,"Test7.2");
       
   199 	
       
   200 	return ret;
       
   201 	}
       
   202 
       
   203 CEsockTest7_2::~CEsockTest7_2()
       
   204 	{
       
   205 	}
       
   206 
       
   207 enum TVerdict CEsockTest7_2::easyTestStepPreambleL()
       
   208 	{
       
   209 	if (iEsockSuite->GetSocketListCount() != 1)
       
   210 		{
       
   211 		CloseSockets();
       
   212 		
       
   213 		TInt ret = OpenSockets(KAfInet, KSockDatagram, KProtocolInetUdp);
       
   214 		if (KErrNone != ret)
       
   215 			{
       
   216 			Logger().WriteFormat(_L("Open UDP socket failed, returned %d"), ret);
       
   217 			return EFail;
       
   218 			}
       
   219 		}
       
   220 	return EPass;
       
   221 	}
       
   222 
       
   223 enum TVerdict CEsockTest7_2::easyTestStepL()
       
   224 	{
       
   225 	TInt nSockets = iEsockSuite->GetSocketListCount();
       
   226 	TESTEL(1 == nSockets, nSockets);
       
   227 	
       
   228 	// Test UDP only options (KSolInetUdp)
       
   229 
       
   230 	RSocket &sock = iEsockSuite->GetSocketHandle(1);
       
   231 	
       
   232 	// KSoUdpReceiveICMPError option, default value is disabled (0)
       
   233 	
       
   234 	// get option and check its default value
       
   235 	TInt nRet;
       
   236 	TInt ret = sock.GetOpt(KSoUdpReceiveICMPError, KSolInetUdp, nRet);
       
   237 	TESTEL(KErrNone == ret, ret);
       
   238 	TESTEL(nRet == 0, nRet);
       
   239 	
       
   240 	// set new value - check it has been set correctly
       
   241 	ret = sock.SetOpt(KSoUdpReceiveICMPError, KSolInetUdp, 1);
       
   242 	TESTEL(KErrNone == ret, ret);
       
   243 	ret = sock.GetOpt(KSoUdpReceiveICMPError, KSolInetUdp, nRet);
       
   244 	TESTEL(KErrNone == ret, ret);
       
   245 	TESTEL(nRet == 1, nRet);
       
   246 	
       
   247 	// restore default
       
   248 	ret = sock.SetOpt(KSoUdpReceiveICMPError, KSolInetUdp, 0);
       
   249 	TESTEL(KErrNone == ret, ret);
       
   250 	
       
   251 	// KSoIpOptions option is not supported
       
   252 	
       
   253 	// get/set - unsuccessful
       
   254 	TBuf8<40> buf;
       
   255 	ret = sock.GetOpt(KSoIpOptions, KSolInetIp, buf);			// Returned -5
       
   256 	TESTEL(KErrNotSupported == ret, ret);
       
   257 	ret = sock.SetOpt(KSoIpOptions, KSolInetIp, _L8("abc"));			// Returned -5
       
   258 	TESTEL(KErrNotSupported == ret, ret);
       
   259 	
       
   260 	// KSoRawMode option, default value is disabled (0)
       
   261 	
       
   262 	// get option and check its default value
       
   263 	ret = sock.GetOpt(KSoRawMode, KSolInetIp, nRet);
       
   264 	TESTEL(KErrNone == ret, ret);
       
   265 	TESTEL(nRet == 0, nRet);
       
   266 	
       
   267 	// set new value - check it has been set correctly
       
   268 	ret = sock.SetOpt(KSoRawMode, KSolInetIp, 1);
       
   269 	TESTEL(KErrNone == ret, ret);
       
   270 	ret = sock.GetOpt(KSoRawMode, KSolInetIp, nRet);
       
   271 	TESTEL(KErrNone == ret, ret);
       
   272 	TESTEL(nRet == 1, nRet);
       
   273 	
       
   274 	// restore default
       
   275 	ret = sock.SetOpt(KSoRawMode, KSolInetIp, 0);
       
   276 	TESTEL(KErrNone == ret, ret);
       
   277 	
       
   278 	// KSoHeaderIncluded option, default value is disabled (0)
       
   279 	
       
   280 	// get option and check its default value
       
   281 	ret = sock.GetOpt(KSoHeaderIncluded, KSolInetIp, nRet);
       
   282 	TESTEL(KErrNone == ret, ret);
       
   283 	TESTEL(nRet == 0, nRet);
       
   284 	
       
   285 	// set new value - check it has been set correctly
       
   286 	// must set raw mode first
       
   287 	ret = sock.SetOpt(KSoHeaderIncluded, KSolInetIp, 1);
       
   288 	TESTEL(KErrNotSupported == ret, ret);
       
   289 	ret = sock.SetOpt(KSoRawMode, KSolInetIp, 1);
       
   290 	TESTEL(KErrNone == ret, ret);
       
   291 	ret = sock.SetOpt(KSoHeaderIncluded, KSolInetIp, 1);
       
   292 	TESTEL(KErrNone == ret, ret);
       
   293 	ret = sock.GetOpt(KSoHeaderIncluded, KSolInetIp, nRet);
       
   294 	TESTEL(KErrNone == ret, ret);
       
   295 	TESTEL(nRet == 1, nRet);
       
   296 	
       
   297 	// restore default
       
   298 	ret = sock.SetOpt(KSoHeaderIncluded, KSolInetIp, 0);
       
   299 	TESTEL(KErrNone == ret, ret);
       
   300 	
       
   301 	ret = sock.SetOpt(KSoRawMode, KSolInetIp, 0);
       
   302 	TESTEL(KErrNone == ret, ret);
       
   303 	
       
   304 	CloseSockets(2);
       
   305 	
       
   306 	return EPass;
       
   307 	}
       
   308 
       
   309 
       
   310 // Test step 7.3
       
   311 const TDesC& CEsockTest7_3::GetTestName()
       
   312 	{
       
   313 	// store the name of this test case
       
   314 	_LIT(ret,"Test7.3");
       
   315 	
       
   316 	return ret;
       
   317 	}
       
   318 
       
   319 CEsockTest7_3::~CEsockTest7_3()
       
   320 	{
       
   321 	}
       
   322 
       
   323 enum TVerdict CEsockTest7_3::easyTestStepPreambleL()
       
   324 	{
       
   325 	if (iEsockSuite->GetSocketListCount() != 1)
       
   326 		{
       
   327 		CloseSockets();
       
   328 		
       
   329 		TInt ret = OpenSockets(KAfInet, KSockStream, KProtocolInetTcp);
       
   330 		if (KErrNone != ret)
       
   331 			{
       
   332 			Logger().WriteFormat(_L("Open TCP socket failed, returned %d"), ret);
       
   333 			return EFail;
       
   334 			}
       
   335 		}
       
   336 	return EPass;
       
   337 	}
       
   338 
       
   339 enum TVerdict CEsockTest7_3::easyTestStepL()
       
   340 	{
       
   341 	TInt nSockets = iEsockSuite->GetSocketListCount();
       
   342 	TESTEL(1 == nSockets, nSockets);
       
   343 	
       
   344 	// Test TCP only options (KSolInetTcp)
       
   345 
       
   346 	RSocket &sock = iEsockSuite->GetSocketHandle(1);
       
   347 	
       
   348 	// KSoTcpSendWinSize option, default value is 16384
       
   349 	
       
   350 	// get option and check its default value
       
   351 	TInt nRet;
       
   352 	TInt ret = sock.GetOpt(KSoTcpSendWinSize, KSolInetTcp, nRet);
       
   353 	TESTEL(KErrNone == ret, ret);
       
   354 	TESTEL(nRet == 16384, nRet);
       
   355 	
       
   356 	// set new value - check it has been set correctly
       
   357 	ret = sock.SetOpt(KSoTcpSendWinSize, KSolInetTcp, 4096);
       
   358 	TESTEL(KErrNone == ret, ret);
       
   359 	ret = sock.GetOpt(KSoTcpSendWinSize, KSolInetTcp, nRet);
       
   360 	TESTEL(KErrNone == ret, ret);
       
   361 	TESTEL(nRet == 4096, nRet);
       
   362 	
       
   363 	// restore default
       
   364 	ret = sock.SetOpt(KSoTcpSendWinSize, KSolInetTcp, 16384);
       
   365 	TESTEL(KErrNone == ret, ret);
       
   366 	
       
   367 	
       
   368 	// KSoTcpRecvWinSize option, default value is 49152
       
   369 	
       
   370 	// get option and check its default value
       
   371 	ret = sock.GetOpt(KSoTcpRecvWinSize, KSolInetTcp, nRet);
       
   372 	TESTEL(KErrNone == ret, ret);
       
   373 	TESTEL(nRet == 49152, nRet);
       
   374 	
       
   375 	// set new value - check it has been set correctly
       
   376 	ret = sock.SetOpt(KSoTcpRecvWinSize, KSolInetTcp, 16384);
       
   377 	TESTEL(KErrNone == ret, ret);
       
   378 	ret = sock.GetOpt(KSoTcpRecvWinSize, KSolInetTcp, nRet);
       
   379 	TESTEL(KErrNone == ret, ret);
       
   380 	TESTEL(nRet == 16384, nRet);
       
   381 	
       
   382 	// restore default
       
   383 	ret = sock.SetOpt(KSoTcpRecvWinSize, KSolInetTcp, 49152);
       
   384 	TESTEL(KErrNone == ret, ret);
       
   385 	
       
   386 	// KSoTcpMaxSegSize option, default value is 65535
       
   387 	
       
   388 	// get option and check its default value
       
   389 	ret = sock.GetOpt(KSoTcpMaxSegSize, KSolInetTcp, nRet);
       
   390 	TESTEL(KErrNone == ret, ret);
       
   391 	TESTEL(nRet == 65535, nRet);
       
   392 	
       
   393 	// set new value - check it has been set correctly
       
   394 	ret = sock.SetOpt(KSoTcpMaxSegSize, KSolInetTcp, 400);
       
   395 	TESTEL(KErrNone == ret, ret);
       
   396 	ret = sock.GetOpt(KSoTcpMaxSegSize, KSolInetTcp, nRet);
       
   397 	TESTEL(KErrNone == ret, ret);
       
   398 	TESTEL(nRet == 400, nRet);
       
   399 	
       
   400 	// restore default
       
   401 	ret = sock.SetOpt(KSoTcpMaxSegSize, KSolInetTcp, 65535);
       
   402 	TESTEL(KErrNone == ret, ret);
       
   403 	
       
   404 	// KSoTcpNoDelay option, default value is disabled (0)
       
   405 	
       
   406 	// get option and check its default value
       
   407 	ret = sock.GetOpt(KSoTcpNoDelay, KSolInetTcp, nRet);
       
   408 	TESTEL(KErrNone == ret, ret);
       
   409 	TESTEL(nRet == 0, nRet);
       
   410 	
       
   411 	// set new value - check it has been set correctly
       
   412 	ret = sock.SetOpt(KSoTcpNoDelay, KSolInetTcp, 1);
       
   413 	TESTEL(KErrNone == ret, ret);
       
   414 	ret = sock.GetOpt(KSoTcpNoDelay, KSolInetTcp, nRet);
       
   415 	TESTEL(KErrNone == ret, ret);
       
   416 	TESTEL(nRet == 1, nRet);
       
   417 	
       
   418 	// restore default
       
   419 	ret = sock.SetOpt(KSoTcpNoDelay, KSolInetTcp, 0);
       
   420 	TESTEL(KErrNone == ret, ret);
       
   421 	
       
   422 	// KSoTcpKeepAlive option, is supported
       
   423 	// get option and check its default value
       
   424 	ret = sock.GetOpt(KSoTcpKeepAlive, KSolInetTcp, nRet);
       
   425 	TESTEL(KErrNone == ret, ret);
       
   426 	TESTEL(nRet == 0, nRet);
       
   427 	
       
   428 	// get/set option - check it has been set correctly
       
   429 	ret = sock.SetOpt(KSoTcpKeepAlive, KSolInetTcp, 1);
       
   430 	TESTEL(KErrNone == ret, ret);
       
   431 	ret = sock.GetOpt(KSoTcpKeepAlive, KSolInetTcp, nRet);
       
   432 	TESTEL(KErrNone == ret, ret);
       
   433 	TESTEL(nRet == 1, nRet);
       
   434 	
       
   435 	//Set the default
       
   436 	ret = sock.SetOpt(KSoTcpKeepAlive, KSolInetTcp, 0);
       
   437 	TESTEL(KErrNone == ret, ret);
       
   438 	
       
   439 	// KSoTcpAsync2MslWait option, not supported
       
   440 	
       
   441 	// get/set option - unsuccessful
       
   442 	ret = sock.GetOpt(KSoTcpAsync2MslWait, KSolInetTcp, nRet);
       
   443 	TESTEL(KErrNotSupported == ret, ret);
       
   444 	ret = sock.SetOpt(KSoTcpAsync2MslWait, KSolInetTcp, 1);
       
   445 	TESTEL(KErrNotSupported == ret, ret);
       
   446 	
       
   447 	// KSoTcpNextSendUrgentData option, default value is disabled (0)
       
   448 	
       
   449 	// get option and check its default value
       
   450 	ret = sock.GetOpt(KSoTcpNextSendUrgentData, KSolInetTcp, nRet);
       
   451 	TESTEL(KErrNone == ret, ret);
       
   452 	TESTEL(nRet == 0, nRet);
       
   453 	
       
   454 	// set new value - check it has been set correctly
       
   455 	ret = sock.SetOpt(KSoTcpNextSendUrgentData, KSolInetTcp, 1);
       
   456 	TESTEL(KErrNone == ret, ret);
       
   457 	ret = sock.GetOpt(KSoTcpNextSendUrgentData, KSolInetTcp, nRet);
       
   458 	TESTEL(KErrNone == ret, ret);
       
   459 	TESTEL(nRet == 1, nRet);
       
   460 	
       
   461 	// restore default
       
   462 	ret = sock.SetOpt(KSoTcpNextSendUrgentData, KSolInetTcp, 0);
       
   463 	TESTEL(KErrNone == ret, ret);
       
   464 	
       
   465 	// KSoTcpOobInline option, default value is disabled (0)
       
   466 	
       
   467 	// get option and check its default value
       
   468 	ret = sock.GetOpt(KSoTcpOobInline, KSolInetTcp, nRet);
       
   469 	TESTEL(KErrNone == ret, ret);
       
   470 	TESTEL(nRet == 0, nRet);
       
   471 	
       
   472 	// set new value - check it has been set correctly
       
   473 	ret = sock.SetOpt(KSoTcpOobInline, KSolInetTcp, 1);
       
   474 	TESTEL(KErrNone == ret, ret);
       
   475 	ret = sock.GetOpt(KSoTcpOobInline, KSolInetTcp, nRet);
       
   476 	TESTEL(KErrNone == ret, ret);
       
   477 	TESTEL(nRet == 1, nRet);
       
   478 	
       
   479 	// restore default
       
   480 	ret = sock.SetOpt(KSoTcpOobInline, KSolInetTcp, 0);
       
   481 	TESTEL(KErrNone == ret, ret);
       
   482 	
       
   483 	CloseSockets(2);
       
   484 	
       
   485 	return EPass;
       
   486 	}
       
   487 	
       
   488 	
       
   489 // Test step 7.4
       
   490 const TDesC& CEsockTest7_4::GetTestName()
       
   491 	{
       
   492 	// store the name of this test case
       
   493 	_LIT(ret,"Test7.4");
       
   494 	
       
   495 	return ret;
       
   496 	}
       
   497 
       
   498 CEsockTest7_4::~CEsockTest7_4()
       
   499 	{
       
   500 	}
       
   501 
       
   502 enum TVerdict CEsockTest7_4::easyTestStepPreambleL()
       
   503 	{
       
   504 	if (iEsockSuite->GetSocketListCount() != 2)
       
   505 		{
       
   506 		CloseSockets();
       
   507 		
       
   508 		TInt ret = OpenSockets(KAfInet, KSockStream, KProtocolInetTcp);
       
   509 		if (KErrNone != ret)
       
   510 			{
       
   511 			Logger().WriteFormat(_L("Open TCP socket failed, returned %d"), ret);
       
   512 			return EFail;
       
   513 			}
       
   514 		
       
   515 		ret = OpenSockets(KAfInet, KSockDatagram, KProtocolInetUdp);
       
   516 		if (KErrNone != ret)
       
   517 			{
       
   518 			Logger().WriteFormat(_L("Open UDP socket failed, returned %d"), ret);
       
   519 			return EFail;
       
   520 			}
       
   521 		}
       
   522 	return EPass;
       
   523 	}
       
   524 
       
   525 enum TVerdict CEsockTest7_4::easyTestStepL()
       
   526 	{
       
   527 	TInt nSockets = iEsockSuite->GetSocketListCount();
       
   528 	TESTEL(2 == nSockets, nSockets);
       
   529 	
       
   530 	RSocket &sock1 = iEsockSuite->GetSocketHandle(1);
       
   531 	RSocket &sock2 = iEsockSuite->GetSocketHandle(2);
       
   532 	
       
   533 	// KSoIp6UnicastHops option, default value is 69
       
   534 	
       
   535 	// get option and check its default value
       
   536 	TInt nRet;
       
   537 	TInt ret = sock1.GetOpt(KSoIp6UnicastHops, KSolInetIp, nRet);
       
   538 	TESTEL(KErrNone == ret, ret);
       
   539 	TESTEL(nRet == 69, nRet);
       
   540 	
       
   541 	// set new value - check it has been set correctly
       
   542 	ret = sock1.SetOpt(KSoIp6UnicastHops, KSolInetIp, 40);
       
   543 	TESTEL(KErrNone == ret, ret);
       
   544 	ret = sock1.GetOpt(KSoIp6UnicastHops, KSolInetIp, nRet);
       
   545 	TESTEL(KErrNone == ret, ret);
       
   546 	TESTEL(nRet == 40, nRet);
       
   547 	
       
   548 	// restore default
       
   549 	ret = sock1.SetOpt(KSoIp6UnicastHops, KSolInetIp, 69);
       
   550 	TESTEL(KErrNone == ret, ret);
       
   551 	
       
   552 	// repeat for UDP socket
       
   553 	ret = sock2.GetOpt(KSoIp6UnicastHops, KSolInetIp, nRet);
       
   554 	TESTEL(KErrNone == ret, ret);
       
   555 	TESTEL(nRet == 69, nRet);
       
   556 	
       
   557 	// set new value - check it has been set correctly
       
   558 	ret = sock2.SetOpt(KSoIp6UnicastHops, KSolInetIp, 30);
       
   559 	TESTEL(KErrNone == ret, ret);
       
   560 	ret = sock2.GetOpt(KSoIp6UnicastHops, KSolInetIp, nRet);
       
   561 	TESTEL(KErrNone == ret, ret);
       
   562 	TESTEL(nRet == 30, nRet);
       
   563 	
       
   564 	// restore default
       
   565 	ret = sock2.SetOpt(KSoIp6UnicastHops, KSolInetIp, 69);
       
   566 	
       
   567 	// KSoIp6MulticastHops option, default value is 1
       
   568 	
       
   569 	// get option and check its default value
       
   570 	ret = sock1.GetOpt(KSoIp6MulticastHops, KSolInetIp, nRet);
       
   571 	TESTEL(KErrNone == ret, ret);
       
   572 	TESTEL(nRet == 1, nRet);
       
   573 	
       
   574 	// set new value - check it has been set correctly
       
   575 	ret = sock1.SetOpt(KSoIp6MulticastHops, KSolInetIp, 3);
       
   576 	TESTEL(KErrNone == ret, ret);
       
   577 	ret = sock1.GetOpt(KSoIp6MulticastHops, KSolInetIp, nRet);
       
   578 	TESTEL(KErrNone == ret, ret);
       
   579 	TESTEL(nRet == 3, nRet);
       
   580 	
       
   581 	// restore default
       
   582 	ret = sock1.SetOpt(KSoIp6MulticastHops, KSolInetIp, 1);
       
   583 	TESTEL(KErrNone == ret, ret);
       
   584 	
       
   585 	// repeat for UDP socket
       
   586 	ret = sock2.GetOpt(KSoIp6MulticastHops, KSolInetIp, nRet);
       
   587 	TESTEL(KErrNone == ret, ret);
       
   588 	TESTEL(nRet == 1, nRet);
       
   589 	
       
   590 	// set new value - check it has been set correctly
       
   591 	ret = sock2.SetOpt(KSoIp6MulticastHops, KSolInetIp, 4);
       
   592 	TESTEL(KErrNone == ret, ret);
       
   593 	ret = sock2.GetOpt(KSoIp6MulticastHops, KSolInetIp, nRet);
       
   594 	TESTEL(KErrNone == ret, ret);
       
   595 	TESTEL(nRet == 4, nRet);
       
   596 	
       
   597 	// restore default
       
   598 	ret = sock2.SetOpt(KSoIp6MulticastHops, KSolInetIp, 1);
       
   599 	TESTEL(KErrNone == ret, ret);
       
   600 	
       
   601 	// KSoIp6MulticastLoop option, default value is enabled (1)
       
   602 	
       
   603 	// get option and check its default value
       
   604 	ret = sock1.GetOpt(KSoIp6MulticastLoop, KSolInetIp, nRet);
       
   605 	TESTEL(KErrNone == ret, ret);
       
   606 	TESTEL(nRet == 1, nRet);
       
   607 	
       
   608 	// set new value - check it has been set correctly
       
   609 	ret = sock1.SetOpt(KSoIp6MulticastHops, KSolInetIp, 0);
       
   610 	TESTEL(KErrNone == ret, ret);
       
   611 	ret = sock1.GetOpt(KSoIp6MulticastHops, KSolInetIp, nRet);
       
   612 	TESTEL(KErrNone == ret, ret);
       
   613 	TESTEL(nRet == 0, nRet);
       
   614 	
       
   615 	// restore default
       
   616 	ret = sock1.SetOpt(KSoIp6MulticastHops, KSolInetIp, 1);
       
   617 	TESTEL(KErrNone == ret, ret);
       
   618 	
       
   619 	// repeat for UDP socket
       
   620 	ret = sock2.GetOpt(KSoIp6MulticastHops, KSolInetIp, nRet);
       
   621 	TESTEL(KErrNone == ret, ret);
       
   622 	TESTEL(nRet == 1, nRet);
       
   623 	
       
   624 	// set new value - check it has been set correctly
       
   625 	ret = sock2.SetOpt(KSoIp6MulticastHops, KSolInetIp, 0);
       
   626 	TESTEL(KErrNone == ret, ret);
       
   627 	ret = sock2.GetOpt(KSoIp6MulticastHops, KSolInetIp, nRet);
       
   628 	TESTEL(KErrNone == ret, ret);
       
   629 	TESTEL(nRet == 0, nRet);
       
   630 	
       
   631 	// restore default
       
   632 	ret = sock2.SetOpt(KSoIp6MulticastHops, KSolInetIp, 1);
       
   633 	TESTEL(KErrNone == ret, ret);
       
   634 	
       
   635 	CloseSockets(2);
       
   636 	
       
   637 	return EPass;
       
   638 	}
       
   639 	
       
   640 	
       
   641 // Test step 7.5
       
   642 const TDesC& CEsockTest7_5::GetTestName()
       
   643 	{
       
   644 	// store the name of this test case
       
   645 	_LIT(ret,"Test7.5");
       
   646 	
       
   647 	return ret;
       
   648 	}
       
   649 
       
   650 CEsockTest7_5::~CEsockTest7_5()
       
   651 	{
       
   652 	}
       
   653 
       
   654 enum TVerdict CEsockTest7_5::easyTestStepPreambleL()
       
   655 	{
       
   656 	if (iEsockSuite->GetSocketListCount() != 1)
       
   657 		{
       
   658 		CloseSockets();
       
   659 		
       
   660 		TInt ret = OpenSockets(KAfInet, KSockStream, KProtocolInetTcp);
       
   661 		if (KErrNone != ret)
       
   662 			{
       
   663 			Logger().WriteFormat(_L("Open TCP socket failed, returned %d"), ret);
       
   664 			return EFail;
       
   665 			}
       
   666 		}
       
   667 	return EPass;
       
   668 	}
       
   669 
       
   670 enum TVerdict CEsockTest7_5::easyTestStepL()
       
   671 	{
       
   672 	TInt nSockets = iEsockSuite->GetSocketListCount();
       
   673 	TESTEL(1 == nSockets, nSockets);
       
   674 	
       
   675 	RSocket &sock = iEsockSuite->GetSocketHandle(1);
       
   676 	
       
   677 	// attempt to set read-only socket options
       
   678 	// KSoTcpReadBytesPending and KSoTcpSocketListening
       
   679 	
       
   680 	// attempt to set new value - check it is not successful
       
   681 	TInt nRet;
       
   682 	TInt ret = sock.SetOpt(KSoTcpReadBytesPending, KSolInetTcp, 40);
       
   683 	TESTEL(KErrNotSupported == ret, ret);
       
   684 	
       
   685 	// check option can be retrieved
       
   686 	ret = sock.GetOpt(KSoTcpReadBytesPending, KSolInetTcp, nRet);
       
   687 	TESTEL(KErrNone == ret, ret);
       
   688 	TESTEL(nRet == 0, nRet);
       
   689 	
       
   690 	// attempt to set new value - check it is not successful
       
   691 	ret = sock.SetOpt(KSoTcpListening, KSolInetTcp, 1);
       
   692 	TESTEL(KErrNotSupported == ret, ret);
       
   693 	
       
   694 	// check option can be retrieved
       
   695 	ret = sock.GetOpt(KSoTcpListening, KSolInetTcp, nRet);
       
   696 	TESTEL(KErrNone == ret, ret);
       
   697 	TESTEL(nRet == 0, nRet);
       
   698 	
       
   699 	CloseSockets(2);
       
   700 	
       
   701 	return EPass;
       
   702 	}
       
   703 
       
   704 
       
   705 // Test step 7.6
       
   706 const TDesC& CEsockTest7_6::GetTestName()
       
   707 	{
       
   708 	// store the name of this test case
       
   709 	_LIT(ret,"Test7.6");
       
   710 	
       
   711 	return ret;
       
   712 	}
       
   713 
       
   714 CEsockTest7_6::~CEsockTest7_6()
       
   715 	{
       
   716 	}
       
   717 
       
   718 enum TVerdict CEsockTest7_6::easyTestStepPreambleL()
       
   719 	{
       
   720 	if (iEsockSuite->GetSocketListCount() != 2)
       
   721 		{
       
   722 		CloseSockets();
       
   723 		
       
   724 		TInt ret = OpenSockets(KAfInet, KSockStream, KProtocolInetTcp);
       
   725 		if (KErrNone != ret)
       
   726 			{
       
   727 			Logger().WriteFormat(_L("Open TCP socket failed, returned %d"), ret);
       
   728 			return EFail;
       
   729 			}
       
   730 		
       
   731 		ret = OpenSockets(KAfInet, KSockDatagram, KProtocolInetUdp);
       
   732 		if (KErrNone != ret)
       
   733 			{
       
   734 			Logger().WriteFormat(_L("Open UDP socket failed, returned %d"), ret);
       
   735 			return EFail;
       
   736 			}
       
   737 		}
       
   738 	return EPass;
       
   739 	}
       
   740 
       
   741 enum TVerdict CEsockTest7_6::easyTestStepL()
       
   742 	{
       
   743 	TInt nSockets = iEsockSuite->GetSocketListCount();
       
   744 	TESTEL(2 == nSockets, nSockets);
       
   745 	
       
   746 	// attempt to set a UDP specific option for a TCP socket
       
   747 	
       
   748 	// attempt to enable KSoRawMode value - check it is not successful
       
   749 	RSocket &sock = iEsockSuite->GetSocketHandle(1);
       
   750 	TInt ret = sock.SetOpt(KSoRawMode, KSolInetIp, 1);
       
   751 	TESTEL(KErrNotSupported == ret, ret);
       
   752 	
       
   753 	// attempt to set a TCP specific option for a UDP socket
       
   754 	
       
   755 	// attempt to set the KSoTcpSendWinSize value - check it is not successful
       
   756 	sock = iEsockSuite->GetSocketHandle(2);
       
   757 	ret = sock.SetOpt(KSoTcpSendWinSize, KSolInetIp, 4096);
       
   758 	TESTEL(KErrNotSupported == ret, ret);
       
   759 
       
   760 	CloseSockets(2);
       
   761 	
       
   762 	return EPass;
       
   763 	}
       
   764 
       
   765 
       
   766 // Test step 7.7
       
   767 const TDesC& CEsockTest7_7::GetTestName()
       
   768 	{
       
   769 	// store the name of this test case
       
   770 	_LIT(ret,"Test7.7");
       
   771 	
       
   772 	return ret;
       
   773 	}
       
   774 
       
   775 CEsockTest7_7::~CEsockTest7_7()
       
   776 	{
       
   777 	}
       
   778 
       
   779 enum TVerdict CEsockTest7_7::easyTestStepPreambleL()
       
   780 	{
       
   781 	if (iEsockSuite->GetSocketListCount() != 1)
       
   782 		{
       
   783 		CloseSockets();
       
   784 		
       
   785 		TInt ret = OpenSockets(KAfInet, KSockStream, KProtocolInetTcp);
       
   786 		if (KErrNone != ret)
       
   787 			{
       
   788 			Logger().WriteFormat(_L("Open TCP socket failed, returned %d"), ret);
       
   789 			return EFail;
       
   790 			}
       
   791 		}
       
   792 	return EPass;
       
   793 	}
       
   794 
       
   795 enum TVerdict CEsockTest7_7::easyTestStepL()
       
   796 	{
       
   797 	TInt nSockets = iEsockSuite->GetSocketListCount();
       
   798 	TESTEL(1 == nSockets, nSockets);
       
   799 	
       
   800 	// set options to an invalid value
       
   801 	
       
   802 	RSocket &sock = iEsockSuite->GetSocketHandle(1);
       
   803 	
       
   804 	// attempt to set KSoIpTTL to invalid value
       
   805 	// - check it is not successful
       
   806 	TInt ret = sock.SetOpt(KSoIpTTL, KSolInetIp, 5000);
       
   807 	TESTEL(KErrArgument == ret, ret);
       
   808 	
       
   809 	CloseSockets(2);
       
   810 	
       
   811 	return EPass;
       
   812 	}
       
   813