1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
13 // Description: |
13 // Description: |
14 // |
14 // |
15 |
15 |
16 #define __PROFILING__ |
16 #define __PROFILING__ |
17 #include <s32file.h> |
17 #include <s32file.h> |
18 #include "TEST.H" |
18 #include "t_logutil2.h" |
19 #include <logview.h> |
19 #include <logview.h> |
20 |
20 |
21 #undef test //there is a "test" macro which hides "RTest test" declaration. |
21 RTest TheTest(_L("t_logbench")); |
22 |
22 |
23 RTest test(_L("Log Engine Benchmark Test Harness")); |
|
24 TLogConfig theConfig; |
23 TLogConfig theConfig; |
25 |
|
26 |
24 |
27 _LIT(KTestString, "%dabcdefghijklmnopqrstuvwxyz"); |
25 _LIT(KTestString, "%dabcdefghijklmnopqrstuvwxyz"); |
28 _LIT(KResultFile, "C:\\LOGENG_TEST.TXT"); |
26 _LIT(KResultFile, "C:\\LOGENG_TEST.TXT"); |
29 |
27 |
30 const TInt KLogSize = 50; |
28 const TInt KLogSize = 50; |
70 @SYMTestExpectedResults Test must not fail |
68 @SYMTestExpectedResults Test must not fail |
71 @SYMREQ REQ0000 |
69 @SYMREQ REQ0000 |
72 */ |
70 */ |
73 LOCAL_C void TestSetupL(CLogClient& aClient) |
71 LOCAL_C void TestSetupL(CLogClient& aClient) |
74 { |
72 { |
75 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0988 ")); |
73 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0988 ")); |
76 CTestActive* active = new(ELeave)CTestActive; |
74 CTestActive* active = new(ELeave)CTestActive; |
77 CleanupStack::PushL(active); |
75 CleanupStack::PushL(active); |
78 |
76 |
79 // Get configuration |
77 // Get configuration |
80 aClient.GetConfig(theConfig, active->iStatus); |
78 aClient.GetConfig(theConfig, active->iStatus); |
81 active->StartL(); |
79 active->StartL(); |
82 CActiveScheduler::Start(); |
80 CActiveScheduler::Start(); |
83 TEST2(active->iStatus.Int(), KErrNone); |
81 TEST2(active->iStatus.Int(), KErrNone); |
84 |
82 |
85 test.Printf(_L(" Log size: %d\n"), theConfig.iMaxLogSize); |
83 TheTest.Printf(_L(" Log size: %d\n"), theConfig.iMaxLogSize); |
86 test.Printf(_L(" Recent list size: %d\n"), theConfig.iMaxRecentLogSize); |
84 TheTest.Printf(_L(" Recent list size: %d\n"), theConfig.iMaxRecentLogSize); |
87 test.Printf(_L(" Max Event Age: %d\n"), theConfig.iMaxEventAge); |
85 TheTest.Printf(_L(" Max Event Age: %d\n"), theConfig.iMaxEventAge); |
88 |
86 |
89 TestUtils::DeleteDatabaseL(); |
87 TestUtils::DeleteDatabaseL(); |
90 |
88 |
91 // Get configuration |
89 // Get configuration |
92 aClient.GetConfig(theConfig, active->iStatus); |
90 aClient.GetConfig(theConfig, active->iStatus); |
93 active->StartL(); |
91 active->StartL(); |
94 CActiveScheduler::Start(); |
92 CActiveScheduler::Start(); |
95 TEST2(active->iStatus.Int(), KErrNone); |
93 TEST2(active->iStatus.Int(), KErrNone); |
96 |
94 |
97 // Wait for user interation |
95 // Wait for user interation |
98 //test.Printf(_L(" Quick tests performed if no key pressed in next 10 seconds\n")); |
96 //TheTest.Printf(_L(" Quick tests performed if no key pressed in next 10 seconds\n")); |
99 //TKeyCode key; |
97 //TKeyCode key; |
100 //if (!TestUtils::WaitForKeyL(10000000, key)) |
98 //if (!TestUtils::WaitForKeyL(10000000, key)) |
101 { |
99 { |
102 theConfig.iMaxLogSize = KLogSize; |
100 theConfig.iMaxLogSize = KLogSize; |
103 |
101 |
120 @SYMTestExpectedResults Test must not fail |
118 @SYMTestExpectedResults Test must not fail |
121 @SYMREQ REQ0000 |
119 @SYMREQ REQ0000 |
122 */ |
120 */ |
123 LOCAL_C void BenchmarkTestL(CLogClient& aClient, RFile& aFile) |
121 LOCAL_C void BenchmarkTestL(CLogClient& aClient, RFile& aFile) |
124 { |
122 { |
125 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0989 ")); |
123 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0989 ")); |
126 CTestActive* active = new(ELeave)CTestActive; |
124 CTestActive* active = new(ELeave)CTestActive; |
127 CleanupStack::PushL(active); |
125 CleanupStack::PushL(active); |
128 |
126 |
129 CLogViewEvent* view = CLogViewEvent::NewL(aClient); |
127 CLogViewEvent* view = CLogViewEvent::NewL(aClient); |
130 CleanupStack::PushL(view); |
128 CleanupStack::PushL(view); |
170 TInt dbSize = DatabaseSizeL(); |
168 TInt dbSize = DatabaseSizeL(); |
171 TInt heapSize = GetHeapSizeL(); |
169 TInt heapSize = GetHeapSizeL(); |
172 TInt serverHeapSize = GetServerHeapSizeL(); |
170 TInt serverHeapSize = GetServerHeapSizeL(); |
173 |
171 |
174 // Store details in file |
172 // Store details in file |
175 test.Printf(_L(" Num: %d, Time: %d, Db Size: %d, Hs: %d, Server Hs: %d\n"), count, I64INT(interval.Int64()), dbSize, heapSize, serverHeapSize); |
173 TheTest.Printf(_L(" Num: %d, Time: %d, Db Size: %d, Hs: %d, Server Hs: %d\n"), count, I64INT(interval.Int64()), dbSize, heapSize, serverHeapSize); |
176 buf.Format(_L8("%d,%d,%d,%d,%d\n"), count, I64INT(interval.Int64()), dbSize, heapSize, serverHeapSize); |
174 buf.Format(_L8("%d,%d,%d,%d,%d\n"), count, I64INT(interval.Int64()), dbSize, heapSize, serverHeapSize); |
177 aFile.Write(buf); |
175 aFile.Write(buf); |
178 } |
176 } |
179 |
177 |
180 aFile.Write(_L8("Navigating View\n")); |
178 aFile.Write(_L8("Navigating View\n")); |
201 |
199 |
202 TInt heapSize = GetHeapSizeL(); |
200 TInt heapSize = GetHeapSizeL(); |
203 TInt serverHeapSize = GetServerHeapSizeL(); |
201 TInt serverHeapSize = GetServerHeapSizeL(); |
204 |
202 |
205 // Store details in file |
203 // Store details in file |
206 test.Printf(_L(" Count: %d, Time: %d, Hs: %d, Server Hs: %d\n"), count, I64INT(interval.Int64()), heapSize, serverHeapSize); |
204 TheTest.Printf(_L(" Count: %d, Time: %d, Hs: %d, Server Hs: %d\n"), count, I64INT(interval.Int64()), heapSize, serverHeapSize); |
207 buf.Format(_L8("%d,%d,%d,%d\n"), count++, I64INT(interval.Int64()), heapSize, serverHeapSize); |
205 buf.Format(_L8("%d,%d,%d,%d\n"), count++, I64INT(interval.Int64()), heapSize, serverHeapSize); |
208 aFile.Write(buf); |
206 aFile.Write(buf); |
209 } |
207 } |
210 |
208 |
211 CleanupStack::PopAndDestroy(4); // event, filter, view, active |
209 CleanupStack::PopAndDestroy(4); // event, filter, view, active |
220 @SYMTestExpectedResults Test must not fail |
218 @SYMTestExpectedResults Test must not fail |
221 @SYMREQ REQ0000 |
219 @SYMREQ REQ0000 |
222 */ |
220 */ |
223 LOCAL_C void DoTestRecentViewsL(CLogClient& aClient, TLogRecentList aList, TInt aRecentCount, TInt aDuplicateCount) |
221 LOCAL_C void DoTestRecentViewsL(CLogClient& aClient, TLogRecentList aList, TInt aRecentCount, TInt aDuplicateCount) |
224 { |
222 { |
225 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0990 ")); |
223 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0990 ")); |
226 CTestActive* active = new(ELeave)CTestActive(); |
224 CTestActive* active = new(ELeave)CTestActive(); |
227 CleanupStack::PushL(active); |
225 CleanupStack::PushL(active); |
228 |
226 |
229 CLogViewRecent* recent = CLogViewRecent::NewL(aClient); |
227 CLogViewRecent* recent = CLogViewRecent::NewL(aClient); |
230 CleanupStack::PushL(recent); |
228 CleanupStack::PushL(recent); |
271 @SYMTestExpectedResults Test must not fail |
269 @SYMTestExpectedResults Test must not fail |
272 @SYMREQ REQ0000 |
270 @SYMREQ REQ0000 |
273 */ |
271 */ |
274 LOCAL_C void DoTestClearDuplicateL(CLogClient& aClient, TLogRecentList aList, RFile& aFile) |
272 LOCAL_C void DoTestClearDuplicateL(CLogClient& aClient, TLogRecentList aList, RFile& aFile) |
275 { |
273 { |
276 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0991 ")); |
274 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0991 ")); |
277 CTestActive* active = new(ELeave)CTestActive(); |
275 CTestActive* active = new(ELeave)CTestActive(); |
278 CleanupStack::PushL(active); |
276 CleanupStack::PushL(active); |
279 |
277 |
280 CLogViewRecent* recent = CLogViewRecent::NewL(aClient); |
278 CLogViewRecent* recent = CLogViewRecent::NewL(aClient); |
281 CleanupStack::PushL(recent); |
279 CleanupStack::PushL(recent); |
292 TTime after; |
290 TTime after; |
293 after.UniversalTime(); |
291 after.UniversalTime(); |
294 TTimeIntervalMicroSeconds interval = after.MicroSecondsFrom(before); |
292 TTimeIntervalMicroSeconds interval = after.MicroSecondsFrom(before); |
295 |
293 |
296 TBuf8<256> buf; |
294 TBuf8<256> buf; |
297 test.Printf(_L("Clearing Duplicates for List %d, %d\n"), recent->RecentList(), I64INT(interval.Int64())); |
295 TheTest.Printf(_L("Clearing Duplicates for List %d, %d\n"), recent->RecentList(), I64INT(interval.Int64())); |
298 buf.Format(_L8("Clearing Duplicates for List %d, %d\n"), recent->RecentList(), I64INT(interval.Int64())); |
296 buf.Format(_L8("Clearing Duplicates for List %d, %d\n"), recent->RecentList(), I64INT(interval.Int64())); |
299 aFile.Write(buf); |
297 aFile.Write(buf); |
300 |
298 |
301 CleanupStack::PopAndDestroy(2); // recent, active |
299 CleanupStack::PopAndDestroy(2); // recent, active |
302 } |
300 } |
309 @SYMTestExpectedResults Test must not fail |
307 @SYMTestExpectedResults Test must not fail |
310 @SYMREQ REQ0000 |
308 @SYMREQ REQ0000 |
311 */ |
309 */ |
312 LOCAL_C void TestRecentListsL(CLogClient& aClient, RFile& aFile) |
310 LOCAL_C void TestRecentListsL(CLogClient& aClient, RFile& aFile) |
313 { |
311 { |
314 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0992 ")); |
312 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0992 ")); |
315 aFile.Write(_L8("Recent Lists\n")); |
313 aFile.Write(_L8("Recent Lists\n")); |
316 |
314 |
317 CTestActive* active = new(ELeave)CTestActive(); |
315 CTestActive* active = new(ELeave)CTestActive(); |
318 CleanupStack::PushL(active); |
316 CleanupStack::PushL(active); |
319 |
317 |
397 TTimeIntervalMicroSeconds interval1 = afterAdd.MicroSecondsFrom(before); |
395 TTimeIntervalMicroSeconds interval1 = afterAdd.MicroSecondsFrom(before); |
398 TTimeIntervalMicroSeconds interval2 = afterNav.MicroSecondsFrom(afterAdd); |
396 TTimeIntervalMicroSeconds interval2 = afterNav.MicroSecondsFrom(afterAdd); |
399 |
397 |
400 // Store details in file |
398 // Store details in file |
401 TBuf8<256> buf; |
399 TBuf8<256> buf; |
402 test.Printf(_L(" Count: %d, Add: %d, Nav: %d\n"), duplicates, I64INT(interval1.Int64()), I64INT(interval2.Int64())); |
400 TheTest.Printf(_L(" Count: %d, Add: %d, Nav: %d\n"), duplicates, I64INT(interval1.Int64()), I64INT(interval2.Int64())); |
403 buf.Format(_L8("%d,%d,%d\n"), duplicates, I64INT(interval1.Int64()), I64INT(interval2.Int64())); |
401 buf.Format(_L8("%d,%d,%d\n"), duplicates, I64INT(interval1.Int64()), I64INT(interval2.Int64())); |
404 aFile.Write(buf); |
402 aFile.Write(buf); |
405 } |
403 } |
406 |
404 |
407 DoTestClearDuplicateL(aClient, KLogRecentIncomingCalls, aFile); |
405 DoTestClearDuplicateL(aClient, KLogRecentIncomingCalls, aFile); |
429 client->GetConfig(config, active->iStatus); |
427 client->GetConfig(config, active->iStatus); |
430 active->StartL(); |
428 active->StartL(); |
431 CActiveScheduler::Start(); |
429 CActiveScheduler::Start(); |
432 TEST2(active->iStatus.Int(), KErrNone); |
430 TEST2(active->iStatus.Int(), KErrNone); |
433 |
431 |
434 test.Start(_L("Setup")); |
432 TheTest.Start(_L("Setup")); |
435 TestSetupL(*client); |
433 TestSetupL(*client); |
436 theLog.Write(_L8("Test 1 OK\n")); |
434 theLog.Write(_L8("Test 1 OK\n")); |
437 |
435 |
438 RFile results; |
436 RFile results; |
439 LEAVE_IF_ERROR(results.Replace(theFs, KResultFile, EFileWrite|EFileShareExclusive)); |
437 LEAVE_IF_ERROR(results.Replace(theFs, KResultFile, EFileWrite|EFileShareExclusive)); |
440 |
438 |
441 test.Next(_L("Benchmark tests")); |
439 TheTest.Next(_L("Benchmark tests")); |
442 BenchmarkTestL(*client, results); |
440 BenchmarkTestL(*client, results); |
443 theLog.Write(_L8("Test 2 OK\n")); |
441 theLog.Write(_L8("Test 2 OK\n")); |
444 |
442 |
445 TestUtils::DeleteDatabaseL(); |
443 TestUtils::DeleteDatabaseL(); |
446 |
444 |
447 test.Next(_L("Recent List tests")); |
445 TheTest.Next(_L("Recent List tests")); |
448 TestRecentListsL(*client, results); |
446 TestRecentListsL(*client, results); |
449 theLog.Write(_L8("Test 3 OK\n")); |
447 theLog.Write(_L8("Test 3 OK\n")); |
450 |
448 |
451 // Restore Config |
449 // Restore Config |
452 client->ChangeConfig(config, active->iStatus); |
450 client->ChangeConfig(config, active->iStatus); |