kerneltest/e32test/emul/t_emul_slave.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2007-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 the License "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 // e32test\emul\t_emul_slave.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32std.h>
       
    19 #include <e32std_private.h>
       
    20 #include "t_emul.h"
       
    21 
       
    22 void TrapExceptionInExe()
       
    23 	{
       
    24 	TRAP_IGNORE(User::Leave(KErrGeneral));
       
    25 	}
       
    26 
       
    27 TInt LoadLibraryAndCallFunc()
       
    28 	{
       
    29 	RLibrary l;
       
    30 	TInt r = l.Load(KTEmulDll2Name);
       
    31 	if (r != KErrNone)
       
    32 		return r;
       
    33 	TTrapExceptionInDllFunc func =
       
    34 		(TTrapExceptionInDllFunc)l.Lookup(KTrapExceptionInDllOrdinal);
       
    35 	if (func != NULL)
       
    36 		func();
       
    37 	else
       
    38 		return KErrNotFound;
       
    39 	l.Close();
       
    40 	return KErrNone;
       
    41 	}
       
    42 
       
    43 GLDEF_C TInt E32Main()
       
    44 	{
       
    45 	TBuf<8> arg;
       
    46 	User::CommandLine(arg);
       
    47 	TLex lex(arg);
       
    48 	TInt val;
       
    49 	TInt r = lex.Val(val);
       
    50 	if (r != KErrNone)
       
    51 		return r;
       
    52 
       
    53 	r = KErrNone;
       
    54 	switch(val)
       
    55 		{
       
    56 		case ESlaveDoNothing:
       
    57 			break;
       
    58 
       
    59 		case ESlaveTrapExceptionInExe:
       
    60 			TrapExceptionInExe();
       
    61 			break;
       
    62 
       
    63 		case ESlaveTrapExceptionInLinkedDll:
       
    64 			TrapExceptionInDll();
       
    65 			break;
       
    66 			
       
    67 		case ESlaveTrapExceptionInLoadedDll:
       
    68 			r = LoadLibraryAndCallFunc();
       
    69 			break;
       
    70 		
       
    71 		default:
       
    72 			r = KErrNotSupported;
       
    73 			break;
       
    74 		}
       
    75 
       
    76 	return r;
       
    77 	}