56
|
1 |
// Copyright (c) 2005-2010 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 "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\ost\t_tracecore.cpp
|
|
15 |
// Overview:
|
|
16 |
// Tests activation/deactivation of traces using the TraceCore
|
|
17 |
// kernel - side APIs
|
|
18 |
//
|
|
19 |
|
|
20 |
#define __E32TEST_EXTENSION__
|
|
21 |
#include <e32svr.h>
|
|
22 |
#include <e32def.h>
|
|
23 |
#include <e32def_private.h>
|
|
24 |
#include <e32btrace.h>
|
|
25 |
#include <test/tracedataparser.h>
|
|
26 |
#include "t_rtest_panic.h"
|
|
27 |
|
|
28 |
|
|
29 |
// the following definition is mutually exclusive
|
|
30 |
// with loading tracecore as extension
|
|
31 |
// eg epoc.ini extension tracecore.dll
|
|
32 |
|
|
33 |
|
|
34 |
#include "TraceCoreConstants.h"
|
|
35 |
#include "d_tracecore.h"
|
|
36 |
#include "t_tracecore.h"
|
|
37 |
#include "TestDataWriterNotifier.h"
|
|
38 |
|
|
39 |
#define __TRACE_LINE__() test.Printf(_L("%d\n"),__LINE__)
|
|
40 |
|
|
41 |
RTest test(_L("T_TRACECORE"));
|
|
42 |
|
|
43 |
RTraceCoreTest TraceTest;
|
|
44 |
TComponentId KOstTraceComponentID;
|
|
45 |
TUint32 KTraceMultipartTestData[60];
|
|
46 |
TBuf8<KTcTdwBufSize> buf;
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
/**
|
|
51 |
* Validate all filters are in sync for the component ids in this test
|
|
52 |
* @param aComponentId the component id to check group id (category) filters on
|
|
53 |
*/
|
|
54 |
void ValidateGroupIdFiltersInSync(TUint32 aComponentId)
|
|
55 |
{
|
|
56 |
TInt r = KErrNone;
|
|
57 |
TcDriverParameters p;
|
|
58 |
|
|
59 |
p.iComponentId = aComponentId;
|
|
60 |
for (TInt i = BTrace::EThreadIdentification; i < KMaxGroupId; i++)
|
|
61 |
{
|
|
62 |
p.iGroupId = i;
|
|
63 |
r = TraceTest.ValidateFilterSync(p);
|
|
64 |
TEST_KErrNone(r);
|
|
65 |
}
|
|
66 |
}
|
|
67 |
|
|
68 |
void ValidateAllFiltersInSync()
|
|
69 |
{
|
|
70 |
ValidateGroupIdFiltersInSync(KTestComponentID1);
|
|
71 |
ValidateGroupIdFiltersInSync(KTestComponentID2);
|
|
72 |
}
|
|
73 |
|
|
74 |
/*
|
|
75 |
* Activate a trace depending on aMatch
|
|
76 |
*
|
|
77 |
* @param aMatch if aMatch is true then activate the correct GID and CID
|
|
78 |
* @param aNum Number of group id's and component id pairs to activate
|
|
79 |
*
|
|
80 |
*/
|
|
81 |
void ActivateTrace(TBool aMatch, TInt aNum = 1)
|
|
82 |
{
|
|
83 |
test.Printf(_L("In ActivateTrace()\n"));
|
|
84 |
TcDriverParameters p;
|
|
85 |
TInt r = 0;
|
|
86 |
p.iComponentId = (aMatch) ? KTestComponentID1 : KTestComponentID2;
|
|
87 |
p.iGroupId = (aMatch) ? KTestGroupId1 : KTestGroupId2;
|
|
88 |
|
|
89 |
r = TraceTest.ValidateFilterSync(p);
|
|
90 |
TEST_KErrNone(r);
|
|
91 |
|
|
92 |
//if we want to activate correct gids &cids, activate the correct number of them
|
|
93 |
//starting from KTestGroupId1 and KTestComponentID1 else just activate one incorrect
|
|
94 |
//pair i.e KTestComponentID2 & KTestGroupId1
|
|
95 |
if (aMatch)
|
|
96 |
r = TraceTest.ActivateTrace(p, aNum);
|
|
97 |
else
|
|
98 |
r = TraceTest.ActivateTrace(p);
|
|
99 |
TEST_KErrNone(r);
|
|
100 |
|
|
101 |
r = TraceTest.ValidateFilterSync(p);
|
|
102 |
TEST_KErrNone(r);
|
|
103 |
|
|
104 |
}
|
|
105 |
|
|
106 |
/*
|
|
107 |
* Deactivate a trace depending on aMatch
|
|
108 |
*
|
|
109 |
* @param aMatch if aMatch is true then deactivate the correct GID and CID
|
|
110 |
* @param aNum Number of group id's to deactivate
|
|
111 |
*
|
|
112 |
*/
|
|
113 |
void DeactivateTrace(TBool aMatch, TInt aNum = 1)
|
|
114 |
{
|
|
115 |
test.Printf(_L("In DeactivateTrace()\n"));
|
|
116 |
TcDriverParameters p;
|
|
117 |
TInt r = 0;
|
|
118 |
p.iComponentId = (aMatch) ? KTestComponentID1 : KTestComponentID2;
|
|
119 |
p.iGroupId = (aMatch) ? KTestGroupId1 : KTestGroupId2;
|
|
120 |
|
|
121 |
r = TraceTest.ValidateFilterSync(p);
|
|
122 |
TEST_KErrNone(r);
|
|
123 |
|
|
124 |
//if we want to deactivate correct gids &cids, deactivate the correct number of them
|
|
125 |
//starting from KTestGroupId1 and KTestComponentID1 else just deactivate one incorrect
|
|
126 |
//pair i.e KTestComponentID2 & KTestGroupId1
|
|
127 |
if (aMatch)
|
|
128 |
r = TraceTest.DeactivateTrace(p, aNum);
|
|
129 |
else
|
|
130 |
r = TraceTest.DeactivateTrace(p);
|
|
131 |
TEST_KErrNone(r);
|
|
132 |
|
|
133 |
r = TraceTest.ValidateFilterSync(p);
|
|
134 |
TEST_KErrNone(r);
|
|
135 |
}
|
|
136 |
|
|
137 |
/*
|
|
138 |
* Tell the test writer to start/stop dropping
|
|
139 |
* traces
|
|
140 |
*
|
|
141 |
* @param aDrop ETrue to drop Traces, EFalse to stop
|
|
142 |
* dropping them
|
|
143 |
*/
|
|
144 |
void DropNextTrace(TBool aDrop)
|
|
145 |
{
|
|
146 |
TInt r = KErrNone;
|
|
147 |
r = TraceTest.DropNextTrace(aDrop);
|
|
148 |
TEST_KErrNone(r);
|
|
149 |
}
|
|
150 |
|
|
151 |
/*
|
|
152 |
* Activate/deactivate the printf handler
|
|
153 |
*
|
|
154 |
* TBool aActivate to activate(ETrue)/deactivate(EFalse)
|
|
155 |
*
|
|
156 |
* Activate/Deactivate TRACECORE_KERN_PRINTF=BTrace::EKernPrintf=0
|
|
157 |
* TRACECORE_RDEBUG_PRINT=BTrace::ERDebugPrintf=1
|
|
158 |
* TRACECORE_PLATSEC_PRINTF=BTrace::EPlatsecPrintf=2
|
|
159 |
*
|
|
160 |
*/
|
|
161 |
void ActivatePrintfHandler(TBool aActivate, TInt aMaxCategory = BTrace::EPlatsecPrintf)
|
|
162 |
{
|
|
163 |
TcDriverParameters p;
|
|
164 |
TInt r=0;
|
|
165 |
TInt maxPrintfCategory = aMaxCategory;
|
|
166 |
p.iComponentId = 0x2001022D; //from BTraceHooks_0x2001022D_dictionary.xml
|
|
167 |
p.iGroupId = BTrace::ERDebugPrintf;
|
|
168 |
|
|
169 |
for(TInt i=0; i<=maxPrintfCategory; i++)
|
|
170 |
{
|
|
171 |
if(aActivate)
|
|
172 |
r = TraceTest.ActivateTrace(p);
|
|
173 |
else
|
|
174 |
r = TraceTest.DeactivateTrace(p);
|
|
175 |
if (r!=KErrNone)
|
|
176 |
{
|
|
177 |
test.Printf(_L("Unable to activate/deactivate printf handler for printf %d: error: %d"), i, r);
|
|
178 |
}
|
|
179 |
TEST_KErrNone(r);
|
|
180 |
p.iGroupId++;
|
|
181 |
}
|
|
182 |
r = TraceTest.ValidateFilterSync(p);
|
|
183 |
TEST_KErrNone(r);
|
|
184 |
}
|
|
185 |
|
|
186 |
/*
|
|
187 |
* Activate/deactivate kernel GIDs
|
|
188 |
*
|
|
189 |
* TBool aActivate to activate(ETrue)/deactivate(EFalse)
|
|
190 |
* TBool aFirstGID start of range of GIDs to activate/deactivate
|
|
191 |
* TBool aLastGID end of range of GIDs to activate/deactivate
|
|
192 |
*
|
|
193 |
*/
|
|
194 |
void ActivateKernelTraces(TBool aActivate, TInt aFirstGID = -1, TInt aLastGID = -1)
|
|
195 |
{
|
|
196 |
TInt r=KErrNone;
|
|
197 |
|
|
198 |
if(aFirstGID == -1)
|
|
199 |
{
|
|
200 |
aFirstGID = KMinKernelCategory;
|
|
201 |
if(aLastGID == -1)
|
|
202 |
{
|
|
203 |
aLastGID = KMaxKernelCategory;
|
|
204 |
}
|
|
205 |
}
|
|
206 |
if(aLastGID < aFirstGID)
|
|
207 |
{
|
|
208 |
aLastGID = aFirstGID;
|
|
209 |
}
|
|
210 |
|
|
211 |
TcDriverParameters p;
|
|
212 |
p.iComponentId = 0x2001022D; //from BTraceHooks_0x2001022D_dictionary.xml
|
|
213 |
|
|
214 |
for(TInt i=aFirstGID; i<=aLastGID; i++)
|
|
215 |
{
|
|
216 |
p.iGroupId = i;
|
|
217 |
if(aActivate)
|
|
218 |
r = TraceTest.ActivateTrace(p);
|
|
219 |
else
|
|
220 |
r = TraceTest.DeactivateTrace(p);
|
|
221 |
if (r<KErrNone)
|
|
222 |
{
|
|
223 |
test.Printf(_L("Unable to activate/deactivate kernel trace for GID %d: error: %d"), i, r);
|
|
224 |
}
|
|
225 |
TEST_KErrNone(r);
|
|
226 |
}
|
|
227 |
}
|
|
228 |
|
|
229 |
/*
|
|
230 |
* Validate the trace data in memory buffer
|
|
231 |
*
|
|
232 |
* @param aTracePresent determines if trace data should be present or not
|
|
233 |
* @param aBuffer the buffer containing the trace data
|
|
234 |
* @param aSize size of the trace buffer
|
|
235 |
* @param aGID expected GID
|
|
236 |
* @param aCID expected CID
|
|
237 |
*
|
|
238 |
*/
|
|
239 |
TInt ValidatePayload(TBool aTracePresent, TUint8 aGID, TUint32 aCID, TBool aMissingTrace=EFalse, TBool aPrintfTrace=EFalse, TDesC8* aExpectedPrintfTrace=NULL)
|
|
240 |
{
|
|
241 |
#ifdef TRACECORE_TRACE_DISABLED
|
|
242 |
if (!aPrintfTrace)
|
|
243 |
{
|
|
244 |
aTracePresent = EFalse;
|
|
245 |
}
|
|
246 |
#endif
|
|
247 |
return TTraceDataParser::ValidatePayload(buf, aTracePresent,
|
|
248 |
(TGroupId) aGID, (TComponentId)aCID, KTestData, aPrintfTrace, aMissingTrace, aExpectedPrintfTrace);
|
|
249 |
}
|
|
250 |
|
|
251 |
/*
|
|
252 |
* Make a request to the test writer to start watching for data
|
|
253 |
*
|
|
254 |
* @param aStatus holds the status of the request
|
|
255 |
* @param aNumTraces number of traces to write
|
|
256 |
*
|
|
257 |
*/
|
|
258 |
void RequestDataNotification(TRequestStatus& aStatus, TInt aNumTraces=1)
|
|
259 |
{
|
|
260 |
buf.Zero();
|
|
261 |
TraceTest.RequestTraceData(aStatus, buf, aNumTraces);
|
|
262 |
}
|
|
263 |
|
|
264 |
/*
|
|
265 |
* Read the trace data in memory buffer
|
|
266 |
*
|
|
267 |
* @param aBuffer on return, buffer containing the trace data
|
|
268 |
* @param aSize on return, size of the trace buffer
|
|
269 |
* @return
|
|
270 |
*
|
|
271 |
*/
|
|
272 |
TInt ReadTraceFromBuffer(TRequestStatus& aStatus, TUint8*& aBuffer,
|
|
273 |
TInt& aSize)
|
|
274 |
{
|
|
275 |
RTimer timer;
|
|
276 |
TRequestStatus status;
|
|
277 |
TInt ret = timer.CreateLocal();
|
|
278 |
// wait for WriteComplete to complete
|
|
279 |
|
|
280 |
timer.After(status, 10000);
|
|
281 |
User::WaitForRequest(status,aStatus);
|
|
282 |
|
|
283 |
if (aStatus.Int() != KErrNone)
|
|
284 |
//if the read request didn't complete, force it to look like it completed (this doesn't cancel the request tho)
|
|
285 |
aStatus = KErrNone;
|
|
286 |
|
|
287 |
aBuffer = (TUint8*) buf.Ptr();
|
|
288 |
aSize = buf.Size();
|
|
289 |
|
|
290 |
//test.Printf(_L("In ReadTraceFromBuffer()\n"));
|
|
291 |
timer.Close();
|
|
292 |
return KErrNone;
|
|
293 |
}
|
|
294 |
|
|
295 |
/*
|
|
296 |
* Send Simple (<80 bytes) Test Traces.
|
|
297 |
* Each trace has the same payload containing numbers
|
|
298 |
* starting from KTestData and incrementing until the required size is filled up.
|
|
299 |
* Each trace has a different group id and component id pair incrementing up from
|
|
300 |
* KTestGroupId1 and KTestComponentID1.
|
|
301 |
*
|
|
302 |
* @param aTracePresent indicates id a trace packet should be present or not
|
|
303 |
* @param aSize size of trace to send in words (groups of 4 bytes),defaults to 1.
|
|
304 |
* @param aNum Number of traces to send, defaults to 1.
|
|
305 |
*/
|
|
306 |
TInt SendAndValidateTestTraces(TBool aTracePresent, TInt aSize = 1,
|
|
307 |
TInt aNum = 1, TBool aPrintfTrace = EFalse, TInt aNumberDropped = 0)
|
|
308 |
{
|
|
309 |
if (aSize > 18)
|
|
310 |
{
|
|
311 |
test.Printf(
|
|
312 |
_L("Incorrect argument... Please use a trace size that is <=18 words (72bytes)"));
|
|
313 |
return KErrArgument;
|
|
314 |
}
|
|
315 |
|
|
316 |
if (aNumberDropped>=aNum)
|
|
317 |
{
|
|
318 |
test.Printf(
|
|
319 |
_L("Incorrect argument... Please use aNumberDropped less than number you wish to send)"));
|
|
320 |
return KErrArgument;
|
|
321 |
}
|
|
322 |
|
|
323 |
test.Printf(_L("In SendTestTraces()\n"));
|
|
324 |
TUint32 traceword = TEST_TRACE;
|
|
325 |
KOstTraceComponentID = KTestComponentID1;
|
|
326 |
TRequestStatus status;
|
|
327 |
TUint8* buffer = NULL;
|
|
328 |
|
|
329 |
//Drop next Trace
|
|
330 |
DropNextTrace(ETrue);
|
|
331 |
TBool dropped = ETrue;
|
|
332 |
TBool missing = EFalse;
|
|
333 |
|
|
334 |
for (TInt i = 0; i < aNum; i++)
|
|
335 |
{
|
|
336 |
if (i>=aNumberDropped)
|
|
337 |
{
|
|
338 |
DropNextTrace(EFalse); //stop dropping traces
|
|
339 |
dropped = EFalse;
|
|
340 |
}
|
|
341 |
|
|
342 |
if ((i==aNumberDropped)&&(i!=0))
|
|
343 |
missing = ETrue;
|
|
344 |
else
|
|
345 |
missing = EFalse;
|
|
346 |
|
|
347 |
TInt size = 0;
|
|
348 |
|
|
349 |
//make request to read trace data from memory
|
|
350 |
TInt bufferedTraces=1;
|
|
351 |
if (aPrintfTrace&&missing&&!dropped) // if it's a printf trace and we're dropped traces
|
|
352 |
bufferedTraces++; // and the one we're currently sending isn't to be dropped
|
|
353 |
RequestDataNotification(status, bufferedTraces);
|
|
354 |
|
|
355 |
if (!aPrintfTrace)
|
|
356 |
OstTraceData(TRACE_NORMAL+i, traceword, "You will only see this text in Trace Viewer: %d", KTraceMultipartTestData,(aSize*4));
|
|
357 |
else
|
|
358 |
{
|
|
359 |
ActivatePrintfHandler(ETrue,BTrace::ERDebugPrintf);
|
|
360 |
RDebug::Printf(KTestPrintfTraceString);
|
|
361 |
ActivatePrintfHandler(EFalse,BTrace::ERDebugPrintf);
|
|
362 |
}
|
|
363 |
|
|
364 |
//read traces from memory
|
|
365 |
TEST_KErrNone(ReadTraceFromBuffer(status, buffer, size));
|
|
366 |
|
|
367 |
//Validate Traces
|
|
368 |
//test.Next(_L("Validate payload"));
|
|
369 |
TPtrC8 expectedPrintfData(KTestPrintfTraceLiteral);
|
|
370 |
TInt r = ValidatePayload((aTracePresent&&!dropped), TRACE_NORMAL+i, KOstTraceComponentID, missing, aPrintfTrace, &expectedPrintfData);
|
|
371 |
TEST_KErrNone(r);
|
|
372 |
traceword += (1 << GROUPIDSHIFT); //incrememnt the group id part of the trace word...
|
|
373 |
KOstTraceComponentID++;
|
|
374 |
}
|
|
375 |
|
|
376 |
return KErrNone;
|
|
377 |
}
|
|
378 |
|
|
379 |
/*
|
|
380 |
* Send a big (>80bytes)Test Trace
|
|
381 |
*
|
|
382 |
* @param aTracePresent indicates id a trace packet should be present or not
|
|
383 |
*/
|
|
384 |
void SendAndValidateBigTestTrace(TBool aTracePresent)
|
|
385 |
{
|
|
386 |
test.Printf(_L("In SendBigTestTrace()\n"));
|
|
387 |
KOstTraceComponentID = KTestComponentID1;
|
|
388 |
TRequestStatus status;
|
|
389 |
|
|
390 |
TUint8* buffer = NULL;
|
|
391 |
TInt size = 0;
|
|
392 |
|
|
393 |
//make request to read trace data from memory
|
|
394 |
RequestDataNotification(status);
|
|
395 |
|
|
396 |
OstTraceData(TRACE_NORMAL, TEST_TRACE, "You will only see this text in Trace Viewer", KTraceMultipartTestData,240);
|
|
397 |
TEST_KErrNone(ReadTraceFromBuffer(status, buffer, size));
|
|
398 |
|
|
399 |
//Validate Traces
|
|
400 |
test.Next(_L("Validate payload for test big trace"));
|
|
401 |
TEST_KErrNone(ValidatePayload(aTracePresent,TRACE_NORMAL,KOstTraceComponentID));
|
|
402 |
}
|
|
403 |
|
|
404 |
/*
|
|
405 |
* Test Trace Activation in Trace core
|
|
406 |
*
|
|
407 |
* @pre Trace Core settings must be cleared before trying to activate correct attributes
|
|
408 |
*/
|
|
409 |
void TestBasicActivation()
|
|
410 |
{
|
|
411 |
test.Printf(_L("In TestBasicActivation()\n"));
|
|
412 |
|
|
413 |
//Send Activation
|
|
414 |
test.Next(_L("Send Activation message to TraceCore"));
|
|
415 |
ActivateTrace(ETrue);
|
|
416 |
|
|
417 |
//Send and Validate Traces
|
|
418 |
TEST_KErrNone(SendAndValidateTestTraces(ETrue));
|
|
419 |
|
|
420 |
//Deactivate when done sending trace
|
|
421 |
DeactivateTrace(ETrue);
|
|
422 |
}
|
|
423 |
|
|
424 |
/*
|
|
425 |
* Test Trace Deactivation in Trace core
|
|
426 |
*
|
|
427 |
*/
|
|
428 |
void TestBasicDeactivation()
|
|
429 |
{
|
|
430 |
test.Printf(_L("In TestBasicDeactivation()\n"));
|
|
431 |
|
|
432 |
//Have correct trace attributes activated, then try to deactivate them
|
|
433 |
ActivateTrace(ETrue);
|
|
434 |
|
|
435 |
//Send Deactivation
|
|
436 |
test.Next(_L("Send Deactivation message to TraceCore"));
|
|
437 |
DeactivateTrace(ETrue);
|
|
438 |
|
|
439 |
//Send and Validate Traces
|
|
440 |
TEST_KErrNone(SendAndValidateTestTraces(EFalse));
|
|
441 |
}
|
|
442 |
|
|
443 |
/*
|
|
444 |
* Negative Test Trace Activation in Trace core
|
|
445 |
*
|
|
446 |
* @pre Trace Core settings must be cleared before trying to activate wrong attributes
|
|
447 |
*/
|
|
448 |
void NegativeTestActivation()
|
|
449 |
{
|
|
450 |
test.Printf(_L("In NegativeTestActivation()\n"));
|
|
451 |
|
|
452 |
//Send Activation
|
|
453 |
test.Next(_L("Send Negative Activation message to TraceCore"));
|
|
454 |
ActivateTrace(EFalse);
|
|
455 |
|
|
456 |
//Send and Validate Traces
|
|
457 |
TEST_KErrNone(SendAndValidateTestTraces(EFalse));
|
|
458 |
|
|
459 |
//Deactivate when done sending trace
|
|
460 |
DeactivateTrace(EFalse);
|
|
461 |
}
|
|
462 |
|
|
463 |
/*
|
|
464 |
* Test Trace Deactivation in Trace core
|
|
465 |
*
|
|
466 |
*/
|
|
467 |
void NegativeTestDeactivation()
|
|
468 |
{
|
|
469 |
test.Printf(_L("In NegativeTestDeactivation()\n"));
|
|
470 |
|
|
471 |
//Have correct trace attributes activated, then try to deactivate the wrong ones
|
|
472 |
ActivateTrace(ETrue);
|
|
473 |
|
|
474 |
//Send Deactivation
|
|
475 |
test.Next(_L("Send Negative Deactivation message to TraceCore"));
|
|
476 |
DeactivateTrace(EFalse);
|
|
477 |
|
|
478 |
//Send and Validate Traces
|
|
479 |
TEST_KErrNone(SendAndValidateTestTraces(ETrue));
|
|
480 |
|
|
481 |
//Deactivate when done sending trace
|
|
482 |
DeactivateTrace(ETrue);
|
|
483 |
}
|
|
484 |
|
|
485 |
/*
|
|
486 |
* Test Trace Activation in Trace core when multiple (16 here) GID and CID pairs are activated
|
|
487 |
*
|
|
488 |
* @pre Trace Core settings must be cleared before trying to activate correct attributes
|
|
489 |
*/
|
|
490 |
void TestMultipleActivation()
|
|
491 |
{
|
|
492 |
test.Printf(_L("In TestMultipleActivation()\n"));
|
|
493 |
|
|
494 |
//Send Activation
|
|
495 |
test.Next(_L("Send Activation message to TraceCore"));
|
|
496 |
ActivateTrace(ETrue, 16);
|
|
497 |
|
|
498 |
//Send and Validate Traces
|
|
499 |
TEST_KErrNone(SendAndValidateTestTraces(ETrue,1,16));
|
|
500 |
|
|
501 |
//Deactivate when done sending trace
|
|
502 |
DeactivateTrace(ETrue, 16);
|
|
503 |
}
|
|
504 |
|
|
505 |
/*
|
|
506 |
* Test Trace Deactivation in Trace core when multiple (64 here) GID and CID pairs are activated
|
|
507 |
*
|
|
508 |
* @pre Trace Core settings must be cleared before trying to activate correct attributes
|
|
509 |
*/
|
|
510 |
void TestMultipleDeactivation()
|
|
511 |
{
|
|
512 |
test.Printf(_L("In TestMultipleDeactivation()\n"));
|
|
513 |
|
|
514 |
//Have correct trace attributes activated, then try to deactivate them
|
|
515 |
ActivateTrace(ETrue, 16);
|
|
516 |
|
|
517 |
//Send Deactivation
|
|
518 |
test.Next(_L("Send Deactivation message to TraceCore"));
|
|
519 |
DeactivateTrace(ETrue, 16);
|
|
520 |
|
|
521 |
//Send Traces
|
|
522 |
TEST_KErrNone(SendAndValidateTestTraces(EFalse,1,16));
|
|
523 |
}
|
|
524 |
|
|
525 |
/*
|
|
526 |
* Test Trace Activation when big traces are sent
|
|
527 |
*
|
|
528 |
*/
|
|
529 |
void TestBigTrace()
|
|
530 |
{
|
|
531 |
test.Printf(_L("In TestBigTrace()\n"));
|
|
532 |
|
|
533 |
//Send Activation
|
|
534 |
test.Next(_L("Send Activation message to TraceCore"));
|
|
535 |
ActivateTrace(ETrue);
|
|
536 |
|
|
537 |
//Send and Validate Big Trace
|
|
538 |
SendAndValidateBigTestTrace(ETrue);
|
|
539 |
|
|
540 |
//Deactivate when done sending trace
|
|
541 |
DeactivateTrace(ETrue);
|
|
542 |
|
|
543 |
}
|
|
544 |
|
|
545 |
/*
|
|
546 |
* Test that TraceCore Handlers ouput missing data notification when traces are dropped
|
|
547 |
*/
|
|
548 |
void TestDroppedTraces()
|
|
549 |
{
|
|
550 |
test.Printf(_L("In TestDroppedTraces()\n"));
|
|
551 |
|
|
552 |
//Send Activation
|
|
553 |
test.Next(_L("Send Activation message to TraceCore"));
|
|
554 |
ActivateTrace(ETrue, 5);
|
|
555 |
|
|
556 |
//Send and Validate 5 Traces when no traces are dropped
|
|
557 |
TEST_KErrNone(SendAndValidateTestTraces(ETrue,1,5,EFalse,0));
|
|
558 |
|
|
559 |
//Send and Validate 5 Traces where 1st 2 traces are dropped (check for missing flag on 3rd)
|
|
560 |
TEST_KErrNone(SendAndValidateTestTraces(ETrue,1,5,EFalse,2));
|
|
561 |
|
|
562 |
//Send and Validate 1 Printf Trace where no traces are dropped
|
|
563 |
TEST_KErrNone(SendAndValidateTestTraces(ETrue,1,5,ETrue,0));
|
|
564 |
|
|
565 |
//Send and Validate 2 Printf Trace where 1st trace is dropped
|
|
566 |
TEST_KErrNone(SendAndValidateTestTraces(ETrue,1,2,ETrue,1));//(check for "dropped trace" on 2nd)
|
|
567 |
|
|
568 |
//Send and Validate 7 Printf Trace where 1st 5 traces are dropped
|
|
569 |
TEST_KErrNone(SendAndValidateTestTraces(ETrue,1,7,ETrue,5));//(check for "dropped trace" on 6th)
|
|
570 |
|
|
571 |
//Deactivate when done sending traces
|
|
572 |
DeactivateTrace(ETrue, 5);
|
|
573 |
}
|
|
574 |
|
|
575 |
/*
|
|
576 |
* Test that when activation notification is received, the group is actually activated from TraceCore
|
|
577 |
*/
|
|
578 |
void TestActivationNotification()
|
|
579 |
{
|
|
580 |
test.Printf(_L("In TestActivationNotification()\n"));
|
|
581 |
|
|
582 |
// Create activation parameters
|
|
583 |
TcDriverParameters p; p.iComponentId = 5; p.iGroupId = 7;
|
|
584 |
TcDriverParameters p2; p2.iComponentId = 6; p2.iGroupId = 8;
|
|
585 |
|
|
586 |
// Register activation notification listener
|
|
587 |
TraceTest.RegisterActivationNotification(p, ETrue);
|
|
588 |
|
|
589 |
// Activate and test that we receive notification and it's in sync with TraceCore
|
|
590 |
for (TInt i=0;i<5;i++)
|
|
591 |
{
|
|
592 |
TraceTest.ActivateTrace(p);
|
|
593 |
TEST_KErrNone(TraceTest.CheckActivationNotificationOk(ETrue));
|
|
594 |
TraceTest.DeactivateTrace(p);
|
|
595 |
TEST_KErrNone(TraceTest.CheckActivationNotificationOk(ETrue));
|
|
596 |
}
|
|
597 |
|
|
598 |
// Activate with different ID's, we shouldn't get notification
|
|
599 |
TraceTest.ActivateTrace(p2);
|
|
600 |
TEST_KErrNone(TraceTest.CheckActivationNotificationOk(EFalse));
|
|
601 |
|
|
602 |
// Unregister activation notification listener
|
|
603 |
TraceTest.RegisterActivationNotification(p, EFalse);
|
|
604 |
}
|
|
605 |
|
|
606 |
/*
|
|
607 |
* Test RefreshActivations() method for kernel GIDs
|
|
608 |
*
|
|
609 |
* The purpose of this test is to make sure TraceCore can refresh all activations with no error when
|
|
610 |
* different numbers of kernel GIDs have been activated
|
|
611 |
*/
|
|
612 |
void TestRefreshActivations()
|
|
613 |
{
|
|
614 |
test.Printf(_L("In TestRefreshActivations()\n"));
|
|
615 |
|
|
616 |
test.Next(_L("Test RefreshActivations() when all kernel GIDs are deactivated\n"));
|
|
617 |
|
|
618 |
//Deactivate all kernel GIDs
|
|
619 |
ActivateKernelTraces(EFalse);
|
|
620 |
|
|
621 |
//deactivate and reactivate all active GIDs
|
|
622 |
TEST_KErrNone(TraceTest.RefreshActivations());
|
|
623 |
|
|
624 |
test.Next(_L("Test RefreshActivations() when all some kernel GIDs are activated\n"));
|
|
625 |
|
|
626 |
//Activate some kernel GIDs
|
|
627 |
ActivateKernelTraces(ETrue,BTrace::EThreadIdentification);
|
|
628 |
ActivateKernelTraces(ETrue,BTrace::EPaging);
|
|
629 |
ActivateKernelTraces(ETrue,BTrace::EClientServer);
|
|
630 |
|
|
631 |
//deactivate and reactivate all active GIDs
|
|
632 |
TEST_KErrNone(TraceTest.RefreshActivations());
|
|
633 |
|
|
634 |
//Deactivate the kernel GIDs previously activated
|
|
635 |
ActivateKernelTraces(EFalse,BTrace::EThreadIdentification);
|
|
636 |
ActivateKernelTraces(EFalse,BTrace::EPaging);
|
|
637 |
ActivateKernelTraces(EFalse,BTrace::EClientServer);
|
|
638 |
|
|
639 |
test.Next(_L("Test RefreshActivations() when all kernel GIDs are activated\n"));
|
|
640 |
|
|
641 |
//Activate all kernel GIDs
|
|
642 |
ActivateKernelTraces(ETrue);
|
|
643 |
|
|
644 |
//deactivate and reactivate all active GIDs
|
|
645 |
TEST_KErrNone(TraceTest.RefreshActivations());
|
|
646 |
|
|
647 |
//Deactivate all kernel GIDs
|
|
648 |
ActivateKernelTraces(EFalse);
|
|
649 |
}
|
|
650 |
|
|
651 |
/*
|
|
652 |
* Utility function for generating a trace packet
|
|
653 |
* until the test memory writer is available
|
|
654 |
*
|
|
655 |
*/
|
|
656 |
void GenerateTraceData()
|
|
657 |
{
|
|
658 |
|
|
659 |
//actual data that will be sent in trace tests
|
|
660 |
for (TInt i = 0; i < 60; i++)
|
|
661 |
KTraceMultipartTestData[i] = KTestData + i;
|
|
662 |
}
|
|
663 |
|
|
664 |
GLDEF_C TInt E32Main()
|
|
665 |
{
|
|
666 |
|
|
667 |
test.Title();
|
|
668 |
|
|
669 |
test.Start(_L("Trace Core tests"));
|
|
670 |
|
|
671 |
GenerateTraceData();
|
|
672 |
|
|
673 |
// free the tcore related LDD's this is because
|
|
674 |
// if one of the other tests say t_tracecoreostldd
|
|
675 |
// panics the LDDs will not be released
|
|
676 |
User::FreeLogicalDevice(_L("TraceCoreOstLdd"));
|
|
677 |
User::FreeLogicalDevice(_L("TcLdd"));
|
|
678 |
|
|
679 |
TInt r = KErrNone;
|
|
680 |
|
|
681 |
|
|
682 |
test.Next(_L("Open test LDD"));
|
|
683 |
r = User::LoadLogicalDevice(RTraceCoreTest::Name());
|
|
684 |
TEST(r==KErrNone || r==KErrAlreadyExists);
|
|
685 |
r = TraceTest.Open();
|
|
686 |
TEST_KErrNone(r);
|
|
687 |
|
|
688 |
ValidateAllFiltersInSync();
|
|
689 |
|
|
690 |
ActivatePrintfHandler(EFalse);
|
|
691 |
|
|
692 |
test.Next(_L("Test Basic TraceCore Activation"));
|
|
693 |
TestBasicActivation();
|
|
694 |
test.Next(_L("Test Basic TraceCore Deactivation"));
|
|
695 |
TestBasicDeactivation();
|
|
696 |
test.Next(_L("Negative Test TraceCore Activation"));
|
|
697 |
NegativeTestActivation();
|
|
698 |
test.Next(_L("Negative Test TraceCore Deactivation"));
|
|
699 |
NegativeTestDeactivation();
|
|
700 |
test.Next(_L("Test Multiple TraceCore Activation"));
|
|
701 |
TestMultipleActivation();
|
|
702 |
test.Next(_L("Test Multiple TraceCore Deactivation"));
|
|
703 |
TestMultipleDeactivation();
|
|
704 |
test.Next(_L("Test Big Trace"));
|
|
705 |
TestBigTrace();
|
|
706 |
test.Next(_L("Test Dropped Traces"));
|
|
707 |
TestDroppedTraces();
|
|
708 |
test.Next(_L("Test Activation Notification"));
|
|
709 |
TestActivationNotification();
|
|
710 |
test.Next(_L("Test Refresh Activations"));
|
|
711 |
TestRefreshActivations();
|
|
712 |
|
|
713 |
|
|
714 |
ActivatePrintfHandler(ETrue);
|
|
715 |
|
|
716 |
ValidateAllFiltersInSync();
|
|
717 |
|
|
718 |
test.Next(_L("Close LDD"));
|
|
719 |
TraceTest.Close();
|
|
720 |
User::FreeLogicalDevice(RTraceCoreTest::Name());
|
|
721 |
|
|
722 |
|
|
723 |
|
|
724 |
test.Printf(_L("\nFinished Simple Activation/Deactivation tests in trace Core!!!"));
|
|
725 |
//test.Getch();
|
|
726 |
test.End();
|
|
727 |
test.Close();
|
|
728 |
return (0);
|
|
729 |
}
|