First public contribution.
1 // Copyright (c) 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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32test\bench\t_notify_perf.cpp
18 #include "t_notify_perf.h"
21 RTest test(_L("Enhanced Notification Performance Test"));
23 extern void ClearTestPathL();
24 extern void SetTestPaths();
25 extern void CopyLogFilesL();
26 extern void DeleteLogFilesL();
30 ESingleSession = 0x01,
32 EOtherTestCase = 0x04,
37 const TInt KTestControlMask = 0x07;
39 // Note: Format of command line argument
40 // t_notify_perf <Drive> <-s|-m|-o> [-p] [-cplg] <Number>
42 // <Drive> The drive you want to run the test on
43 // -s Execute single session test - PBASE-T_NOTIFY-2456
44 // -m Execute multi sessions test - PBASE-T_NOTIFY-2457
45 // -o Execute other edge use test - PBASE-T_NOTIFY-2458
46 // -p Enable Mds plugin test, this does not take effect in multi session test
47 // -cplg Copy the log files to MMC card after test finish, not work for emulator. MMC drive hard coded to be "D"
48 // <Number> The number of files you want to use in the tests, does not take effect in other esge use test
50 // Function for parsing command line arguments for the test
51 LOCAL_C void ParseCmdArg(TUint16& aTestControl, TInt& aNumFiles)
55 User::CommandLine(cmd);
58 TPtrC token = lex.NextToken();
59 TFileName thisfile = RProcess().FileName();
60 if (token.MatchF(thisfile)==0)
62 token.Set(lex.NextToken());
67 gDriveToTest=token[0];
68 gDriveToTest.UpperCase();
77 token.Set(lex.NextToken());
78 if (token.Compare(_L("-s")) == 0 || token.Compare(_L("-S")) == 0)
80 aTestControl |= ESingleSession;
82 else if (token.Compare(_L("-m")) == 0 || token.Compare(_L("-M")) == 0)
84 aTestControl |= EMultiSession;
86 else if (token.Compare(_L("-o")) == 0 || token.Compare(_L("-O")) == 0)
88 aTestControl |= EOtherTestCase;
90 else if (token.Compare(_L("-p")) == 0 || token.Compare(_L("-P")) == 0)
92 aTestControl |= EPluginTest;
94 else if (token.Compare(_L("-cplg")) == 0 || token.Compare(_L("-CPLG")) == 0)
96 aTestControl |= ECopyLogs;
101 TInt r = valArg.Val(aNumFiles);
104 RDebug::Print(_L("Bad Argument: %S"), &token);
110 TInt mode = aTestControl & KTestControlMask;
111 if ((mode != ESingleSession) && (mode != EMultiSession) && (mode != EOtherTestCase))
113 RDebug::Print(_L("Bad Argument: One and only one mode (-s/-m/-o) should be set."));
114 test((mode == ESingleSession) || (mode == EMultiSession) || (mode == EOtherTestCase));
117 if ((aNumFiles <= 0) && ((mode == ESingleSession) || (mode == EMultiSession)))
119 RDebug::Print(_L("Bad Argument: number of files invalid"));
123 if ((aNumFiles > 0) && (mode == EOtherTestCase))
124 RDebug::Print(_L("File numbers ignored..."));
126 if ((mode == EMultiSession) && (aTestControl & EPluginTest))
127 RDebug::Print(_L("-p option ignored..."));
130 gLogPostFix.Append('_');
131 gLogPostFix.Append(gDriveToTest);
133 if (mode == EOtherTestCase)
134 gLogPostFix.Append(_L("_O"));
136 if ((aTestControl & EPluginTest) && (mode != EMultiSession))
137 gLogPostFix.Append(_L("_Plugin"));
139 if (mode != EOtherTestCase)
140 gLogPostFix.AppendFormat(_L("_%d"), aNumFiles);
142 gLogPostFix.Append(_L(".log"));
145 //---------------------------------------------
146 //! @SYMTestCaseID PBASE-T_NOTIFY-2456
149 //! @SYMTestCaseDesc Performance Test – Single File Server Session
150 //! @SYMTestActions Perform a series of file operations with different numbers with different notification
151 //! mechanism, measure the time taken and produce the log with the results
152 //! @SYMTestExpectedResults Figures of performance
153 //! @SYMTestPriority High
154 //! @SYMTestStatus Implemented
155 //---------------------------------------------
156 LOCAL_C void SingleFileSessionTestL(TInt aNum, TBool aRunPlugin)
158 test.Start(_L("Performance Test - Single File Server Session, Test Preparation"));
160 const TInt KNumClients = 1;
163 // ------------------ Files --------------------------
165 test.Next(_L("Files, Single file session, no notification"));
166 TTestSetting setting (aNum, 0, ENoNotify, KDefaultOpList);
167 CTestExecutor testcase (setting);
168 testcase.RunTestCaseL();
170 test.Next(_L("Files, Single file session, enhanced notification - Change reporting enabled"));
172 setting.iOption = (EEnhanced|EReportChg|EBigBuffer);
173 setting.iNumCli = KNumClients;
174 testcase.SetTestSetting(setting);
175 testcase.RunTestCaseL();
177 test.Next(_L("Files, Single file session, original notification - Change reporting enabled"));
179 setting.iOption = (EOriginal|EReportChg);
180 testcase.SetTestSetting(setting);
181 testcase.RunTestCaseL();
185 test.Next(_L("Files, Single file session, Plugin - Change reporting enabled"));
187 setting.iOption = (EPlugin|EReportChg);
188 testcase.SetTestSetting(setting);
189 testcase.RunTestCaseL();
192 test.Next(_L("Files, Single file session, enhanced notification - Change reporting disabled"));
194 setting.iOption = (EEnhanced|EBigBuffer);
195 testcase.SetTestSetting(setting);
196 testcase.RunTestCaseL();
198 test.Next(_L("Files, Single file session, original notification - Change reporting disabled"));
200 setting.iOption = (EOriginal);
201 testcase.SetTestSetting(setting);
202 testcase.RunTestCaseL();
206 test.Next(_L("Files, Single file session, Plugin - Change reporting disabled"));
208 setting.iOption = (EPlugin);
209 testcase.SetTestSetting(setting);
210 testcase.RunTestCaseL();
213 test.Next(_L("Files, Single file session, enhanced notification - with long list of filters"));
215 setting.iOption = (EEnhanced|EReportChg|EBigBuffer|EBigFilter);
216 testcase.SetTestSetting(setting);
217 testcase.RunTestCaseL();
219 // ------------------------- Directories -------------------------
220 test.Next(_L("Dirs, Single file session, enhanced notification"));
222 setting.iOperationList = KDefaultOpListDir;
223 setting.iOption = (EEnhanced|EReportChg|EBigBuffer);
224 testcase.SetTestSetting(setting);
225 testcase.RunTestCaseL();
227 test.Next(_L("Dirs, Single file session, original notification"));
229 setting.iOption = (EOriginal|EReportChg);
230 testcase.SetTestSetting(setting);
231 testcase.RunTestCaseL();
235 test.Next(_L("Dirs, Single file session, Plugin"));
237 setting.iOption = (EPlugin|EReportChg);
238 testcase.SetTestSetting(setting);
239 testcase.RunTestCaseL();
242 test.Next(_L("Test finishing - clearing test path"));
248 //---------------------------------------------
249 //! @SYMTestCaseID PBASE-T_NOTIFY-2457
252 //! @SYMTestCaseDesc Performance Test – Multiple File Server Sessions
253 //! @SYMTestActions Perform a series of file operations with different numbers with different notification
254 //! mechanism, create multiple notification threads to collect the notifications, measure
255 //! the time taken and produce the log with the results
256 //! @SYMTestExpectedResults Figures of performance
257 //! @SYMTestPriority High
258 //! @SYMTestStatus Implemented
259 //---------------------------------------------
260 LOCAL_C void MultipleFileSessionTestL(TInt aNum)
262 test.Start(_L("Performance Test - Multi File Server Session, Test Preparation"));
264 const TInt KNumClients = 4;
267 test.Next(_L("Multi file sessions, enhanced notification"));
268 TTestSetting setting (aNum, KNumClients, (EEnhanced|EReportChg|EBigBuffer), KDefaultOpList);
269 CTestExecutor testcase (setting);
270 testcase.RunTestCaseL();
272 test.Next(_L("Multi file sessions, original notification"));
274 setting.iOption = (EOriginal|EReportChg);
275 testcase.SetTestSetting(setting);
276 testcase.RunTestCaseL();
278 test.Next(_L("Multi file sessions, enhanced notification - Lots of Filters"));
280 setting.iOption = (EEnhanced|EReportChg|EBigFilter|EBigBuffer);
281 testcase.SetTestSetting(setting);
282 testcase.RunTestCaseL();
284 test.Next(_L("Multi file sessions, multi notifications Mode 1, enhanced notification"));
286 setting.iOption = (EEnhanced|EReportChg|EBigBuffer|EMultiNoti1);
287 testcase.SetTestSetting(setting);
288 testcase.RunTestCaseL();
290 test.Next(_L("Multi file sessions, multi notifications Mode 2, enhanced notification"));
292 setting.iOption = (EEnhanced|EReportChg|EBigBuffer|EMultiNoti2);
293 testcase.SetTestSetting(setting);
294 testcase.RunTestCaseL();
296 test.Next(_L("Test finishing - clearing test path"));
302 //---------------------------------------------
303 //! @SYMTestCaseID PBASE-T_NOTIFY-2458
306 //! @SYMTestCaseDesc Performance Test – Test of other edge use cases
307 //! @SYMTestActions Perform 1. Large number of changes in single file; 2. small changes in large number of files;
308 //! 3. Mixed File operations; on each kind of notification mechanism, and measure the performance
309 //! @SYMTestExpectedResults Figures of performance
310 //! @SYMTestPriority High
311 //! @SYMTestStatus Implemented
312 //---------------------------------------------
313 LOCAL_C void EdgeUseCaseTestL(TBool aRunPlugin)
315 test.Start(_L("Performance Test - Test of other edge use cases, Test Preparation"));
317 const TInt KNumChanges = 1000;
318 const TInt KNumMixed = 50; // using a small number because the mixed operation test will perform (18 * KNumMixed) operations
319 const TInt KNumClients = 1;
322 test.Next(_L("Single file session, enhanced notification, big number of changes on single file"));
323 TTestSetting setting (KNumChanges, KNumClients, (EEnhanced|EReportChg|EBigBuffer), KManyChangesOpList);
324 CTestExecutor testcase (setting);
325 testcase.RunTestCaseL();
327 test.Next(_L("Single file session, original notification, big number of changes on single file"));
329 setting.iOption = (EOriginal|EReportChg);
330 testcase.SetTestSetting(setting);
331 testcase.RunTestCaseL();
333 test.Next(_L("Single file session, enhanced notification, small changes on big number of files"));
335 setting.iOption = (EEnhanced|EReportChg|EBigBuffer);
336 setting.iOperationList = KManyFilesOpList;
337 testcase.SetTestSetting(setting);
338 testcase.RunTestCaseL();
340 test.Next(_L("Single file session, original notification, small changes on big number of files"));
342 setting.iOption = (EOriginal|EReportChg);
343 testcase.SetTestSetting(setting);
344 testcase.RunTestCaseL();
346 test.Next(_L("Single file session, enhanced notification, mixed file operations, big buffer"));
348 setting.iNumFiles = KNumMixed;
349 setting.iOption = (EEnhanced|EReportChg|EBigBuffer);
350 setting.iOperationList = KMixedOpTestList;
351 testcase.SetTestSetting(setting);
352 testcase.RunTestCaseL();
354 test.Next(_L("Single file session, original notification, mixed file operations"));
356 setting.iOption = (EOriginal|EReportChg);
357 testcase.SetTestSetting(setting);
358 testcase.RunTestCaseL();
362 test.Next(_L("Single file session, Plugin, mixed file operations"));
364 setting.iOption = (EPlugin|EReportChg);
365 testcase.SetTestSetting(setting);
366 testcase.RunTestCaseL();
369 test.Next(_L("Single file session, enhanced notification, mixed file operations, small buffer"));
371 setting.iOption = (EEnhanced|EReportChg);
372 testcase.SetTestSetting(setting);
373 testcase.RunTestCaseL();
375 test.Next(_L("Test finishing - clearing test path"));
381 GLDEF_C void CallTestsL()
383 test.Start(_L("Enhanced Notification Performance Test - Initializing..."));
385 gPerfMeasure = ETrue;
389 ParseCmdArg(ctrl, num);
394 if (ctrl & ESingleSession)
396 test.Next(_L("Performance Test - Single File Server Session"));
397 SingleFileSessionTestL(num, (ctrl & EPluginTest));
400 if (ctrl & EMultiSession)
402 test.Next(_L("Performance Test - Multi File Server Session"));
403 MultipleFileSessionTestL(num);
406 if (ctrl & EOtherTestCase)
408 test.Next(_L("Performance Test - Test of other edge use cases"));
409 EdgeUseCaseTestL(ctrl & EPluginTest);
412 if (ctrl & ECopyLogs)