genericopenlibs/openenvcore/libc/test/testlocalsocket/src/tlocalsocketserver.cpp
changeset 0 e4d67989cc36
child 48 ab61c4cedc64
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2007-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 // Description:
       
    14 // Name        : tlocalsocketserver.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <c32comm.h>
       
    19 
       
    20 #if defined (__WINS__)
       
    21 #define PDD_NAME		_L("ECDRV")
       
    22 #else
       
    23 #define PDD_NAME		_L("EUART1")
       
    24 #define PDD2_NAME		_L("EUART2")
       
    25 #define PDD3_NAME		_L("EUART3")
       
    26 #define PDD4_NAME		_L("EUART4")
       
    27 #endif
       
    28 
       
    29 #define LDD_NAME		_L("ECOMM")
       
    30 
       
    31 /**
       
    32  * @file
       
    33  *
       
    34  * Pipe test server implementation
       
    35  */
       
    36 #include "tlocalsocketserver.h"
       
    37 #include "tlocalsocket.h"
       
    38 
       
    39 
       
    40 _LIT(KServerName, "tlocalsocket");
       
    41 
       
    42 CLocalSocketTestServer* CLocalSocketTestServer::NewL()
       
    43 	{
       
    44 	CLocalSocketTestServer *server = new(ELeave) CLocalSocketTestServer();
       
    45 	CleanupStack::PushL(server);
       
    46 	server->ConstructL(KServerName);
       
    47 	CleanupStack::Pop(server);
       
    48 	return server;
       
    49 	}
       
    50 
       
    51 static void InitCommsL()
       
    52     {
       
    53     TInt ret = User::LoadPhysicalDevice(PDD_NAME);
       
    54     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    55 
       
    56 #ifndef __WINS__
       
    57     ret = User::LoadPhysicalDevice(PDD2_NAME);
       
    58     ret = User::LoadPhysicalDevice(PDD3_NAME);
       
    59     ret = User::LoadPhysicalDevice(PDD4_NAME);
       
    60 #endif
       
    61 
       
    62     ret = User::LoadLogicalDevice(LDD_NAME);
       
    63     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    64     ret = StartC32();
       
    65     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    66     }
       
    67 
       
    68 LOCAL_C void MainL()
       
    69 	{
       
    70 	// Leave the hooks in for platform security
       
    71 #if (defined __DATA_CAGING__)
       
    72 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    73 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    74 #endif
       
    75 	InitCommsL();
       
    76 	
       
    77 	CActiveScheduler* sched=NULL;
       
    78 	sched=new(ELeave) CActiveScheduler;
       
    79 	CActiveScheduler::Install(sched);
       
    80 	CLocalSocketTestServer* server = NULL;
       
    81 	// Create the CTestServer derived server
       
    82 	TRAPD(err, server = CLocalSocketTestServer::NewL());
       
    83 	if(!err)
       
    84 		{
       
    85 		// Sync with the client and enter the active scheduler
       
    86 		RProcess::Rendezvous(KErrNone);
       
    87 		sched->Start();
       
    88 		}
       
    89 	delete server;
       
    90 	delete sched;
       
    91 	}
       
    92 
       
    93 /**
       
    94  * Server entry point
       
    95  * @return Standard Epoc error code on exit
       
    96  */
       
    97 TInt main()
       
    98 	{
       
    99 	__UHEAP_MARK;
       
   100 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   101 	if(cleanup == NULL) 
       
   102 		{
       
   103 		return KErrNoMemory;  
       
   104 		}
       
   105 	TRAP_IGNORE(MainL());
       
   106 	delete cleanup;
       
   107 	__UHEAP_MARKEND;
       
   108 	
       
   109 	return KErrNone;
       
   110 	}
       
   111 
       
   112 CTestStep* CLocalSocketTestServer::CreateTestStep(const TDesC& aStepName)
       
   113 	{
       
   114 	CTestStep* testStep = NULL;
       
   115 
       
   116 	// This server creates just one step but create as many as you want
       
   117 	// They are created "just in time" when the worker thread is created
       
   118 	// install steps
       
   119 	if(aStepName == KTestBind)
       
   120 		{
       
   121 		testStep = new CTestLocalSocket(aStepName);
       
   122 		}
       
   123 	if(aStepName == KTestLseek)
       
   124 		{
       
   125 		testStep = new CTestLocalSocket(aStepName);
       
   126 		}
       
   127 	if(aStepName == KTestFstat)
       
   128 		{
       
   129 		testStep = new CTestLocalSocket(aStepName);
       
   130 		}
       
   131 	if(aStepName == KTestThreadSocketRead)
       
   132 		{
       
   133 		testStep = new CTestLocalSocket(aStepName);
       
   134 		}
       
   135 	if(aStepName == KTestThreadSocketWrite)
       
   136 		{
       
   137 		testStep = new CTestLocalSocket(aStepName);
       
   138 		}
       
   139 	if(aStepName == KTestThreadSocketRecv)
       
   140 		{
       
   141 		testStep = new CTestLocalSocket(aStepName);
       
   142 		}
       
   143 	if(aStepName == KTestThreadSocketSend)
       
   144 		{
       
   145 		testStep = new CTestLocalSocket(aStepName);
       
   146 		}
       
   147 	if(aStepName == KTestMultProc)
       
   148 		{
       
   149 		testStep = new CTestLocalSocket(aStepName);
       
   150 		}
       
   151 	if(aStepName == KTestMultThread)
       
   152 		{
       
   153 		testStep = new CTestLocalSocket(aStepName);
       
   154 		}
       
   155 	if(aStepName == KTestSetGetSockOpt)
       
   156 		{
       
   157 		testStep = new CTestLocalSocket(aStepName);
       
   158 		}
       
   159 	if(aStepName == KTestSetSockOptNegative1)
       
   160 		{
       
   161 		testStep = new CTestLocalSocket(aStepName);
       
   162 		}
       
   163 	if(aStepName == KTestSetSockOptNegative2)
       
   164 		{
       
   165 		testStep = new CTestLocalSocket(aStepName);
       
   166 		}
       
   167 	if(aStepName == KTestSetSockOptNegative3)
       
   168 		{
       
   169 		testStep = new CTestLocalSocket(aStepName);
       
   170 		}
       
   171 	if(aStepName == KTestSetSockOptNegative4)
       
   172 		{
       
   173 		testStep = new CTestLocalSocket(aStepName);
       
   174 		}
       
   175 	if(aStepName == KTestGetSockOptNegative1)
       
   176 		{
       
   177 		testStep = new CTestLocalSocket(aStepName);
       
   178 		}
       
   179 	if(aStepName == KTestGetSockOptNegative2)
       
   180 		{
       
   181 		testStep = new CTestLocalSocket(aStepName);
       
   182 		}
       
   183 	if(aStepName == KTestGetSockOptNegative3)
       
   184 		{
       
   185 		testStep = new CTestLocalSocket(aStepName);
       
   186 		}
       
   187 	if(aStepName == KTestGetSockOptNegative4)
       
   188 		{
       
   189 		testStep = new CTestLocalSocket(aStepName);
       
   190 		}
       
   191 	if(aStepName == KTestLocalSockIoctl)
       
   192 		{
       
   193 		testStep = new CTestLocalSocket(aStepName);
       
   194 		}
       
   195 	if(aStepName == KTestLocalSockFcntl)
       
   196 		{
       
   197 		testStep = new CTestLocalSocket(aStepName);
       
   198 		}
       
   199 	if(aStepName == KTestNegativeBind1)
       
   200 		{
       
   201 		testStep = new CTestLocalSocket(aStepName);
       
   202 		}
       
   203 	if(aStepName == KTestNegativeBind2)
       
   204 		{
       
   205 		testStep = new CTestLocalSocket(aStepName);
       
   206 		}
       
   207 	if(aStepName == KTestNegativeBind3)
       
   208 		{
       
   209 		testStep = new CTestLocalSocket(aStepName);
       
   210 		}
       
   211 	if(aStepName == KTestNegativeBind4)
       
   212 		{
       
   213 		testStep = new CTestLocalSocket(aStepName);
       
   214 		}
       
   215 	if(aStepName == KTestNegativeBind5)
       
   216 		{
       
   217 		testStep = new CTestLocalSocket(aStepName);
       
   218 		}
       
   219 	if(aStepName == KTestListenonUnixsoc)
       
   220 		{
       
   221 		testStep = new CTestLocalSocket(aStepName);
       
   222 		}
       
   223 	if(aStepName == KTestNonblockAcceptSetfl)
       
   224 		{
       
   225 		testStep = new CTestLocalSocket(aStepName);
       
   226 		}
       
   227 	if(aStepName == KTestNonblockAcceptSelect)
       
   228 		{
       
   229 		testStep = new CTestLocalSocket(aStepName);
       
   230 		}
       
   231 	if(aStepName == KTestNonblockingRead)
       
   232 		{
       
   233 		testStep = new CTestLocalSocket(aStepName);
       
   234 		}
       
   235 	if(aStepName == KTestNonblockingRecv)
       
   236 		{
       
   237 		testStep = new CTestLocalSocket(aStepName);
       
   238 		}
       
   239 	if(aStepName == KTestGetSockName)
       
   240 		{
       
   241 		testStep = new CTestLocalSocket(aStepName);
       
   242 		}
       
   243 	if(aStepName == KTestGetPeerName)
       
   244 		{
       
   245 		testStep = new CTestLocalSocket(aStepName);
       
   246 		}
       
   247 	if(aStepName == KTestThreadSendto)
       
   248 		{
       
   249 		testStep = new CTestLocalSocket(aStepName);
       
   250 		}
       
   251 	if(aStepName == KTestThreadRecvfrom)
       
   252 		{
       
   253 		testStep = new CTestLocalSocket(aStepName);
       
   254 		}
       
   255 	if(aStepName == KTestLocalSockMultipleBind)
       
   256 		{
       
   257 		testStep = new CTestLocalSocket(aStepName);
       
   258 		}	
       
   259 	return testStep;
       
   260 	}