genericopenlibs/openenvcore/libc/test/testlargefile/src/tlargefileserver.cpp
changeset 0 e4d67989cc36
child 48 ab61c4cedc64
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     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 "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 //  Name        : tlargefileeserver.cpp
       
    14 
       
    15 
       
    16 #include <c32comm.h>
       
    17 
       
    18 #if defined (__WINS__)
       
    19 #define PDD_NAME		_L("ECDRV")
       
    20 #else
       
    21 #define PDD_NAME		_L("EUART1")
       
    22 #define PDD2_NAME		_L("EUART2")
       
    23 #define PDD3_NAME		_L("EUART3")
       
    24 #define PDD4_NAME		_L("EUART4")
       
    25 #endif
       
    26 
       
    27 #define LDD_NAME		_L("ECOMM")
       
    28 
       
    29 
       
    30 #include "tlargefileserver.h"
       
    31 #include "tlargefile.h"
       
    32 
       
    33 
       
    34 _LIT(KServerName, "tlargefile");
       
    35 
       
    36 CLargefileTestServer* CLargefileTestServer::NewL()
       
    37 	{
       
    38 	CLargefileTestServer *server = new(ELeave) CLargefileTestServer();
       
    39 	CleanupStack::PushL(server);
       
    40 	server->ConstructL(KServerName);
       
    41 	CleanupStack::Pop(server);
       
    42 	return server;
       
    43 	}
       
    44 
       
    45 static void InitCommsL()
       
    46     {
       
    47     TInt ret = User::LoadPhysicalDevice(PDD_NAME);
       
    48     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    49 
       
    50 #ifndef __WINS__
       
    51     ret = User::LoadPhysicalDevice(PDD2_NAME);
       
    52     ret = User::LoadPhysicalDevice(PDD3_NAME);
       
    53     ret = User::LoadPhysicalDevice(PDD4_NAME);
       
    54 #endif
       
    55 
       
    56     ret = User::LoadLogicalDevice(LDD_NAME);
       
    57     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    58     ret = StartC32();
       
    59     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    60     }
       
    61 
       
    62 LOCAL_C void MainL()
       
    63 	{
       
    64 	// Leave the hooks in for platform security
       
    65 #if (defined __DATA_CAGING__)
       
    66 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    67 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    68 #endif
       
    69 	InitCommsL();
       
    70 	
       
    71 	CActiveScheduler* sched=NULL;
       
    72 	sched=new(ELeave) CActiveScheduler;
       
    73 	CActiveScheduler::Install(sched);
       
    74 	CLargefileTestServer* server = NULL;
       
    75 	// Create the CTestServer derived server
       
    76 	TRAPD(err, server = CLargefileTestServer::NewL());
       
    77 	if(!err)
       
    78 		{
       
    79 		// Sync with the client and enter the active scheduler
       
    80 		RProcess::Rendezvous(KErrNone);
       
    81 		sched->Start();
       
    82 		}
       
    83 	delete server;
       
    84 	delete sched;
       
    85 	}
       
    86 
       
    87 /**
       
    88  * Server entry point
       
    89  * @return Standard Epoc error code on exit
       
    90  */
       
    91 TInt main()
       
    92 	{
       
    93 	__UHEAP_MARK;
       
    94 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    95 	if(cleanup == NULL) 
       
    96 		{
       
    97 		return KErrNoMemory;  
       
    98 		}
       
    99 	TRAP_IGNORE(MainL());
       
   100 	delete cleanup;
       
   101 	__UHEAP_MARKEND;
       
   102 	
       
   103 	return KErrNone;
       
   104 	}
       
   105 
       
   106 CTestStep* CLargefileTestServer::CreateTestStep(const TDesC& aStepName)
       
   107 	{
       
   108 	CTestStep* testStep = NULL;
       
   109     if(aStepName == KTestLargeFileTruncate)
       
   110 		{
       
   111 		testStep = new CTestLargefile(aStepName);
       
   112 		}
       
   113     else if(aStepName == KTestLargeFileFtruncate)
       
   114 		{
       
   115 		testStep = new CTestLargefile(aStepName);
       
   116 		}
       
   117     else if(aStepName == KTestLargeFileReadWrite)
       
   118 		{
       
   119 		testStep = new CTestLargefile(aStepName);
       
   120 		}
       
   121     else if(aStepName == KTestLargeFileFseeknTell)
       
   122 		{
       
   123 		testStep = new CTestLargefile(aStepName);
       
   124 		}
       
   125     else if(aStepName == KTestLargeFileLseeknTell)
       
   126 		{
       
   127 		testStep = new CTestLargefile(aStepName);
       
   128 		}
       
   129     else if(aStepName == KTestCreatenFseeknPos)
       
   130 		{
       
   131 		testStep = new CTestLargefile(aStepName);
       
   132 		}
       
   133     else if(aStepName == KTestCreatenLseeknPos)
       
   134 		{
       
   135 		testStep = new CTestLargefile(aStepName);
       
   136 		}
       
   137     else if(aStepName == KTestChildFileTransfer)
       
   138 		{
       
   139 		testStep = new CTestLargefile(aStepName);
       
   140 		}
       
   141     else if(aStepName == KTestLargeFileFtw)
       
   142 		{
       
   143 		testStep = new CTestLargefile(aStepName);
       
   144 		}
       
   145     else if(aStepName == KTestLargeFileReaddir)
       
   146 		{
       
   147 		testStep = new CTestLargefile(aStepName);
       
   148 		}
       
   149     else if(aStepName == KTestLargeFileWreaddir)
       
   150 		{
       
   151 		testStep = new CTestLargefile(aStepName);
       
   152 		}
       
   153     else if(aStepName == KTestLargeFileAlphasort)
       
   154 		{
       
   155 		testStep = new CTestLargefile(aStepName);
       
   156 		}
       
   157     else if(aStepName == KTestNonsortScandir)
       
   158 		{
       
   159 		testStep = new CTestLargefile(aStepName);
       
   160 		}
       
   161     else if(aStepName == KTestSortScandir)
       
   162 		{
       
   163 		testStep = new CTestLargefile(aStepName);
       
   164 		}
       
   165     else if(aStepName == KTestFcntlwithSinglefd)
       
   166 		{
       
   167 		testStep = new CTestLargefile(aStepName);
       
   168 		}
       
   169     else if(aStepName == KTestFcntlwithDoublefds)
       
   170 		{
       
   171 		testStep = new CTestLargefile(aStepName);
       
   172 		}
       
   173     else if(aStepName == KTestLargeFileSeek)
       
   174 		{
       
   175 		testStep = new CTestLargefile(aStepName);
       
   176 		}
       
   177     else if(aStepName == KTestLargeFileGlob)
       
   178 		{
       
   179 		testStep = new CTestLargefile(aStepName);
       
   180 		}
       
   181     else if(aStepName == KTestLargeFileMmapWrite)
       
   182 		{
       
   183 		testStep = new CTestLargefile(aStepName);
       
   184 		}
       
   185     else if(aStepName == KTestLargeFileWriteMmap)
       
   186 		{
       
   187 		testStep = new CTestLargefile(aStepName);
       
   188 		}
       
   189     else if(aStepName == KTestNegSmallOffsetValues)
       
   190 		{
       
   191 		testStep = new CTestLargefile(aStepName);
       
   192 		}
       
   193     else if(aStepName == KTestNegLargeOffsetValues)
       
   194 		{
       
   195 		testStep = new CTestLargefile(aStepName);
       
   196 		}
       
   197     else if(aStepName == KTestLargeFileFreopen)
       
   198 		{
       
   199 		testStep = new CTestLargefile(aStepName);
       
   200 		}
       
   201     else if(aStepName == KTestLargeFileWfreopen)
       
   202 		{
       
   203 		testStep = new CTestLargefile(aStepName);
       
   204 		}
       
   205     else if(aStepName == KTestFcntlWriteLockwithMaxSize)
       
   206         {
       
   207         testStep = new CTestLargefile(aStepName);
       
   208         }
       
   209 
       
   210 	return testStep;
       
   211 	}
       
   212