os/kernelhwsrv/kerneltest/f32test/bench/t_notify_perf.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // f32test\bench\t_notify_perf.cpp
    15 // 
    16 //
    17 
    18 #include "t_notify_perf.h"
    19 #include "t_server.h"
    20 
    21 RTest test(_L("Enhanced Notification Performance Test"));
    22 
    23 extern void ClearTestPathL();
    24 extern void SetTestPaths();
    25 extern void CopyLogFilesL();
    26 extern void DeleteLogFilesL();
    27 
    28 enum TTestControl
    29     {
    30     ESingleSession  = 0x01,
    31     EMultiSession   = 0x02,
    32     EOtherTestCase  = 0x04,
    33     EPluginTest     = 0x08,
    34     ECopyLogs       = 0x10
    35     };
    36 
    37 const TInt KTestControlMask = 0x07;
    38 
    39 // Note: Format of command line argument
    40 // t_notify_perf <Drive> <-s|-m|-o> [-p] [-cplg] <Number>
    41 //
    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   
    49 
    50 // Function for parsing command line arguments for the test
    51 LOCAL_C void ParseCmdArg(TUint16& aTestControl, TInt& aNumFiles)
    52 
    53     {
    54     TBuf<0x100> cmd;
    55     User::CommandLine(cmd);
    56     TLex lex(cmd);
    57     
    58     TPtrC token = lex.NextToken();
    59     TFileName thisfile = RProcess().FileName();
    60     if (token.MatchF(thisfile)==0)
    61         {
    62         token.Set(lex.NextToken());
    63         }
    64 
    65     if(token.Length()!=0)       
    66         {
    67         gDriveToTest=token[0];
    68         gDriveToTest.UpperCase();
    69         }
    70     else
    71         {
    72         gDriveToTest='C';
    73         }
    74     
    75     while (!lex.Eos())
    76         {
    77         token.Set(lex.NextToken());
    78         if (token.Compare(_L("-s")) == 0 || token.Compare(_L("-S")) == 0)
    79             {
    80             aTestControl |= ESingleSession;
    81             }
    82         else if (token.Compare(_L("-m")) == 0 || token.Compare(_L("-M")) == 0)
    83             {
    84             aTestControl |= EMultiSession;
    85             }
    86         else if (token.Compare(_L("-o")) == 0 || token.Compare(_L("-O")) == 0)
    87             {
    88             aTestControl |= EOtherTestCase;
    89             }
    90         else if (token.Compare(_L("-p")) == 0 || token.Compare(_L("-P")) == 0)
    91             {
    92             aTestControl |= EPluginTest;
    93             }
    94         else if (token.Compare(_L("-cplg")) == 0 || token.Compare(_L("-CPLG")) == 0)
    95             {
    96             aTestControl |= ECopyLogs;
    97             }
    98         else
    99             {
   100             TLex valArg(token);
   101             TInt r = valArg.Val(aNumFiles);
   102             if (r != KErrNone)
   103                 {
   104                 RDebug::Print(_L("Bad Argument: %S"), &token);
   105                 test(r == KErrNone);
   106                 }
   107             }
   108         }
   109     
   110     TInt mode = aTestControl & KTestControlMask;
   111     if ((mode != ESingleSession) && (mode != EMultiSession) && (mode != EOtherTestCase))
   112         {
   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));
   115         }
   116     
   117     if ((aNumFiles <= 0) && ((mode == ESingleSession) || (mode == EMultiSession)))
   118         {
   119         RDebug::Print(_L("Bad Argument: number of files invalid"));
   120         test(aNumFiles > 0);
   121         }
   122     
   123     if ((aNumFiles > 0) && (mode == EOtherTestCase))
   124         RDebug::Print(_L("File numbers ignored..."));
   125     
   126     if ((mode == EMultiSession) && (aTestControl & EPluginTest))
   127         RDebug::Print(_L("-p option ignored..."));
   128     
   129     gLogPostFix.FillZ();
   130     gLogPostFix.Append('_');
   131     gLogPostFix.Append(gDriveToTest);
   132     
   133     if (mode == EOtherTestCase)
   134         gLogPostFix.Append(_L("_O"));
   135     
   136     if ((aTestControl & EPluginTest) && (mode != EMultiSession))
   137         gLogPostFix.Append(_L("_Plugin"));
   138     
   139     if (mode != EOtherTestCase)
   140         gLogPostFix.AppendFormat(_L("_%d"), aNumFiles);
   141 
   142     gLogPostFix.Append(_L(".log"));
   143     }
   144 
   145 //---------------------------------------------
   146 //! @SYMTestCaseID			PBASE-T_NOTIFY-2456
   147 //! @SYMTestType 			PT
   148 //! @SYMREQ 				PREQ1847
   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)
   157 	{
   158 	test.Start(_L("Performance Test - Single File Server Session, Test Preparation"));
   159 	
   160 	const TInt KNumClients = 1;
   161 	ClearTestPathL();
   162 	
   163 	// ------------------ Files --------------------------
   164 	
   165 	test.Next(_L("Files, Single file session, no notification"));
   166 	TTestSetting setting (aNum, 0, ENoNotify, KDefaultOpList);
   167 	CTestExecutor testcase (setting);
   168 	testcase.RunTestCaseL();
   169 
   170 	test.Next(_L("Files, Single file session, enhanced notification - Change reporting enabled"));
   171 	ClearTestPathL();
   172 	setting.iOption = (EEnhanced|EReportChg|EBigBuffer);
   173 	setting.iNumCli = KNumClients;
   174 	testcase.SetTestSetting(setting);
   175 	testcase.RunTestCaseL();
   176 	
   177 	test.Next(_L("Files, Single file session, original notification - Change reporting enabled"));
   178 	ClearTestPathL();
   179 	setting.iOption = (EOriginal|EReportChg);
   180 	testcase.SetTestSetting(setting);
   181 	testcase.RunTestCaseL();
   182 
   183 	if (aRunPlugin)
   184 	    {
   185         test.Next(_L("Files, Single file session, Plugin - Change reporting enabled"));
   186         ClearTestPathL();
   187         setting.iOption = (EPlugin|EReportChg);
   188         testcase.SetTestSetting(setting);
   189         testcase.RunTestCaseL();
   190 	    }
   191 	
   192 	test.Next(_L("Files, Single file session, enhanced notification - Change reporting disabled"));
   193 	ClearTestPathL();
   194 	setting.iOption = (EEnhanced|EBigBuffer);
   195 	testcase.SetTestSetting(setting);
   196 	testcase.RunTestCaseL();
   197 	
   198 	test.Next(_L("Files, Single file session, original notification - Change reporting disabled"));
   199 	ClearTestPathL();
   200 	setting.iOption = (EOriginal);
   201 	testcase.SetTestSetting(setting);
   202 	testcase.RunTestCaseL();
   203 
   204     if (aRunPlugin)
   205         {
   206         test.Next(_L("Files, Single file session, Plugin - Change reporting disabled"));
   207         ClearTestPathL();
   208         setting.iOption = (EPlugin);
   209         testcase.SetTestSetting(setting);
   210         testcase.RunTestCaseL();
   211         }
   212     
   213 	test.Next(_L("Files, Single file session, enhanced notification - with long list of filters"));
   214 	ClearTestPathL();
   215 	setting.iOption = (EEnhanced|EReportChg|EBigBuffer|EBigFilter);
   216 	testcase.SetTestSetting(setting);
   217 	testcase.RunTestCaseL();
   218 
   219 	// ------------------------- Directories -------------------------
   220 	test.Next(_L("Dirs, Single file session, enhanced notification"));
   221 	ClearTestPathL();
   222 	setting.iOperationList = KDefaultOpListDir;
   223 	setting.iOption = (EEnhanced|EReportChg|EBigBuffer);
   224 	testcase.SetTestSetting(setting);
   225 	testcase.RunTestCaseL();
   226 	
   227 	test.Next(_L("Dirs, Single file session, original notification"));
   228 	ClearTestPathL();
   229 	setting.iOption = (EOriginal|EReportChg);
   230 	testcase.SetTestSetting(setting);
   231 	testcase.RunTestCaseL();
   232 
   233     if (aRunPlugin)
   234         {
   235         test.Next(_L("Dirs, Single file session, Plugin"));
   236         ClearTestPathL();
   237         setting.iOption = (EPlugin|EReportChg);
   238         testcase.SetTestSetting(setting);
   239         testcase.RunTestCaseL();
   240         }
   241 
   242 	test.Next(_L("Test finishing - clearing test path"));
   243 	
   244 	ClearTestPathL();
   245 	test.End();
   246 	}
   247 
   248 //---------------------------------------------
   249 //! @SYMTestCaseID          PBASE-T_NOTIFY-2457
   250 //! @SYMTestType            PT
   251 //! @SYMREQ                 PREQ1847
   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)
   261     {
   262     test.Start(_L("Performance Test - Multi File Server Session, Test Preparation"));
   263     
   264     const TInt KNumClients = 4;
   265     ClearTestPathL();
   266     
   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();
   271     
   272     test.Next(_L("Multi file sessions, original notification"));
   273     ClearTestPathL();
   274     setting.iOption = (EOriginal|EReportChg);
   275     testcase.SetTestSetting(setting);
   276     testcase.RunTestCaseL();
   277     
   278     test.Next(_L("Multi file sessions, enhanced notification - Lots of Filters"));
   279     ClearTestPathL();
   280     setting.iOption = (EEnhanced|EReportChg|EBigFilter|EBigBuffer);
   281     testcase.SetTestSetting(setting);
   282     testcase.RunTestCaseL();
   283     
   284     test.Next(_L("Multi file sessions, multi notifications Mode 1, enhanced notification"));
   285     ClearTestPathL();
   286     setting.iOption = (EEnhanced|EReportChg|EBigBuffer|EMultiNoti1);
   287     testcase.SetTestSetting(setting);
   288     testcase.RunTestCaseL();
   289     
   290     test.Next(_L("Multi file sessions, multi notifications Mode 2, enhanced notification"));
   291     ClearTestPathL();
   292     setting.iOption = (EEnhanced|EReportChg|EBigBuffer|EMultiNoti2);
   293     testcase.SetTestSetting(setting);
   294     testcase.RunTestCaseL();
   295     
   296     test.Next(_L("Test finishing - clearing test path"));
   297     
   298     ClearTestPathL();
   299     test.End();
   300     }
   301 
   302 //---------------------------------------------
   303 //! @SYMTestCaseID			PBASE-T_NOTIFY-2458
   304 //! @SYMTestType 			PT
   305 //! @SYMREQ 				PREQ1847
   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)
   314 	{
   315 	test.Start(_L("Performance Test - Test of other edge use cases, Test Preparation"));
   316 	
   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;
   320 	ClearTestPathL();
   321 	
   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();
   326 	
   327 	test.Next(_L("Single file session, original notification, big number of changes on single file"));
   328 	ClearTestPathL();
   329 	setting.iOption = (EOriginal|EReportChg);
   330 	testcase.SetTestSetting(setting);
   331 	testcase.RunTestCaseL();
   332 	
   333 	test.Next(_L("Single file session, enhanced notification, small changes on big number of files"));
   334 	ClearTestPathL();
   335 	setting.iOption = (EEnhanced|EReportChg|EBigBuffer);
   336 	setting.iOperationList = KManyFilesOpList;
   337 	testcase.SetTestSetting(setting);
   338 	testcase.RunTestCaseL();
   339 	
   340 	test.Next(_L("Single file session, original notification, small changes on big number of files"));
   341 	ClearTestPathL();
   342 	setting.iOption = (EOriginal|EReportChg);
   343 	testcase.SetTestSetting(setting);
   344 	testcase.RunTestCaseL();	
   345 
   346 	test.Next(_L("Single file session, enhanced notification, mixed file operations, big buffer"));
   347 	ClearTestPathL();
   348 	setting.iNumFiles = KNumMixed;
   349 	setting.iOption = (EEnhanced|EReportChg|EBigBuffer);
   350 	setting.iOperationList = KMixedOpTestList;
   351 	testcase.SetTestSetting(setting);
   352 	testcase.RunTestCaseL();
   353 	
   354 	test.Next(_L("Single file session, original notification, mixed file operations"));
   355 	ClearTestPathL();
   356 	setting.iOption = (EOriginal|EReportChg);
   357 	testcase.SetTestSetting(setting);
   358 	testcase.RunTestCaseL();
   359 
   360     if (aRunPlugin)
   361         {
   362         test.Next(_L("Single file session, Plugin, mixed file operations"));
   363         ClearTestPathL();
   364         setting.iOption = (EPlugin|EReportChg);
   365         testcase.SetTestSetting(setting);
   366         testcase.RunTestCaseL();
   367         }
   368 	
   369 	test.Next(_L("Single file session, enhanced notification, mixed file operations, small buffer"));
   370 	ClearTestPathL();
   371 	setting.iOption = (EEnhanced|EReportChg);
   372 	testcase.SetTestSetting(setting);
   373 	testcase.RunTestCaseL();
   374 	
   375 	test.Next(_L("Test finishing - clearing test path"));
   376 	ClearTestPathL();
   377 	test.End();
   378 	}
   379 
   380 // Entry Point
   381 GLDEF_C void CallTestsL()
   382 	{
   383 	test.Start(_L("Enhanced Notification Performance Test - Initializing...")); 
   384 	 
   385 	gPerfMeasure = ETrue;
   386 	
   387 	TUint16 ctrl = 0;
   388 	TInt num = 0;
   389 	ParseCmdArg(ctrl, num);
   390 
   391 	SetTestPaths();
   392 	DeleteLogFilesL();
   393 	
   394 	if (ctrl & ESingleSession)
   395 	    {
   396         test.Next(_L("Performance Test - Single File Server Session")); 
   397         SingleFileSessionTestL(num, (ctrl & EPluginTest));
   398 	    }
   399 	
   400 	if (ctrl & EMultiSession)
   401 	    {
   402         test.Next(_L("Performance Test - Multi File Server Session"));
   403         MultipleFileSessionTestL(num);
   404 	    }
   405 	
   406 	if (ctrl & EOtherTestCase)
   407 	    {
   408         test.Next(_L("Performance Test - Test of other edge use cases"));
   409         EdgeUseCaseTestL(ctrl & EPluginTest);
   410 	    }
   411 
   412 	if (ctrl & ECopyLogs)
   413 	    {
   414 #ifndef __WINSCW__
   415 	    CopyLogFilesL();
   416 #endif
   417 	    }
   418 
   419 	test.End();
   420 	test.Close();
   421 	}
   422 
   423 
   424