commsprocess/commsrootserverconfig/ts_rootserver/RootServerTestSection3.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 ESock Test cases from section 3
       
    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 
       
    31 #include "RootServerTest.h"
       
    32 #include "RootServerTestSection3.h"
       
    33 
       
    34 
       
    35 // Note: Test step 3.1 was a RRootServ::Connect() test; this is now obsolete
       
    36 
       
    37 // Test step 3.2 - SetMBufPoolSize After LoadServer
       
    38 CRootServerTest3_2::CRootServerTest3_2()
       
    39 	{
       
    40 	// store the name of this test case
       
    41 	iTestStepName = _L("Test3.2");
       
    42 	}
       
    43 
       
    44 
       
    45 TVerdict CRootServerTest3_2::doTestStepL( void )
       
    46 	{
       
    47 	TVerdict verdict = EPass;
       
    48 
       
    49 	Log(_L("Test Purpose: SetMBufPoolSize After LoadServer"));
       
    50 
       
    51 	// Create scheduler/active object framework
       
    52 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
    53     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
    54 
       
    55 	Log(_L8("01 Loading test module: %S"), &KModule1());
       
    56 	LoadNormalModuleL(asynchHandler, KModule1);
       
    57 
       
    58 	// uninstall and destroy active scheduler
       
    59 	CleanupStack::PopAndDestroy(asynchHandler);
       
    60 	CleanupStack::PopAndDestroy(scheduler);
       
    61 
       
    62 	// now try to set the buffer pool size
       
    63 	Log(_L("03 Setting MBufPoolSize"));
       
    64 	TInt ret = iRootServerSuite->RootSess().SetMBufPoolSize(0,KMBufDefaultHeapSize);
       
    65 
       
    66 	Log(_L("SetMBufPoolSize returned %d"), ret);
       
    67 	if (KErrInUse != ret)
       
    68 		{
       
    69 		verdict = EFail;
       
    70 		}
       
    71 
       
    72 	return verdict;
       
    73 	}
       
    74 
       
    75 
       
    76 TVerdict CRootServerTest3_DblLoad::LoadSameModuleTwiceL(TThreadPriority aPriority)
       
    77 	{
       
    78 	TVerdict verdict = EPass;
       
    79 
       
    80 	// Create scheduler/active object framework
       
    81 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
    82     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
    83 
       
    84 	TRSStartModuleParams startParams;
       
    85 	TTestModuleIniData iniData;
       
    86 	DefaultStartParams(startParams, iniData);
       
    87 	startParams.iParams.iName = KModule1;
       
    88 	startParams.iParams.iPriority = aPriority;
       
    89 
       
    90 	Log(_L8("02 Loading module: %S"), &startParams.iParams.iName);
       
    91 	asynchHandler->TryLoad(startParams, iniData);
       
    92 
       
    93 	CActiveScheduler::Start();
       
    94 
       
    95     if (asynchHandler->iStatus != KErrNone)
       
    96 		{
       
    97 		Log(_L("LoadServer returned error: <%d> "), asynchHandler->iStatus.Int());
       
    98 		User::Leave(asynchHandler->iStatus.Int());
       
    99 		}
       
   100 
       
   101 	// try to load same module again
       
   102 	Log(_L("03 Trying to load same module again"));
       
   103 	asynchHandler->TryLoad(startParams, iniData);
       
   104 	CActiveScheduler::Start();
       
   105 
       
   106 	Log(_L("LoadServer returned %d"), asynchHandler->iStatus.Int());
       
   107     if (asynchHandler->iStatus != KErrRSModuleAlreadyExist)
       
   108 		{
       
   109 		verdict = EFail;
       
   110 		}
       
   111 	// uninstall and destroy active scheduler
       
   112 	CleanupStack::PopAndDestroy(asynchHandler);
       
   113 	CleanupStack::PopAndDestroy(scheduler);
       
   114 
       
   115 	return verdict;
       
   116 	}
       
   117 
       
   118 // Test step 3.3 - Load Same Module Twice
       
   119 CRootServerTest3_3::CRootServerTest3_3()
       
   120 	{
       
   121 	// store the name of this test case
       
   122 	iTestStepName = _L("Test3.3");
       
   123 	}
       
   124 
       
   125 TVerdict CRootServerTest3_3::doTestStepL( void )
       
   126 	{
       
   127 	Log(_L("Test Purpose: Load Same Module Twice (normal priority)"));
       
   128 	return LoadSameModuleTwiceL(EPriorityNormal);
       
   129 	}
       
   130 
       
   131 // Test step 3.4 - Load Same Module Twice with elevated priority
       
   132 CRootServerTest3_4::CRootServerTest3_4()
       
   133 	{
       
   134 	// store the name of this test case
       
   135 	iTestStepName = _L("Test3.4");
       
   136 	}
       
   137 
       
   138 TVerdict CRootServerTest3_4::doTestStepL( void )
       
   139 	{
       
   140 	Log(_L("Test Purpose: Load Same Module Twice (elevated priority)"));
       
   141 	return LoadSameModuleTwiceL(EPriorityRealTime);
       
   142 	}
       
   143 
       
   144 
       
   145 // Test step 3.5 - Retrieve Module Information
       
   146 CRootServerTest3_5::CRootServerTest3_5()
       
   147 	{
       
   148 	// store the name of this test case
       
   149 	iTestStepName = _L("Test3.5");
       
   150 	}
       
   151 
       
   152 TVerdict CRootServerTest3_5::doTestStepL( void )
       
   153 	{
       
   154 	TVerdict verdict = EPass;
       
   155 
       
   156 	Log(_L("Test Purpose: Retrieve Module Information"));
       
   157 
       
   158 	// Create scheduler/active object framework
       
   159 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
   160     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
   161 
       
   162 	TRSStartModuleParams startParams;
       
   163 	TTestModuleIniData iniData;
       
   164 	DefaultStartParams(startParams, iniData);
       
   165 	startParams.iParams.iName = KModule1;
       
   166 
       
   167 	Log(_L8("02 Loading module: %S"), &startParams.iParams.iName);
       
   168 	asynchHandler->TryLoad(startParams, iniData);
       
   169 	CActiveScheduler::Start();
       
   170 
       
   171     if (asynchHandler->iStatus != KErrNone)
       
   172 		{
       
   173 		Log(_L("LoadServer returned error: <%d> "), asynchHandler->iStatus.Int());
       
   174 		User::Leave(asynchHandler->iStatus.Int());
       
   175 		}
       
   176 	CleanupStack::PopAndDestroy(asynchHandler);
       
   177 	CleanupStack::PopAndDestroy(scheduler);
       
   178 
       
   179 	// now try to retrieve information about the module
       
   180 	Log(_L("03 Getting module information"));
       
   181 	TRSModuleInfo info;
       
   182 	TCFModuleName moduleName = KModule1();
       
   183 	TInt ret = iRootServerSuite->RootSess().GetModuleInfo(moduleName, info);
       
   184 	Log(_L8("GetModuleInfo for %S returned %d"), &moduleName, ret);
       
   185 
       
   186 	if(KErrNone != ret)
       
   187 		{
       
   188 		return EFail;
       
   189 		}
       
   190 
       
   191 	Log(_L("Filename %S, State %d, NumSubmodules %d"),
       
   192 		&info.iParams.iDll, info.iParams.iState, info.iParams.iNumSubModules);
       
   193 
       
   194 	if (startParams.iParams.iFilename != info.iParams.iDll ||
       
   195 		ERunning != info.iParams.iState ||
       
   196 		3 != info.iParams.iNumSubModules)
       
   197 		{
       
   198 		return EFail;
       
   199 		}
       
   200 
       
   201 	// now ask for info about a non-existent module
       
   202 	Log(_L("04 Getting module information for non-existent module"));
       
   203 
       
   204 	moduleName = KModule2;
       
   205 	ret = iRootServerSuite->RootSess().GetModuleInfo(moduleName, info);
       
   206 	Log(_L8("GetModuleInfo for %S returned %d"), &moduleName, ret);
       
   207 
       
   208 	if(KErrRSModuleUnknown != ret)
       
   209 		{
       
   210 		return EFail;
       
   211 		}
       
   212 
       
   213 	return verdict;
       
   214 	}
       
   215 
       
   216 
       
   217 // Test step 3.6 - CancelLoadModule Before Thread Starts
       
   218 CRootServerTest3_6::CRootServerTest3_6()
       
   219 	{
       
   220 	// store the name of this test case
       
   221 	iTestStepName = _L("Test3.6");
       
   222 	}
       
   223 
       
   224 TVerdict CRootServerTest3_6::doTestStepL( void )
       
   225 	{
       
   226 	TVerdict verdict = EPass;
       
   227 
       
   228 	Log(_L("Test Purpose: CancelLoadModule Before Thread Starts"));
       
   229 
       
   230 	// Create scheduler/active object framework
       
   231 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
   232     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
   233 
       
   234 	TRSStartModuleParams startParams;
       
   235 	TTestModuleIniData iniData;
       
   236 	DefaultStartParams(startParams, iniData);
       
   237 	startParams.iParams.iName = KModule1;
       
   238 	iniData.iParams.iInitDelay = isRendezvousDelayTime;
       
   239 
       
   240 	Log(_L8("02 Loading module: %S"), &startParams.iParams.iName);
       
   241 	asynchHandler->TryLoad(startParams, iniData);
       
   242 
       
   243 //	User::After(5000000);
       
   244 
       
   245 	Log(_L8("03 Cancelling Loading module: %S"), &startParams.iParams.iName);
       
   246 	iRootServerSuite->RootSess().CancelLoadCpm(startParams.iParams.iName);
       
   247 
       
   248 	CActiveScheduler::Start();
       
   249 
       
   250     Log(_L("LoadServer status was: <%d> "), asynchHandler->iStatus.Int());
       
   251 
       
   252     if ((KErrCancel != asynchHandler->iStatus.Int()) && (KErrNone != asynchHandler->iStatus.Int()))
       
   253 		{
       
   254 		verdict = EFail;
       
   255 		}
       
   256     
       
   257     // Unload the CPM anyway in case we were too late to cancel the load.
       
   258     TRequestStatus status;
       
   259     iRootServerSuite->RootSess().UnloadCpm(status, startParams.iParams.iName, EImmediate);
       
   260     User::WaitForRequest(status);
       
   261 
       
   262 	CleanupStack::PopAndDestroy(asynchHandler);
       
   263 	CleanupStack::PopAndDestroy(scheduler);
       
   264 	return verdict;
       
   265 	}
       
   266 
       
   267 
       
   268 // Test step 3.7 - CancelLoadServer After Rendezvous
       
   269 CRootServerTest3_7::CRootServerTest3_7()
       
   270 	{
       
   271 	// store the name of this test case
       
   272 	iTestStepName = _L("Test3.7");
       
   273 	}
       
   274 
       
   275 TVerdict CRootServerTest3_7::doTestStepL( void )
       
   276 	{
       
   277 	TVerdict verdict = EPass;
       
   278 
       
   279 	Log(_L("Test Purpose: CancelLoadServer After Rendezvous"));
       
   280 
       
   281 	// Create scheduler/active object framework
       
   282 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
   283     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
   284 
       
   285 	TRSStartModuleParams startParams;
       
   286 	TTestModuleIniData iniData;
       
   287 	DefaultStartParams(startParams, iniData);
       
   288 	startParams.iParams.iName = KModule1;
       
   289 	Log(_L8("02 Loading module: %S"), &startParams.iParams.iName);
       
   290 	asynchHandler->TryLoad(startParams, iniData);
       
   291 
       
   292 	// now wait for testserver to meet rendezvous before cancelling load (give it
       
   293 	User::After(1000000);
       
   294 	Log(_L8("03 Cancelling Loading module: %S"), &startParams.iParams.iName);
       
   295 	iRootServerSuite->RootSess().CancelLoadCpm(startParams.iParams.iName);
       
   296 
       
   297 	CActiveScheduler::Start();
       
   298 
       
   299     Log(_L("LoadServer status was: <%d> "), asynchHandler->iStatus.Int());
       
   300 
       
   301     if (KErrNone != asynchHandler->iStatus.Int())
       
   302 		{
       
   303 		verdict = EFail;
       
   304 		}
       
   305 
       
   306 	CleanupStack::PopAndDestroy(asynchHandler);
       
   307 	CleanupStack::PopAndDestroy(scheduler);
       
   308 
       
   309 	return verdict;
       
   310 	}
       
   311 
       
   312 // Test step 3.8 - Close Session with Pending LoadServer
       
   313 CRootServerTest3_8::CRootServerTest3_8()
       
   314 	{
       
   315 	// store the name of this test case
       
   316 	iTestStepName = _L("Test3.8");
       
   317 	}
       
   318 
       
   319 TVerdict CRootServerTest3_8::doTestStepL( void )
       
   320 	{
       
   321 	TVerdict verdict = EPass;
       
   322 
       
   323 	Log(_L("Test Purpose: Close Session with Pending LoadServer"));
       
   324 
       
   325 	// Create scheduler/active object framework
       
   326 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
   327     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
   328 
       
   329 	TRSStartModuleParams startParams;
       
   330 	TTestModuleIniData iniData;
       
   331 	DefaultStartParams(startParams, iniData);
       
   332 	startParams.iParams.iName = KModule1;
       
   333 	iniData.iParams.iInitDelay = isRendezvousDelayTime;
       
   334 
       
   335 	Log(_L8("02 Loading module: %S"), &startParams.iParams.iName);
       
   336 	asynchHandler->TryLoad(startParams, iniData);
       
   337 
       
   338 	Log(_L("03 Closing Session"));
       
   339 	iRootServerSuite->RootSess().Close();
       
   340 	Log(_L("RRootServ.Close() completed"));
       
   341 
       
   342 	CActiveScheduler::Start();
       
   343 
       
   344 	// note that if the session was closed before the module's thread started,
       
   345 	// the handler should have been KErrCancelled
       
   346     Log(_L("LoadServer status was: <%d> "), asynchHandler->iStatus.Int());
       
   347     if ((KErrCancel != asynchHandler->iStatus.Int()) && (KErrNone != asynchHandler->iStatus.Int()))
       
   348 		{
       
   349 		verdict = EFail;
       
   350 		}
       
   351 
       
   352 	CleanupStack::PopAndDestroy(asynchHandler);
       
   353 	CleanupStack::PopAndDestroy(scheduler);
       
   354 
       
   355 	return verdict;
       
   356 	}
       
   357 
       
   358 
       
   359 // Test step 3.9 - Module Exits Before Rendezvous
       
   360 CRootServerTest3_9::CRootServerTest3_9()
       
   361 	{
       
   362 	// store the name of this test case
       
   363 	iTestStepName = _L("Test3.9");
       
   364 	}
       
   365 
       
   366 TVerdict CRootServerTest3_9::doTestStepL( void )
       
   367 	{
       
   368 	TVerdict verdict = EFail;
       
   369 
       
   370 	Log(_L("Test Purpose: Module Exits Before Rendezvous"));
       
   371 
       
   372 	// Create scheduler/active object framework
       
   373 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
   374     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
   375 
       
   376 	TRSStartModuleParams startParams;
       
   377 	TTestModuleIniData iniData;
       
   378 	DefaultStartParams(startParams, iniData);
       
   379 	startParams.iParams.iName = KModule1;
       
   380 	iniData.iParams.iInitDelay = EXIT_BEFORE_RENDEZVOUS;
       
   381 
       
   382 	Log(_L8("03 Loading module: %S"), &startParams.iParams.iName);
       
   383 	asynchHandler->TryLoad(startParams, iniData);
       
   384 
       
   385 	CActiveScheduler::Start();
       
   386 
       
   387     Log(_L("LoadServer status was: <%d>"), asynchHandler->iStatus.Int());
       
   388 
       
   389     if (KErrNone != asynchHandler->iStatus.Int())
       
   390 		{
       
   391 		verdict = EPass;
       
   392 		}
       
   393 
       
   394 	CleanupStack::PopAndDestroy(asynchHandler);
       
   395 	CleanupStack::PopAndDestroy(scheduler);
       
   396 
       
   397 	return verdict;
       
   398 	}
       
   399 
       
   400 // Test step 3.10 - Module Panics Before Meeting Rendezvous
       
   401 CRootServerTest3_10::CRootServerTest3_10()
       
   402 	{
       
   403 	// store the name of this test case
       
   404 	iTestStepName = _L("Test3.10");
       
   405 	}
       
   406 
       
   407 TVerdict CRootServerTest3_10::doTestStepL( void )
       
   408 	{
       
   409 	TVerdict verdict = EFail;
       
   410 
       
   411 	Log(_L("Test Purpose: Module Panics Before Meeting Rendezvous"));
       
   412 
       
   413 	// Create scheduler/active object framework
       
   414 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
   415     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
   416 
       
   417 	TRSStartModuleParams startParams;
       
   418 	TTestModuleIniData iniData;
       
   419 	DefaultStartParams(startParams, iniData);
       
   420 	startParams.iParams.iName = KModule1;
       
   421 #ifdef SYMBIAN_C32ROOT_API_V3
       
   422 	startParams.iParams.iControlFlags = TRSStartModuleParamContainer::KCF_UnstableModule;
       
   423 #endif
       
   424 	iniData.iParams.iInitDelay = PANIC_BEFORE_RENDEZVOUS;
       
   425 
       
   426 	// make sure WINS doesn't stop at panic
       
   427 	TBool jitDbg = User::JustInTime();
       
   428 	User::SetJustInTime(EFalse);
       
   429 	Log(_L8("03 Loading module: %S"), &startParams.iParams.iName);
       
   430 	asynchHandler->TryLoad(startParams, iniData);
       
   431 
       
   432 	CActiveScheduler::Start();
       
   433 
       
   434     Log(_L("LoadServer status was: <%d> "), asynchHandler->iStatus.Int());
       
   435 
       
   436     if (KErrNone != asynchHandler->iStatus.Int())
       
   437 		{
       
   438 		verdict = EPass;
       
   439 		}
       
   440 
       
   441 	// Restore enclosing JIT status
       
   442 	User::SetJustInTime(jitDbg);
       
   443 
       
   444 	CleanupStack::PopAndDestroy(asynchHandler);
       
   445 	CleanupStack::PopAndDestroy(scheduler);
       
   446 
       
   447 	return verdict;
       
   448 	}
       
   449 
       
   450 // Test step 3.11 - Module Panics After Meeting Rendezvous
       
   451 CRootServerTest3_11::CRootServerTest3_11()
       
   452 	{
       
   453 	// store the name of this test case
       
   454 	iTestStepName = _L("Test3.11");
       
   455 	}
       
   456 
       
   457 TVerdict CRootServerTest3_11::doTestStepL( void )
       
   458 	{
       
   459 	TVerdict verdict = EFail;
       
   460 
       
   461 	Log(_L("Test Purpose: Module Panics After Meeting Rendezvous"));
       
   462 
       
   463 	// Create scheduler/active object framework
       
   464 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
   465     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
   466 
       
   467 	TRSStartModuleParams startParams;
       
   468 	TTestModuleIniData iniData;
       
   469 	DefaultStartParams(startParams, iniData);
       
   470 	startParams.iParams.iName = KModule1;
       
   471 #ifdef SYMBIAN_C32ROOT_API_V3
       
   472 	startParams.iParams.iControlFlags = TRSStartModuleParamContainer::KCF_UnstableModule;
       
   473 #endif
       
   474 	iniData.iParams.iInitDelay = PANIC_AFTER_RENDEZVOUS;
       
   475 
       
   476 	// make sure WINS doesn't stop at panic
       
   477 	TBool jitDbg = User::JustInTime();
       
   478 	User::SetJustInTime(EFalse);
       
   479 	Log(_L8("03 Loading module: %S"), &startParams.iParams.iName);
       
   480 	asynchHandler->TryLoad(startParams, iniData);
       
   481 
       
   482 	CActiveScheduler::Start();
       
   483 
       
   484     Log(_L("LoadServer status was: <%d> "), asynchHandler->iStatus.Int());
       
   485 
       
   486     if (KErrServerTerminated == asynchHandler->iStatus.Int())
       
   487 		{
       
   488 		verdict = EPass;
       
   489 		}
       
   490 
       
   491 	// Restore enclosing JIT status
       
   492 	User::SetJustInTime(jitDbg);
       
   493 
       
   494 	// destroy active scheduler
       
   495 	CleanupStack::PopAndDestroy(asynchHandler);
       
   496 	CleanupStack::PopAndDestroy(scheduler);
       
   497 
       
   498 	return verdict;
       
   499 	}
       
   500 
       
   501 
       
   502 // Test step 3.12 - Load 2 modules sharing the same heap
       
   503 CRootServerTest3_12::CRootServerTest3_12()
       
   504 	{
       
   505 	// store the name of this test case
       
   506 	iTestStepName = _L("Test3.12");
       
   507 	}
       
   508 
       
   509 TVerdict CRootServerTest3_12::doTestStepL( void )
       
   510 	{
       
   511 	Log(_L("Test Purpose: Load 2 modules sharing the same heap"));
       
   512 
       
   513 	TVerdict verdict = EPass;
       
   514 
       
   515 	// Create scheduler/active object framework
       
   516 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
   517     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
   518 
       
   519 	TRSStartModuleParams startParams;
       
   520 	TTestModuleIniData iniData;
       
   521 	DefaultStartParams(startParams, iniData);
       
   522 	_LIT8(KShareModule1, "Test ModuleShare1");
       
   523 	_LIT8(KShareModule2, "Test ModuleShare2");
       
   524 	startParams.iParams.iName = KShareModule1;
       
   525 
       
   526 	asynchHandler->TryLoad(startParams, iniData);
       
   527     CActiveScheduler::Start();
       
   528    	if (asynchHandler->iStatus != KErrNone)
       
   529 		{
       
   530 		Log(_L("LoadServer returned error: <%d> "), asynchHandler->iStatus.Int());
       
   531 		User::Leave(asynchHandler->iStatus.Int());
       
   532 		}
       
   533 
       
   534 	//*****************step 3************************
       
   535 	Log(_L("03 Load Test Module"));
       
   536 	startParams.iParams.iName = KShareModule2;
       
   537 	startParams.iParams.iHeapType = EShareHeap;
       
   538 	startParams.iParams.iShareHeapWith = KShareModule1;
       
   539 
       
   540 	asynchHandler->TryLoad(startParams, iniData);
       
   541 	CActiveScheduler::Start();
       
   542 
       
   543 	if (asynchHandler->iStatus != KErrNone)
       
   544 		{
       
   545 		Log(_L("LoadServer returned error: <%d> "), asynchHandler->iStatus.Int());
       
   546 		verdict = EFail;
       
   547 		}
       
   548 
       
   549 	CleanupStack::PopAndDestroy(asynchHandler);
       
   550 	CleanupStack::PopAndDestroy(scheduler);
       
   551 	return verdict;
       
   552 	}
       
   553 
       
   554 // Test step 3.13 - Load 2 modules with private heaps
       
   555 CRootServerTest3_13::CRootServerTest3_13()
       
   556 	{
       
   557 	// store the name of this test case
       
   558 	iTestStepName = _L("Test3.13");
       
   559 	}
       
   560 
       
   561 TVerdict CRootServerTest3_13::doTestStepL( void )
       
   562 	{
       
   563 	Log(_L("Test Purpose: Load 2 modules with private heaps"));
       
   564 
       
   565 	TVerdict verdict = EPass;
       
   566 
       
   567 	// Create scheduler/active object framework
       
   568 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
   569     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
   570 
       
   571 	TRSStartModuleParams startParams;
       
   572 	TTestModuleIniData iniData;
       
   573 	DefaultStartParams(startParams, iniData);
       
   574 	startParams.iParams.iName = KModule1;
       
   575 	startParams.iParams.iHeapType = ENewHeap;
       
   576 
       
   577 	asynchHandler->TryLoad(startParams, iniData);
       
   578     CActiveScheduler::Start();
       
   579    	if (asynchHandler->iStatus != KErrNone)
       
   580 		{
       
   581 		Log(_L("LoadServer returned error: <%d> "), asynchHandler->iStatus.Int());
       
   582 		User::Leave(asynchHandler->iStatus.Int());
       
   583 		}
       
   584 
       
   585 	//*****************step 3************************
       
   586 	Log(_L("03 Load Test Module"));
       
   587 	startParams.iParams.iName = KModule2;
       
   588 	startParams.iParams.iHeapType = ENewHeap;
       
   589 
       
   590 	asynchHandler->TryLoad(startParams, iniData);
       
   591 	CActiveScheduler::Start();
       
   592 
       
   593 	if (asynchHandler->iStatus != KErrNone)
       
   594 		{
       
   595 		Log(_L("LoadServer returned error: <%d> "), asynchHandler->iStatus.Int());
       
   596 		verdict = EFail;
       
   597 		}
       
   598 
       
   599 	CleanupStack::PopAndDestroy(asynchHandler);
       
   600 	CleanupStack::PopAndDestroy(scheduler);
       
   601 	return verdict;
       
   602 	}
       
   603 
       
   604 // Test step 3.14 - Load sluggish module
       
   605 CRootServerTest3_14::CRootServerTest3_14()
       
   606 	{
       
   607 	// store the name of this test case
       
   608 	iTestStepName = _L("Test3.14");
       
   609 	}
       
   610 
       
   611 TVerdict CRootServerTest3_14::doTestStepL( void )
       
   612 	{
       
   613 	Log(_L("Test Purpose: Load sluggish module"));
       
   614 	TVerdict verdict = EPass;
       
   615 
       
   616 	// Create scheduler/active object framework
       
   617 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
   618     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
   619 
       
   620 	TRSStartModuleParams startParams;
       
   621 	TTestModuleIniData iniData;
       
   622 	DefaultStartParams(startParams, iniData);
       
   623 	startParams.iParams.iName = KModule1;
       
   624 	iniData.iParams.iDiscoveryDelay = 500;
       
   625 	iniData.iParams.iBindDelay = 1000;
       
   626 	iniData.iParams.iUnbindDelay = 1000;
       
   627 	iniData.iParams.iShutdownDelay = 1000;
       
   628 	asynchHandler->TryLoad(startParams, iniData);
       
   629 
       
   630     CActiveScheduler::Start();
       
   631    	if (asynchHandler->iStatus != KErrNone)
       
   632 		{
       
   633 		Log(_L("LoadServer returned error: <%d> "), asynchHandler->iStatus.Int());
       
   634 		verdict = EFail;
       
   635 		}
       
   636 
       
   637 	CleanupStack::PopAndDestroy(asynchHandler);
       
   638 	CleanupStack::PopAndDestroy(scheduler);
       
   639 	return verdict;
       
   640 
       
   641 	}
       
   642 
       
   643 // Test step 3.14 - Load dormant module
       
   644 CRootServerTest3_15::CRootServerTest3_15()
       
   645 	{
       
   646 	// store the name of this test case
       
   647 	iTestStepName = _L("Test3.15");
       
   648 	}
       
   649 
       
   650 TVerdict CRootServerTest3_15::doTestStepL( void )
       
   651 	{
       
   652 	Log(_L("Test Purpose: Load Dormant module"));
       
   653 	//*****************step 1*************************//
       
   654 	TVerdict verdict = EFail;
       
   655 
       
   656 	// Create scheduler/active object framework
       
   657 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
   658     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
   659 
       
   660 	//*****************step 3************************
       
   661 	Log(_L("03 Load Dormant Module"));
       
   662 
       
   663 	TRSStartModuleParams startParams;
       
   664 	TTestModuleIniData iniData;
       
   665 	DefaultStartParams(startParams, iniData);
       
   666 	startParams.iParams.iName = KModule1;
       
   667 	startParams.iParams.iHeapType = ENewHeap;	// when zombie is killed memory will leak
       
   668 	iniData.iParams.iDiscoveryDelay = 30000;
       
   669 
       
   670 	asynchHandler->TryLoad(startParams, iniData);
       
   671     CActiveScheduler::Start();
       
   672    	if (asynchHandler->iStatus != KErrRSZombie)
       
   673 		{
       
   674 		Log(_L("LoadServer returned error: <%d> "), asynchHandler->iStatus.Int());
       
   675 		verdict = EFail;
       
   676 		}
       
   677 	else
       
   678 		{
       
   679 		//*****************step 4***********************
       
   680 		Log(_L("04 Unload Dormant Module"));
       
   681 		asynchHandler->TryUnLoad(startParams.iParams.iName, EUnGraceful);
       
   682 		CActiveScheduler::Start();
       
   683 
       
   684 		if (asynchHandler->iStatus != KErrNone)
       
   685 			{
       
   686 			Log(_L("Unload returned error: <%d> "), asynchHandler->iStatus.Int());
       
   687 			verdict = EInconclusive;
       
   688 			}
       
   689 		else
       
   690 			verdict = EPass;
       
   691 		}
       
   692 
       
   693 	CleanupStack::PopAndDestroy(asynchHandler);
       
   694 	CleanupStack::PopAndDestroy(scheduler);
       
   695 	return verdict;
       
   696 
       
   697 	}
       
   698 
       
   699 // Test step 3.16 - Load test module and wait for death
       
   700 CRootServerTest3_16::CRootServerTest3_16()
       
   701 	{
       
   702 	// store the name of this test case
       
   703 	iTestStepName = _L("Test3.16");
       
   704 	}
       
   705 
       
   706 TVerdict CRootServerTest3_16::doTestStepL( void )
       
   707 	{
       
   708 	Log(_L("Test Purpose: Load test module, wait for death and check heap"));
       
   709 	//*****************step 1*************************//
       
   710 	TVerdict verdict = EFail;
       
   711 
       
   712 	// Create scheduler/active object framework
       
   713 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
   714     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
   715 
       
   716 	//*****************step 3************************
       
   717 	Log(_L("03 Load Test Module"));
       
   718 
       
   719 	TRSStartModuleParams startParams;
       
   720 	TTestModuleIniData iniData;
       
   721 	DefaultStartParams(startParams, iniData);
       
   722 	startParams.iParams.iName = KModule1;
       
   723 #ifdef SYMBIAN_C32ROOT_API_V3
       
   724 	startParams.iParams.iControlFlags = TRSStartModuleParamContainer::KCF_UnstableModule;
       
   725 #endif
       
   726 	iniData.iParams.iDeathDelay = 5000;
       
   727 
       
   728 	asynchHandler->TryLoad(startParams, iniData);
       
   729     CActiveScheduler::Start();
       
   730    	if (asynchHandler->iStatus != KErrNone)
       
   731 		{
       
   732 		Log(_L("LoadServer returned error: <%d> "), asynchHandler->iStatus.Int());
       
   733 		verdict = EInconclusive;
       
   734 		}
       
   735 	else
       
   736 		{
       
   737 		//*****************step 4***********************
       
   738 		Log(_L("04 Waiting for module to die"));
       
   739 
       
   740 		User::After(6000000);
       
   741 
       
   742 		TRSModuleInfo info;
       
   743 		TInt ret = iRootServerSuite->RootSess().GetModuleInfo(KModule1(), info);
       
   744 		Log(_L8("GetModuleInfo for %S returned %d"), &KModule1(), ret);
       
   745 
       
   746 		if(KErrRSModuleUnknown == ret)
       
   747 			{
       
   748 			verdict = EPass;
       
   749 			}
       
   750 		}
       
   751 
       
   752 	// uninstall and destroy active scheduler
       
   753 	CleanupStack::PopAndDestroy(asynchHandler);
       
   754 	CleanupStack::PopAndDestroy(scheduler);
       
   755 	return verdict;
       
   756 
       
   757 	}
       
   758 
       
   759 // Test step 3.17 - Load unknown module and cancel
       
   760 CRootServerTest3_17::CRootServerTest3_17()
       
   761 	{
       
   762 	// store the name of this test case
       
   763 	iTestStepName = _L("Test3.17");
       
   764 	}
       
   765 
       
   766 TVerdict CRootServerTest3_17::doTestStepL( void )
       
   767 	{
       
   768 	TVerdict verdict = EPass;
       
   769 
       
   770 	Log(_L("Test Purpose: Load unknown module and cancel"));
       
   771 
       
   772 	// Create scheduler/active object framework
       
   773 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
   774     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
   775 
       
   776 	TRSStartModuleParams startParams;
       
   777 	TTestModuleIniData iniData;
       
   778 	DefaultStartParams(startParams, iniData);
       
   779 	startParams.iParams.iFilename = _L("unknown_module.cpm");
       
   780 	startParams.iParams.iName = KModule1;
       
   781 
       
   782 	Log(_L8("02 Loading module: %S"), &startParams.iParams.iName);
       
   783 	asynchHandler->TryLoad(startParams, iniData);
       
   784 
       
   785 	User::After(1000000);
       
   786 	Log(_L8("03 Cancelling Loading module: %S"), &startParams.iParams.iName);
       
   787 	iRootServerSuite->RootSess().CancelLoadCpm(startParams.iParams.iName);
       
   788 
       
   789 	CActiveScheduler::Start();
       
   790 
       
   791     Log(_L("LoadServer status was: <%d> "), asynchHandler->iStatus.Int());
       
   792 
       
   793     if (KErrNotFound != asynchHandler->iStatus.Int())
       
   794 		{
       
   795 		verdict = EFail;
       
   796 		}
       
   797 
       
   798 	CleanupStack::PopAndDestroy(asynchHandler);
       
   799 	CleanupStack::PopAndDestroy(scheduler);
       
   800 	return verdict;
       
   801 	}
       
   802 
       
   803 
       
   804 // Test step 3.18 - UnLoad unknown module and cancel
       
   805 CRootServerTest3_18::CRootServerTest3_18()
       
   806 	{
       
   807 	// store the name of this test case
       
   808 	iTestStepName = _L("Test3.18");
       
   809 	}
       
   810 
       
   811 TVerdict CRootServerTest3_18::doTestStepL( void )
       
   812 	{
       
   813 	TVerdict verdict = EPass;
       
   814 
       
   815 	Log(_L("Test Purpose: UnLoad unknown module and cancel"));
       
   816 
       
   817 	// Create scheduler/active object framework
       
   818 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
   819     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
   820 	_LIT8(KUnknownModule, "unknown_module.cpm");
       
   821 	Log(_L8("02 UnLoading module: %S"), &KUnknownModule());
       
   822 	asynchHandler->TryUnLoad(KUnknownModule(), EUnGraceful);
       
   823 
       
   824 	User::After(1000000);
       
   825 	Log(_L8("03 Cancelling Unloading module: %S"), &KUnknownModule());
       
   826 	iRootServerSuite->RootSess().CancelUnloadCpm(KUnknownModule());
       
   827 
       
   828 	CActiveScheduler::Start();
       
   829 
       
   830     Log(_L("UnLoadServer status was: <%d> "), asynchHandler->iStatus.Int());
       
   831 
       
   832     if (KErrRSModuleNotLoaded != asynchHandler->iStatus.Int())
       
   833 		{
       
   834 		verdict = EFail;
       
   835 		}
       
   836 
       
   837 	CleanupStack::PopAndDestroy(asynchHandler);
       
   838 	CleanupStack::PopAndDestroy(scheduler);
       
   839 	return verdict;
       
   840 	}
       
   841 
       
   842 
       
   843