author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 14 May 2010 17:13:29 +0300 | |
changeset 109 | b3a1d9898418 |
parent 90 | 947f0dc9f7a8 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2005-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 |
// Kernel Performance Logger test |
|
15 |
// Uses helper LDD for performing actual logging from the kernel side. |
|
16 |
// See |
|
17 |
// |
|
18 |
// |
|
19 |
||
20 |
/** |
|
21 |
@file |
|
22 |
*/ |
|
23 |
||
24 |
||
25 |
#include <e32std.h> |
|
26 |
#include <e32std_private.h> |
|
27 |
#include <e32cons.h> |
|
28 |
#include <e32test.h> |
|
29 |
#include <e32math.h> |
|
30 |
||
31 |
||
32 |
#include "t_perflogger.h" |
|
33 |
#include "t_perflogger_drv.h" |
|
34 |
||
35 |
||
36 |
//------------------------------------------------------------------------------------- |
|
37 |
||
38 |
//-- logging subcategoty test tags |
|
39 |
const TUint8 KLogSubCat_UserThread = 0x11; |
|
40 |
const TUint8 KLogSubCat_KernelThread = 0x12; |
|
41 |
const TUint8 KLogSubCat_ISR = 0x13; |
|
42 |
const TUint8 KLogSubCat_IDFC = 0x14; |
|
43 |
||
44 |
||
45 |
//------------------------------------------------------------------------------------- |
|
46 |
||
47 |
RTest test(_L("T_PerfLogger")); |
|
48 |
TInt64 rndSeed; |
|
49 |
||
50 |
//------------------------------------------------------------------------------------- |
|
51 |
||
52 |
/** |
|
53 |
Print out the logging record. |
|
54 |
@param aTraceLayout unrolled trace record structure |
|
55 |
*/ |
|
56 |
void PrintTraceRecord(const TTraceLayout& aTraceLayout) |
|
57 |
{ |
|
58 |
TBuf<256> printBuf; |
|
59 |
||
60 |
printBuf.Format(_L("Record: Size:%d, Flags:0x%02x, Cat:%d, SubCat:%d "), aTraceLayout.iSize, aTraceLayout.iFlags, aTraceLayout.iCategory, aTraceLayout.iSubCategory); |
|
61 |
||
62 |
TUint flags = aTraceLayout.iFlags; |
|
63 |
||
64 |
if(flags&(BTrace::EHeader2Present)) |
|
65 |
printBuf.AppendFormat(_L("Header2:0x%08x "), aTraceLayout.iHeader2); |
|
66 |
||
67 |
if(flags & (BTrace::ETimestampPresent)) |
|
68 |
printBuf.AppendFormat(_L("Timestamp:0x%x "), aTraceLayout.iTimestamp); |
|
69 |
||
70 |
if(flags & (BTrace::ETimestamp2Present)) |
|
71 |
printBuf.AppendFormat(_L("Timestamp2:0x%x "), aTraceLayout.iTimestamp2); |
|
72 |
||
73 |
if(flags & (BTrace::EContextIdPresent)) |
|
74 |
printBuf.AppendFormat(_L("Context:0x%08x "), aTraceLayout.iContext); |
|
75 |
||
76 |
if(flags & (BTrace::EPcPresent)) |
|
77 |
printBuf.AppendFormat(_L("PC: 0x%08x "), aTraceLayout.iPC); |
|
78 |
||
79 |
if(flags & (BTrace::EExtraPresent)) |
|
80 |
printBuf.AppendFormat(_L("Extra: 0x%08x "), aTraceLayout.iExtra); |
|
81 |
||
82 |
printBuf.Append(_L("| ")); |
|
83 |
for(TInt i=0; i< aTraceLayout.iDataWords; ++i) |
|
84 |
{ |
|
85 |
printBuf.AppendFormat(_L(" 0x%08x"), aTraceLayout.ipData[i]); |
|
86 |
} |
|
87 |
||
88 |
printBuf.Append(_L("\n")); |
|
89 |
test.Printf(printBuf); |
|
90 |
||
91 |
} |
|
92 |
||
93 |
//------------------------------------------------------------------------------------- |
|
94 |
||
95 |
/** |
|
96 |
Get logging trace from the kernel trace engine and optionally check if it corresponds to the |
|
97 |
TTestLogCtrl structure fields. Actually, the logging trace in our case shall be the result of the |
|
98 |
test helper LDD worr, that in turn, is controlled by the data in TTestLogCtrl structure. |
|
99 |
||
100 |
@param aTrace ref. to the kernel trace engine LDD. |
|
101 |
@param apControlStruct if not NULL obtained trace fields checked against fields of this structure. |
|
102 |
||
103 |
*/ |
|
104 |
void GetParseRecordData(RBTrace& aTrace, const TTestLogCtrl* apControlStruct = NULL) |
|
105 |
{ |
|
106 |
TUint8* record; |
|
107 |
TTraceLayout traceLayout; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
108 |
TInt nRecords = 0; |
0 | 109 |
|
110 |
for(TInt i=0; ;++i) |
|
111 |
{ |
|
112 |
//-- get raw trace record |
|
113 |
TInt dataSize = aTrace.GetData(record); |
|
114 |
||
115 |
if(i != 0 && !dataSize) |
|
116 |
break; //-- no more data |
|
117 |
||
118 |
//-- check if we get log data at all at the very beginning |
|
119 |
if(i == 0 && !dataSize) |
|
120 |
{ |
|
121 |
if(!apControlStruct) |
|
122 |
{//-- it's ok, no check |
|
123 |
break; |
|
124 |
} |
|
125 |
else |
|
126 |
{//-- panic if there is no log data, but we are required to get some. |
|
127 |
if(apControlStruct->iLogsNum > 0) |
|
128 |
{ |
|
129 |
test.Printf(_L("GetParseRecordData() No trace data found!\n")); |
|
130 |
test(0); |
|
131 |
} |
|
132 |
} |
|
133 |
} |
|
134 |
||
135 |
||
136 |
TUint8* end = record+dataSize; |
|
137 |
TUint8* currPos = record; |
|
138 |
TUint nBytes = 0; |
|
139 |
||
140 |
//-- parser the record, print out fields and optionally check the correspondence to the fields of the control structure. |
|
141 |
for(; currPos<end; currPos+=nBytes) |
|
142 |
{ |
|
143 |
||
144 |
nBytes = ParseTraceRecord(currPos ,traceLayout); |
|
145 |
test(nBytes >0 ); |
|
146 |
||
147 |
//-- skip possible loggings that we didn't make |
|
148 |
if(traceLayout.iCategory != BTrace::EKernPerfLog) |
|
149 |
continue; |
|
150 |
||
151 |
++nRecords; |
|
152 |
||
153 |
//-- print the record out |
|
154 |
PrintTraceRecord(traceLayout); |
|
155 |
||
156 |
//-- check the obtained record structure |
|
157 |
if(apControlStruct) |
|
158 |
{ |
|
159 |
test(traceLayout.iCategory == apControlStruct->iCategory); |
|
160 |
test(traceLayout.iSubCategory == apControlStruct->iSubCategory); |
|
161 |
||
162 |
if(traceLayout.iDataWords > 1) //-- we have at least 1 word of user data (1 is for TickCount) |
|
163 |
test(traceLayout.ipData[0] == apControlStruct->iUserData); |
|
164 |
||
165 |
if(traceLayout.iDataWords > 2) //-- we have 2 words of user data (1 is for TickCount) |
|
166 |
test(traceLayout.ipData[1] == apControlStruct->iUserData2); |
|
167 |
||
168 |
} |
|
169 |
||
170 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
171 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
172 |
//-- release data buffer. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
173 |
aTrace.DataUsed(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
174 |
} |
0 | 175 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
176 |
//-- check number of trace records obtained |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
177 |
if(apControlStruct) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
178 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
179 |
test(nRecords == apControlStruct->iLogsNum); |
0 | 180 |
} |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
181 |
|
0 | 182 |
} |
183 |
||
184 |
||
185 |
//--------------------------------------------------------------------------------- |
|
186 |
||
187 |
/** |
|
188 |
Parse logging record, converting it from the raw representation to the unrolled data |
|
189 |
structure. |
|
190 |
||
191 |
@param apRecord points to the buffer with the raw trace record |
|
192 |
@param aTraceLayout here parsed record will bre returned |
|
193 |
||
194 |
@return sise of the record, bytes |
|
195 |
*/ |
|
196 |
TUint ParseTraceRecord(const TUint8* apRecord, TTraceLayout& aTraceLayout) |
|
197 |
{ |
|
198 |
aTraceLayout.iSize = apRecord[BTrace::ESizeIndex]; |
|
199 |
aTraceLayout.iFlags = apRecord[BTrace::EFlagsIndex]; |
|
200 |
aTraceLayout.iCategory = apRecord[BTrace::ECategoryIndex]; |
|
201 |
aTraceLayout.iSubCategory = apRecord[BTrace::ESubCategoryIndex]; |
|
202 |
||
203 |
const TUint flags= aTraceLayout.iFlags; |
|
204 |
TInt size = aTraceLayout.iSize; |
|
205 |
const TUint32* pData = (const TUint32*)(apRecord+4); |
|
206 |
||
207 |
size -= 4; //-- count header |
|
208 |
||
209 |
//-- process header flags and appropriate fields of the record |
|
210 |
if(flags&(BTrace::EHeader2Present)) |
|
211 |
{ |
|
212 |
aTraceLayout.iHeader2 = *pData++; |
|
213 |
size -= sizeof(TUint32); |
|
214 |
test(size >= 0); |
|
215 |
} |
|
216 |
||
217 |
if(flags & (BTrace::ETimestampPresent)) |
|
218 |
{ |
|
219 |
aTraceLayout.iTimestamp = *pData++; |
|
220 |
size -= sizeof(TUint32); |
|
221 |
test(size >= 0); |
|
222 |
} |
|
223 |
||
224 |
if(flags & (BTrace::ETimestamp2Present)) |
|
225 |
{ |
|
226 |
aTraceLayout.iTimestamp2 = *pData++; |
|
227 |
size -= sizeof(TUint32); |
|
228 |
test(size >= 0); |
|
229 |
} |
|
230 |
||
231 |
if(flags & (BTrace::EContextIdPresent)) |
|
232 |
{ |
|
233 |
aTraceLayout.iContext = *pData++; |
|
234 |
size -= sizeof(TUint32); |
|
235 |
test(size >= 0); |
|
236 |
} |
|
237 |
||
238 |
if(flags & (BTrace::EPcPresent)) |
|
239 |
{ |
|
240 |
aTraceLayout.iPC = *pData++; |
|
241 |
size -= sizeof(TUint32); |
|
242 |
test(size >= 0); |
|
243 |
} |
|
244 |
||
245 |
if(flags & (BTrace::EExtraPresent)) |
|
246 |
{ |
|
247 |
aTraceLayout.iExtra = *pData++; |
|
248 |
size -= sizeof(TUint32); |
|
249 |
test(size >= 0); |
|
250 |
} |
|
251 |
||
252 |
//-- process user data if present |
|
253 |
test(size >= 0); |
|
254 |
test(size % sizeof(TUint32) == 0); |
|
255 |
||
256 |
aTraceLayout.iDataWords = size / sizeof(TUint32); |
|
257 |
aTraceLayout.ipData = (aTraceLayout.iDataWords!=0) ? pData : NULL; |
|
258 |
||
259 |
return aTraceLayout.iSize; |
|
260 |
} |
|
261 |
||
262 |
//--------------------------------------------------------------------------------- |
|
263 |
//! @SYMTestCaseID KBASE-T_PERFLOGGER-0055 |
|
264 |
//! @SYMTestType UT |
|
265 |
//! @SYMPREQ PREQ1030 |
|
266 |
//! @SYMTestCaseDesc Tests logging from different contexts: user thread, ISR, Kernel thread and IDFC. |
|
267 |
//! The main functionality is performed by test heller LDD, "d_perflogger_test" that acually calls the logging function from different contexts |
|
268 |
//! following the commands from user application. |
|
269 |
//! |
|
270 |
//! @SYMTestActions 0 setup the data structures that specify the logging parameters. |
|
271 |
//! 1 call RKPLoggerTestHelper::MakeLogFromUserThread() this is a synchronous operation. Performs logging from the user thread context. |
|
272 |
//! 1.1 Parse the log record data and ensure that the logged information matches the data we passed to the helper LDD. |
|
273 |
//! |
|
274 |
//! 2 call RKPLoggerTestHelper::MakeLogFromISR() this is asynchronous operation. Performs logging from the ISR context. |
|
275 |
//! 2.1 Wait for operation to complete, validate the completion status. |
|
276 |
//! 2.2 Parse the log record data and ensure that the logged information matches the data we passed to the helper LDD. |
|
277 |
//! |
|
278 |
//! |
|
279 |
//! 3 call RKPLoggerTestHelper::MakeLogFromDFC() this is asynchronous operation. Performs logging from the Kernel thread context (DFC). |
|
280 |
//! 3.1 Wait for operation to complete, validate the completion status. |
|
281 |
//! 3.2 Parse the log record data and ensure that the logged information matches the data we passed to the helper LDD. |
|
282 |
//! |
|
283 |
//! 4 call RKPLoggerTestHelper::MakeLogFromIDFC() this is asynchronous operation. Performs logging from the IDFC. |
|
284 |
//! 4.1 Wait for operation to complete, validate the completion status. |
|
285 |
//! 4.2 Parse the log record data and ensure that the logged information matches the data we passed to the helper LDD. |
|
286 |
//! |
|
287 |
//! 5. Make scattered overlapped logging from ISR, DFC & IDFC simultaneously, ensure that this work. |
|
288 |
//! |
|
289 |
//! @SYMTestExpectedResults return if the performace logger behaves as expected, panic otherwise |
|
290 |
//! @SYMTestPriority High |
|
291 |
//! @SYMTestStatus Implemented |
|
292 |
//--------------------------------------------------------------------------------- |
|
293 |
void TestPerfLogger(RBTrace &aTrace) |
|
294 |
{ |
|
295 |
TInt nRes; |
|
296 |
||
297 |
const TUint32 KLogUserData = 0xBAAABEEF; //-- just for testing |
|
298 |
const TUint32 KLogUserData2 = 0x11FFDDCC; //-- just for testing |
|
299 |
||
300 |
||
301 |
test.Next(_L("testing kernel performance logger functionality\n")); |
|
302 |
||
303 |
RKPLoggerTestHelper testHelperLDD; //-- helper test driver |
|
304 |
CleanupClosePushL(testHelperLDD); |
|
305 |
||
306 |
nRes = testHelperLDD.Open(TVersion(1,0,1)); //-- open test helper ldd for a logger |
|
307 |
test(nRes == KErrNone); |
|
308 |
||
309 |
//--- |
|
310 |
TTestLogCtrl logCtrl_UserThread; |
|
311 |
TTestLogCtrl logCtrl_ISR; |
|
312 |
TTestLogCtrl logCtrl_DFC; |
|
313 |
TTestLogCtrl logCtrl_IDFC; |
|
314 |
||
315 |
||
316 |
TRequestStatus rqStatLogFromISR; |
|
317 |
TRequestStatus rqStatLogFromDFC; |
|
318 |
TRequestStatus rqStatLogFromIDFC; |
|
319 |
||
320 |
||
321 |
//-- setup log control structures |
|
322 |
logCtrl_UserThread.iLogsNum = 3; |
|
323 |
logCtrl_UserThread.iCategory = BTrace::EKernPerfLog; |
|
324 |
logCtrl_UserThread.iSubCategory = KLogSubCat_UserThread; |
|
325 |
logCtrl_UserThread.iUserData = KLogUserData; |
|
326 |
logCtrl_UserThread.iUserData2 = KLogUserData2; |
|
327 |
||
328 |
||
329 |
logCtrl_ISR.iLogsNum = 3; |
|
330 |
logCtrl_ISR.iCategory = BTrace::EKernPerfLog; |
|
331 |
logCtrl_ISR.iSubCategory = KLogSubCat_ISR; |
|
332 |
logCtrl_ISR.iUserData = KLogUserData; |
|
333 |
logCtrl_ISR.iUserData2 = KLogUserData2; |
|
334 |
||
335 |
||
336 |
logCtrl_DFC.iLogsNum = 3; |
|
337 |
logCtrl_DFC.iCategory = BTrace::EKernPerfLog; |
|
338 |
logCtrl_DFC.iSubCategory = KLogSubCat_KernelThread; |
|
339 |
logCtrl_DFC.iUserData = KLogUserData; |
|
340 |
logCtrl_DFC.iUserData2 = KLogUserData2; |
|
341 |
||
342 |
||
343 |
logCtrl_IDFC.iLogsNum = 3; |
|
344 |
logCtrl_IDFC.iCategory = BTrace::EKernPerfLog; |
|
345 |
logCtrl_IDFC.iSubCategory = KLogSubCat_IDFC; |
|
346 |
logCtrl_IDFC.iUserData = KLogUserData; |
|
347 |
logCtrl_IDFC.iUserData2 = KLogUserData2; |
|
348 |
||
349 |
||
350 |
||
351 |
test.Printf(_L("Testing logging from user thread\n")); |
|
352 |
//============================================================ |
|
353 |
//-- 1. make logging from user thread, this is a synchronous operation |
|
354 |
nRes = testHelperLDD.MakeLogFromUserThread(logCtrl_UserThread); |
|
355 |
test(nRes == KErrNone); |
|
356 |
||
357 |
//-- 1.1 check the results |
|
358 |
GetParseRecordData(aTrace, &logCtrl_UserThread); |
|
359 |
||
360 |
||
361 |
test.Printf(_L("Testing logging from ISR\n")); |
|
362 |
//============================================================ |
|
363 |
//-- 2. make logging from ISR, this is asynchronous operation |
|
364 |
testHelperLDD.MakeLogFromISR(rqStatLogFromISR, logCtrl_ISR); |
|
365 |
User::WaitForRequest(rqStatLogFromISR); |
|
366 |
test(rqStatLogFromISR.Int() == KErrNone); |
|
367 |
||
368 |
//-- 2.1 check the results |
|
369 |
GetParseRecordData(aTrace, &logCtrl_ISR); |
|
370 |
||
371 |
test.Printf(_L("Testing logging from DFC\n")); |
|
372 |
//============================================================ |
|
373 |
//-- 3. make logging from DFC kennel thread, this is asynchronous operation |
|
374 |
testHelperLDD.MakeLogFromDFC(rqStatLogFromDFC, logCtrl_DFC); |
|
375 |
User::WaitForRequest(rqStatLogFromDFC); |
|
376 |
test(rqStatLogFromDFC.Int() == KErrNone); |
|
377 |
||
378 |
//-- 3.1 check the results |
|
379 |
GetParseRecordData(aTrace, &logCtrl_DFC); |
|
380 |
||
381 |
test.Printf(_L("Testing logging from IDFC\n")); |
|
382 |
//============================================================ |
|
383 |
//-- 4. make logging from IDFC, this is asynchronous operation |
|
384 |
testHelperLDD.MakeLogFromIDFC(rqStatLogFromIDFC, logCtrl_IDFC); |
|
385 |
User::WaitForRequest(rqStatLogFromIDFC); |
|
386 |
test(rqStatLogFromIDFC.Int() == KErrNone); |
|
387 |
||
388 |
//-- 4.1 check the results |
|
389 |
GetParseRecordData(aTrace, &logCtrl_IDFC); |
|
390 |
||
391 |
||
392 |
test.Printf(_L("Testing overlapped logging from ISR, DFC & IDFC\n")); |
|
393 |
//============================================================ |
|
394 |
//-- 5. make logging from ISR, DFC and IDFC simultaneously |
|
395 |
||
396 |
//-- use random numbers for number and period of loggings |
|
397 |
logCtrl_ISR.iLogsNum = URnd(16)+1; |
|
398 |
logCtrl_ISR.iLogPeriodTick = URnd(20)+1; |
|
399 |
||
400 |
logCtrl_DFC.iLogsNum = URnd(16)+1; |
|
401 |
logCtrl_DFC.iLogPeriodTick = URnd(20)+1; |
|
402 |
||
403 |
logCtrl_IDFC.iLogsNum = URnd(16)+1; |
|
404 |
logCtrl_IDFC.iLogPeriodTick = URnd(20)+1; |
|
405 |
||
406 |
//-- start logging |
|
407 |
testHelperLDD.MakeLogFromISR(rqStatLogFromISR, logCtrl_ISR); |
|
408 |
testHelperLDD.MakeLogFromDFC(rqStatLogFromDFC, logCtrl_DFC); |
|
409 |
testHelperLDD.MakeLogFromIDFC(rqStatLogFromIDFC, logCtrl_IDFC); |
|
410 |
||
411 |
//-- wait for logging to finish |
|
412 |
User::WaitForRequest(rqStatLogFromISR); |
|
413 |
User::WaitForRequest(rqStatLogFromDFC); |
|
414 |
User::WaitForRequest(rqStatLogFromIDFC); |
|
415 |
||
416 |
GetParseRecordData(aTrace); |
|
417 |
||
418 |
||
419 |
CleanupStack::PopAndDestroy(1); //-- testHelperLDD |
|
420 |
||
421 |
} |
|
422 |
||
423 |
||
424 |
//--------------------------------------------------------------------------------- |
|
425 |
//! @SYMTestCaseID KBASE-T_PERFLOGGER-0056 |
|
426 |
//! @SYMTestType UT |
|
427 |
//! @SYMPREQ PREQ1030 |
|
428 |
//! @SYMTestCaseDesc Test of PERF_LOG0, PERF_LOG1, PERF_LOG macros performed by helper LDD |
|
429 |
//! @SYMTestActions Calls helper LDD API that in turn implies using PERF_LOG0, PERF_LOG1, PERF_LOG macros by helper LDD |
|
430 |
//! @SYMTestExpectedResults return if the performace logger behaves as expected, panic otherwise |
|
431 |
//! @SYMTestPriority High |
|
432 |
//! @SYMTestStatus Implemented |
|
433 |
//--------------------------------------------------------------------------------- |
|
434 |
void TestMacros(RBTrace &aTrace) |
|
435 |
{ |
|
436 |
TInt nRes; |
|
437 |
||
438 |
const TUint32 KLogUserData = 0xBAAABEEF; //-- just for testing |
|
439 |
const TUint32 KLogUserData2 = 0x11FFDDCC; //-- just for testing |
|
440 |
||
441 |
||
442 |
test.Next(_L("Unit test for different macros\n")); |
|
443 |
||
444 |
RKPLoggerTestHelper testHelperLDD; //-- helper test driver |
|
445 |
CleanupClosePushL(testHelperLDD); |
|
446 |
||
447 |
nRes = testHelperLDD.Open(TVersion(1,0,1)); //-- open test helper ldd for a logger |
|
448 |
test(nRes == KErrNone); |
|
449 |
||
450 |
//--- |
|
451 |
TTestLogCtrl logCtrl; |
|
452 |
||
453 |
//-- setup log control structures |
|
454 |
logCtrl.iLogsNum = 1; |
|
455 |
logCtrl.iCategory = BTrace::EKernPerfLog; |
|
456 |
logCtrl.iSubCategory = KLogSubCat_UserThread; |
|
457 |
logCtrl.iUserData = KLogUserData; |
|
458 |
logCtrl.iUserData2 = KLogUserData2; |
|
459 |
||
460 |
//-- make logging from user thread using different macros, PERF_LOG0, PERF_LOG1, PERF_LOG |
|
461 |
//-- see the helper driver |
|
462 |
nRes = testHelperLDD.TestDifferentMacros(logCtrl); |
|
463 |
test(nRes == KErrNone); |
|
464 |
||
465 |
//-- print out the results |
|
466 |
GetParseRecordData(aTrace); |
|
467 |
||
468 |
||
469 |
CleanupStack::PopAndDestroy(1); //-- testHelperLDD |
|
470 |
||
471 |
} |
|
472 |
||
473 |
//--------------------------------------------------------------------------------- |
|
474 |
void MainL(void) |
|
475 |
{ |
|
476 |
test.Start(_L("Kern Perf Logger tests")); |
|
477 |
Initialise(); |
|
478 |
||
479 |
||
480 |
RBTrace trace; |
|
481 |
TInt error = trace.Open(); |
|
482 |
test(error == KErrNone); |
|
483 |
||
484 |
trace.Empty(); |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
485 |
trace.SetFilter(BTrace::EThreadIdentification,0); |
0 | 486 |
|
487 |
||
488 |
||
489 |
//-- actually, for hardware platforms, the testing category and trace enabling |
|
490 |
//-- may be set up in appropriate "header.iby" file |
|
491 |
trace.SetMode(RBTrace::EEnable); |
|
492 |
trace.SetFilter(BTrace::EKernPerfLog, ETrue); |
|
493 |
||
494 |
//-- unit-test for PERF_LOG macros |
|
495 |
TestMacros(trace); |
|
496 |
||
497 |
//-- functionality test |
|
498 |
TestPerfLogger(trace); |
|
499 |
||
500 |
trace.Close(); |
|
501 |
||
502 |
Finalise(); |
|
503 |
test.End(); |
|
504 |
} |
|
505 |
||
506 |
||
507 |
//--------------------------------------------------------------------------------- |
|
508 |
//! @SYMTestCaseID KBASE-T_PERFLOGGER-0162 |
|
509 |
//! @SYMTestType UT |
|
510 |
//! @SYMPREQ PREQ1030 |
|
511 |
//! @SYMTestCaseDesc Load test helper LDD and check the result |
|
512 |
//! @SYMTestActions load specified LDD by calling User::LoadLogicalDevice() |
|
513 |
//! @SYMTestExpectedResults return if helper LDD is loaded OK, panic otherwise |
|
514 |
//! @SYMTestPriority High |
|
515 |
//! @SYMTestStatus Implemented |
|
516 |
//--------------------------------------------------------------------------------- |
|
517 |
void Initialise() |
|
518 |
{ |
|
519 |
rndSeed = Math::Random(); |
|
520 |
||
521 |
//-- load device drivers |
|
522 |
TInt nRes; |
|
523 |
||
524 |
test.Printf(_L("Loading test helper LDD...\n")); |
|
525 |
nRes = User::LoadLogicalDevice(KPLoggerHelperTestDrv); |
|
526 |
test(nRes == KErrNone || nRes == KErrAlreadyExists); |
|
527 |
} |
|
528 |
||
529 |
/** Finalise environment */ |
|
530 |
void Finalise(void) |
|
531 |
{ |
|
532 |
} |
|
533 |
||
534 |
||
535 |
||
536 |
/** |
|
537 |
Main |
|
538 |
*/ |
|
539 |
GLDEF_C TInt E32Main() |
|
540 |
{ |
|
541 |
CTrapCleanup* cleanup=CTrapCleanup::New() ; // get clean-up stack |
|
542 |
||
543 |
TRAPD(r,MainL()); |
|
544 |
||
545 |
delete cleanup ; // destroy clean-up stack |
|
546 |
||
547 |
return r; |
|
548 |
||
549 |
} |
|
550 |
||
551 |
//------------------------------------------------------------------------------------- |
|
552 |
||
553 |
TUint URnd(TUint aMin, TUint aMax) |
|
554 |
{ |
|
555 |
test(aMin < aMax); |
|
556 |
TUint uRes; |
|
557 |
||
558 |
do |
|
559 |
{ |
|
560 |
uRes = Math::Rand(rndSeed) % aMax; |
|
561 |
}while(uRes < aMin); |
|
562 |
||
563 |
return uRes; |
|
564 |
} |
|
565 |
||
566 |
TUint URnd(TUint aMax) |
|
567 |
{ |
|
568 |
return Math::Rand(rndSeed) % aMax; |
|
569 |
} |
|
570 |
||
571 |
||
572 |
||
573 |
||
574 |
||
575 |
||
576 |
||
577 |
||
578 |
||
579 |
||
580 |