|
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 if ( aFullReport ) |
|
530 { |
|
531 VCXTESTSTATS_W2( aFileName, "CVCXTestStatsKeeper:: Data size for the report: %d kBs", DataSizeL() ); |
|
532 } |
|
533 |
|
534 if( iReportName ) |
|
535 { |
|
536 VCXTESTSTATS_W1(aFileName, ""); |
|
537 VCXTESTSTATS_W1(aFileName, "-------------------------------------------------------------------------"); |
|
538 VCXTESTSTATS_W2(aFileName, " %S", iReportName); |
|
539 VCXTESTSTATS_W1(aFileName, "-------------------------------------------------------------------------"); |
|
540 } |
|
541 |
|
542 if( aFullReport ) |
|
543 { |
|
544 const TInt KMaxDescLen = 52; |
|
545 |
|
546 for( TInt i = 0; i < iActions.Count(); i++ ) |
|
547 { |
|
548 TBuf<256> startTime; |
|
549 TBuf<256> endTime; |
|
550 |
|
551 CVCXTestStatsItem* item = iActions[i]; |
|
552 |
|
553 FormatDate( item->iStartTime, startTime ); |
|
554 if( !item->iIsActive ) |
|
555 { |
|
556 FormatDate( item->iEndTime, endTime ); |
|
557 } |
|
558 |
|
559 TBuf<KMaxDescLen+10> shortened; |
|
560 if( item->iDesc->Length() > KMaxDescLen ) |
|
561 { |
|
562 TPtrC left = item->iDesc->Left( KMaxDescLen/2 ); |
|
563 TPtrC right = item->iDesc->Right( KMaxDescLen/2 ); |
|
564 shortened.Format( _L("%S ... %S"), &left, &right ); |
|
565 } |
|
566 else |
|
567 { |
|
568 shortened.Copy( *item->iDesc ); |
|
569 } |
|
570 |
|
571 TBuf<1024*2> buff; |
|
572 buff.Format( _L("%- *S %S"), 60, &shortened, &startTime); |
|
573 VCXTESTSTATS_W2(aFileName, "%S", &buff); |
|
574 |
|
575 if( item->iProgresses.Count() > 0 ) |
|
576 { |
|
577 for( TInt e = 0; e < item->iProgresses.Count(); e++ ) |
|
578 { |
|
579 FormatDate( item->iProgresses[e]->iStartTime, startTime ); |
|
580 if( item->iProgresses[e]->iDesc->Length() > KMaxDescLen ) |
|
581 { |
|
582 TPtrC left = item->iProgresses[e]->iDesc->Left( KMaxDescLen/2-2 ); |
|
583 TPtrC right = item->iProgresses[e]->iDesc->Right( KMaxDescLen/2-2 ); |
|
584 shortened.Format( _L("%S .. %S"), &left, &right ); |
|
585 } |
|
586 else |
|
587 { |
|
588 shortened.Copy( *item->iProgresses[e]->iDesc ); |
|
589 } |
|
590 buff.Format( _L(" %- *S %S"), 57, &shortened, &startTime ); |
|
591 VCXTESTSTATS_W2(aFileName, "%S", &buff); |
|
592 } |
|
593 } |
|
594 |
|
595 if( item->iTraces.Count() > 0 ) |
|
596 { |
|
597 VCXTESTSTATS_W1(aFileName, " Traces:"); |
|
598 for( TInt e = 0; e < item->iTraces.Count(); e++ ) |
|
599 { |
|
600 VCXTESTSTATS_W2(aFileName, " %S", item->iTraces[e]); |
|
601 } |
|
602 } |
|
603 } |
|
604 } |
|
605 |
|
606 RPointerArray<CVCXTestStatsItemSummary> summaries; |
|
607 CleanupResetAndDestroyPushL( summaries ); |
|
608 GetActionSummariesL( summaries, ETrue ); |
|
609 |
|
610 TBuf<256> buff; |
|
611 |
|
612 _LIT( KVCXTESTDest, "Desc" ); |
|
613 _LIT( KVCXTESTFails, "Fails" ); |
|
614 _LIT( KVCXTESTTotal, "Total" ); |
|
615 _LIT( KVCXTESTMinTime, "MinTime" ); |
|
616 _LIT( KVCXTESTMaxTime, "MaxTime" ); |
|
617 _LIT( KVCXTESTAvgTime, "AvgTime"); |
|
618 _LIT( KVCXTESTTotalTime, "TotTime"); |
|
619 |
|
620 const TInt KDescFieldLen = 32; |
|
621 |
|
622 // Header. |
|
623 buff.Format( _L("%- *S %+ 6S %+ 6S %+ 6S %+ 6S %+ 6S %+ 6S"), KDescFieldLen, |
|
624 &KVCXTESTDest, &KVCXTESTFails, &KVCXTESTTotal, &KVCXTESTMinTime, &KVCXTESTMaxTime, &KVCXTESTAvgTime, &KVCXTESTTotalTime ); |
|
625 VCXTESTSTATS_W2(aFileName, "%S", &buff); |
|
626 |
|
627 // Data. |
|
628 for( TInt e = 0; e < summaries.Count(); e++ ) |
|
629 { |
|
630 TBuf<KDescFieldLen+10> shortened; |
|
631 if( summaries[e]->iDesc->Length() > KDescFieldLen ) |
|
632 { |
|
633 TPtrC left = summaries[e]->iDesc->Left( KDescFieldLen/2-2 ); |
|
634 TPtrC right = summaries[e]->iDesc->Right( KDescFieldLen/2-2 ); |
|
635 shortened.Format( _L("%S .. %S"), &left, &right ); |
|
636 } |
|
637 else |
|
638 { |
|
639 shortened.Copy( *summaries[e]->iDesc ); |
|
640 } |
|
641 |
|
642 const TReal KXXXMillion = 1000000; |
|
643 TReal minTime = (TReal)summaries[e]->iMinTime / KXXXMillion; |
|
644 TReal maxTime = (TReal)summaries[e]->iMaxTime / KXXXMillion; |
|
645 TReal avgTime = (TReal)summaries[e]->iAvgTime / KXXXMillion; |
|
646 TInt totalTime = (TReal)summaries[e]->iTotalTime / KXXXMillion; |
|
647 |
|
648 buff.Format( _L("%- *S %+ 6d %+ 6d %+ 6.2f %+ 6.2f %+ 6.2f %+ 6d"), KDescFieldLen, |
|
649 &shortened, summaries[e]->iFailCount, summaries[e]->iCount, |
|
650 minTime, maxTime, avgTime, totalTime ); |
|
651 VCXTESTSTATS_W2(aFileName, "%S", &buff); |
|
652 } |
|
653 |
|
654 if( iAbortedBecauseTooManyFails ) |
|
655 { |
|
656 VCXTESTSTATS_W1(aFileName, "Too many fails, test was aborted!"); |
|
657 } |
|
658 |
|
659 CleanupStack::PopAndDestroy( &summaries ); |
|
660 } |
|
661 |
|
662 // ----------------------------------------------------------------------------- |
|
663 // CVCXTestStatsKeeper::GetActionSummariesL |
|
664 // ----------------------------------------------------------------------------- |
|
665 // |
|
666 void CVCXTestStatsKeeper::GetActionSummariesL( RPointerArray<CVCXTestStatsItemSummary>& aSummaries, TBool aFailActiveActions ) |
|
667 { |
|
668 if( aFailActiveActions ) |
|
669 { |
|
670 for( TInt i = 0; i < iActions.Count(); i++ ) |
|
671 { |
|
672 CVCXTestStatsItem* item = iActions[i]; |
|
673 if( item->iIsActive ) |
|
674 { |
|
675 item->iError = KErrUnknown; |
|
676 item->iEndTime.HomeTime(); |
|
677 item->iIsActive = EFalse; |
|
678 } |
|
679 } |
|
680 } |
|
681 |
|
682 for( TInt i = 0; i < iActions.Count(); i++ ) |
|
683 { |
|
684 CVCXTestStatsItem* item = iActions[i]; |
|
685 if( item->iIsActive ) |
|
686 { |
|
687 continue; |
|
688 } |
|
689 |
|
690 CVCXTestStatsItemSummary* itemSummary( NULL ); |
|
691 |
|
692 // Find summary item. |
|
693 for( TInt e = 0; e < aSummaries.Count(); e++ ) |
|
694 { |
|
695 if( item->iDesc && aSummaries[e]->iDesc && *item->iDesc == *aSummaries[e]->iDesc ) |
|
696 { |
|
697 itemSummary = aSummaries[e]; |
|
698 break; |
|
699 } |
|
700 } |
|
701 |
|
702 // Not found, create new one. |
|
703 if( !itemSummary ) |
|
704 { |
|
705 itemSummary = CVCXTestStatsItemSummary::NewL(); |
|
706 itemSummary->iId = item->iId; |
|
707 itemSummary->iTotalTime = 0; |
|
708 itemSummary->iMaxTime = -1; |
|
709 itemSummary->iMinTime = -1; |
|
710 if( item->iDescId ) itemSummary->iDescId = item->iDescId->AllocL(); |
|
711 itemSummary->iDesc = item->iDesc->AllocL(); |
|
712 aSummaries.Append( itemSummary ); |
|
713 } |
|
714 |
|
715 // Increase counts. |
|
716 itemSummary->iCount++; |
|
717 if( item->iError != KErrNone ) |
|
718 { |
|
719 itemSummary->iFailCount++; |
|
720 } |
|
721 |
|
722 // Add item to stats. |
|
723 TTimeIntervalMicroSeconds runTime( 0 ); |
|
724 runTime = item->iEndTime.MicroSecondsFrom( item->iStartTime ); |
|
725 if( runTime.Int64() > 0 ) |
|
726 { |
|
727 if( item->iError != KErrNone ) |
|
728 { |
|
729 itemSummary->iFailTime += runTime.Int64(); |
|
730 } |
|
731 itemSummary->iTotalTime += runTime.Int64(); |
|
732 TReal run = (TReal)runTime.Int64() / 1000000; |
|
733 |
|
734 itemSummary->iMaxTime = |
|
735 ( runTime.Int64() > itemSummary->iMaxTime || itemSummary->iMaxTime < 0 ) ? runTime.Int64() : itemSummary->iMaxTime; |
|
736 itemSummary->iMinTime = |
|
737 ( runTime.Int64() < itemSummary->iMinTime || itemSummary->iMinTime < 0) ? runTime.Int64() : itemSummary->iMinTime; |
|
738 } |
|
739 } |
|
740 |
|
741 // Calc avg times and check other times. |
|
742 for( TInt e = 0; e < aSummaries.Count(); e++ ) |
|
743 { |
|
744 aSummaries[e]->iAvgTime = (TReal)aSummaries[e]->iTotalTime / (TReal)aSummaries[e]->iCount; |
|
745 aSummaries[e]->iMinTime = aSummaries[e]->iMinTime < 0 ? 0 : aSummaries[e]->iMinTime; |
|
746 aSummaries[e]->iMaxTime = aSummaries[e]->iMaxTime < 0 ? 0 : aSummaries[e]->iMaxTime; |
|
747 } |
|
748 |
|
749 } |
|
750 |
|
751 // ----------------------------------------------------------------------------- |
|
752 // CVCXTestStatsKeeper::DataSizeL |
|
753 // ----------------------------------------------------------------------------- |
|
754 // |
|
755 TUint CVCXTestStatsKeeper::DataSizeL() |
|
756 { |
|
757 TUint size( 0 ); |
|
758 |
|
759 size += iActions.Count() * sizeof( CVCXTestStatsItem ); |
|
760 |
|
761 for( TInt i = 0; i < iActions.Count(); i++ ) |
|
762 { |
|
763 CVCXTestStatsItem* item = iActions[i]; |
|
764 if( item->iDescId ) size += item->iDescId->Size(); |
|
765 size += item->iDesc->Size(); |
|
766 |
|
767 size += item->iProgresses.Count() * sizeof( CVCXTestStatsItem ); |
|
768 |
|
769 for( TInt e = 0; e < item->iProgresses.Count(); e++ ) |
|
770 { |
|
771 size += item->iProgresses[e]->iDesc->Size(); |
|
772 } |
|
773 |
|
774 if( item->iTraces.Count() > 0 ) |
|
775 { |
|
776 for( TInt e = 0; e < item->iTraces.Count(); e++ ) |
|
777 { |
|
778 size += item->iTraces[e]->Size(); |
|
779 } |
|
780 } |
|
781 } |
|
782 return size/1024; |
|
783 } |
|
784 |
|
785 // ----------------------------------------------------------------------------- |
|
786 // CVCXTestStatsKeeper::CheckFailsL |
|
787 // ----------------------------------------------------------------------------- |
|
788 // |
|
789 void CVCXTestStatsKeeper::CheckFailsL() |
|
790 { |
|
791 RPointerArray<CVCXTestStatsItemSummary> summaries; |
|
792 CleanupResetAndDestroyPushL( summaries ); |
|
793 GetActionSummariesL( summaries, EFalse ); |
|
794 |
|
795 const TReal KVCXTestStatsKeeperMaxFailPercent = 0.33; |
|
796 |
|
797 for( TInt i = 0; i < summaries.Count(); i++ ) |
|
798 { |
|
799 // Check fails only when there's some actions done. |
|
800 if( summaries[i]->iCount > 10 ) |
|
801 { |
|
802 // Check if there's too many fails. |
|
803 TReal failPercent = (TReal)summaries[i]->iFailCount / (TReal)summaries[i]->iCount; |
|
804 |
|
805 if( failPercent > KVCXTestStatsKeeperMaxFailPercent ) |
|
806 { |
|
807 iAbortedBecauseTooManyFails = ETrue; |
|
808 VCXLOGLO1("CVCXTestStatsKeeper:: Too many fails, leaving with KErrAbort"); |
|
809 User::Leave( KErrAbort ); |
|
810 } |
|
811 |
|
812 const TInt64 KTest10Minutes = 1000000 * 60 * 10; |
|
813 |
|
814 // Check if failing cases take too long to run. |
|
815 if( summaries[i]->iTotalTime > 0 && summaries[i]->iFailTime > KTest10Minutes ) |
|
816 { |
|
817 TReal failTimePercent = (TReal)summaries[i]->iFailTime / (TReal)summaries[i]->iTotalTime; |
|
818 if( failTimePercent > KVCXTestStatsKeeperMaxFailPercent ) |
|
819 { |
|
820 VCXLOGLO1("CVCXTestStatsKeeper:: Too many fails, leaving with KErrAbort"); |
|
821 iAbortedBecauseTooManyFails = ETrue; |
|
822 User::Leave( KErrAbort ); |
|
823 } |
|
824 } |
|
825 } |
|
826 } |
|
827 CleanupStack::PopAndDestroy( &summaries ); |
|
828 } |
|
829 |
|
830 // End of File |