genericopenlibs/openenvcore/libc/test/testtime_blr/src/ttime_blrserver.cpp
changeset 0 e4d67989cc36
child 48 ab61c4cedc64
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /*
       
     2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <c32comm.h>
       
    21 
       
    22 #if defined (__WINS__)
       
    23 #define PDD_NAME		_L("ECDRV")
       
    24 #else
       
    25 #define PDD_NAME		_L("EUART1")
       
    26 #define PDD2_NAME		_L("EUART2")
       
    27 #define PDD3_NAME		_L("EUART3")
       
    28 #define PDD4_NAME		_L("EUART4")
       
    29 #endif
       
    30 
       
    31 #define LDD_NAME		_L("ECOMM")
       
    32 
       
    33 /**
       
    34  * @file
       
    35  *
       
    36  * Pipe test server implementation
       
    37  */
       
    38 #include "ttime_blrserver.h"
       
    39 #include "ttime_blr.h"
       
    40 
       
    41 
       
    42 _LIT(KServerName, "ttime_blr");
       
    43 
       
    44 CTimeBlrTestServer* CTimeBlrTestServer::NewL()
       
    45 	{
       
    46 	CTimeBlrTestServer *server = new(ELeave) CTimeBlrTestServer();
       
    47 	CleanupStack::PushL(server);
       
    48 	server->ConstructL(KServerName);
       
    49 	CleanupStack::Pop(server);
       
    50 	return server;
       
    51 	}
       
    52 
       
    53 static void InitCommsL()
       
    54     {
       
    55     TInt ret = User::LoadPhysicalDevice(PDD_NAME);
       
    56     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    57 
       
    58 #ifndef __WINS__
       
    59     ret = User::LoadPhysicalDevice(PDD2_NAME);
       
    60     ret = User::LoadPhysicalDevice(PDD3_NAME);
       
    61     ret = User::LoadPhysicalDevice(PDD4_NAME);
       
    62 #endif
       
    63 
       
    64     ret = User::LoadLogicalDevice(LDD_NAME);
       
    65     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    66     ret = StartC32();
       
    67     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    68     }
       
    69 
       
    70 LOCAL_C void MainL()
       
    71 	{
       
    72 	// Leave the hooks in for platform security
       
    73 #if (defined __DATA_CAGING__)
       
    74 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    75 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    76 #endif
       
    77 	InitCommsL();
       
    78 	
       
    79 	CActiveScheduler* sched=NULL;
       
    80 	sched=new(ELeave) CActiveScheduler;
       
    81 	CActiveScheduler::Install(sched);
       
    82 	CTimeBlrTestServer* server = NULL;
       
    83 	// Create the CTestServer derived server
       
    84 	TRAPD(err, server = CTimeBlrTestServer::NewL());
       
    85 	if(!err)
       
    86 		{
       
    87 		// Sync with the client and enter the active scheduler
       
    88 		RProcess::Rendezvous(KErrNone);
       
    89 		sched->Start();
       
    90 		}
       
    91 	delete server;
       
    92 	delete sched;
       
    93 	}
       
    94 
       
    95 /**
       
    96  * Server entry point
       
    97  * @return Standard Epoc error code on exit
       
    98  */
       
    99 TInt main()
       
   100 	{
       
   101 	__UHEAP_MARK;
       
   102 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   103 	if(cleanup == NULL) 
       
   104 		{
       
   105 		return KErrNoMemory;  
       
   106 		}
       
   107 	TRAP_IGNORE(MainL());
       
   108 	delete cleanup;
       
   109 	__UHEAP_MARKEND;
       
   110 	
       
   111 	return KErrNone;
       
   112 	}
       
   113 
       
   114 CTestStep* CTimeBlrTestServer::CreateTestStep(const TDesC& aStepName)
       
   115 	{
       
   116 	CTestStep* testStep = NULL;
       
   117 
       
   118 	// This server creates just one step but create as many as you want
       
   119 	// They are created "just in time" when the worker thread is created
       
   120 	// install steps
       
   121 	if(aStepName == Kasctime_test_all)
       
   122 		{
       
   123 		testStep = new CTestTimeBlr(aStepName);
       
   124 		}
       
   125 	if(aStepName == Kasctime_test_null)
       
   126 		{
       
   127 		testStep = new CTestTimeBlr(aStepName);
       
   128 		}
       
   129 	if(aStepName == Klocaltime_test_all)
       
   130 		{
       
   131 		testStep = new CTestTimeBlr(aStepName);
       
   132 		}
       
   133     if(aStepName == Kgmtime_test_all)
       
   134 		{
       
   135 		testStep = new CTestTimeBlr(aStepName);
       
   136 		}
       
   137     if(aStepName == Kmktime_test_null)
       
   138 		{
       
   139 		testStep = new CTestTimeBlr(aStepName);
       
   140 		}
       
   141     if(aStepName == Kmktime_test_epoch)
       
   142 		{
       
   143 		testStep = new CTestTimeBlr(aStepName);
       
   144 		}
       
   145     if(aStepName == Kmktime_test_extreme)
       
   146 		{
       
   147 		testStep = new CTestTimeBlr(aStepName);
       
   148 		}
       
   149     if(aStepName == Kctime_test_all)
       
   150 		{
       
   151 		testStep = new CTestTimeBlr(aStepName);
       
   152 		}
       
   153     if(aStepName == Kdifftime_test_all)
       
   154 		{
       
   155 		testStep = new CTestTimeBlr(aStepName);
       
   156 		}
       
   157     if(aStepName == Kdifftime_test_extreme)
       
   158 		{
       
   159 		testStep = new CTestTimeBlr(aStepName);
       
   160 		}
       
   161     if(aStepName == Ktzset_test)
       
   162 		{
       
   163 		testStep = new CTestTimeBlr(aStepName);
       
   164 		}
       
   165     if(aStepName == Kasctime_r_all)
       
   166 		{
       
   167 		testStep = new CTestTimeBlr(aStepName);
       
   168 		}
       
   169     if(aStepName == Kasctime_r_null)
       
   170 		{
       
   171 		testStep = new CTestTimeBlr(aStepName);
       
   172 		}
       
   173     if(aStepName == Klocaltime_r_all)
       
   174 		{
       
   175 		testStep = new CTestTimeBlr(aStepName);
       
   176 		}
       
   177     if(aStepName == Kgmtime_r_all)
       
   178 		{
       
   179 		testStep = new CTestTimeBlr(aStepName);
       
   180 		}
       
   181     if(aStepName == Kctime_r_all)
       
   182 		{
       
   183 		testStep = new CTestTimeBlr(aStepName);
       
   184 		}
       
   185     if(aStepName == Kmultithread_asctime_r)
       
   186 		{
       
   187 		testStep = new CTestTimeBlr(aStepName);
       
   188 		}
       
   189     if(aStepName == Kmultithread_localtime_r)
       
   190 		{
       
   191 		testStep = new CTestTimeBlr(aStepName);
       
   192 		}
       
   193 	if(aStepName == Kmultithread_ctime_r)
       
   194 		{
       
   195 		testStep = new CTestTimeBlr(aStepName);
       
   196 		}      
       
   197     if(aStepName == Kmultithread_gmtime_r)
       
   198 		{
       
   199 		testStep = new CTestTimeBlr(aStepName);
       
   200 		}
       
   201     if(aStepName == Kclock_getres_pos_test)
       
   202 		{
       
   203 		testStep = new CTestTimeBlr(aStepName);
       
   204 		}
       
   205     if(aStepName == Kclock_gettime_pos_test)
       
   206 		{
       
   207 		testStep = new CTestTimeBlr(aStepName);
       
   208 		}
       
   209     if(aStepName == Kclock_settime_pos_test)
       
   210 		{
       
   211 		testStep = new CTestTimeBlr(aStepName);
       
   212 		}
       
   213     if(aStepName == Kclock_getcpuid_pos_test)
       
   214 		{
       
   215 		testStep = new CTestTimeBlr(aStepName);
       
   216 		}
       
   217     if(aStepName == Kclock_getres_neg_test)
       
   218 		{
       
   219 		testStep = new CTestTimeBlr(aStepName);
       
   220 		}
       
   221     if(aStepName == Kclock_gettime_neg_test)
       
   222 		{
       
   223 		testStep = new CTestTimeBlr(aStepName);
       
   224 		}
       
   225     if(aStepName == Kclock_settime_neg_test)
       
   226 		{
       
   227 		testStep = new CTestTimeBlr(aStepName);
       
   228 		}
       
   229     if(aStepName == Kclock_getcpuid_neg_test)
       
   230 		{
       
   231 		testStep = new CTestTimeBlr(aStepName);
       
   232 		}
       
   233 	if(aStepName == Kadjtime_pos_test)
       
   234 		{
       
   235 		testStep = new CTestTimeBlr(aStepName);
       
   236 		}
       
   237 	if(aStepName == Kadjtime_neg_test)
       
   238 		{
       
   239 		testStep = new CTestTimeBlr(aStepName);
       
   240 		}
       
   241 	if(aStepName == Kgetoffset_test)
       
   242 		{
       
   243 		testStep = new CTestTimeBlr(aStepName);
       
   244 		}
       
   245 	if(aStepName == Kgetrule_test)
       
   246 		{
       
   247 		testStep = new CTestTimeBlr(aStepName);
       
   248 		}
       
   249 	if(aStepName == Ktzset1)
       
   250 		{
       
   251 		testStep = new CTestTimeBlr(aStepName);
       
   252 		}
       
   253 	if(aStepName == Ktimegm_Test)
       
   254 		{
       
   255 		testStep = new CTestTimeBlr(aStepName);
       
   256 		}
       
   257 	if(aStepName == Kclock_getres_null_test)
       
   258 		{
       
   259 		testStep = new CTestTimeBlr(aStepName);
       
   260 		}
       
   261 	if(aStepName == Kadjtime_null_test)
       
   262 		{
       
   263 		testStep = new CTestTimeBlr(aStepName);
       
   264 		}
       
   265 	if(aStepName == Kadjtime_range_test)
       
   266 		{
       
   267 		testStep = new CTestTimeBlr(aStepName);
       
   268 		}
       
   269 	if(aStepName == Kclock_gettime_null_test)
       
   270 		{
       
   271 		testStep = new CTestTimeBlr(aStepName);
       
   272 		}
       
   273 	if(aStepName == Kclock_settime_null_test)
       
   274 		{
       
   275 		testStep = new CTestTimeBlr(aStepName);
       
   276 		}
       
   277 	if(aStepName == Kclock_settime_range1_test)
       
   278 		{
       
   279 		testStep = new CTestTimeBlr(aStepName);
       
   280 		}
       
   281 	if(aStepName == Kclock_settime_range2_test)
       
   282 		{
       
   283 		testStep = new CTestTimeBlr(aStepName);
       
   284 		}
       
   285 	if(aStepName == Kmktime_test_extreme1)
       
   286 		{
       
   287 		testStep = new CTestTimeBlr(aStepName);
       
   288 		}
       
   289 	if(aStepName == KtimeTestWithTzset)
       
   290 	    {
       
   291 	    testStep = new CTestTimeBlr(aStepName);
       
   292 	    }
       
   293 	if(aStepName == Klocal_and_mktime)
       
   294 		{
       
   295 		testStep = new CTestTimeBlr(aStepName);
       
   296 		}
       
   297 	return testStep;
       
   298 	}
       
   299 
       
   300 
       
   301