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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\personality\example\t_expers.cpp
19 #include <e32base_private.h>
22 #include "../../misc/prbs.h"
24 RTest test(_L("EXAMPLE PERSONALITY"));
26 _LIT(KIfcLddName,"expers.ldd");
28 class CRxData : public CActive
32 static void New(RRtosIfc aIfc);
41 void CRxData::New(RRtosIfc aIfc)
43 CRxData* p = new CRxData;
46 CActiveScheduler::Add(p);
55 void CRxData::DoCancel()
57 iIfc.Cancel(RRtosIfc::ECancelReceive);
62 iIfc.Receive(iStatus, *(SRxData*)iBuf);
68 SRxData& rxd = *(SRxData*)iBuf;
74 test( (cs & 0xff) == rxd.iChecksum);
75 test.Printf(_L("RXD: l=%02x cs=%02x\n"), l, rxd.iChecksum);
79 class CReport : public CActive
83 static void New(RRtosIfc aIfc);
94 void CReport::New(RRtosIfc aIfc)
96 CReport* p = new CReport;
99 CActiveScheduler::Add(p);
106 iSeed[0] = 0xb504f333;
109 void CReport::DoCancel()
111 iIfc.Cancel(RRtosIfc::ECancelReport);
114 void CReport::Start()
116 iIfc.Report(iStatus, iRpt);
125 test.Printf(_L("SEM: C:%10d OK:%10d BAD:%10d\n"), iRpt.iCount, iRpt.iOkCount, iRpt.iBadCount);
126 if (iRpt.iOkCount>1000000)
127 CActiveScheduler::Stop();
130 test.Printf(_L("RCV: C:%10d OK:%10d BAD:%10d\n"), iRpt.iCount, iRpt.iOkCount, iRpt.iBadCount);
133 test.Printf(_L("TM: C:%10d\n"), iRpt.iCount);
135 if (iRpt.iCount > 100000)
136 CActiveScheduler::Stop();
138 TUint x = Random(iSeed) & 3;
150 void CReport::SendData()
152 TInt l = (Random(iSeed)&127)+128;
156 buf[i] = Random(iSeed);
157 TPtrC8 ptr((const TUint8*)buf, l);
158 TInt r = iIfc.SendData(ptr);
163 GLDEF_C TInt E32Main()
166 test.Start(_L("Load interface LDD"));
168 TInt r = User::LoadLogicalDevice(KIfcLddName);
169 test(r==KErrNone || r==KErrAlreadyExists);
171 test.Next(_L("Open channel"));
173 RThread().SetPriority(EPriorityAbsoluteHigh);
177 test.Next(_L("Start personality tests"));
181 ifc.WaitInitialTests(s);
182 User::WaitForRequest(s);
185 CActiveScheduler* as = new CActiveScheduler;
187 CActiveScheduler::Install(as);
191 CActiveScheduler::Start();