kerneltest/e32test/usbho/t_usbdi/src/main.cpp
author Tom Cosgrove <tom.cosgrove@nokia.com>
Fri, 28 May 2010 16:29:07 +0100
changeset 30 8aab599e3476
parent 0 a41df078684a
child 43 c1f20ce4abcf
permissions -rw-r--r--
Fix for bug 2283 (RVCT 4.0 support is missing from PDK 3.0.h) Have multiple extension sections in the bld.inf, one for each version of the compiler. The RVCT version building the tools will build the runtime libraries for its version, but make sure we extract all the other versions from zip archives. Also add the archive for RVCT4.

// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
// @file main.cpp
// @internalComponent
// 
//

#include <e32base.h>
#include <e32base_private.h>
#include <e32test.h>

#include "testdebug.h"
#include "TestEngine.h"

using namespace NUnitTesting_USBDI;

// The test object

RTest gtest(_L("USBDI Unit Testing"));

static void MainL()
	{
	LOG_CFUNC
	// Leave the hooks in for platform security
#ifdef __DATA_CAGING__
	RProcess().DataCaging(RProcess::EDataCagingOn);
	RProcess().SecureApi(RProcess::ESecureApiOn);
#endif		

	// Identify the process and main thread
	RProcess testProcess;
	RThread().Process(testProcess);
	testProcess.RenameMe(_L("t_usbdi.exe"));
	RThread().RenameMe(_L("t_usbdi.exe main thread"));

	// Create a new active scheduler for this main thread
	CActiveScheduler* sched = new (ELeave) CActiveScheduler;
	CleanupStack::PushL(sched);
	CActiveScheduler::Install(sched);
	
	// create test engine for host or client depending upon command line arguments.
	CTestEngine* testEngine = NULL;
	TRAPD(err, testEngine = CTestEngine::NewL());
	if(err == KErrNone)
		{
		CleanupStack::PushL(testEngine);
			
		// Synchronise with the client and start the active scheduler
		RProcess::Rendezvous(KErrNone);

        User::After(150000);
		RDebug::Print(_L("CActiveScheduler::Start MainL"));	
		CActiveScheduler::Start();
		
		CleanupStack::PopAndDestroy(testEngine);
		}
	else
		{
		gtest.Printf(_L("Unable to create the test engine: %d\n"),err);
		}
		
	User::After(5000000);
	CleanupStack::PopAndDestroy(sched);		
	}

TInt E32Main()
	{
	LOG_CFUNC
	// Create the new trap-cleanup mechanism
	CTrapCleanup* cleanup = CTrapCleanup::New();
	
	if(cleanup == NULL)
		{
		return KErrNoMemory;
		}
		
	// Perform the tests
	TRAPD(err,MainL());
	if(err != KErrNone)
		{
		gtest.Printf(_L("MainL error: %d\n"),err);		
		}
	
	delete cleanup;
	
	// Provide no error
	return KErrNone;
	}