os/kernelhwsrv/kerneltest/f32test/bench/t_notify_perf.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// f32test\bench\t_notify_perf.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "t_notify_perf.h"
sl@0
    19
#include "t_server.h"
sl@0
    20
sl@0
    21
RTest test(_L("Enhanced Notification Performance Test"));
sl@0
    22
sl@0
    23
extern void ClearTestPathL();
sl@0
    24
extern void SetTestPaths();
sl@0
    25
extern void CopyLogFilesL();
sl@0
    26
extern void DeleteLogFilesL();
sl@0
    27
sl@0
    28
enum TTestControl
sl@0
    29
    {
sl@0
    30
    ESingleSession  = 0x01,
sl@0
    31
    EMultiSession   = 0x02,
sl@0
    32
    EOtherTestCase  = 0x04,
sl@0
    33
    EPluginTest     = 0x08,
sl@0
    34
    ECopyLogs       = 0x10
sl@0
    35
    };
sl@0
    36
sl@0
    37
const TInt KTestControlMask = 0x07;
sl@0
    38
sl@0
    39
// Note: Format of command line argument
sl@0
    40
// t_notify_perf <Drive> <-s|-m|-o> [-p] [-cplg] <Number>
sl@0
    41
//
sl@0
    42
// <Drive>  The drive you want to run the test on
sl@0
    43
// -s       Execute single session test - PBASE-T_NOTIFY-2456
sl@0
    44
// -m       Execute multi sessions test - PBASE-T_NOTIFY-2457
sl@0
    45
// -o       Execute other edge use test - PBASE-T_NOTIFY-2458
sl@0
    46
// -p       Enable Mds plugin test, this does not take effect in multi session test
sl@0
    47
// -cplg    Copy the log files to MMC card after test finish, not work for emulator. MMC drive hard coded to be "D"
sl@0
    48
// <Number> The number of files you want to use in the tests, does not take effect in other esge use test   
sl@0
    49
sl@0
    50
// Function for parsing command line arguments for the test
sl@0
    51
LOCAL_C void ParseCmdArg(TUint16& aTestControl, TInt& aNumFiles)
sl@0
    52
sl@0
    53
    {
sl@0
    54
    TBuf<0x100> cmd;
sl@0
    55
    User::CommandLine(cmd);
sl@0
    56
    TLex lex(cmd);
sl@0
    57
    
sl@0
    58
    TPtrC token = lex.NextToken();
sl@0
    59
    TFileName thisfile = RProcess().FileName();
sl@0
    60
    if (token.MatchF(thisfile)==0)
sl@0
    61
        {
sl@0
    62
        token.Set(lex.NextToken());
sl@0
    63
        }
sl@0
    64
sl@0
    65
    if(token.Length()!=0)       
sl@0
    66
        {
sl@0
    67
        gDriveToTest=token[0];
sl@0
    68
        gDriveToTest.UpperCase();
sl@0
    69
        }
sl@0
    70
    else
sl@0
    71
        {
sl@0
    72
        gDriveToTest='C';
sl@0
    73
        }
sl@0
    74
    
sl@0
    75
    while (!lex.Eos())
sl@0
    76
        {
sl@0
    77
        token.Set(lex.NextToken());
sl@0
    78
        if (token.Compare(_L("-s")) == 0 || token.Compare(_L("-S")) == 0)
sl@0
    79
            {
sl@0
    80
            aTestControl |= ESingleSession;
sl@0
    81
            }
sl@0
    82
        else if (token.Compare(_L("-m")) == 0 || token.Compare(_L("-M")) == 0)
sl@0
    83
            {
sl@0
    84
            aTestControl |= EMultiSession;
sl@0
    85
            }
sl@0
    86
        else if (token.Compare(_L("-o")) == 0 || token.Compare(_L("-O")) == 0)
sl@0
    87
            {
sl@0
    88
            aTestControl |= EOtherTestCase;
sl@0
    89
            }
sl@0
    90
        else if (token.Compare(_L("-p")) == 0 || token.Compare(_L("-P")) == 0)
sl@0
    91
            {
sl@0
    92
            aTestControl |= EPluginTest;
sl@0
    93
            }
sl@0
    94
        else if (token.Compare(_L("-cplg")) == 0 || token.Compare(_L("-CPLG")) == 0)
sl@0
    95
            {
sl@0
    96
            aTestControl |= ECopyLogs;
sl@0
    97
            }
sl@0
    98
        else
sl@0
    99
            {
sl@0
   100
            TLex valArg(token);
sl@0
   101
            TInt r = valArg.Val(aNumFiles);
sl@0
   102
            if (r != KErrNone)
sl@0
   103
                {
sl@0
   104
                RDebug::Print(_L("Bad Argument: %S"), &token);
sl@0
   105
                test(r == KErrNone);
sl@0
   106
                }
sl@0
   107
            }
sl@0
   108
        }
sl@0
   109
    
sl@0
   110
    TInt mode = aTestControl & KTestControlMask;
sl@0
   111
    if ((mode != ESingleSession) && (mode != EMultiSession) && (mode != EOtherTestCase))
sl@0
   112
        {
sl@0
   113
        RDebug::Print(_L("Bad Argument: One and only one mode (-s/-m/-o) should be set."));
sl@0
   114
        test((mode == ESingleSession) || (mode == EMultiSession) || (mode == EOtherTestCase));
sl@0
   115
        }
sl@0
   116
    
sl@0
   117
    if ((aNumFiles <= 0) && ((mode == ESingleSession) || (mode == EMultiSession)))
sl@0
   118
        {
sl@0
   119
        RDebug::Print(_L("Bad Argument: number of files invalid"));
sl@0
   120
        test(aNumFiles > 0);
sl@0
   121
        }
sl@0
   122
    
sl@0
   123
    if ((aNumFiles > 0) && (mode == EOtherTestCase))
sl@0
   124
        RDebug::Print(_L("File numbers ignored..."));
sl@0
   125
    
sl@0
   126
    if ((mode == EMultiSession) && (aTestControl & EPluginTest))
sl@0
   127
        RDebug::Print(_L("-p option ignored..."));
sl@0
   128
    
sl@0
   129
    gLogPostFix.FillZ();
sl@0
   130
    gLogPostFix.Append('_');
sl@0
   131
    gLogPostFix.Append(gDriveToTest);
sl@0
   132
    
sl@0
   133
    if (mode == EOtherTestCase)
sl@0
   134
        gLogPostFix.Append(_L("_O"));
sl@0
   135
    
sl@0
   136
    if ((aTestControl & EPluginTest) && (mode != EMultiSession))
sl@0
   137
        gLogPostFix.Append(_L("_Plugin"));
sl@0
   138
    
sl@0
   139
    if (mode != EOtherTestCase)
sl@0
   140
        gLogPostFix.AppendFormat(_L("_%d"), aNumFiles);
sl@0
   141
sl@0
   142
    gLogPostFix.Append(_L(".log"));
sl@0
   143
    }
sl@0
   144
sl@0
   145
//---------------------------------------------
sl@0
   146
//! @SYMTestCaseID			PBASE-T_NOTIFY-2456
sl@0
   147
//! @SYMTestType 			PT
sl@0
   148
//! @SYMREQ 				PREQ1847
sl@0
   149
//! @SYMTestCaseDesc 		Performance Test – Single File Server Session
sl@0
   150
//! @SYMTestActions         Perform a series of file operations with different numbers with different notification
sl@0
   151
//!                         mechanism, measure the time taken and produce the log with the results
sl@0
   152
//! @SYMTestExpectedResults	Figures of performance
sl@0
   153
//! @SYMTestPriority        High
sl@0
   154
//! @SYMTestStatus          Implemented
sl@0
   155
//---------------------------------------------
sl@0
   156
LOCAL_C void SingleFileSessionTestL(TInt aNum, TBool aRunPlugin)
sl@0
   157
	{
sl@0
   158
	test.Start(_L("Performance Test - Single File Server Session, Test Preparation"));
sl@0
   159
	
sl@0
   160
	const TInt KNumClients = 1;
sl@0
   161
	ClearTestPathL();
sl@0
   162
	
sl@0
   163
	// ------------------ Files --------------------------
sl@0
   164
	
sl@0
   165
	test.Next(_L("Files, Single file session, no notification"));
sl@0
   166
	TTestSetting setting (aNum, 0, ENoNotify, KDefaultOpList);
sl@0
   167
	CTestExecutor testcase (setting);
sl@0
   168
	testcase.RunTestCaseL();
sl@0
   169
sl@0
   170
	test.Next(_L("Files, Single file session, enhanced notification - Change reporting enabled"));
sl@0
   171
	ClearTestPathL();
sl@0
   172
	setting.iOption = (EEnhanced|EReportChg|EBigBuffer);
sl@0
   173
	setting.iNumCli = KNumClients;
sl@0
   174
	testcase.SetTestSetting(setting);
sl@0
   175
	testcase.RunTestCaseL();
sl@0
   176
	
sl@0
   177
	test.Next(_L("Files, Single file session, original notification - Change reporting enabled"));
sl@0
   178
	ClearTestPathL();
sl@0
   179
	setting.iOption = (EOriginal|EReportChg);
sl@0
   180
	testcase.SetTestSetting(setting);
sl@0
   181
	testcase.RunTestCaseL();
sl@0
   182
sl@0
   183
	if (aRunPlugin)
sl@0
   184
	    {
sl@0
   185
        test.Next(_L("Files, Single file session, Plugin - Change reporting enabled"));
sl@0
   186
        ClearTestPathL();
sl@0
   187
        setting.iOption = (EPlugin|EReportChg);
sl@0
   188
        testcase.SetTestSetting(setting);
sl@0
   189
        testcase.RunTestCaseL();
sl@0
   190
	    }
sl@0
   191
	
sl@0
   192
	test.Next(_L("Files, Single file session, enhanced notification - Change reporting disabled"));
sl@0
   193
	ClearTestPathL();
sl@0
   194
	setting.iOption = (EEnhanced|EBigBuffer);
sl@0
   195
	testcase.SetTestSetting(setting);
sl@0
   196
	testcase.RunTestCaseL();
sl@0
   197
	
sl@0
   198
	test.Next(_L("Files, Single file session, original notification - Change reporting disabled"));
sl@0
   199
	ClearTestPathL();
sl@0
   200
	setting.iOption = (EOriginal);
sl@0
   201
	testcase.SetTestSetting(setting);
sl@0
   202
	testcase.RunTestCaseL();
sl@0
   203
sl@0
   204
    if (aRunPlugin)
sl@0
   205
        {
sl@0
   206
        test.Next(_L("Files, Single file session, Plugin - Change reporting disabled"));
sl@0
   207
        ClearTestPathL();
sl@0
   208
        setting.iOption = (EPlugin);
sl@0
   209
        testcase.SetTestSetting(setting);
sl@0
   210
        testcase.RunTestCaseL();
sl@0
   211
        }
sl@0
   212
    
sl@0
   213
	test.Next(_L("Files, Single file session, enhanced notification - with long list of filters"));
sl@0
   214
	ClearTestPathL();
sl@0
   215
	setting.iOption = (EEnhanced|EReportChg|EBigBuffer|EBigFilter);
sl@0
   216
	testcase.SetTestSetting(setting);
sl@0
   217
	testcase.RunTestCaseL();
sl@0
   218
sl@0
   219
	// ------------------------- Directories -------------------------
sl@0
   220
	test.Next(_L("Dirs, Single file session, enhanced notification"));
sl@0
   221
	ClearTestPathL();
sl@0
   222
	setting.iOperationList = KDefaultOpListDir;
sl@0
   223
	setting.iOption = (EEnhanced|EReportChg|EBigBuffer);
sl@0
   224
	testcase.SetTestSetting(setting);
sl@0
   225
	testcase.RunTestCaseL();
sl@0
   226
	
sl@0
   227
	test.Next(_L("Dirs, Single file session, original notification"));
sl@0
   228
	ClearTestPathL();
sl@0
   229
	setting.iOption = (EOriginal|EReportChg);
sl@0
   230
	testcase.SetTestSetting(setting);
sl@0
   231
	testcase.RunTestCaseL();
sl@0
   232
sl@0
   233
    if (aRunPlugin)
sl@0
   234
        {
sl@0
   235
        test.Next(_L("Dirs, Single file session, Plugin"));
sl@0
   236
        ClearTestPathL();
sl@0
   237
        setting.iOption = (EPlugin|EReportChg);
sl@0
   238
        testcase.SetTestSetting(setting);
sl@0
   239
        testcase.RunTestCaseL();
sl@0
   240
        }
sl@0
   241
sl@0
   242
	test.Next(_L("Test finishing - clearing test path"));
sl@0
   243
	
sl@0
   244
	ClearTestPathL();
sl@0
   245
	test.End();
sl@0
   246
	}
sl@0
   247
sl@0
   248
//---------------------------------------------
sl@0
   249
//! @SYMTestCaseID          PBASE-T_NOTIFY-2457
sl@0
   250
//! @SYMTestType            PT
sl@0
   251
//! @SYMREQ                 PREQ1847
sl@0
   252
//! @SYMTestCaseDesc        Performance Test – Multiple File Server Sessions
sl@0
   253
//! @SYMTestActions         Perform a series of file operations with different numbers with different notification
sl@0
   254
//!                         mechanism, create multiple notification threads to collect the notifications, measure 
sl@0
   255
//!                         the time taken and produce the log with the results
sl@0
   256
//! @SYMTestExpectedResults Figures of performance
sl@0
   257
//! @SYMTestPriority        High
sl@0
   258
//! @SYMTestStatus          Implemented
sl@0
   259
//---------------------------------------------
sl@0
   260
LOCAL_C void MultipleFileSessionTestL(TInt aNum)
sl@0
   261
    {
sl@0
   262
    test.Start(_L("Performance Test - Multi File Server Session, Test Preparation"));
sl@0
   263
    
sl@0
   264
    const TInt KNumClients = 4;
sl@0
   265
    ClearTestPathL();
sl@0
   266
    
sl@0
   267
    test.Next(_L("Multi file sessions, enhanced notification"));
sl@0
   268
    TTestSetting setting (aNum, KNumClients, (EEnhanced|EReportChg|EBigBuffer), KDefaultOpList);
sl@0
   269
    CTestExecutor testcase (setting);
sl@0
   270
    testcase.RunTestCaseL();
sl@0
   271
    
sl@0
   272
    test.Next(_L("Multi file sessions, original notification"));
sl@0
   273
    ClearTestPathL();
sl@0
   274
    setting.iOption = (EOriginal|EReportChg);
sl@0
   275
    testcase.SetTestSetting(setting);
sl@0
   276
    testcase.RunTestCaseL();
sl@0
   277
    
sl@0
   278
    test.Next(_L("Multi file sessions, enhanced notification - Lots of Filters"));
sl@0
   279
    ClearTestPathL();
sl@0
   280
    setting.iOption = (EEnhanced|EReportChg|EBigFilter|EBigBuffer);
sl@0
   281
    testcase.SetTestSetting(setting);
sl@0
   282
    testcase.RunTestCaseL();
sl@0
   283
    
sl@0
   284
    test.Next(_L("Multi file sessions, multi notifications Mode 1, enhanced notification"));
sl@0
   285
    ClearTestPathL();
sl@0
   286
    setting.iOption = (EEnhanced|EReportChg|EBigBuffer|EMultiNoti1);
sl@0
   287
    testcase.SetTestSetting(setting);
sl@0
   288
    testcase.RunTestCaseL();
sl@0
   289
    
sl@0
   290
    test.Next(_L("Multi file sessions, multi notifications Mode 2, enhanced notification"));
sl@0
   291
    ClearTestPathL();
sl@0
   292
    setting.iOption = (EEnhanced|EReportChg|EBigBuffer|EMultiNoti2);
sl@0
   293
    testcase.SetTestSetting(setting);
sl@0
   294
    testcase.RunTestCaseL();
sl@0
   295
    
sl@0
   296
    test.Next(_L("Test finishing - clearing test path"));
sl@0
   297
    
sl@0
   298
    ClearTestPathL();
sl@0
   299
    test.End();
sl@0
   300
    }
sl@0
   301
sl@0
   302
//---------------------------------------------
sl@0
   303
//! @SYMTestCaseID			PBASE-T_NOTIFY-2458
sl@0
   304
//! @SYMTestType 			PT
sl@0
   305
//! @SYMREQ 				PREQ1847
sl@0
   306
//! @SYMTestCaseDesc 		Performance Test – Test of other edge use cases
sl@0
   307
//! @SYMTestActions         Perform 1. Large number of changes in single file; 2. small changes in large number of files;
sl@0
   308
//!                         3. Mixed File operations; on each kind of notification mechanism, and measure the performance
sl@0
   309
//! @SYMTestExpectedResults	Figures of performance
sl@0
   310
//! @SYMTestPriority        High
sl@0
   311
//! @SYMTestStatus          Implemented
sl@0
   312
//---------------------------------------------
sl@0
   313
LOCAL_C void EdgeUseCaseTestL(TBool aRunPlugin)
sl@0
   314
	{
sl@0
   315
	test.Start(_L("Performance Test - Test of other edge use cases, Test Preparation"));
sl@0
   316
	
sl@0
   317
	const TInt KNumChanges = 1000;
sl@0
   318
	const TInt KNumMixed = 50;	// using a small number because the mixed operation test will perform (18 * KNumMixed) operations
sl@0
   319
	const TInt KNumClients = 1;
sl@0
   320
	ClearTestPathL();
sl@0
   321
	
sl@0
   322
	test.Next(_L("Single file session, enhanced notification, big number of changes on single file"));
sl@0
   323
	TTestSetting setting (KNumChanges, KNumClients, (EEnhanced|EReportChg|EBigBuffer), KManyChangesOpList);
sl@0
   324
	CTestExecutor testcase (setting);
sl@0
   325
	testcase.RunTestCaseL();
sl@0
   326
	
sl@0
   327
	test.Next(_L("Single file session, original notification, big number of changes on single file"));
sl@0
   328
	ClearTestPathL();
sl@0
   329
	setting.iOption = (EOriginal|EReportChg);
sl@0
   330
	testcase.SetTestSetting(setting);
sl@0
   331
	testcase.RunTestCaseL();
sl@0
   332
	
sl@0
   333
	test.Next(_L("Single file session, enhanced notification, small changes on big number of files"));
sl@0
   334
	ClearTestPathL();
sl@0
   335
	setting.iOption = (EEnhanced|EReportChg|EBigBuffer);
sl@0
   336
	setting.iOperationList = KManyFilesOpList;
sl@0
   337
	testcase.SetTestSetting(setting);
sl@0
   338
	testcase.RunTestCaseL();
sl@0
   339
	
sl@0
   340
	test.Next(_L("Single file session, original notification, small changes on big number of files"));
sl@0
   341
	ClearTestPathL();
sl@0
   342
	setting.iOption = (EOriginal|EReportChg);
sl@0
   343
	testcase.SetTestSetting(setting);
sl@0
   344
	testcase.RunTestCaseL();	
sl@0
   345
sl@0
   346
	test.Next(_L("Single file session, enhanced notification, mixed file operations, big buffer"));
sl@0
   347
	ClearTestPathL();
sl@0
   348
	setting.iNumFiles = KNumMixed;
sl@0
   349
	setting.iOption = (EEnhanced|EReportChg|EBigBuffer);
sl@0
   350
	setting.iOperationList = KMixedOpTestList;
sl@0
   351
	testcase.SetTestSetting(setting);
sl@0
   352
	testcase.RunTestCaseL();
sl@0
   353
	
sl@0
   354
	test.Next(_L("Single file session, original notification, mixed file operations"));
sl@0
   355
	ClearTestPathL();
sl@0
   356
	setting.iOption = (EOriginal|EReportChg);
sl@0
   357
	testcase.SetTestSetting(setting);
sl@0
   358
	testcase.RunTestCaseL();
sl@0
   359
sl@0
   360
    if (aRunPlugin)
sl@0
   361
        {
sl@0
   362
        test.Next(_L("Single file session, Plugin, mixed file operations"));
sl@0
   363
        ClearTestPathL();
sl@0
   364
        setting.iOption = (EPlugin|EReportChg);
sl@0
   365
        testcase.SetTestSetting(setting);
sl@0
   366
        testcase.RunTestCaseL();
sl@0
   367
        }
sl@0
   368
	
sl@0
   369
	test.Next(_L("Single file session, enhanced notification, mixed file operations, small buffer"));
sl@0
   370
	ClearTestPathL();
sl@0
   371
	setting.iOption = (EEnhanced|EReportChg);
sl@0
   372
	testcase.SetTestSetting(setting);
sl@0
   373
	testcase.RunTestCaseL();
sl@0
   374
	
sl@0
   375
	test.Next(_L("Test finishing - clearing test path"));
sl@0
   376
	ClearTestPathL();
sl@0
   377
	test.End();
sl@0
   378
	}
sl@0
   379
sl@0
   380
// Entry Point
sl@0
   381
GLDEF_C void CallTestsL()
sl@0
   382
	{
sl@0
   383
	test.Start(_L("Enhanced Notification Performance Test - Initializing...")); 
sl@0
   384
	 
sl@0
   385
	gPerfMeasure = ETrue;
sl@0
   386
	
sl@0
   387
	TUint16 ctrl = 0;
sl@0
   388
	TInt num = 0;
sl@0
   389
	ParseCmdArg(ctrl, num);
sl@0
   390
sl@0
   391
	SetTestPaths();
sl@0
   392
	DeleteLogFilesL();
sl@0
   393
	
sl@0
   394
	if (ctrl & ESingleSession)
sl@0
   395
	    {
sl@0
   396
        test.Next(_L("Performance Test - Single File Server Session")); 
sl@0
   397
        SingleFileSessionTestL(num, (ctrl & EPluginTest));
sl@0
   398
	    }
sl@0
   399
	
sl@0
   400
	if (ctrl & EMultiSession)
sl@0
   401
	    {
sl@0
   402
        test.Next(_L("Performance Test - Multi File Server Session"));
sl@0
   403
        MultipleFileSessionTestL(num);
sl@0
   404
	    }
sl@0
   405
	
sl@0
   406
	if (ctrl & EOtherTestCase)
sl@0
   407
	    {
sl@0
   408
        test.Next(_L("Performance Test - Test of other edge use cases"));
sl@0
   409
        EdgeUseCaseTestL(ctrl & EPluginTest);
sl@0
   410
	    }
sl@0
   411
sl@0
   412
	if (ctrl & ECopyLogs)
sl@0
   413
	    {
sl@0
   414
#ifndef __WINSCW__
sl@0
   415
	    CopyLogFilesL();
sl@0
   416
#endif
sl@0
   417
	    }
sl@0
   418
sl@0
   419
	test.End();
sl@0
   420
	test.Close();
sl@0
   421
	}
sl@0
   422
sl@0
   423
sl@0
   424