datacommsserver/esockserver/test/TE_ESock/TestStepEsock.h
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2004-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 CTestCaseEsock which is the base class for all 
       
    15 // the ESOCK suite test cases
       
    16 // 
       
    17 //
       
    18 
       
    19 #if (!defined __ESOCKTESTSTEP_H__)
       
    20 #define __ESOCKTESTSTEP_H__
       
    21 #include <in_sock.h>
       
    22 #include <test/testexecutestepbase.h>
       
    23 #include "TestSuiteEsock.h"
       
    24 
       
    25 class CEasyTestStep : public CTestStep
       
    26 	{
       
    27 	public:
       
    28 		virtual TVerdict doTestStepPreambleL()
       
    29 			{
       
    30 			SetTestStepResult(easyTestStepPreambleL());
       
    31 			return TestStepResult(); 
       
    32 			}
       
    33 		virtual TVerdict doTestStepL()
       
    34 			{
       
    35 			MergeVerdict(easyTestStepL());
       
    36 			return TestStepResult(); 
       
    37 			}
       
    38 		virtual TVerdict doTestStepPostambleL()
       
    39 			{
       
    40 			MergeVerdict(easyTestStepPostambleL());
       
    41 			return TestStepResult(); 
       
    42 			}
       
    43 		
       
    44 		virtual TVerdict easyTestStepPreambleL()
       
    45 			{ return EPass; }
       
    46 		virtual TVerdict easyTestStepL() = 0;
       
    47 		virtual TVerdict easyTestStepPostambleL()
       
    48 			{ return EPass; }
       
    49 		
       
    50 		void MergeVerdict(TVerdict aVerdict)
       
    51 			{
       
    52 			if(TestStepResult() == EPass)
       
    53 				{
       
    54 				SetTestStepResult(aVerdict);
       
    55 				}
       
    56 			}
       
    57 	};
       
    58 
       
    59 class CTestStepEsock : public CEasyTestStep
       
    60     {
       
    61 	
       
    62 	public :
       
    63 		enum { ipAddress1 =0 , ipAddress2 , ipAddress3 , ipAddress4 , ipAddress5 , ipAddress7, ipAddress8, ipAddress9 } ip_table;
       
    64 	public:
       
    65 		// Close sockets in Postamble.
       
    66 		TVerdict easyTestStepPostambleL();
       
    67 		
       
    68 		const TDesC& SectionName(const TDesC& aSectName);
       
    69 		
       
    70 		// config file access - Esock specific
       
    71 		TBool GetIpAddressFromConfig(const TDesC &aSectName,const TDesC &aKeyName,TInetAddr &anAddr);
       
    72 		
       
    73 		void StripeDes32(TDes8 &aBuf, TInt aStartPos, TInt anEndPos);
       
    74 		void StripeMem32(TUint *aBuf, TInt aStartPos, TInt aEndPos);
       
    75 		void StripeMem(TUint8 *aBuf, TInt aStartPos, TInt anEndPos, TUint aStartChar, TUint anEndChar, TInt aOffset=0);
       
    76 		void StripeDes(TDes8 &aBuf, TInt aStartPos, TInt anEndPos, TUint aStartChar, TUint anEndChar, TInt aOffset=0);
       
    77 		
       
    78 		// common socket operations
       
    79 		TInt OpenListeningSocketL(TInetAddr anAddr, TInt &aSockIndex, TInt aPort=1, TInt aSize=5);
       
    80 		TInt OpenActiveSocketL(TInetAddr anAddr, TInt &aSockIndex, TInt aPort=1);
       
    81 		TInt AcceptConnectionL(TInt &aSockIndex, TInt aListenIndex);
       
    82 		void CloseSockets(TUint aLoglevel = 0);
       
    83 		TInt OpenSockets(TUint addrFamily, TUint aSockType, TUint aProtocol, TUint aNumSockets = 1);
       
    84 		TInt OpenSockets(const TDesC &aName, TUint aNumSockets = 1);
       
    85 		TInt OpenSockets(TUint aNumSockets = 1);
       
    86 		TInt OpenMinSockets(const TDesC &aSectName, TUint addrFamily, TUint aSockType, TUint aProtocol, TUint aMinSockets = 1);
       
    87 		TInt OpenConnectionsL(const TDesC &aSectName, TInt &aSockIndex2, TInt &aSockIndex3);
       
    88 		
       
    89 		TInt SetRoute(TInt aOp, TUint32 aDest, TUint32 aNetMask, TUint32 aGateway, TUint32 aInterface, TInt aMetric);
       
    90 		TInt ListRoutes();
       
    91 		
       
    92 		void GetHostByNameL(TNameRecord& aRecord, const TDesC& aHost);
       
    93 		void GetHostByAddrL(TNameRecord& aRecord, const TInetAddr& aAddr);
       
    94 		void GetHostNameL();
       
    95 		void SetHostNameL(const TDesC& aHost);
       
    96 		void GetHostByNameCancelL(TNameRecord& aRecord, const TDesC& aHost);
       
    97 		
       
    98 		// IPv4
       
    99 		TBool GetAppendixB1();
       
   100 		TBool GetAppendixB2();
       
   101 		TBool GetAppendixB3();
       
   102 		TBool GetAppendixB4();
       
   103 		TBool GetAppendixB5();
       
   104 		TBool GetAppendixB6();
       
   105 		
       
   106 		// IPv6
       
   107 		TBool GetAppendixC1();
       
   108 		void GetAppendixC2();
       
   109 		TBool GetAppendixC3();
       
   110 		
       
   111 		// pointer to suite which owns this test 
       
   112 		CTestSuiteEsock* iEsockSuite;
       
   113 		
       
   114 		RArray<TInetAddr> appendixInArray, appendixOutArray; 
       
   115 		
       
   116 		RHeap* TestHeap;
       
   117 		
       
   118 	private:
       
   119     };
       
   120     
       
   121   class CESockTestStep_OOMCapable : public CTestStepEsock
       
   122 	{
       
   123 public:
       
   124 	~CESockTestStep_OOMCapable()
       
   125 		{
       
   126 		iOOMSess.Close();
       
   127 		}
       
   128 		
       
   129 	void SetHeapFailNext(TInt aFailureIndex)
       
   130 		{
       
   131 		if(iOOMSess.Handle() == KNullHandle)
       
   132 			{
       
   133 			iOOMSess.Connect();
       
   134 			}
       
   135 		if(iOOMSess.Handle() != KNullHandle)
       
   136 			{
       
   137 			iOOMSess.__DbgFailNext(aFailureIndex - 1);	// want to start with 0th
       
   138 			}
       
   139 		}
       
   140 		
       
   141 	void ResetHeapFailNext()
       
   142 		{
       
   143 		if(iOOMSess.Handle() != KNullHandle)
       
   144 			{
       
   145 			iOOMSess.__DbgFailNext(-1);
       
   146 			}
       
   147 		}
       
   148 		
       
   149 	TBool CheckForHeapFailNext()
       
   150 		{
       
   151 		if(iOOMSess.Handle() != KNullHandle)
       
   152 		{
       
   153 		// If ESOCK heaps are still in FailNext mode then we try to flag the termination
       
   154 		// of the loop to TEF by setting the local heap to fail. Because this might get
       
   155 		// "eaten" inside TEF before it checks we walk a failure point here too
       
   156 		return iOOMSess.__DbgCheckFailNext();
       
   157 		}
       
   158 	return ETrue;
       
   159 	}
       
   160 	// virtual enum TVerdict InternalDoTestStepL() =0;
       
   161 private:
       
   162 	RSocketServ iOOMSess;
       
   163 	};
       
   164 
       
   165 
       
   166 #endif /* __ESOCKTESTSTEP_H__ */
       
   167 
       
   168