sl@0: // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\realtime\t_write.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include "u32std.h" sl@0: #include "../misc/prbs.h" sl@0: sl@0: LOCAL_D RTest test(_L("Remote Write")); sl@0: sl@0: class RMySession : public RSessionBase sl@0: { sl@0: public: sl@0: TInt Connect(RServer2 aSrv,TRequestStatus& aStat) sl@0: {return CreateSession(aSrv,TVersion(),1,EIpcSession_Unsharable,0,&aStat);} sl@0: void Test(TDes8& aDes) sl@0: {Send(0,TIpcArgs(&aDes));} sl@0: }; sl@0: sl@0: void RunTest(RMessage2& aMsg,TPtr8& aDes) sl@0: { sl@0: // never return or complete message, just do lots of writes... sl@0: sl@0: TUint seed[2]; sl@0: seed[0]=0xadf85458; sl@0: seed[1]=0; sl@0: sl@0: TInt* pS=(TInt*)User::Alloc(65536); sl@0: TInt* pD=(TInt*)User::Alloc(65536); sl@0: TPtrC8 s((TUint8*)pS,65536); sl@0: aDes.Set((TUint8*)pD,0,65536); sl@0: if (!pS || !pD) sl@0: User::Panic(_L("OOM"),0); sl@0: sl@0: RProcess().SetPriority(EPriorityLow); sl@0: FOREVER sl@0: { sl@0: TInt i; sl@0: for (i=0; i<16384; i++) sl@0: pS[i]=(TInt)Random(seed); sl@0: TInt r=aMsg.Write(0,s); sl@0: if (r!=KErrNone) sl@0: User::Panic(_L("WriteL"),r); sl@0: for (i=0; i<16384; i++) sl@0: { sl@0: if (pD[i]!=pS[i]) sl@0: User::Panic(_L("ERROR"),i); sl@0: } sl@0: } sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: test.Title(); sl@0: sl@0: RServer2 srv; sl@0: srv.CreateGlobal(KNullDesC); sl@0: sl@0: RMySession sess; sl@0: TRequestStatus stat; sl@0: sess.Connect(srv,stat); sl@0: sl@0: RMessage2 m; sl@0: srv.Receive(m); sl@0: m.Complete(KErrNone); // connect message sl@0: sl@0: User::WaitForRequest(stat); // connected sl@0: sl@0: TPtr8 des(0,0); sl@0: sess.Test(des); sl@0: sl@0: srv.Receive(m); sl@0: RunTest(m, des); sl@0: sl@0: test.End(); sl@0: return 0; sl@0: } sl@0: