os/kernelhwsrv/kerneltest/e32test/misc/t_abt.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 1997-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\misc\t_abt.cpp
    15 // 
    16 //
    17 
    18 #include <e32test.h>
    19 
    20 LOCAL_D RTest test(_L("ABT"));
    21 LOCAL_D TInt junk=0x11;
    22 
    23 class RMySession : public RSessionBase
    24 	{
    25 public:
    26 	TInt Connect(RServer2 aSrv,TRequestStatus& aStat)
    27 		{return CreateSession(aSrv,TVersion(),1,EIpcSession_Unsharable,0,&aStat);}
    28 	void Test(TDesC8& aDes)
    29 		{Send(0,TIpcArgs(&aDes));}
    30 	};
    31 
    32 void RunTest(RMessage2& aMsg,TPtrC8& aDes)
    33 	{
    34 	RProcess().SetPriority(EPriorityLow);
    35 	TUint8* pD=(TUint8*)User::Alloc(2048);
    36 	TPtr8 d(pD,2048);
    37 	TInt* pJ=&junk;
    38 	*pJ++=0x2233;
    39 	TUint32 data_addr=(TUint32)pJ;
    40 	data_addr=(data_addr+4095)&~4095;
    41 	data_addr-=2044;
    42 	const TUint8* p=(const TUint8*)data_addr;
    43 	aDes.Set(p,2048);
    44 	FOREVER
    45 		{
    46 		TInt r=aMsg.Read(0,d);
    47 		if (r!=KErrBadDescriptor)
    48 			{
    49 			test.Printf(_L("Return code %d\n"),r);
    50 			test(0);
    51 			}
    52 		}
    53 	}
    54 
    55 GLDEF_C TInt E32Main()
    56 	{
    57 	test.Title();
    58 
    59 	RServer2 srv;
    60 	srv.CreateGlobal(KNullDesC);
    61 
    62 	RMySession sess;
    63 	TRequestStatus stat;
    64 	sess.Connect(srv,stat);
    65 
    66 	RMessage2 m;
    67 	srv.Receive(m);
    68 	m.Complete(KErrNone);	// connect message
    69 
    70 	User::WaitForRequest(stat);	// connected
    71 
    72 	TPtrC8 des;
    73 	sess.Test(des);
    74 
    75 	srv.Receive(m);
    76 	RunTest(m, des);
    77 
    78 	test.End();
    79 	return 0;
    80 	}
    81