|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include "VCXTestStatsKeeper.h" |
|
21 #include "VCXTestLog.h" |
|
22 #include <flogger.h> |
|
23 #include <mmf/common/mmfcontrollerpluginresolver.h> // CleanupResetAndDestroyPushL |
|
24 |
|
25 // CONSTANTS |
|
26 const TUint KMaxTraces = 20; |
|
27 |
|
28 // MACROS |
|
29 |
|
30 #ifndef __WINSCW__ |
|
31 |
|
32 _LIT( KVCXTestLogFolder, "Fusion" ); |
|
33 |
|
34 #define VCXTESTSTATS_W1(FILE,AAA) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::Write(KVCXTestLogFolder,FILE,EFileLoggingModeAppend,tempIPTVLogDes()); } while ( EFalse ) |
|
35 #define VCXTESTSTATS_W2(FILE,AAA,BBB) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KVCXTestLogFolder,FILE,EFileLoggingModeAppend,TRefByValue<const TDesC>(tempIPTVLogDes()),BBB); } while ( EFalse ) |
|
36 #define VCXTESTSTATS_W3(FILE,AAA,BBB,CCC) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KVCXTestLogFolder,FILE,EFileLoggingModeAppend,TRefByValue<const TDesC>(tempIPTVLogDes()),BBB,CCC); } while ( EFalse ) |
|
37 #define VCXTESTSTATS_W4(FILE,AAA,BBB,CCC,DDD) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KVCXTestLogFolder,FILE,EFileLoggingModeAppend,TRefByValue<const TDesC>(tempIPTVLogDes()),BBB,CCC,DDD); } while ( EFalse ) |
|
38 #define VCXTESTSTATS_W5(FILE,AAA,BBB,CCC,DDD,EEE) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KVCXTestLogFolder,FILE,EFileLoggingModeAppend,TRefByValue<const TDesC>(tempIPTVLogDes()),BBB,CCC,DDD,EEE); } while ( EFalse ) |
|
39 |
|
40 #else |
|
41 |
|
42 #define VCXTESTSTATS_W1(FILE,s) RDebug::Print(_L(#s)) |
|
43 #define VCXTESTSTATS_W2(FILE,s, a) RDebug::Print(_L(#s), a) |
|
44 #define VCXTESTSTATS_W3(FILE,s, a, b) RDebug::Print(_L(#s), a, b) |
|
45 #define VCXTESTSTATS_W4(FILE,s, a, b, c) RDebug::Print(_L(#s), a, b, c) |
|
46 #define VCXTESTSTATS_W5(FILE,s, a, b, c, d) RDebug::Print(_L(#s), a, b, c, d) |
|
47 |
|
48 #endif |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CVCXTestStatsItem::NewL |
|
52 // C++ default constructor can NOT contain any code, that |
|
53 // might leave. |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CVCXTestStatsItem* CVCXTestStatsItem::NewL() |
|
57 { |
|
58 CVCXTestStatsItem* self = new (ELeave)CVCXTestStatsItem(); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(); |
|
61 CleanupStack::Pop( self ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CVCXTestStatsItem::~CVCXTestStatsKeeper |
|
67 // destructor |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CVCXTestStatsItem::~CVCXTestStatsItem() |
|
71 { |
|
72 delete iDesc; |
|
73 iDesc = NULL; |
|
74 |
|
75 delete iDescId; |
|
76 iDescId = NULL; |
|
77 |
|
78 iTraces.ResetAndDestroy(); |
|
79 iProgresses.ResetAndDestroy(); |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CVCXTestStatsItem::CVCXTestStatsItem() |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 CVCXTestStatsItem::CVCXTestStatsItem() |
|
87 { |
|
88 |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CVCXTestStatsItem::ConstructL() |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 void CVCXTestStatsItem::ConstructL() |
|
96 { |
|
97 |
|
98 } |
|
99 |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CVCXTestStatsItemSummary::NewL |
|
103 // C++ default constructor can NOT contain any code, that |
|
104 // might leave. |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 CVCXTestStatsItemSummary* CVCXTestStatsItemSummary::NewL() |
|
108 { |
|
109 CVCXTestStatsItemSummary* self = new (ELeave)CVCXTestStatsItemSummary(); |
|
110 CleanupStack::PushL( self ); |
|
111 self->ConstructL(); |
|
112 CleanupStack::Pop( self ); |
|
113 return self; |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CVCXTestStatsItemSummary::~CVCXTestStatsKeeper |
|
118 // destructor |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 CVCXTestStatsItemSummary::~CVCXTestStatsItemSummary() |
|
122 { |
|
123 delete iDesc; |
|
124 iDesc = NULL; |
|
125 |
|
126 delete iDescId; |
|
127 iDescId = NULL; |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CVCXTestStatsItemSummary::CVCXTestStatsItemSummary() |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 CVCXTestStatsItemSummary::CVCXTestStatsItemSummary() |
|
135 { |
|
136 |
|
137 } |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 // CVCXTestStatsItemSummary::ConstructL() |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 void CVCXTestStatsItemSummary::ConstructL() |
|
144 { |
|
145 |
|
146 } |
|
147 |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CVCXTestStatsKeeper::NewL |
|
151 // C++ default constructor can NOT contain any code, that |
|
152 // might leave. |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 EXPORT_C CVCXTestStatsKeeper* CVCXTestStatsKeeper::NewL() |
|
156 { |
|
157 CVCXTestStatsKeeper* self = new (ELeave)CVCXTestStatsKeeper(); |
|
158 CleanupStack::PushL( self ); |
|
159 self->ConstructL(); |
|
160 CleanupStack::Pop( self ); |
|
161 return self; |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CVCXTestStatsKeeper::~CVCXTestStatsKeeper |
|
166 // destructor |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 CVCXTestStatsKeeper::~CVCXTestStatsKeeper () |
|
170 { |
|
171 if( iStarted ) |
|
172 { |
|
173 GenerateReportL( _L("FusionStats.txt"), EFalse ); |
|
174 GenerateReportL( _L("FusionStatsFull.txt"), ETrue ); |
|
175 } |
|
176 |
|
177 delete iReportName; |
|
178 iReportName = NULL; |
|
179 |
|
180 delete iReportFileName; |
|
181 iReportFileName = NULL; |
|
182 |
|
183 iActions.ResetAndDestroy(); |
|
184 iTraces.ResetAndDestroy(); |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CVCXTestStatsKeeper::CVCXTestStatsKeeper |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 CVCXTestStatsKeeper::CVCXTestStatsKeeper() |
|
192 { |
|
193 |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CVCXTestStatsKeeper::ConstructL |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 void CVCXTestStatsKeeper::ConstructL() |
|
201 { |
|
202 |
|
203 } |
|
204 |
|
205 // ----------------------------------------------------------------------------- |
|
206 // CVCXTestStatsKeeper::StartStatsKeepingL |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 EXPORT_C void CVCXTestStatsKeeper::StartStatsKeepingL( const TDesC& aName, const TDesC& aFileName ) |
|
210 { |
|
211 iStarted = ETrue; |
|
212 iReportName = aName.AllocL(); |
|
213 iReportFileName = aFileName.AllocL(); |
|
214 } |
|
215 |
|
216 // ----------------------------------------------------------------------------- |
|
217 // CVCXTestStatsKeeper::ActionStartL |
|
218 // ----------------------------------------------------------------------------- |
|
219 // |
|
220 EXPORT_C void CVCXTestStatsKeeper::ActionStartL( TInt32 aId, const TDesC& aDesc ) |
|
221 { |
|
222 VCXLOGLO3(">>>CVCXTestStatsKeeper::ActionStartL: %d = %S ------>", aId, &aDesc); |
|
223 if( !iStarted ) |
|
224 { |
|
225 return; |
|
226 } |
|
227 |
|
228 CVCXTestStatsItem* item = CVCXTestStatsItem::NewL(); |
|
229 item->iId = aId; |
|
230 item->iDesc = aDesc.AllocL(); |
|
231 item->iStartTime.HomeTime(); |
|
232 item->iIsActive = ETrue; |
|
233 |
|
234 iActions.AppendL( item ); |
|
235 VCXLOGLO1("<<<CVCXTestStatsKeeper::ActionStartL"); |
|
236 } |
|
237 |
|
238 // ----------------------------------------------------------------------------- |
|
239 // CVCXTestStatsKeeper::ActionStartL |
|
240 // ----------------------------------------------------------------------------- |
|
241 // |
|
242 EXPORT_C void CVCXTestStatsKeeper::ActionStartL( const TDesC& aDescId, const TDesC& aDesc, TBool aDescMerge ) |
|
243 { |
|
244 VCXLOGLO3(">>>CVCXTestStatsKeeper::ActionStartL %S = %S ------>", &aDescId, &aDesc); |
|
245 if( !iStarted ) |
|
246 { |
|
247 return; |
|
248 } |
|
249 |
|
250 CVCXTestStatsItem* item = CVCXTestStatsItem::NewL(); |
|
251 item->iDescId = aDescId.AllocL(); |
|
252 if( aDescMerge ) |
|
253 { |
|
254 item->iDesc = HBufC::NewL( aDesc.Length() + aDescId.Length() ); |
|
255 item->iDesc->Des().Append( aDesc ); |
|
256 item->iDesc->Des().Append( aDescId ); |
|
257 } |
|
258 else |
|
259 { |
|
260 item->iDesc = aDesc.AllocL(); |
|
261 } |
|
262 item->iStartTime.HomeTime(); |
|
263 item->iIsActive = ETrue; |
|
264 |
|
265 iActions.AppendL( item ); |
|
266 VCXLOGLO1("<<<CVCXTestStatsKeeper::ActionStartL (desc)"); |
|
267 } |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // CVCXTestStatsKeeper::ActionEndL |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 EXPORT_C void CVCXTestStatsKeeper::ActionEndL( TInt32 aId, TInt aError ) |
|
274 { |
|
275 VCXLOGLO3(">>>CVCXTestStatsKeeper::ActionEndL: %d, err: %d ------>", aId, aError); |
|
276 if( !iStarted ) |
|
277 { |
|
278 return; |
|
279 } |
|
280 |
|
281 CVCXTestStatsItem* item = GetActiveAction( aId ); |
|
282 |
|
283 if( !item ) |
|
284 { |
|
285 VCXLOGLO1("CVCXTestStatsKeeper:: No active action to end!"); |
|
286 VCXLOGLO1("<<<CVCXTestStatsKeeper::ActionEndL"); |
|
287 return; |
|
288 } |
|
289 |
|
290 item->iError = aError; |
|
291 item->iEndTime.HomeTime(); |
|
292 |
|
293 TBuf<64> prgBuff( _L("OK") ); |
|
294 if( aError != KErrNone ) |
|
295 { |
|
296 prgBuff.Format( _L("Failed (%d)"), item->iError); |
|
297 } |
|
298 ActionProgressL( aId, prgBuff ); |
|
299 |
|
300 item->iIsActive = EFalse; |
|
301 |
|
302 if( aError != KErrNone ) |
|
303 { |
|
304 for( TInt i = 0; i < iTraces.Count(); i++ ) |
|
305 { |
|
306 item->iTraces.AppendL( iTraces[i] ); |
|
307 } |
|
308 iTraces.Reset(); |
|
309 } |
|
310 |
|
311 CheckFailsL(); |
|
312 |
|
313 VCXLOGLO1("<<<CVCXTestStatsKeeper::ActionEndL"); |
|
314 } |
|
315 |
|
316 // ----------------------------------------------------------------------------- |
|
317 // CVCXTestStatsKeeper::ActionEndL |
|
318 // ----------------------------------------------------------------------------- |
|
319 // |
|
320 EXPORT_C void CVCXTestStatsKeeper::ActionEndL( const TDesC& aDescId, TInt aError ) |
|
321 { |
|
322 VCXLOGLO3(">>>CVCXTestStatsKeeper::ActionEndL :%S, err: %d ------>", &aDescId, aError); |
|
323 if( !iStarted ) |
|
324 { |
|
325 return; |
|
326 } |
|
327 |
|
328 CVCXTestStatsItem* item = GetActiveAction( aDescId ); |
|
329 |
|
330 if( !item ) |
|
331 { |
|
332 VCXLOGLO1("CVCXTestStatsKeeper:: No active action to end!"); |
|
333 VCXLOGLO1("<<<CVCXTestStatsKeeper::ActionEndL (tdesc)"); |
|
334 return; |
|
335 } |
|
336 |
|
337 item->iError = aError; |
|
338 item->iEndTime.HomeTime(); |
|
339 |
|
340 TBuf<64> prgBuff( _L("OK") ); |
|
341 if( aError != KErrNone ) |
|
342 { |
|
343 prgBuff.Format( _L("Failed (%d)"), item->iError); |
|
344 } |
|
345 ActionProgressL( aDescId, prgBuff ); |
|
346 |
|
347 item->iIsActive = EFalse; |
|
348 |
|
349 if( aError != KErrNone ) |
|
350 { |
|
351 for( TInt i = 0; i < iTraces.Count(); i++ ) |
|
352 { |
|
353 item->iTraces.AppendL( iTraces[i] ); |
|
354 } |
|
355 iTraces.Reset(); |
|
356 } |
|
357 |
|
358 CheckFailsL(); |
|
359 |
|
360 VCXLOGLO1("<<<CVCXTestStatsKeeper::ActionEndL (tdesc)"); |
|
361 } |
|
362 |
|
363 // ----------------------------------------------------------------------------- |
|
364 // CVCXTestStatsKeeper::ActionProgressL |
|
365 // ----------------------------------------------------------------------------- |
|
366 // |
|
367 EXPORT_C void CVCXTestStatsKeeper::ActionProgressL( TInt32 aId, const TDesC& aProgressDesc ) |
|
368 { |
|
369 VCXLOGLO3(">>>CVCXTestStatsKeeper::ActionProgressL: %d = %S", aId, &aProgressDesc); |
|
370 if( !iStarted ) |
|
371 { |
|
372 return; |
|
373 } |
|
374 |
|
375 CVCXTestStatsItem* item = GetActiveAction( aId ); |
|
376 |
|
377 if( !item ) |
|
378 { |
|
379 User::Leave( KErrNotFound ); |
|
380 } |
|
381 |
|
382 CVCXTestStatsItem* progress = CVCXTestStatsItem::NewL(); |
|
383 |
|
384 progress->iStartTime.HomeTime(); |
|
385 progress->iDesc = aProgressDesc.AllocL(); |
|
386 |
|
387 item->iProgresses.AppendL( progress ); |
|
388 VCXLOGLO1("<<<CVCXTestStatsKeeper::ActionProgressL"); |
|
389 } |
|
390 |
|
391 // ----------------------------------------------------------------------------- |
|
392 // CVCXTestStatsKeeper::ActionProgressL |
|
393 // ----------------------------------------------------------------------------- |
|
394 // |
|
395 EXPORT_C void CVCXTestStatsKeeper::ActionProgressL( const TDesC& aDescId, const TDesC& aProgressDesc ) |
|
396 { |
|
397 VCXLOGLO3(">>>CVCXTestStatsKeeper::ActionProgressL: %S = %S", &aDescId, &aProgressDesc); |
|
398 if( !iStarted ) |
|
399 { |
|
400 return; |
|
401 } |
|
402 |
|
403 CVCXTestStatsItem* item = GetActiveAction( aDescId ); |
|
404 |
|
405 if( !item ) |
|
406 { |
|
407 User::Leave( KErrNotFound ); |
|
408 } |
|
409 |
|
410 CVCXTestStatsItem* progress = CVCXTestStatsItem::NewL(); |
|
411 |
|
412 progress->iStartTime.HomeTime(); |
|
413 progress->iDesc = aProgressDesc.AllocL(); |
|
414 |
|
415 item->iProgresses.AppendL( progress ); |
|
416 VCXLOGLO1("<<<CVCXTestStatsKeeper::ActionProgressL (desc)"); |
|
417 } |
|
418 |
|
419 // ----------------------------------------------------------------------------- |
|
420 // CVCXTestStatsKeeper::ActionTraceL |
|
421 // ----------------------------------------------------------------------------- |
|
422 // |
|
423 EXPORT_C void CVCXTestStatsKeeper::ActionTraceL( const TDesC& aDesc ) |
|
424 { |
|
425 VCXLOGLO1(">>>CVCXTestStatsKeeper::ActionTraceL"); |
|
426 if( !iStarted ) |
|
427 { |
|
428 return; |
|
429 } |
|
430 |
|
431 while( iTraces.Count() > KMaxTraces ) |
|
432 { |
|
433 iTraces.Remove( 0 ); |
|
434 } |
|
435 |
|
436 iTraces.AppendL( aDesc.AllocL() ); |
|
437 VCXLOGLO1("<<<CVCXTestStatsKeeper::ActionTraceL"); |
|
438 } |
|
439 |
|
440 // ----------------------------------------------------------------------------- |
|
441 // CVCXTestStatsKeeper::GetActiveAction |
|
442 // ----------------------------------------------------------------------------- |
|
443 // |
|
444 CVCXTestStatsItem* CVCXTestStatsKeeper::GetActiveAction( TInt32 aId ) |
|
445 { |
|
446 VCXLOGLO1(">>>CVCXTestStatsKeeper::GetActiveAction"); |
|
447 for( TInt i = 0; i < iActions.Count(); i++ ) |
|
448 { |
|
449 if( iActions[i]->iId == aId && iActions[i]->iIsActive ) |
|
450 { |
|
451 VCXLOGLO2("CVCXTestStatsKeeper:: Found %S.", iActions[i]->iDesc); |
|
452 VCXLOGLO1("<<<CVCXTestStatsKeeper::GetActiveAction"); |
|
453 return iActions[i]; |
|
454 } |
|
455 } |
|
456 VCXLOGLO1("<<<CVCXTestStatsKeeper::GetActiveAction"); |
|
457 return GetLastActiveAction( EFalse ); |
|
458 } |
|
459 |
|
460 // ----------------------------------------------------------------------------- |
|
461 // CVCXTestStatsKeeper::GetActiveAction |
|
462 // ----------------------------------------------------------------------------- |
|
463 // |
|
464 CVCXTestStatsItem* CVCXTestStatsKeeper::GetActiveAction( const TDesC& aDescId ) |
|
465 { |
|
466 VCXLOGLO1(">>>CVCXTestStatsKeeper::GetActiveAction (desc)"); |
|
467 for( TInt i = 0; i < iActions.Count(); i++ ) |
|
468 { |
|
469 if( iActions[i]->iDescId && *iActions[i]->iDescId == aDescId && iActions[i]->iIsActive ) |
|
470 { |
|
471 VCXLOGLO2("CVCXTestStatsKeeper:: Found %S.", iActions[i]->iDesc); |
|
472 VCXLOGLO1("<<<CVCXTestStatsKeeper::GetActiveAction (desc)"); |
|
473 return iActions[i]; |
|
474 } |
|
475 } |
|
476 VCXLOGLO1("<<<CVCXTestStatsKeeper::GetActiveAction (desc)"); |
|
477 return GetLastActiveAction( ETrue ); |
|
478 } |
|
479 |
|
480 // ----------------------------------------------------------------------------- |
|
481 // CVCXTestStatsKeeper::GetLastActiveAction |
|
482 // ----------------------------------------------------------------------------- |
|
483 // |
|
484 CVCXTestStatsItem* CVCXTestStatsKeeper::GetLastActiveAction( TBool aOnlyDescId ) |
|
485 { |
|
486 VCXLOGLO1(">>>CVCXTestStatsKeeper::GetLastActiveAction"); |
|
487 for( TInt i = iActions.Count()-1; i >= 0; i-- ) |
|
488 { |
|
489 if( iActions[i]->iIsActive ) |
|
490 { |
|
491 if( ( aOnlyDescId && iActions[i]->iDesc ) || ( !aOnlyDescId && !iActions[i]->iDesc ) ) |
|
492 { |
|
493 continue; |
|
494 } |
|
495 VCXLOGLO2("CVCXTestStatsKeeper:: Found: %S.", iActions[i]->iDesc); |
|
496 VCXLOGLO1("<<<CVCXTestStatsKeeper::GetLastActiveAction"); |
|
497 return iActions[i]; |
|
498 } |
|
499 } |
|
500 VCXLOGLO1("<<<CVCXTestStatsKeeper::GetLastActiveAction"); |
|
501 return NULL; |
|
502 } |
|
503 |
|
504 // ----------------------------------------------------------------------------- |
|
505 // CVCXTestStatsKeeper::FormatDate |
|
506 // ----------------------------------------------------------------------------- |
|
507 // |
|
508 TInt CVCXTestStatsKeeper::FormatDate( const TTime& aDate, TDes& aStr ) |
|
509 { |
|
510 _LIT(KDateTimeString,"%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%H%:1%T%:2%S%.%*C2%:3%-B"); |
|
511 |
|
512 TRAPD( err, aDate.FormatL( aStr, KDateTimeString ) ); |
|
513 return err; |
|
514 } |
|
515 |
|
516 // ----------------------------------------------------------------------------- |
|
517 // CVCXTestStatsKeeper::GenerateReport |
|
518 // ----------------------------------------------------------------------------- |
|
519 // |
|
520 void CVCXTestStatsKeeper::GenerateReportL( const TDesC& aFileName, TBool aFullReport ) |
|
521 { |
|
522 aFileName.Length(); |
|
523 |
|
524 if( !iStarted ) |
|
525 { |
|
526 return; |
|
527 } |
|
528 |
|
529 VCXTESTSTATS_W2( aFileName, "CVCXTestStatsKeeper:: Data size for the report: %d kBs", DataSizeL() ); |
|
530 |
|
531 if( iReportName ) |
|
532 { |
|
533 VCXTESTSTATS_W1(aFileName, ""); |
|
534 VCXTESTSTATS_W1(aFileName, "-------------------------------------------------------------------------"); |
|
535 VCXTESTSTATS_W2(aFileName, " %S", iReportName); |
|
536 VCXTESTSTATS_W1(aFileName, "-------------------------------------------------------------------------"); |
|
537 } |
|
538 |
|
539 if( aFullReport ) |
|
540 { |
|
541 const TInt KMaxDescLen = 52; |
|
542 |
|
543 for( TInt i = 0; i < iActions.Count(); i++ ) |
|
544 { |
|
545 TBuf<256> startTime; |
|
546 TBuf<256> endTime; |
|
547 |
|
548 CVCXTestStatsItem* item = iActions[i]; |
|
549 |
|
550 FormatDate( item->iStartTime, startTime ); |
|
551 if( !item->iIsActive ) |
|
552 { |
|
553 FormatDate( item->iEndTime, endTime ); |
|
554 } |
|
555 |
|
556 TBuf<KMaxDescLen+10> shortened; |
|
557 if( item->iDesc->Length() > KMaxDescLen ) |
|
558 { |
|
559 TPtrC left = item->iDesc->Left( KMaxDescLen/2 ); |
|
560 TPtrC right = item->iDesc->Right( KMaxDescLen/2 ); |
|
561 shortened.Format( _L("%S ... %S"), &left, &right ); |
|
562 } |
|
563 else |
|
564 { |
|
565 shortened.Copy( *item->iDesc ); |
|
566 } |
|
567 |
|
568 TBuf<1024*2> buff; |
|
569 buff.Format( _L("%- *S %S"), 60, &shortened, &startTime); |
|
570 VCXTESTSTATS_W2(aFileName, "%S", &buff); |
|
571 |
|
572 if( item->iProgresses.Count() > 0 ) |
|
573 { |
|
574 for( TInt e = 0; e < item->iProgresses.Count(); e++ ) |
|
575 { |
|
576 FormatDate( item->iProgresses[e]->iStartTime, startTime ); |
|
577 if( item->iProgresses[e]->iDesc->Length() > KMaxDescLen ) |
|
578 { |
|
579 TPtrC left = item->iProgresses[e]->iDesc->Left( KMaxDescLen/2-2 ); |
|
580 TPtrC right = item->iProgresses[e]->iDesc->Right( KMaxDescLen/2-2 ); |
|
581 shortened.Format( _L("%S .. %S"), &left, &right ); |
|
582 } |
|
583 else |
|
584 { |
|
585 shortened.Copy( *item->iProgresses[e]->iDesc ); |
|
586 } |
|
587 buff.Format( _L(" %- *S %S"), 57, &shortened, &startTime ); |
|
588 VCXTESTSTATS_W2(aFileName, "%S", &buff); |
|
589 } |
|
590 } |
|
591 |
|
592 if( item->iTraces.Count() > 0 ) |
|
593 { |
|
594 VCXTESTSTATS_W1(aFileName, " Traces:"); |
|
595 for( TInt e = 0; e < item->iTraces.Count(); e++ ) |
|
596 { |
|
597 VCXTESTSTATS_W2(aFileName, " %S", item->iTraces[e]); |
|
598 } |
|
599 } |
|
600 } |
|
601 } |
|
602 |
|
603 RPointerArray<CVCXTestStatsItemSummary> summaries; |
|
604 CleanupResetAndDestroyPushL( summaries ); |
|
605 GetActionSummariesL( summaries, ETrue ); |
|
606 |
|
607 TBuf<256> buff; |
|
608 |
|
609 _LIT( KVCXTESTDest, "Desc" ); |
|
610 _LIT( KVCXTESTFails, "Fails" ); |
|
611 _LIT( KVCXTESTTotal, "Total" ); |
|
612 _LIT( KVCXTESTMinTime, "MinTime" ); |
|
613 _LIT( KVCXTESTMaxTime, "MaxTime" ); |
|
614 _LIT( KVCXTESTAvgTime, "AvgTime"); |
|
615 _LIT( KVCXTESTTotalTime, "TotTime"); |
|
616 |
|
617 const TInt KDescFieldLen = 32; |
|
618 |
|
619 // Header. |
|
620 buff.Format( _L("%- *S %+ 6S %+ 6S %+ 6S %+ 6S %+ 6S %+ 6S"), KDescFieldLen, |
|
621 &KVCXTESTDest, &KVCXTESTFails, &KVCXTESTTotal, &KVCXTESTMinTime, &KVCXTESTMaxTime, &KVCXTESTAvgTime, &KVCXTESTTotalTime ); |
|
622 VCXTESTSTATS_W2(aFileName, "%S", &buff); |
|
623 |
|
624 // Data. |
|
625 for( TInt e = 0; e < summaries.Count(); e++ ) |
|
626 { |
|
627 TBuf<KDescFieldLen+10> shortened; |
|
628 if( summaries[e]->iDesc->Length() > KDescFieldLen ) |
|
629 { |
|
630 TPtrC left = summaries[e]->iDesc->Left( KDescFieldLen/2-2 ); |
|
631 TPtrC right = summaries[e]->iDesc->Right( KDescFieldLen/2-2 ); |
|
632 shortened.Format( _L("%S .. %S"), &left, &right ); |
|
633 } |
|
634 else |
|
635 { |
|
636 shortened.Copy( *summaries[e]->iDesc ); |
|
637 } |
|
638 |
|
639 const TReal KXXXMillion = 1000000; |
|
640 TReal minTime = (TReal)summaries[e]->iMinTime / KXXXMillion; |
|
641 TReal maxTime = (TReal)summaries[e]->iMaxTime / KXXXMillion; |
|
642 TReal avgTime = (TReal)summaries[e]->iAvgTime / KXXXMillion; |
|
643 TInt totalTime = (TReal)summaries[e]->iTotalTime / KXXXMillion; |
|
644 |
|
645 buff.Format( _L("%- *S %+ 6d %+ 6d %+ 6.2f %+ 6.2f %+ 6.2f %+ 6d"), KDescFieldLen, |
|
646 &shortened, summaries[e]->iFailCount, summaries[e]->iCount, |
|
647 minTime, maxTime, avgTime, totalTime ); |
|
648 VCXTESTSTATS_W2(aFileName, "%S", &buff); |
|
649 } |
|
650 |
|
651 if( iAbortedBecauseTooManyFails ) |
|
652 { |
|
653 VCXTESTSTATS_W1(aFileName, "Too many fails, test was aborted!"); |
|
654 } |
|
655 |
|
656 CleanupStack::PopAndDestroy( &summaries ); |
|
657 } |
|
658 |
|
659 // ----------------------------------------------------------------------------- |
|
660 // CVCXTestStatsKeeper::GetActionSummariesL |
|
661 // ----------------------------------------------------------------------------- |
|
662 // |
|
663 void CVCXTestStatsKeeper::GetActionSummariesL( RPointerArray<CVCXTestStatsItemSummary>& aSummaries, TBool aFailActiveActions ) |
|
664 { |
|
665 if( aFailActiveActions ) |
|
666 { |
|
667 for( TInt i = 0; i < iActions.Count(); i++ ) |
|
668 { |
|
669 CVCXTestStatsItem* item = iActions[i]; |
|
670 if( item->iIsActive ) |
|
671 { |
|
672 item->iError = KErrUnknown; |
|
673 item->iEndTime.HomeTime(); |
|
674 item->iIsActive = EFalse; |
|
675 } |
|
676 } |
|
677 } |
|
678 |
|
679 for( TInt i = 0; i < iActions.Count(); i++ ) |
|
680 { |
|
681 CVCXTestStatsItem* item = iActions[i]; |
|
682 if( item->iIsActive ) |
|
683 { |
|
684 continue; |
|
685 } |
|
686 |
|
687 CVCXTestStatsItemSummary* itemSummary( NULL ); |
|
688 |
|
689 // Find summary item. |
|
690 for( TInt e = 0; e < aSummaries.Count(); e++ ) |
|
691 { |
|
692 if( item->iDesc && aSummaries[e]->iDesc && *item->iDesc == *aSummaries[e]->iDesc ) |
|
693 { |
|
694 itemSummary = aSummaries[e]; |
|
695 break; |
|
696 } |
|
697 } |
|
698 |
|
699 // Not found, create new one. |
|
700 if( !itemSummary ) |
|
701 { |
|
702 itemSummary = CVCXTestStatsItemSummary::NewL(); |
|
703 itemSummary->iId = item->iId; |
|
704 itemSummary->iTotalTime = 0; |
|
705 itemSummary->iMaxTime = -1; |
|
706 itemSummary->iMinTime = -1; |
|
707 if( item->iDescId ) itemSummary->iDescId = item->iDescId->AllocL(); |
|
708 itemSummary->iDesc = item->iDesc->AllocL(); |
|
709 aSummaries.Append( itemSummary ); |
|
710 } |
|
711 |
|
712 // Increase counts. |
|
713 itemSummary->iCount++; |
|
714 if( item->iError != KErrNone ) |
|
715 { |
|
716 itemSummary->iFailCount++; |
|
717 } |
|
718 |
|
719 // Add item to stats. |
|
720 TTimeIntervalMicroSeconds runTime( 0 ); |
|
721 runTime = item->iEndTime.MicroSecondsFrom( item->iStartTime ); |
|
722 if( runTime.Int64() > 0 ) |
|
723 { |
|
724 if( item->iError != KErrNone ) |
|
725 { |
|
726 itemSummary->iFailTime += runTime.Int64(); |
|
727 } |
|
728 itemSummary->iTotalTime += runTime.Int64(); |
|
729 TReal run = (TReal)runTime.Int64() / 1000000; |
|
730 |
|
731 itemSummary->iMaxTime = |
|
732 ( runTime.Int64() > itemSummary->iMaxTime || itemSummary->iMaxTime < 0 ) ? runTime.Int64() : itemSummary->iMaxTime; |
|
733 itemSummary->iMinTime = |
|
734 ( runTime.Int64() < itemSummary->iMinTime || itemSummary->iMinTime < 0) ? runTime.Int64() : itemSummary->iMinTime; |
|
735 } |
|
736 } |
|
737 |
|
738 // Calc avg times and check other times. |
|
739 for( TInt e = 0; e < aSummaries.Count(); e++ ) |
|
740 { |
|
741 aSummaries[e]->iAvgTime = (TReal)aSummaries[e]->iTotalTime / (TReal)aSummaries[e]->iCount; |
|
742 aSummaries[e]->iMinTime = aSummaries[e]->iMinTime < 0 ? 0 : aSummaries[e]->iMinTime; |
|
743 aSummaries[e]->iMaxTime = aSummaries[e]->iMaxTime < 0 ? 0 : aSummaries[e]->iMaxTime; |
|
744 } |
|
745 |
|
746 } |
|
747 |
|
748 // ----------------------------------------------------------------------------- |
|
749 // CVCXTestStatsKeeper::DataSizeL |
|
750 // ----------------------------------------------------------------------------- |
|
751 // |
|
752 TUint CVCXTestStatsKeeper::DataSizeL() |
|
753 { |
|
754 TUint size( 0 ); |
|
755 |
|
756 size += iActions.Count() * sizeof( CVCXTestStatsItem ); |
|
757 |
|
758 for( TInt i = 0; i < iActions.Count(); i++ ) |
|
759 { |
|
760 CVCXTestStatsItem* item = iActions[i]; |
|
761 if( item->iDescId ) size += item->iDescId->Size(); |
|
762 size += item->iDesc->Size(); |
|
763 |
|
764 size += item->iProgresses.Count() * sizeof( CVCXTestStatsItem ); |
|
765 |
|
766 for( TInt e = 0; e < item->iProgresses.Count(); e++ ) |
|
767 { |
|
768 size += item->iProgresses[e]->iDesc->Size(); |
|
769 } |
|
770 |
|
771 if( item->iTraces.Count() > 0 ) |
|
772 { |
|
773 for( TInt e = 0; e < item->iTraces.Count(); e++ ) |
|
774 { |
|
775 size += item->iTraces[e]->Size(); |
|
776 } |
|
777 } |
|
778 } |
|
779 return size/1024; |
|
780 } |
|
781 |
|
782 // ----------------------------------------------------------------------------- |
|
783 // CVCXTestStatsKeeper::CheckFailsL |
|
784 // ----------------------------------------------------------------------------- |
|
785 // |
|
786 void CVCXTestStatsKeeper::CheckFailsL() |
|
787 { |
|
788 RPointerArray<CVCXTestStatsItemSummary> summaries; |
|
789 CleanupResetAndDestroyPushL( summaries ); |
|
790 GetActionSummariesL( summaries, EFalse ); |
|
791 |
|
792 const TReal KVCXTestStatsKeeperMaxFailPercent = 0.33; |
|
793 |
|
794 for( TInt i = 0; i < summaries.Count(); i++ ) |
|
795 { |
|
796 // Check fails only when there's some actions done. |
|
797 if( summaries[i]->iCount > 10 ) |
|
798 { |
|
799 // Check if there's too many fails. |
|
800 TReal failPercent = (TReal)summaries[i]->iFailCount / (TReal)summaries[i]->iCount; |
|
801 |
|
802 if( failPercent > KVCXTestStatsKeeperMaxFailPercent ) |
|
803 { |
|
804 iAbortedBecauseTooManyFails = ETrue; |
|
805 VCXLOGLO1("CVCXTestStatsKeeper:: Too many fails, leaving with KErrAbort"); |
|
806 User::Leave( KErrAbort ); |
|
807 } |
|
808 |
|
809 const TInt64 KTest10Minutes = 1000000 * 60 * 10; |
|
810 |
|
811 // Check if failing cases take too long to run. |
|
812 if( summaries[i]->iTotalTime > 0 && summaries[i]->iFailTime > KTest10Minutes ) |
|
813 { |
|
814 TReal failTimePercent = (TReal)summaries[i]->iFailTime / (TReal)summaries[i]->iTotalTime; |
|
815 if( failTimePercent > KVCXTestStatsKeeperMaxFailPercent ) |
|
816 { |
|
817 VCXLOGLO1("CVCXTestStatsKeeper:: Too many fails, leaving with KErrAbort"); |
|
818 iAbortedBecauseTooManyFails = ETrue; |
|
819 User::Leave( KErrAbort ); |
|
820 } |
|
821 } |
|
822 } |
|
823 } |
|
824 CleanupStack::PopAndDestroy( &summaries ); |
|
825 } |
|
826 |
|
827 // End of File |