commsprocess/commsrootserverconfig/ts_rootserver/RootServerTestSection7.cpp
changeset 72 ae47d0499bee
parent 68 5da8188e392b
child 77 c9776eadbffd
equal deleted inserted replaced
68:5da8188e392b 72:ae47d0499bee
     1 // Copyright (c) 2003-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 RootServer Test cases from section 8
       
    15 // 
       
    16 //
       
    17 
       
    18 // EPOC includes
       
    19 #include <e32base.h>
       
    20 #include <es_mbman.h>
       
    21 
       
    22 // Test system includes
       
    23 #include <networking/log.h>
       
    24 #include <networking/teststep.h>
       
    25 #include <networking/testsuite.h>
       
    26 
       
    27 #include "TestStepRootServer.h"
       
    28 #include "TestSuiteRootServer.h"
       
    29 #include "TestAsynchHandler.h"
       
    30 #include "RootServerTestSection7.h"
       
    31 #include "RootServerTest.h"
       
    32 
       
    33 // Test step 7.1 - OOM loop Test1 - Load, Enumerate, GetInfo
       
    34 CRootServerTest7_1::CRootServerTest7_1()
       
    35 {
       
    36 	// store the name of this test case
       
    37 	iTestStepName = _L("Test7.1");
       
    38 }
       
    39 
       
    40 TVerdict CRootServerTest7_1::doTestStepL( void )
       
    41 	{
       
    42 	Log(_L("Test Purpose: OOM loop test 1: Load, Enumerate, GetInfo"));
       
    43 	TVerdict verdict = EPass;
       
    44 	// Create scheduler/active object framework 
       
    45 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
    46     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
    47 
       
    48 
       
    49 	TInt failure = 1000;
       
    50 	while(verdict == EPass)
       
    51 		{
       
    52 		iRootServerSuite->RootSess().__DbgFailNext(failure);
       
    53 		failure++;
       
    54 
       
    55 		TRSStartModuleParams startParams;
       
    56 		TTestModuleIniData iniData;
       
    57 		DefaultStartParams(startParams, iniData);
       
    58 		startParams.iParams.iName = KModule1;
       
    59 		
       
    60 		asynchHandler->TryLoad(startParams, iniData);
       
    61     	CActiveScheduler::Start();
       
    62 
       
    63 		if (asynchHandler->iStatus != KErrNone)
       
    64 			{
       
    65 			Log(_L("TryLoad: %d with FailNext(%d)"), asynchHandler->iStatus.Int(), failure);
       
    66 if(asynchHandler->iStatus == KErrRSModuleAlreadyExist)
       
    67 	User::Leave(KErrRSModuleAlreadyExist);
       
    68 			continue;
       
    69 			}
       
    70 
       
    71 		TCFModuleName moduleName;
       
    72 		TRSIter position;
       
    73 		TInt ret = iRootServerSuite->RootSess().EnumerateModules(position, moduleName);
       
    74 		if(ret != KErrNone)
       
    75 			{
       
    76 			Log(_L("EnumerateModules: %d with FailNext(%d)"), asynchHandler->iStatus.Int(), failure);
       
    77 			continue;
       
    78 			}
       
    79 
       
    80 		if(moduleName != KModule1)
       
    81 			{
       
    82 			Log(_L8("EnumerateModules() returned KErrNone but wrong name: %S"), &moduleName);
       
    83 			verdict = EFail;
       
    84 			break;
       
    85 			}
       
    86 
       
    87 		TRSModuleInfo info;
       
    88 		ret = iRootServerSuite->RootSess().GetModuleInfo(KModule1(), info);
       
    89 		if(ret != KErrNone)
       
    90 			{
       
    91 			Log(_L("GetModuleInfo: %d with FailNext(%d)"), asynchHandler->iStatus.Int(), failure);
       
    92 			continue;
       
    93 			}
       
    94 
       
    95 		if(info.iParams.iState != ERunning)
       
    96 			{
       
    97 			Log(_L("GetModuleInfo() returned KErrNone but wrong state: %d"), info.iParams.iState);
       
    98 			verdict = EFail;
       
    99 			}
       
   100 		// everything worked;
       
   101 		Log(_L("OOM loop complete"));
       
   102 		break;
       
   103 		}
       
   104 
       
   105 
       
   106 	Log(_L("Resetting heap"));
       
   107 	iRootServerSuite->RootSess().__DbgFailNext(-1);
       
   108 	// uninstall and destroy active scheduler
       
   109 	CleanupStack::PopAndDestroy(asynchHandler);
       
   110 	CleanupStack::PopAndDestroy(scheduler);
       
   111 	return verdict;
       
   112 	}
       
   113 
       
   114 // Test step 7.2 - OOM loop Test2 - Unload, GetInfo
       
   115 CRootServerTest7_2::CRootServerTest7_2()
       
   116 {
       
   117 	// store the name of this test case
       
   118 	iTestStepName = _L("Test7.2");
       
   119 }
       
   120 
       
   121 TVerdict CRootServerTest7_2::doTestStepL( void )
       
   122 	{
       
   123 	Log(_L("Test Purpose: Heap loop Test2 - Unload, GetInfo"));
       
   124 	TVerdict verdict = EPass;
       
   125 	// Create scheduler/active object framework 
       
   126 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
   127     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
   128 
       
   129 	Log(_L8("01 Loading cpm: %S"), &KModule1());
       
   130 	LoadNormalModuleL(asynchHandler, KModule1);
       
   131 
       
   132 	TInt failure = 1;
       
   133 	while(verdict == EPass)
       
   134 		{
       
   135 		iRootServerSuite->RootSess().__DbgFailNext(failure);
       
   136 		failure++;
       
   137 
       
   138 		asynchHandler->TryUnLoad(KModule1(), EUnGraceful);
       
   139     	CActiveScheduler::Start();
       
   140 
       
   141 		if (asynchHandler->iStatus != KErrNone)
       
   142 			{
       
   143 			Log(_L("TryUnload: %d with FailNext(%d)"), asynchHandler->iStatus.Int(), failure);
       
   144 			if(asynchHandler->iStatus != KErrRSModuleNotLoaded)
       
   145 				{
       
   146 				continue;
       
   147 				}
       
   148 			}
       
   149 
       
   150 		TRSModuleInfo info;
       
   151 		TInt ret = iRootServerSuite->RootSess().GetModuleInfo(KModule1(), info);
       
   152 		if(ret == KErrRSModuleUnknown)
       
   153 			{
       
   154 			// everything worked;
       
   155 			Log(_L("OOM loop complete"));
       
   156 			break;
       
   157 			}
       
   158 		else if(ret == KErrNone)
       
   159 			{
       
   160 			Log(_L("GetModuleInfo() returned KErrNone for unloaded module"));
       
   161 			verdict = EFail;
       
   162 			}
       
   163 		else 
       
   164 			{
       
   165 			Log(_L("GetModuleInfo: %d with FailNext(%d)"), ret, failure);
       
   166 			continue;
       
   167 			}
       
   168 		}
       
   169 
       
   170 	Log(_L("Resetting heap"));
       
   171 	iRootServerSuite->RootSess().__DbgFailNext(-1);
       
   172 	// uninstall and destroy active scheduler
       
   173 	CleanupStack::PopAndDestroy(asynchHandler);
       
   174 	CleanupStack::PopAndDestroy(scheduler);
       
   175 	return verdict;
       
   176 	}
       
   177 	
       
   178 
       
   179 // Test step 7.3 - OOM loop Test 3 - Bind
       
   180 CRootServerTest7_3::CRootServerTest7_3()
       
   181 {
       
   182 	// store the name of this test case
       
   183 	iTestStepName = _L("Test7.3");
       
   184 }
       
   185 
       
   186 TVerdict CRootServerTest7_3::doTestStepL( void )
       
   187 	{
       
   188 	Log(_L("Test Purpose: Heap loop Test3 - Bind, EnumerateBindings"));
       
   189 	TVerdict verdict = EPass;
       
   190 	// Create scheduler/active object framework 
       
   191 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
   192     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
   193 
       
   194 	Log(_L8("01 Loading cpm: %S"), &KModule1());
       
   195 	LoadNormalModuleL(asynchHandler, KModule1);
       
   196 
       
   197 	TCFSubModuleAddress fullName1;
       
   198 	fullName1.SetModule(KModule1());
       
   199 	fullName1.SetSubModule(KSubModule1());
       
   200 	TInt failure = 1;
       
   201 	while(verdict == EPass)
       
   202 		{
       
   203 		Log(_L("Failing after %d Allocs"), failure);
       
   204 		iRootServerSuite->RootSess().__DbgFailNext(failure);
       
   205 		failure++;
       
   206 
       
   207 		TInt ret = TryHierachicalBind(asynchHandler, KModule1, KSubModule1, KModule1, KSubModule2);
       
   208 		if(ret != KErrNone)
       
   209 			continue;
       
   210 
       
   211 		Log(_L("02 Enumerate bindings"));
       
   212 		TRSBindingInfo bindInfo;
       
   213 		TRSIter position;
       
   214 		ret = iRootServerSuite->RootSess().EnumerateBindings(fullName1, position, bindInfo);
       
   215 		if(ret != KErrNone)
       
   216 			continue;
       
   217 
       
   218 		// everything worked;
       
   219 		Log(_L("OOM loop complete"));
       
   220 		break;
       
   221 		}		
       
   222 
       
   223 	CleanupStack::PopAndDestroy(asynchHandler);
       
   224 	CleanupStack::PopAndDestroy(scheduler);
       
   225 	return verdict;
       
   226 	}
       
   227 
       
   228 // Test step 7.4 - OOM loop Test 4 - Unbind
       
   229 CRootServerTest7_4::CRootServerTest7_4()
       
   230 {
       
   231 	// store the name of this test case
       
   232 	iTestStepName = _L("Test7.4");
       
   233 }
       
   234 
       
   235 TVerdict CRootServerTest7_4::doTestStepL( void )
       
   236 	{
       
   237 	Log(_L("Test Purpose: Heap loop Test4 - Unbind, EnumerateBindings"));
       
   238 	TVerdict verdict = EPass;
       
   239 	// Create scheduler/active object framework 
       
   240 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
   241     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
   242 
       
   243 	Log(_L8("01 Loading and binding cpm: %S"), &KModule1());
       
   244 	LoadNormalModuleL(asynchHandler, KModule1);
       
   245 	TInt ret = TryHierachicalBind(asynchHandler, KModule1, KSubModule1, KModule1, KSubModule2);
       
   246 	if(ret != KErrNone)
       
   247 		{
       
   248 		Log(_L("Binding CPM failed with %d"), ret);
       
   249 		User::Leave(ret);
       
   250 		}
       
   251 
       
   252 	TCFSubModuleAddress fullName1;
       
   253 	fullName1.SetModule(KModule1());
       
   254 	fullName1.SetSubModule(KSubModule1());
       
   255 	TInt failure = 1;
       
   256 	while(verdict == EPass)
       
   257 		{
       
   258 		iRootServerSuite->RootSess().__DbgFailNext(failure);
       
   259 		failure++;
       
   260 
       
   261 		TRSUnBindingInfo unbindInfo;
       
   262 		unbindInfo.iParams.iAddress1.SetModule(KModule1());
       
   263 		unbindInfo.iParams.iAddress1.SetSubModule(KSubModule1());
       
   264 		unbindInfo.iParams.iAddress2.SetModule(KModule1());
       
   265 		unbindInfo.iParams.iAddress2.SetSubModule(KSubModule2());
       
   266 		asynchHandler->TryUnBind( unbindInfo );
       
   267 		
       
   268 		CActiveScheduler::Start();
       
   269 
       
   270 		if (asynchHandler->iStatus != KErrNone)
       
   271 			{
       
   272 			Log(_L("TryUnload: %d with FailNext(%d)"), asynchHandler->iStatus.Int(), failure);
       
   273 			continue;
       
   274 			}
       
   275 
       
   276 		Log(_L("03 Enumerate bindings"));
       
   277 		TRSBindingInfo bindInfo;
       
   278 		TRSIter position;
       
   279 		ret = iRootServerSuite->RootSess().EnumerateBindings(fullName1, position, bindInfo);
       
   280 		if(ret == KErrEof)
       
   281 			{
       
   282 			Log(_L("OOM loop complete"));
       
   283 			break;
       
   284 			}
       
   285 		else if(ret == KErrNone)
       
   286 			{
       
   287 			Log(_L("EnumerateBindings returned KErrNone for unbound submodules"));
       
   288 			verdict = EFail;
       
   289 			}
       
   290 		else 
       
   291 			{
       
   292 			Log(_L("EnumerateBindings: %d with FailNext(%d)"), ret, failure);
       
   293 			continue;
       
   294 			}
       
   295 		}		
       
   296 
       
   297 	CleanupStack::PopAndDestroy(asynchHandler);
       
   298 	CleanupStack::PopAndDestroy(scheduler);
       
   299 	return verdict;
       
   300 	}
       
   301 	
       
   302 	
       
   303