os/mm/mmtestenv/mmtestfw/Source/TestFrameworkServer/TestFrameworkServer.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmtestenv/mmtestfw/Source/TestFrameworkServer/TestFrameworkServer.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,726 @@
     1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <e32svr.h>
    1.20 +
    1.21 +#include "TestFrameworkServer.h"
    1.22 +
    1.23 +#include "TestFrameworkServer.inl"
    1.24 +
    1.25 +#include <testframeworkipc.h>
    1.26 +
    1.27 +
    1.28 +/**
    1.29 + *
    1.30 + * Initiate server exit when the timer expires
    1.31 + *
    1.32 + * @xxxx
    1.33 + * 
    1.34 + */
    1.35 +void CTestFrameworkServerShutdown::RunL()
    1.36 +	{
    1.37 +	CActiveScheduler::Stop();
    1.38 +	}
    1.39 +
    1.40 +/**
    1.41 + *
    1.42 + * Test Framework server static constructor
    1.43 + * NOTE : only one instance of the server process should run
    1.44 + * during any Test Framework run; all client sessions
    1.45 + * will use this one instance.
    1.46 + *
    1.47 + * @xxxx
    1.48 + * 
    1.49 + */
    1.50 +CMmfIpcServer* CTestFrameworkServer::NewL()
    1.51 +	{
    1.52 +	CTestFrameworkServer* s = new(ELeave) CTestFrameworkServer;
    1.53 +	CleanupStack::PushL(s);
    1.54 +	s->ConstructL();
    1.55 +	CleanupStack::Pop();
    1.56 +	return s;
    1.57 +	}
    1.58 +
    1.59 +/**
    1.60 + *
    1.61 + * Test Framework server first-phase constructor
    1.62 + *
    1.63 + * @xxxx
    1.64 + * 
    1.65 + */
    1.66 +CTestFrameworkServer::CTestFrameworkServer()
    1.67 +	:CMmfIpcServer(0, ESharableSessions)
    1.68 +	{
    1.69 +	}
    1.70 +
    1.71 +// set up so that iConsole is NULL. A call to OpenLogL will initialise the console
    1.72 +// and file (if any)
    1.73 +
    1.74 +/**
    1.75 + *
    1.76 + * Test Framework server second-phase constructor
    1.77 + * Starts the server; does not initialise the log
    1.78 + * (this must be done independently with a call to OpenLogL)
    1.79 + *
    1.80 + * @xxxx
    1.81 + * 
    1.82 + */
    1.83 +void CTestFrameworkServer::ConstructL()
    1.84 +	{
    1.85 +	StartL(KTestFrameworkServerName);
    1.86 +	//Ensure that the server will exit even if the first client fails to connect
    1.87 +	iShutdown.ConstructL();
    1.88 +	iShutdown.Start();
    1.89 +
    1.90 +	iLogMode = 0;	// initial value : not running any log
    1.91 +	iConsole = NULL;
    1.92 +	iFileLogger = NULL;
    1.93 +	}
    1.94 +
    1.95 +/**
    1.96 + *
    1.97 + * Test Framework server destructor
    1.98 + *
    1.99 + * @xxxx
   1.100 + * 
   1.101 + */
   1.102 +CTestFrameworkServer::~CTestFrameworkServer()
   1.103 +	{
   1.104 +	CloseLog();
   1.105 +	}
   1.106 +
   1.107 +/**
   1.108 + *
   1.109 + * Create new server session.
   1.110 + *
   1.111 + * @param	"const TVersion &aVersion"
   1.112 + *			Server version (required)
   1.113 + *
   1.114 + * @return	"CSharableSession*"
   1.115 + *			The created server session.
   1.116 + * 
   1.117 + * @xxxx
   1.118 + * 
   1.119 + */
   1.120 +CMmfIpcSession* CTestFrameworkServer::NewSessionL(const TVersion &aVersion) const
   1.121 +	{
   1.122 +	TVersion ver(KTestFrameworkServerMajorVersionNumber,
   1.123 +			     KTestFrameworkServerMinorVersionNumber,
   1.124 +			     KTestFrameworkServerBuildVersionNumber);
   1.125 +	if (!User::QueryVersionSupported(ver, aVersion))
   1.126 +		User::Leave(KErrNotSupported);
   1.127 +	// make new session
   1.128 +	return new(ELeave) CTestFrameworkServerSession();
   1.129 +	}
   1.130 +
   1.131 +/**
   1.132 + *
   1.133 + * Add a server session.
   1.134 + * 
   1.135 + * @xxxx
   1.136 + * 
   1.137 + */
   1.138 +void CTestFrameworkServer::AddSession()
   1.139 +	{
   1.140 +	++iSessionCount;
   1.141 +	iShutdown.Cancel();
   1.142 +	}
   1.143 +
   1.144 +/**
   1.145 + *
   1.146 + * Drop a server session.
   1.147 + * 
   1.148 + * @xxxx
   1.149 + * 
   1.150 + */
   1.151 +void CTestFrameworkServer::DropSession()
   1.152 +	{
   1.153 +	if (--iSessionCount <= 0)
   1.154 +		iShutdown.Start();
   1.155 +	}
   1.156 +
   1.157 +/**
   1.158 + *
   1.159 + * Add an input window (at request from client).
   1.160 + * 
   1.161 + * @param	"CTestFrameworkServerSession* aOwner"
   1.162 + *			Window owning server session
   1.163 + *
   1.164 + * @xxxx
   1.165 + * 
   1.166 + */
   1.167 +void CTestFrameworkServer::AddInputWindowL(CTestFrameworkServerSession* aOwner)
   1.168 +	{
   1.169 +	if (iInputWindow.HasOwner())
   1.170 +		User::Leave(KErrAlreadyExists);
   1.171 +	// else
   1.172 +	iInputWindow.SetOwner(aOwner);
   1.173 +	TRect rect;
   1.174 +	rect.iTl = TPoint(0,0);
   1.175 +	rect.iBr = TPoint(KConsFullScreen, KConsFullScreen);
   1.176 +	iInputWindow.SetWinRectAndNotifyOwner(rect);
   1.177 +	}
   1.178 +
   1.179 +/**
   1.180 + *
   1.181 + * Remove an input window (at request from client).
   1.182 + * 
   1.183 + * @param	"CTestFrameworkServerSession* aOwner"
   1.184 + *			Window owning server session
   1.185 + *
   1.186 + * @xxxx
   1.187 + * 
   1.188 + */
   1.189 +void CTestFrameworkServer::RemoveWindow(CTestFrameworkServerSession* aOwner)
   1.190 +	{
   1.191 +	if (aOwner == iInputWindow.Owner())
   1.192 +		{
   1.193 +		iInputWindow.SetOwner(NULL);
   1.194 +		}
   1.195 +	}
   1.196 +
   1.197 +/**
   1.198 + *
   1.199 + * Open a log.
   1.200 + * 
   1.201 + * @param	"const TDesC& aLogName"
   1.202 + *			The log name
   1.203 + *
   1.204 + * @param	"TInt aLogMode"
   1.205 + *			The log mode (as bitmask of TTestFrameworkLogMode)
   1.206 + *
   1.207 + * @xxxx
   1.208 + * 
   1.209 + */
   1.210 +void CTestFrameworkServer::OpenLogL(const TDesC& aLogName, TInt aLogMode)
   1.211 +	{
   1.212 +	// NB we need to check if a console is already open - if so, we do NOT
   1.213 +	// create another one. Ditto with file / port.
   1.214 +
   1.215 +	if(aLogMode & ELogToConsole)
   1.216 +		{
   1.217 +		if(!iConsole)
   1.218 +			{
   1.219 +			iConsole = CServerConsole::NewL(aLogName);
   1.220 +
   1.221 +			CConsoleBase* theConsole = iConsole->Console();
   1.222 +			theConsole->Printf(_L("%S : Server log starting\n"), &aLogName);
   1.223 +
   1.224 +			iLogMode |= ELogToConsole;
   1.225 +			
   1.226 +			if (aLogMode & ELogConsoleFull)
   1.227 +				iLogMode |= ELogConsoleFull;
   1.228 +			}
   1.229 +		}
   1.230 +
   1.231 +	// NB relative paths will not work with TParse (there is no file server open).
   1.232 +	// Exception is a bare filename (with no path) : this will be found in root of C:
   1.233 +
   1.234 +	// NOTE! We have no mechanism to notify this error. The console will display
   1.235 +	// and then exit. The log file cannot be opened.
   1.236 +
   1.237 +	// TO BE ENHANCED - if console is made active, then we can pause
   1.238 +
   1.239 +	if(aLogMode & ELogToFile)
   1.240 +	{
   1.241 +		if(!iFileLogger)
   1.242 +			{
   1.243 +			TRAPD(err, iFileLogger = CFileLogger::NewL());
   1.244 +			if(err != KErrNone)
   1.245 +				{
   1.246 +				// if we can't create a logger, we panic
   1.247 +				User::Panic(_L("TestFrameworkServer"), 1);
   1.248 +				}
   1.249 +
   1.250 +			_LIT(KLogPath, "C:\\Logs\\TestResults");
   1.251 +			_LIT(KDefault, "C:\\.htm"); 
   1.252 +
   1.253 +			TParse parseLogName;
   1.254 +			parseLogName.Set(aLogName, NULL, NULL); 
   1.255 +
   1.256 +			TFileName logFilePath;
   1.257 +			logFilePath = KLogPath;
   1.258 +
   1.259 +			if(parseLogName.PathPresent())
   1.260 +				logFilePath.Append(parseLogName.Path());
   1.261 +			else
   1.262 +				logFilePath.Append(_L("\\"));
   1.263 +
   1.264 +
   1.265 +			// overwrite extension if supplied with .htm
   1.266 +			TParse logFileFullName;
   1.267 +			TInt returnCode = logFileFullName.Set(KDefault, &logFilePath, &aLogName);
   1.268 +			if (returnCode == KErrNone)
   1.269 +				{
   1.270 +				TInt ret = iFileLogger->Connect();
   1.271 +				if (ret == KErrNone)
   1.272 +					{
   1.273 +					iFileLogger->CreateLog(logFilePath, logFileFullName.NameAndExt());
   1.274 +					iLogMode |= ELogToFile;
   1.275 +					}
   1.276 +				}
   1.277 +			}
   1.278 +		}
   1.279 +
   1.280 +	if(aLogMode & ELogToPort)
   1.281 +		{
   1.282 +		// RDebug::Print will deal with the serial port, we don't do anything special here
   1.283 +		iLogMode |= ELogToPort;
   1.284 +		}
   1.285 +	}
   1.286 +
   1.287 +/**
   1.288 + *
   1.289 + * Write to the log.
   1.290 + * 
   1.291 + * @param	"const TDesC& aMsg"
   1.292 + *			The message string to write
   1.293 + *
   1.294 + * @param	"TInt aLogMode"
   1.295 + *			The log mode (as bitmask of TTestFrameworkLogMode)
   1.296 + *
   1.297 + * @xxxx
   1.298 + * 
   1.299 + */
   1.300 +void CTestFrameworkServer::WriteLog(const TDesC& aMsg, TInt aLogMode)
   1.301 +	{
   1.302 +	if(aLogMode & ELogToConsole)
   1.303 +		{
   1.304 +		if(iConsole)
   1.305 +			{
   1.306 +			CConsoleBase* theConsole = iConsole->Console();
   1.307 +			theConsole->Printf(aMsg);
   1.308 +			theConsole->Printf(_L("\n")); // add newline
   1.309 +			}
   1.310 +		}
   1.311 +
   1.312 +	if(aLogMode & ELogToFile)
   1.313 +		{
   1.314 +		if(iFileLogger)
   1.315 +			{
   1.316 +			iFileLogger->WriteLog(aMsg);
   1.317 +			}
   1.318 +		}
   1.319 +
   1.320 +	if(aLogMode & ELogToPort)
   1.321 +		{
   1.322 +		RDebug::Print(aMsg);
   1.323 +		}
   1.324 +	}
   1.325 +
   1.326 +/**
   1.327 + *
   1.328 + * Close the log.
   1.329 + * 
   1.330 + * @xxxx
   1.331 + * 
   1.332 + */
   1.333 +void CTestFrameworkServer::CloseLog()
   1.334 +	{
   1.335 +	if (iFileLogger != NULL)
   1.336 +		iFileLogger->CloseLog();
   1.337 +	delete(iFileLogger);
   1.338 +	iFileLogger = NULL;
   1.339 +	delete(iConsole);
   1.340 +	iConsole = NULL;
   1.341 +	iLogMode = 0;
   1.342 +	}
   1.343 +
   1.344 +/**
   1.345 + *
   1.346 + * Get the log status.
   1.347 + *
   1.348 + * @return	"TInt"
   1.349 + *			The log status (as bitmask of TTestFrameworkLogMode)
   1.350 + *
   1.351 + * @xxxx
   1.352 + * 
   1.353 + */
   1.354 +TInt CTestFrameworkServer::LogStatus() const
   1.355 +	{
   1.356 +	return iLogMode;
   1.357 +	}
   1.358 +
   1.359 +
   1.360 +/**
   1.361 + *
   1.362 + * Default window constructor (no owner)
   1.363 + *
   1.364 + * @xxxx
   1.365 + * 
   1.366 + */
   1.367 +TWindow::TWindow()
   1.368 +	{
   1.369 +	iOwner = NULL;
   1.370 +	}
   1.371 +
   1.372 +/**
   1.373 + *
   1.374 + * Default window constructor
   1.375 + *
   1.376 + * @param	"CTestFrameworkServerSession* aOwner"
   1.377 + *			The window owner
   1.378 + * @xxxx
   1.379 + * 
   1.380 + */
   1.381 +TWindow::TWindow(CTestFrameworkServerSession* aOwner)
   1.382 +	{
   1.383 +	iOwner = aOwner;
   1.384 +	}
   1.385 +
   1.386 +/**
   1.387 + *
   1.388 + * Set the window owner
   1.389 + *
   1.390 + * @param	"CTestFrameworkServerSession* aOwner"
   1.391 + *			The window owner
   1.392 + * @xxxx
   1.393 + * 
   1.394 + */
   1.395 +void TWindow::SetOwner(CTestFrameworkServerSession* aOwner)
   1.396 +	{
   1.397 +	iOwner = aOwner;
   1.398 +	}
   1.399 +
   1.400 +/**
   1.401 + *
   1.402 + * Set the window rectangle, and notify owner
   1.403 + *
   1.404 + * @param	"const TRect& aWinRect"
   1.405 + *			The window rectangle
   1.406 + * @xxxx
   1.407 + * 
   1.408 + */
   1.409 +void TWindow::SetWinRectAndNotifyOwner(const TRect& aWinRect)
   1.410 +	{
   1.411 +	if (HasOwner())
   1.412 +		iOwner->NotifyWindowChanged(aWinRect);
   1.413 +	}
   1.414 +
   1.415 +/**
   1.416 + *
   1.417 + * Does this window have an owner?
   1.418 + *
   1.419 + * @return	"TBool"
   1.420 + *			ETrue if window has an owner
   1.421 + * @xxxx
   1.422 + * 
   1.423 + */
   1.424 +TBool TWindow::HasOwner()
   1.425 +	{
   1.426 +	if (iOwner)
   1.427 +		return ETrue;
   1.428 +	return EFalse;
   1.429 +	}
   1.430 +
   1.431 +/**
   1.432 + *
   1.433 + * Server session first-phase constructor
   1.434 + *
   1.435 + * @xxxx
   1.436 + * 
   1.437 + */
   1.438 +CTestFrameworkServerSession::CTestFrameworkServerSession()
   1.439 +	{
   1.440 +	}
   1.441 +
   1.442 +/**
   1.443 + *
   1.444 + * Create a server session.
   1.445 + *
   1.446 + * @param "aServer"
   1.447 + *			The server to add this session to
   1.448 + *
   1.449 + * @xxxx
   1.450 + * 
   1.451 + */
   1.452 +void CTestFrameworkServerSession::CreateL(const CMmfIpcServer& aServer)
   1.453 +	{
   1.454 +	CMmfIpcSession::CreateL(aServer);	// does not leave
   1.455 +	//Add session to server first. If anything leaves, it will be removed by the destructor
   1.456 +	iServer = STATIC_CAST(CTestFrameworkServer*, (CONST_CAST(CMmfIpcServer*, &aServer)));
   1.457 +	iServer->AddSession();
   1.458 +	ConstructL();
   1.459 +	}
   1.460 +
   1.461 +/**
   1.462 + *
   1.463 + * Server session second-phase constructor
   1.464 + *
   1.465 + * @xxxx
   1.466 + * 
   1.467 + */
   1.468 +void CTestFrameworkServerSession::ConstructL()
   1.469 +	{
   1.470 +	}
   1.471 +
   1.472 +/**
   1.473 + *
   1.474 + * Server session destructor
   1.475 + *
   1.476 + * @xxxx
   1.477 + * 
   1.478 + */
   1.479 +CTestFrameworkServerSession::~CTestFrameworkServerSession()
   1.480 +	{
   1.481 +	iServer->RemoveWindow(this);
   1.482 +	iServer->DropSession();
   1.483 +	}
   1.484 +
   1.485 +/**
   1.486 + *
   1.487 + * Server session service function
   1.488 + *
   1.489 + * @param "aMessage"
   1.490 + *			The message to be serviced.
   1.491 + *
   1.492 + * @xxxx
   1.493 + * 
   1.494 + */
   1.495 +void CTestFrameworkServerSession::ServiceL(const RMmfIpcMessage& aMessage)
   1.496 +	{
   1.497 +	switch (aMessage.Function())
   1.498 +		{
   1.499 +	case ECreateInputWindow:
   1.500 +		SetOwnCopyOfWindowMessageL(aMessage);
   1.501 +		iServer->AddInputWindowL(this);
   1.502 +		break;
   1.503 +	case ENotifyIfWindowChange:
   1.504 +		SetOwnCopyOfWindowMessageL(aMessage);
   1.505 +		break;
   1.506 +	case ECancelNotifyIfWindowChange:
   1.507 +		CompleteOwnCopyOfWindowMessage(KErrCancel);
   1.508 +		aMessage.Complete(KErrNone);
   1.509 +		break;
   1.510 +
   1.511 +	// logging messages
   1.512 +
   1.513 +	case EOpenLog:
   1.514 +		{
   1.515 +		TBuf<KMaxLogFilenameLength> msgBuf;
   1.516 +
   1.517 +		TInt r = MmfMessageUtilX::Read(aMessage, 0, msgBuf);
   1.518 +		if (r != KErrNone)
   1.519 +			RunError(aMessage, r);
   1.520 +		else
   1.521 +			{
   1.522 +			iServer->OpenLogL(msgBuf, aMessage.Int1());
   1.523 +			aMessage.Complete(KErrNone);
   1.524 +			}
   1.525 +		}
   1.526 +		break;
   1.527 +
   1.528 +	case EWriteLog:
   1.529 +		{
   1.530 +		TBuf<KMaxLogLineLength> msgBuf;
   1.531 +
   1.532 +		TInt r = MmfMessageUtilX::Read(aMessage, 0, msgBuf);
   1.533 +
   1.534 +		if (r != KErrNone)
   1.535 +			RunError(aMessage, r);
   1.536 +		else
   1.537 +			{
   1.538 +			iServer->WriteLog(msgBuf, aMessage.Int1());
   1.539 +			aMessage.Complete(KErrNone);
   1.540 +			}
   1.541 +		}
   1.542 +		break;
   1.543 +
   1.544 +	case ECloseLog:
   1.545 +		iServer->CloseLog();
   1.546 +		aMessage.Complete(KErrNone);
   1.547 +		break;
   1.548 +
   1.549 +	case ELogStatus:
   1.550 +		{
   1.551 +		TPckgBuf<TInt> countPckg(iServer->LogStatus());
   1.552 +		TInt r = MmfMessageUtilX::Write(aMessage, 0, countPckg);
   1.553 +		if (r != KErrNone)
   1.554 +			RunError(aMessage, r);
   1.555 +		else
   1.556 +			aMessage.Complete(KErrNone);
   1.557 +		}
   1.558 +		break;
   1.559 +
   1.560 +	default:
   1.561 +		// ? should panic here
   1.562 +		break;
   1.563 +		}
   1.564 +	}
   1.565 +
   1.566 +/**
   1.567 + *
   1.568 + * Error handler for server session.
   1.569 + * Completes the pending message using the error code
   1.570 + *
   1.571 + * @param	"TInt aError"
   1.572 + *			The error code
   1.573 + *
   1.574 + * @return	"TInt"
   1.575 + *			The error code (always KErrNone)
   1.576 + *
   1.577 + * @xxxx
   1.578 + *
   1.579 + */
   1.580 + TInt CTestFrameworkServerSession::RunError(const RMmfIpcMessage& aMessage, TInt aError)
   1.581 +	{
   1.582 +	aMessage.Complete(aError);
   1.583 +	return KErrNone;
   1.584 +	}
   1.585 +
   1.586 +/**
   1.587 + *
   1.588 + * Set own copy of message.
   1.589 + * Helper function to enable window change notification.
   1.590 + *
   1.591 + * @param "aMessage"
   1.592 + *			The message to be serviced.
   1.593 + *
   1.594 + * @xxxx
   1.595 + *
   1.596 + */
   1.597 + void CTestFrameworkServerSession::SetOwnCopyOfWindowMessageL(const RMmfIpcMessage& aMessage)
   1.598 +	{
   1.599 +	if (iCanCompleteWindowMessage)
   1.600 +		User::Leave(KErrAlreadyExists);
   1.601 +	//else
   1.602 +	iWindowMessage = aMessage;
   1.603 +	iCanCompleteWindowMessage = ETrue;
   1.604 +	
   1.605 +	if (iNeedToNotifyClientOfWindowSizeChange)
   1.606 +		{
   1.607 +		TInt err = MmfMessageUtil::Write(iWindowMessage, 0, iWinRectBuf);
   1.608 +		CompleteOwnCopyOfWindowMessage(err);
   1.609 +		iNeedToNotifyClientOfWindowSizeChange = EFalse;
   1.610 +		}
   1.611 +	}
   1.612 +
   1.613 +/**
   1.614 + *
   1.615 + * Complete own copy of message.
   1.616 + * Helper function to enable window change notification.
   1.617 + *
   1.618 + * @param "TInt aReason"
   1.619 + *			The message return code.
   1.620 + *
   1.621 + * @xxxx
   1.622 + *
   1.623 + */
   1.624 + void CTestFrameworkServerSession::CompleteOwnCopyOfWindowMessage(TInt aReason)
   1.625 +	{
   1.626 +	if (iCanCompleteWindowMessage)
   1.627 +		iWindowMessage.Complete(aReason);
   1.628 +	iCanCompleteWindowMessage = EFalse;
   1.629 +	}
   1.630 +
   1.631 +/**
   1.632 + *
   1.633 + * Window change notification.
   1.634 + *
   1.635 + * @param "const TRect& aWinRect"
   1.636 + *			The window rectangle.
   1.637 + *
   1.638 + * @xxxx
   1.639 + *
   1.640 + */
   1.641 +void CTestFrameworkServerSession::NotifyWindowChanged(const TRect& aWinRect)
   1.642 +	{
   1.643 +	iWinRectBuf() = aWinRect;
   1.644 +
   1.645 +	if (iCanCompleteWindowMessage)
   1.646 +		{
   1.647 +		TInt err = MmfMessageUtilX::Write(iWindowMessage, 0, iWinRectBuf);
   1.648 +		CompleteOwnCopyOfWindowMessage(err);
   1.649 +		}
   1.650 +	else
   1.651 +		{
   1.652 +		iNeedToNotifyClientOfWindowSizeChange = ETrue;
   1.653 +		}
   1.654 +	}
   1.655 +
   1.656 +// EXE/DLL initialisation
   1.657 +
   1.658 +// NOTE! None of this should be built when compiling for Unit Testing
   1.659 +#if !defined (__TSU_TESTFRAMEWORK__)
   1.660 +
   1.661 +
   1.662 +/**
   1.663 + *
   1.664 + * Perform all server initialisation, in particular creation of the
   1.665 + * scheduler and server; then run the scheduler
   1.666 + *
   1.667 + *
   1.668 + * @xxxx
   1.669 + *
   1.670 + */
   1.671 +static void RunServerL()
   1.672 +	{
   1.673 +	// create and install the active scheduler we need
   1.674 +	CActiveScheduler* s = new(ELeave) CActiveScheduler;
   1.675 +	CleanupStack::PushL(s);
   1.676 +	CActiveScheduler::Install(s);
   1.677 +	//
   1.678 +	// create the server (leave it on the cleanup stack)
   1.679 +	CleanupStack::PushL(CTestFrameworkServer::NewL());
   1.680 +	//
   1.681 +	// Initialisation complete, now signal the client
   1.682 +	RProcess::Rendezvous(KErrNone);
   1.683 +
   1.684 +	//
   1.685 +	// Ready to run
   1.686 +	CActiveScheduler::Start();
   1.687 +	//
   1.688 +	// Cleanup the server and scheduler
   1.689 +	CleanupStack::PopAndDestroy(2);
   1.690 +	}
   1.691 +
   1.692 +/**
   1.693 + *
   1.694 + * Main entry point for the server thread
   1.695 + *
   1.696 + * @param "TTestFrameworkServerStart& aStart"
   1.697 + *			The server starter.
   1.698 + *
   1.699 + * @xxxx
   1.700 + *
   1.701 + */
   1.702 +static TInt RunServer()
   1.703 +	{
   1.704 +	__UHEAP_MARK;
   1.705 +	CTrapCleanup* cleanup = CTrapCleanup::New();
   1.706 +	TInt r = KErrNoMemory;
   1.707 +	if (cleanup)
   1.708 +		{
   1.709 +		TRAP(r, RunServerL());
   1.710 +		delete cleanup;
   1.711 +		}
   1.712 +	//
   1.713 +	__UHEAP_MARKEND;
   1.714 +	return r;
   1.715 +	}
   1.716 +
   1.717 +
   1.718 +GLDEF_C TInt E32Main()
   1.719 +
   1.720 +// Server process entry-point
   1.721 +// Recover the startup parameters and run the server
   1.722 +
   1.723 +	{
   1.724 +	TInt r = RunServer();
   1.725 +	return r;
   1.726 +	}
   1.727 +
   1.728 +
   1.729 +#endif // __TSU_TESTFRAMEWORK__