datacommsserver/esockserver/test/TE_EsockTestSteps/src/Sockets.TestSteps.cpp
branchRCL_3
changeset 18 9644881fedd0
parent 1 21d2ab05f085
equal deleted inserted replaced
17:9ddb1d67ebaf 18:9644881fedd0
    71         {
    71         {
    72         INFO_PRINTF2(_L("%S: Protocol name found."),&iParams.iProtocolName);
    72         INFO_PRINTF2(_L("%S: Protocol name found."),&iParams.iProtocolName);
    73         }
    73         }
    74 	else
    74 	else
    75 		{
    75 		{
    76 	    TPtrC protocol;
    76         TInt protocolInt = 0;
    77 	    if (GetStringFromConfig(iSection,KTe_Protocol,protocol)!=1)
    77         //Try obtaining protocol type as int, failing that, go to predefined types
    78         {
    78         if (GetIntFromConfig(iSection, KTe_Protocol, protocolInt)!=1)
    79 	        INFO_PRINTF2(_L("%S: Protocol missing."),&iParams.iSocketName);
    79             {
    80         	return KErrNotFound;
    80             TPtrC protocolStr;
    81         }
    81             if (GetStringFromConfig(iSection, KTe_Protocol,protocolStr)!=1 )
    82 
    82                 {
    83 	    if (protocol.Compare(KTe_TCPName)==0)
    83                 INFO_PRINTF2(_L("%S: Protocol missing."),&iParams.iSocketName);
    84 		    { iParams.iProtocol = KProtocolInetTcp; iParams.iSocketType = KSockStream; }
    84                 return KErrNotFound;        
    85 	    else if (protocol.Compare(KTe_UDPName)==0)
    85                 }
    86 		    { iParams.iProtocol = KProtocolInetUdp; iParams.iSocketType = KSockDatagram; }
    86             if (protocolStr.Compare(KTe_TCPName)==0)
    87 	    else if (protocol.Compare(KDummyProtocolName)==0)
    87                 { protocolInt = KProtocolInetTcp; iParams.iSocketType = KSockStream;}
    88 		    {
    88             else if (protocolStr.Compare(KTe_UDPName)==0)
    89 			iParams.iProtocol = KProtocolInetDummy;
    89                 { protocolInt = KProtocolInetUdp; iParams.iSocketType = KSockDatagram;}
    90 			iParams.iSocketType = KSockDatagram;
    90             else if (protocolStr.Compare(KTe_DummyNetworkProtocolName)==0)
    91 			}
    91                 { protocolInt = KDummyNetworkProtocol; iParams.iSocketType = KSockDatagram;} 
    92 	    else
    92             else if (protocolStr.Compare(KTe_DummyProtocolName)==0)
    93 	        {
    93                 { protocolInt = KDummyProtocol; iParams.iSocketType = KSockDatagram;} 
    94 	        INFO_PRINTF3(_L("%S: Protocol (%S) not recognised."),&iParams.iSocketName,&protocol);
    94             else
    95 	        return KErrNotFound;
    95                 {
    96 	        }
    96                 INFO_PRINTF3(_L("%S: Protocol (%S) not recognised."),&iParams.iSocketName,&protocolStr);
    97         }
    97                 return KErrNotFound;
       
    98                 }
       
    99             }
       
   100         iParams.iProtocol = protocolInt;
       
   101         }
       
   102     
       
   103 	TPtrC socketTypeStr;	
       
   104     if (GetStringFromConfig(iSection, KTe_SocketType,socketTypeStr)!=1 )
       
   105         {
       
   106         INFO_PRINTF2(_L("%S: Socket type missing, defaulting based on specified protocol"),&iParams.iSocketName);
       
   107         }
       
   108     else
       
   109         {
       
   110         if (socketTypeStr.Compare(KTe_SocketDatagram)==0)
       
   111              { iParams.iSocketType = KSockDatagram;}
       
   112         else if (socketTypeStr.Compare(KTe_SocketStream)==0)
       
   113              { iParams.iSocketType = KSockStream; }
       
   114         else
       
   115             {
       
   116             INFO_PRINTF3(_L("%S: Socket type (%S) not recognised."),&iParams.iSocketName,&socketTypeStr);
       
   117             return KErrNotFound;
       
   118             }
       
   119         }
       
   120     
       
   121     
       
   122     TInt protocolInt = KAfInet;
       
   123     if (GetIntFromConfig(iSection, KTe_ConnectionType, protocolInt)!=1 )
       
   124         {
       
   125         INFO_PRINTF2(_L("%S: Address Family (ConnType) missing, defaulting to KAfInet"),&iParams.iSocketName);
       
   126         }
       
   127     iParams.iAddrFamily = protocolInt;
    98 
   128 
    99     // All ok if we got this far
   129     // All ok if we got this far
   100     return KErrNone;
   130     return KErrNone;
   101 	}
   131 	}
   102 
   132 
   197         return EFail;
   227         return EFail;
   198         }
   228         }
   199 	return EPass;
   229 	return EPass;
   200     }
   230     }
   201 
   231 
       
   232 // Bind Socket
       
   233 //---------------
       
   234 
       
   235 CBindRSocketStep::CBindRSocketStep(CCEsockTestBase*& aEsockTest)
       
   236 :   CTe_EsockStepBase(aEsockTest)
       
   237     {
       
   238     SetTestStepName(KBindRSocketStep);
       
   239     }
       
   240 
       
   241 TInt CBindRSocketStep::ConfigureFromIni()
       
   242     {
       
   243     // Read in appropriate fields
       
   244     if((GetStringFromConfig(iSection, KTe_SocketName, iParams.iSocketName) != 1)
       
   245         || (iParams.iSocketName.Length() == 0))
       
   246         {
       
   247         INFO_PRINTF1(_L("Couldn't find appropriate field in config file"));
       
   248         return KErrNotFound;
       
   249         }
       
   250         
       
   251     TInt protocolInt = 0;
       
   252     if (GetIntFromConfig(iSection, KTe_Protocol, protocolInt)!=1)
       
   253         {
       
   254         TPtrC protocolStr;
       
   255         if (GetStringFromConfig(iSection, KTe_Protocol,protocolStr)!=1 )
       
   256             {
       
   257             INFO_PRINTF2(_L("%S: Protocol missing."),&iParams.iSocketName);
       
   258             return KErrNotFound;        
       
   259             }
       
   260         if (protocolStr.Compare(KTe_TCPName)==0)
       
   261             { protocolInt = KProtocolInetTcp; }
       
   262         else if (protocolStr.Compare(KTe_UDPName)==0)
       
   263             { protocolInt = KProtocolInetUdp; }
       
   264         else if (protocolStr.Compare(KTe_DummyNetworkProtocolName)==0)
       
   265             { protocolInt = KDummyNetworkProtocol; }
       
   266         else if (protocolStr.Compare(KTe_DummyProtocolName)==0)
       
   267             { protocolInt = KDummyProtocol; }
       
   268         else
       
   269             {
       
   270             INFO_PRINTF3(_L("%S: Protocol (%S) not recognised."),&iParams.iSocketName,&protocolStr);
       
   271             return KErrNotFound;
       
   272             }
       
   273         }
       
   274     iParams.iProtocol = protocolInt;
       
   275     
       
   276     // IP Address Local
       
   277     if (GetIpAddressFromConfig(iSection,KTe_SourceAddressName,iParams.iLocalIP)!=1)
       
   278         {
       
   279         INFO_PRINTF2(_L("%S: Local address missing."),&iParams.iSocketName);
       
   280         }    
       
   281     
       
   282     // All ok if we got this far
       
   283     return KErrNone;
       
   284     }
       
   285 
       
   286 TVerdict CBindRSocketStep::doSingleTestStep()
       
   287     {
       
   288     TInt error = iEsockTest->BindSocket(iParams/*,reqStat*/);
       
   289     if (error!=KErrNone)
       
   290         {
       
   291         INFO_PRINTF2(_L("Could not bind socket (%S)."),&iParams.iSocketName);
       
   292         INFO_PRINTF2(_L("Error: %d."),error);
       
   293         SetTestStepResult(EFail);
       
   294         }
       
   295     return TestStepResult();
       
   296     }
   202 
   297 
   203 // Connect Socket
   298 // Connect Socket
   204 //---------------
   299 //---------------
   205 
   300 
   206 CConnectRSocketStep::CConnectRSocketStep(CCEsockTestBase*& aEsockTest)
   301 CConnectRSocketStep::CConnectRSocketStep(CCEsockTestBase*& aEsockTest)
   230 
   325 
   231     if (protocol.Compare(KTe_TCPName)==0)
   326     if (protocol.Compare(KTe_TCPName)==0)
   232 	    { iParams.iProtocol = KProtocolInetTcp; }
   327 	    { iParams.iProtocol = KProtocolInetTcp; }
   233     else if (protocol.Compare(KTe_UDPName)==0)
   328     else if (protocol.Compare(KTe_UDPName)==0)
   234 	    { iParams.iProtocol = KProtocolInetUdp; }
   329 	    { iParams.iProtocol = KProtocolInetUdp; }
   235 	else if (protocol.Compare(KDummyProtocolName)==0)
   330 	else if (protocol.Compare(KTe_DummyNetworkProtocolName)==0)
   236 		{
   331 		{ iParams.iProtocol = KDummyNetworkProtocol; }
   237 		iParams.iProtocol = KProtocolInetDummy;
   332     else if (protocol.Compare(KTe_DummyProtocolName)==0)
   238 		}
   333         { iParams.iProtocol = KDummyProtocol; }    
   239     else
   334     else
   240         {
   335         {
   241         INFO_PRINTF3(_L("%S: Protocol (%S) not recognised."),&iParams.iSocketName,&protocol);
   336         INFO_PRINTF3(_L("%S: Protocol (%S) not recognised."),&iParams.iSocketName,&protocol);
   242         return KErrNotFound;
   337         return KErrNotFound;
   243         }
   338         }
   361 
   456 
   362     if (protocol.Compare(KTe_TCPName)==0)
   457     if (protocol.Compare(KTe_TCPName)==0)
   363 	    { iParams.iProtocol = KProtocolInetTcp; }
   458 	    { iParams.iProtocol = KProtocolInetTcp; }
   364     else if (protocol.Compare(KTe_UDPName)==0)
   459     else if (protocol.Compare(KTe_UDPName)==0)
   365 	    { iParams.iProtocol = KProtocolInetUdp; }
   460 	    { iParams.iProtocol = KProtocolInetUdp; }
   366 	else if (protocol.Compare(KDummyProtocolName)==0)
   461 	else if (protocol.Compare(KTe_DummyNetworkProtocolName)==0)
   367 		{
   462 		{ iParams.iProtocol = KDummyNetworkProtocol; }
   368 		iParams.iProtocol = KProtocolInetDummy;
   463     else if (protocol.Compare(KTe_DummyProtocolName)==0)
   369 		}
   464         { iParams.iProtocol = KDummyProtocol; }    
   370     else
   465     else
   371         {
   466         {
   372         INFO_PRINTF3(_L("%S: Protocol (%S) not recognised."),&iParams.iSocketName,&protocol);
   467         INFO_PRINTF3(_L("%S: Protocol (%S) not recognised."),&iParams.iSocketName,&protocol);
   373         return KErrNotFound;
   468         return KErrNotFound;
   374         }
   469         }