kerneltest/f32test/loader/tld_helper.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 07 Jan 2010 13:38:45 +0200
changeset 33 0173bcd7697c
parent 0 a41df078684a
permissions -rw-r--r--
Revision: 201001 Kit: 201001

// Copyright (c) 2006-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:
// \f32test\loader\tld_helper.cpp
// 
//

#include "t_loader_delete.h"
#include <e32debug.h>
#include <e32ldr.h>
#include <e32ldr_private.h>

TInt E32Main()
	{
#ifdef __WINS__
	// don't use JIT if running on emulator because don't want to halt
	// t_loader_delete test run.
	User::SetJustInTime(EFalse);
#endif

	TInt r;
	RProcess p;

	RLoader l;
	r = l.Connect();
	if (r != KErrNone)
		p.Panic(_L("tldh-noconn"), 0);

	
	TFileName fn;
	User::CommandLine(fn);

	TBuf16<512> aBuf;
	aBuf.Copy(fn);

	if (aBuf.FindF(KBadDescriptor) >= 0)
		{
		const TDesC16 *pBuf = &aBuf;

		((int*)pBuf)[0] = 0x7554444f; //malformed descriptor

		RDebug::Print(_L("Calling RLoader::Delete passing as an argument a malformed descriptor %S\n"),&fn );
		
		r = l.Delete(*pBuf);
		
		// panic with the reason from RLoader::Delete so t_loader_delete
		// can check for the right error code.
		p.Panic(KTldPanicCat, r);

		}
	
	// panic with the reason from RLoader::Delete so t_loader_delete
	// can check for the right error code.
	r = l.Delete(fn);
	p.Panic(KTldPanicCat, r);

	// unused return value - present to prevent compiler warning
	return KErrNone;
	}