1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/realtime/t_write.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,91 @@
1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32test\realtime\t_write.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include <e32test.h>
1.22 +#include "u32std.h"
1.23 +#include "../misc/prbs.h"
1.24 +
1.25 +LOCAL_D RTest test(_L("Remote Write"));
1.26 +
1.27 +class RMySession : public RSessionBase
1.28 + {
1.29 +public:
1.30 + TInt Connect(RServer2 aSrv,TRequestStatus& aStat)
1.31 + {return CreateSession(aSrv,TVersion(),1,EIpcSession_Unsharable,0,&aStat);}
1.32 + void Test(TDes8& aDes)
1.33 + {Send(0,TIpcArgs(&aDes));}
1.34 + };
1.35 +
1.36 +void RunTest(RMessage2& aMsg,TPtr8& aDes)
1.37 + {
1.38 + // never return or complete message, just do lots of writes...
1.39 +
1.40 + TUint seed[2];
1.41 + seed[0]=0xadf85458;
1.42 + seed[1]=0;
1.43 +
1.44 + TInt* pS=(TInt*)User::Alloc(65536);
1.45 + TInt* pD=(TInt*)User::Alloc(65536);
1.46 + TPtrC8 s((TUint8*)pS,65536);
1.47 + aDes.Set((TUint8*)pD,0,65536);
1.48 + if (!pS || !pD)
1.49 + User::Panic(_L("OOM"),0);
1.50 +
1.51 + RProcess().SetPriority(EPriorityLow);
1.52 + FOREVER
1.53 + {
1.54 + TInt i;
1.55 + for (i=0; i<16384; i++)
1.56 + pS[i]=(TInt)Random(seed);
1.57 + TInt r=aMsg.Write(0,s);
1.58 + if (r!=KErrNone)
1.59 + User::Panic(_L("WriteL"),r);
1.60 + for (i=0; i<16384; i++)
1.61 + {
1.62 + if (pD[i]!=pS[i])
1.63 + User::Panic(_L("ERROR"),i);
1.64 + }
1.65 + }
1.66 + }
1.67 +
1.68 +GLDEF_C TInt E32Main()
1.69 + {
1.70 + test.Title();
1.71 +
1.72 + RServer2 srv;
1.73 + srv.CreateGlobal(KNullDesC);
1.74 +
1.75 + RMySession sess;
1.76 + TRequestStatus stat;
1.77 + sess.Connect(srv,stat);
1.78 +
1.79 + RMessage2 m;
1.80 + srv.Receive(m);
1.81 + m.Complete(KErrNone); // connect message
1.82 +
1.83 + User::WaitForRequest(stat); // connected
1.84 +
1.85 + TPtr8 des(0,0);
1.86 + sess.Test(des);
1.87 +
1.88 + srv.Receive(m);
1.89 + RunTest(m, des);
1.90 +
1.91 + test.End();
1.92 + return 0;
1.93 + }
1.94 +