sl@0: // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // f32test\bench\t_notify_perf.cpp sl@0: // sl@0: // sl@0: sl@0: #include "t_notify_perf.h" sl@0: #include "t_server.h" sl@0: sl@0: RTest test(_L("Enhanced Notification Performance Test")); sl@0: sl@0: extern void ClearTestPathL(); sl@0: extern void SetTestPaths(); sl@0: extern void CopyLogFilesL(); sl@0: extern void DeleteLogFilesL(); sl@0: sl@0: enum TTestControl sl@0: { sl@0: ESingleSession = 0x01, sl@0: EMultiSession = 0x02, sl@0: EOtherTestCase = 0x04, sl@0: EPluginTest = 0x08, sl@0: ECopyLogs = 0x10 sl@0: }; sl@0: sl@0: const TInt KTestControlMask = 0x07; sl@0: sl@0: // Note: Format of command line argument sl@0: // t_notify_perf <-s|-m|-o> [-p] [-cplg] sl@0: // sl@0: // The drive you want to run the test on sl@0: // -s Execute single session test - PBASE-T_NOTIFY-2456 sl@0: // -m Execute multi sessions test - PBASE-T_NOTIFY-2457 sl@0: // -o Execute other edge use test - PBASE-T_NOTIFY-2458 sl@0: // -p Enable Mds plugin test, this does not take effect in multi session test sl@0: // -cplg Copy the log files to MMC card after test finish, not work for emulator. MMC drive hard coded to be "D" sl@0: // The number of files you want to use in the tests, does not take effect in other esge use test sl@0: sl@0: // Function for parsing command line arguments for the test sl@0: LOCAL_C void ParseCmdArg(TUint16& aTestControl, TInt& aNumFiles) sl@0: sl@0: { sl@0: TBuf<0x100> cmd; sl@0: User::CommandLine(cmd); sl@0: TLex lex(cmd); sl@0: sl@0: TPtrC token = lex.NextToken(); sl@0: TFileName thisfile = RProcess().FileName(); sl@0: if (token.MatchF(thisfile)==0) sl@0: { sl@0: token.Set(lex.NextToken()); sl@0: } sl@0: sl@0: if(token.Length()!=0) sl@0: { sl@0: gDriveToTest=token[0]; sl@0: gDriveToTest.UpperCase(); sl@0: } sl@0: else sl@0: { sl@0: gDriveToTest='C'; sl@0: } sl@0: sl@0: while (!lex.Eos()) sl@0: { sl@0: token.Set(lex.NextToken()); sl@0: if (token.Compare(_L("-s")) == 0 || token.Compare(_L("-S")) == 0) sl@0: { sl@0: aTestControl |= ESingleSession; sl@0: } sl@0: else if (token.Compare(_L("-m")) == 0 || token.Compare(_L("-M")) == 0) sl@0: { sl@0: aTestControl |= EMultiSession; sl@0: } sl@0: else if (token.Compare(_L("-o")) == 0 || token.Compare(_L("-O")) == 0) sl@0: { sl@0: aTestControl |= EOtherTestCase; sl@0: } sl@0: else if (token.Compare(_L("-p")) == 0 || token.Compare(_L("-P")) == 0) sl@0: { sl@0: aTestControl |= EPluginTest; sl@0: } sl@0: else if (token.Compare(_L("-cplg")) == 0 || token.Compare(_L("-CPLG")) == 0) sl@0: { sl@0: aTestControl |= ECopyLogs; sl@0: } sl@0: else sl@0: { sl@0: TLex valArg(token); sl@0: TInt r = valArg.Val(aNumFiles); sl@0: if (r != KErrNone) sl@0: { sl@0: RDebug::Print(_L("Bad Argument: %S"), &token); sl@0: test(r == KErrNone); sl@0: } sl@0: } sl@0: } sl@0: sl@0: TInt mode = aTestControl & KTestControlMask; sl@0: if ((mode != ESingleSession) && (mode != EMultiSession) && (mode != EOtherTestCase)) sl@0: { sl@0: RDebug::Print(_L("Bad Argument: One and only one mode (-s/-m/-o) should be set.")); sl@0: test((mode == ESingleSession) || (mode == EMultiSession) || (mode == EOtherTestCase)); sl@0: } sl@0: sl@0: if ((aNumFiles <= 0) && ((mode == ESingleSession) || (mode == EMultiSession))) sl@0: { sl@0: RDebug::Print(_L("Bad Argument: number of files invalid")); sl@0: test(aNumFiles > 0); sl@0: } sl@0: sl@0: if ((aNumFiles > 0) && (mode == EOtherTestCase)) sl@0: RDebug::Print(_L("File numbers ignored...")); sl@0: sl@0: if ((mode == EMultiSession) && (aTestControl & EPluginTest)) sl@0: RDebug::Print(_L("-p option ignored...")); sl@0: sl@0: gLogPostFix.FillZ(); sl@0: gLogPostFix.Append('_'); sl@0: gLogPostFix.Append(gDriveToTest); sl@0: sl@0: if (mode == EOtherTestCase) sl@0: gLogPostFix.Append(_L("_O")); sl@0: sl@0: if ((aTestControl & EPluginTest) && (mode != EMultiSession)) sl@0: gLogPostFix.Append(_L("_Plugin")); sl@0: sl@0: if (mode != EOtherTestCase) sl@0: gLogPostFix.AppendFormat(_L("_%d"), aNumFiles); sl@0: sl@0: gLogPostFix.Append(_L(".log")); sl@0: } sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_NOTIFY-2456 sl@0: //! @SYMTestType PT sl@0: //! @SYMREQ PREQ1847 sl@0: //! @SYMTestCaseDesc Performance Test – Single File Server Session sl@0: //! @SYMTestActions Perform a series of file operations with different numbers with different notification sl@0: //! mechanism, measure the time taken and produce the log with the results sl@0: //! @SYMTestExpectedResults Figures of performance sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: LOCAL_C void SingleFileSessionTestL(TInt aNum, TBool aRunPlugin) sl@0: { sl@0: test.Start(_L("Performance Test - Single File Server Session, Test Preparation")); sl@0: sl@0: const TInt KNumClients = 1; sl@0: ClearTestPathL(); sl@0: sl@0: // ------------------ Files -------------------------- sl@0: sl@0: test.Next(_L("Files, Single file session, no notification")); sl@0: TTestSetting setting (aNum, 0, ENoNotify, KDefaultOpList); sl@0: CTestExecutor testcase (setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: test.Next(_L("Files, Single file session, enhanced notification - Change reporting enabled")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EEnhanced|EReportChg|EBigBuffer); sl@0: setting.iNumCli = KNumClients; sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: test.Next(_L("Files, Single file session, original notification - Change reporting enabled")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EOriginal|EReportChg); sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: if (aRunPlugin) sl@0: { sl@0: test.Next(_L("Files, Single file session, Plugin - Change reporting enabled")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EPlugin|EReportChg); sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: } sl@0: sl@0: test.Next(_L("Files, Single file session, enhanced notification - Change reporting disabled")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EEnhanced|EBigBuffer); sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: test.Next(_L("Files, Single file session, original notification - Change reporting disabled")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EOriginal); sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: if (aRunPlugin) sl@0: { sl@0: test.Next(_L("Files, Single file session, Plugin - Change reporting disabled")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EPlugin); sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: } sl@0: sl@0: test.Next(_L("Files, Single file session, enhanced notification - with long list of filters")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EEnhanced|EReportChg|EBigBuffer|EBigFilter); sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: // ------------------------- Directories ------------------------- sl@0: test.Next(_L("Dirs, Single file session, enhanced notification")); sl@0: ClearTestPathL(); sl@0: setting.iOperationList = KDefaultOpListDir; sl@0: setting.iOption = (EEnhanced|EReportChg|EBigBuffer); sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: test.Next(_L("Dirs, Single file session, original notification")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EOriginal|EReportChg); sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: if (aRunPlugin) sl@0: { sl@0: test.Next(_L("Dirs, Single file session, Plugin")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EPlugin|EReportChg); sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: } sl@0: sl@0: test.Next(_L("Test finishing - clearing test path")); sl@0: sl@0: ClearTestPathL(); sl@0: test.End(); sl@0: } sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_NOTIFY-2457 sl@0: //! @SYMTestType PT sl@0: //! @SYMREQ PREQ1847 sl@0: //! @SYMTestCaseDesc Performance Test – Multiple File Server Sessions sl@0: //! @SYMTestActions Perform a series of file operations with different numbers with different notification sl@0: //! mechanism, create multiple notification threads to collect the notifications, measure sl@0: //! the time taken and produce the log with the results sl@0: //! @SYMTestExpectedResults Figures of performance sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: LOCAL_C void MultipleFileSessionTestL(TInt aNum) sl@0: { sl@0: test.Start(_L("Performance Test - Multi File Server Session, Test Preparation")); sl@0: sl@0: const TInt KNumClients = 4; sl@0: ClearTestPathL(); sl@0: sl@0: test.Next(_L("Multi file sessions, enhanced notification")); sl@0: TTestSetting setting (aNum, KNumClients, (EEnhanced|EReportChg|EBigBuffer), KDefaultOpList); sl@0: CTestExecutor testcase (setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: test.Next(_L("Multi file sessions, original notification")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EOriginal|EReportChg); sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: test.Next(_L("Multi file sessions, enhanced notification - Lots of Filters")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EEnhanced|EReportChg|EBigFilter|EBigBuffer); sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: test.Next(_L("Multi file sessions, multi notifications Mode 1, enhanced notification")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EEnhanced|EReportChg|EBigBuffer|EMultiNoti1); sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: test.Next(_L("Multi file sessions, multi notifications Mode 2, enhanced notification")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EEnhanced|EReportChg|EBigBuffer|EMultiNoti2); sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: test.Next(_L("Test finishing - clearing test path")); sl@0: sl@0: ClearTestPathL(); sl@0: test.End(); sl@0: } sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_NOTIFY-2458 sl@0: //! @SYMTestType PT sl@0: //! @SYMREQ PREQ1847 sl@0: //! @SYMTestCaseDesc Performance Test – Test of other edge use cases sl@0: //! @SYMTestActions Perform 1. Large number of changes in single file; 2. small changes in large number of files; sl@0: //! 3. Mixed File operations; on each kind of notification mechanism, and measure the performance sl@0: //! @SYMTestExpectedResults Figures of performance sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: LOCAL_C void EdgeUseCaseTestL(TBool aRunPlugin) sl@0: { sl@0: test.Start(_L("Performance Test - Test of other edge use cases, Test Preparation")); sl@0: sl@0: const TInt KNumChanges = 1000; sl@0: const TInt KNumMixed = 50; // using a small number because the mixed operation test will perform (18 * KNumMixed) operations sl@0: const TInt KNumClients = 1; sl@0: ClearTestPathL(); sl@0: sl@0: test.Next(_L("Single file session, enhanced notification, big number of changes on single file")); sl@0: TTestSetting setting (KNumChanges, KNumClients, (EEnhanced|EReportChg|EBigBuffer), KManyChangesOpList); sl@0: CTestExecutor testcase (setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: test.Next(_L("Single file session, original notification, big number of changes on single file")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EOriginal|EReportChg); sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: test.Next(_L("Single file session, enhanced notification, small changes on big number of files")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EEnhanced|EReportChg|EBigBuffer); sl@0: setting.iOperationList = KManyFilesOpList; sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: test.Next(_L("Single file session, original notification, small changes on big number of files")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EOriginal|EReportChg); sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: test.Next(_L("Single file session, enhanced notification, mixed file operations, big buffer")); sl@0: ClearTestPathL(); sl@0: setting.iNumFiles = KNumMixed; sl@0: setting.iOption = (EEnhanced|EReportChg|EBigBuffer); sl@0: setting.iOperationList = KMixedOpTestList; sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: test.Next(_L("Single file session, original notification, mixed file operations")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EOriginal|EReportChg); sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: if (aRunPlugin) sl@0: { sl@0: test.Next(_L("Single file session, Plugin, mixed file operations")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EPlugin|EReportChg); sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: } sl@0: sl@0: test.Next(_L("Single file session, enhanced notification, mixed file operations, small buffer")); sl@0: ClearTestPathL(); sl@0: setting.iOption = (EEnhanced|EReportChg); sl@0: testcase.SetTestSetting(setting); sl@0: testcase.RunTestCaseL(); sl@0: sl@0: test.Next(_L("Test finishing - clearing test path")); sl@0: ClearTestPathL(); sl@0: test.End(); sl@0: } sl@0: sl@0: // Entry Point sl@0: GLDEF_C void CallTestsL() sl@0: { sl@0: test.Start(_L("Enhanced Notification Performance Test - Initializing...")); sl@0: sl@0: gPerfMeasure = ETrue; sl@0: sl@0: TUint16 ctrl = 0; sl@0: TInt num = 0; sl@0: ParseCmdArg(ctrl, num); sl@0: sl@0: SetTestPaths(); sl@0: DeleteLogFilesL(); sl@0: sl@0: if (ctrl & ESingleSession) sl@0: { sl@0: test.Next(_L("Performance Test - Single File Server Session")); sl@0: SingleFileSessionTestL(num, (ctrl & EPluginTest)); sl@0: } sl@0: sl@0: if (ctrl & EMultiSession) sl@0: { sl@0: test.Next(_L("Performance Test - Multi File Server Session")); sl@0: MultipleFileSessionTestL(num); sl@0: } sl@0: sl@0: if (ctrl & EOtherTestCase) sl@0: { sl@0: test.Next(_L("Performance Test - Test of other edge use cases")); sl@0: EdgeUseCaseTestL(ctrl & EPluginTest); sl@0: } sl@0: sl@0: if (ctrl & ECopyLogs) sl@0: { sl@0: #ifndef __WINSCW__ sl@0: CopyLogFilesL(); sl@0: #endif sl@0: } sl@0: sl@0: test.End(); sl@0: test.Close(); sl@0: } sl@0: sl@0: sl@0: