kerneltest/e32test/usbho/t_usbdi/src/BaseBulkTestCase.cpp
changeset 0 a41df078684a
child 43 c1f20ce4abcf
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2008-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 the License "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 // @file BaseBulkTestCase.cpp
       
    15 // @internalComponent
       
    16 // 
       
    17 //
       
    18 
       
    19 #include "BaseBulkTestCase.h"
       
    20 #include "testpolicy.h"
       
    21 #include "modelleddevices.h"
       
    22 
       
    23 
       
    24  
       
    25 namespace NUnitTesting_USBDI
       
    26 	{
       
    27 
       
    28 //*****************************************************************************************************
       
    29 
       
    30 //Bulk Timer Class 
       
    31 CBulkTestTimer* CBulkTestTimer::NewL(MBulkTestTimerObserver& aParent)
       
    32 	{
       
    33 	CBulkTestTimer* self = new (ELeave) CBulkTestTimer(aParent);
       
    34 	CleanupStack::PushL(self);
       
    35 	self->ConstructL();
       
    36 	CleanupStack::Pop(self);
       
    37 	return self;
       
    38 	}
       
    39 
       
    40 
       
    41 CBulkTestTimer::CBulkTestTimer(MBulkTestTimerObserver& aParent)
       
    42 :	CTimer(EPriorityStandard),
       
    43 	iParent(aParent)
       
    44 	{
       
    45 	CActiveScheduler::Add(this);
       
    46 	}
       
    47 
       
    48 
       
    49 CBulkTestTimer::~CBulkTestTimer()
       
    50 	{
       
    51 	}
       
    52 
       
    53 
       
    54 void CBulkTestTimer::ConstructL()
       
    55 	{
       
    56 	LOG_FUNC
       
    57 	CTimer::ConstructL();
       
    58 	}
       
    59 
       
    60 
       
    61 void CBulkTestTimer::RunL()
       
    62 	{
       
    63 	LOG_FUNC
       
    64 
       
    65 	iParent.HandleBulkTestTimerFired();
       
    66 	}
       
    67 
       
    68 
       
    69 
       
    70 //*****************************************************************************************************
       
    71 
       
    72 
       
    73 //Bulk Test Case Base Class
       
    74 CBaseBulkTestCase::CBaseBulkTestCase(const TDesC& aTestCaseId,TBool aHostFlag, TBool aHostOnly)
       
    75 	: CBaseTestCase(aTestCaseId, aHostFlag, aHostOnly),
       
    76 	iInBufferPtr(NULL,0),
       
    77 	iOutBufferPtr(NULL,0),
       
    78 	iValidateBufferPtr(NULL,0)	
       
    79 	{
       
    80 	
       
    81 	}
       
    82 
       
    83 
       
    84 void CBaseBulkTestCase::BaseBulkConstructL()
       
    85 	{
       
    86 	iTestDevice = new RUsbDeviceD(this);
       
    87 	BaseConstructL();
       
    88 	}
       
    89 
       
    90 
       
    91 CBaseBulkTestCase::~CBaseBulkTestCase()
       
    92 	{
       
    93 	LOG_FUNC
       
    94 	
       
    95 	Cancel();
       
    96 
       
    97 	//Do this before deleting the transfer objects
       
    98 	//NB this should do nothing if already called from a derived test class
       
    99 	CloseInterfaceAndPipes();
       
   100 	
       
   101 	delete iValidateBuffer;
       
   102 	delete iInBuffer;
       
   103 	delete iOutBuffer;
       
   104 
       
   105 	delete iBulkTestTimer;
       
   106 
       
   107 	TUint8 count;
       
   108 	for(count=0;count<KMaxNumOutTransfers;count++)
       
   109 		{
       
   110 		delete iOutTransfer[count];
       
   111 		}
       
   112 	for(count=0;count<KMaxNumInTransfers;count++)
       
   113 		{
       
   114 		delete iInTransfer[count];
       
   115 		}
       
   116 	
       
   117 	delete iControlEp0;
       
   118 	delete iActorFDF;
       
   119 	if(!IsHost() && iTestDevice)
       
   120 		{
       
   121 		iTestDevice->Close();
       
   122 		}
       
   123 	delete iTestDevice;
       
   124 	}
       
   125 	
       
   126 void CBaseBulkTestCase::ExecuteHostTestCaseL()	
       
   127 	{
       
   128 	LOG_FUNC
       
   129 	
       
   130 	iActorFDF = CActorFDF::NewL(*this);
       
   131 	iControlEp0 = new (ELeave) CEp0Transfer(iUsbInterface0);
       
   132 	iActorFDF->Monitor();
       
   133 	TimeoutIn(30);
       
   134 	}
       
   135 	
       
   136 void CBaseBulkTestCase::HostDoCancel()
       
   137 	{
       
   138 	LOG_FUNC
       
   139 	
       
   140 	// Cancel the test step timeout timer
       
   141 	
       
   142 	CancelTimeout();
       
   143 	}
       
   144 	
       
   145 	
       
   146 void CBaseBulkTestCase::ExecuteDeviceTestCaseL()
       
   147 	{
       
   148 	LOG_FUNC
       
   149 	
       
   150 	iTestDevice->OpenL(TestCaseId());
       
   151 	iTestDevice->SubscribeToReports(iStatus);
       
   152 	SetActive();
       
   153 	
       
   154 	// Connect the device to the host
       
   155 	
       
   156 	iTestDevice->SoftwareConnect();
       
   157 	}
       
   158 	
       
   159 void CBaseBulkTestCase::DeviceDoCancel()
       
   160 	{
       
   161 	LOG_FUNC
       
   162 	
       
   163 	// Cancel the test device error reports
       
   164 	
       
   165 	iTestDevice->CancelSubscriptionToReports();
       
   166 	}
       
   167 	
       
   168 	
       
   169 void CBaseBulkTestCase::DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState,
       
   170 				RUsbDevice::TDeviceState aNewState,TInt aCompletionCode)
       
   171 	{
       
   172 	LOG_FUNC
       
   173 	Cancel();
       
   174 	}
       
   175 	
       
   176 	
       
   177 TInt CBaseBulkTestCase::BaseBulkDeviceInsertedL(TUint aDeviceHandle)
       
   178 	{
       
   179 	LOG_FUNC
       
   180 	RDebug::Printf("this - %08x", this);
       
   181 	return BaseBulkDeviceInsertedL(aDeviceHandle, EFalse);
       
   182 	}
       
   183 
       
   184 void CBaseBulkTestCase::DeviceInsertedL(TUint aDeviceHandle)
       
   185 	{
       
   186 	//to be implemnted in individual test cases, possibly with the help of BaseBulkDeviceInsertedL
       
   187 	BaseBulkDeviceInsertedL(aDeviceHandle);
       
   188 	};
       
   189 
       
   190 TInt CBaseBulkTestCase::BaseBulkDeviceInsertedL(TUint aDeviceHandle, TBool aUseTwoInterfaces)
       
   191 	{
       
   192 	LOG_FUNC
       
   193 	TInt err(KErrNone);
       
   194 	
       
   195 	// Validate connected device	
       
   196 	CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle);
       
   197 	
       
   198 	RDebug::Printf("device serial number (%S)",&testDevice.SerialNumber());
       
   199 	RDebug::Printf("Manufacturer (%S)",&testDevice.Manufacturer());
       
   200 	RDebug::Printf("Product (%S)",&testDevice.Product());
       
   201 	RDebug::Printf("ProductId (%d)",testDevice.ProductId());
       
   202 	RDebug::Printf("VendorId (%d)",testDevice.VendorId());
       
   203 	
       
   204 	if(testDevice.SerialNumber().Compare(TestCaseId()) != 0)
       
   205 		{
       
   206 		// Incorrect device for this test case	
       
   207 
       
   208 		RDebug::Printf("<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)",
       
   209 			KErrNotFound,&testDevice.SerialNumber(),&TestCaseId());
       
   210 
       
   211 		// Start the connection timeout again
       
   212 		TimeoutIn(30);
       
   213 		return EDeviceConfigurationError;
       
   214 		}	
       
   215 
       
   216 
       
   217 	TUint32 token0;
       
   218 	err = testDevice.Device().GetTokenForInterface(0,token0);
       
   219 	if(err != KErrNone)
       
   220 		{
       
   221 		RDebug::Printf("<Error %d> Token for interface 0 could not be retrieved",err);
       
   222 
       
   223 		// Start the connection timeout again
       
   224 		TimeoutIn(30);
       
   225 		return EDeviceConfigurationError;
       
   226 		}
       
   227 	err = iUsbInterface0.Open(token0); // Default interface setting 0
       
   228 	if(err != KErrNone)
       
   229 		{
       
   230 		RDebug::Printf("<Error %d> Unable to open interface 0 using token %d",err,token0);
       
   231 		// Start the connection timeout again
       
   232 		TimeoutIn(30);
       
   233 		return EDeviceConfigurationError;
       
   234 		}
       
   235 
       
   236 	err = SetUpInterfaceAndPipesL(aDeviceHandle, 1);
       
   237 	if(err != ENone)
       
   238 		//msg already setup, and failure message sent
       
   239 		{
       
   240 		return EDeviceConfigurationError;	
       
   241 		}
       
   242 	return ENone;
       
   243 	}
       
   244 
       
   245 
       
   246 TInt CBaseBulkTestCase::SetUpInterfaceAndPipesL(TUint aDeviceHandle, TUint8 aInterfaceNum)
       
   247 	{
       
   248 	LOG_FUNC
       
   249 	TInt err(KErrNone);
       
   250 	TInt endpointAddress;
       
   251 	RUsbInterface* pTestInterface = NULL;
       
   252 	RUsbPipe* pTestPipeBulkIn = NULL;
       
   253 	RUsbPipe* pTestPipeBulkOut1 = NULL;
       
   254 	RUsbPipe* pTestPipeBulkOut2 = NULL;
       
   255 	CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle);
       
   256 	
       
   257 	switch(aInterfaceNum)
       
   258 		{
       
   259 		case 1:
       
   260 			pTestInterface = &iUsbInterface1;
       
   261 			pTestPipeBulkIn = &iTestPipeInterface1BulkIn;
       
   262 			pTestPipeBulkOut1 = &iTestPipeInterface1BulkOut;
       
   263 			pTestPipeBulkOut2 = NULL;
       
   264 			break;
       
   265 		case 2:
       
   266 			pTestInterface = &iUsbInterface2;
       
   267 			pTestPipeBulkIn = &iTestPipeInterface2BulkIn;
       
   268 			pTestPipeBulkOut1 = &iTestPipeInterface2BulkOut1;
       
   269 			pTestPipeBulkOut2 = &iTestPipeInterface2BulkOut2;
       
   270 			break;
       
   271 		default:
       
   272 			User::Panic(_L("Bulk Interface Number Out Of Range"), KErrArgument);
       
   273 			break;
       
   274 		}
       
   275 
       
   276 	RDebug::Printf("this - %08x", this);
       
   277 	
       
   278 	TUint32 token;
       
   279 	err = testDevice.Device().GetTokenForInterface(aInterfaceNum,token);
       
   280 	if(err != KErrNone)
       
   281 		{
       
   282 		TBuf<256> msg;
       
   283 		msg.Format(_L("<Error %d> Token for interface 1 could not be retrieved"),err);
       
   284 		RDebug::Print(msg);
       
   285 		TTestCaseFailed request(err,msg);
       
   286 		return EDeviceConfigurationError;
       
   287 		}
       
   288 	if(pTestInterface != NULL)
       
   289 		{
       
   290 		err = pTestInterface->Open(token); // Default interface setting 1
       
   291 		if(err != KErrNone)
       
   292 			{
       
   293 			TBuf<256> msg;
       
   294 			msg.Format(_L("<Error %d> Unable to open interface 1 using token %d"),err,token);
       
   295 			RDebug::Print(msg);
       
   296 			TTestCaseFailed request(err,msg);
       
   297 			return EDeviceConfigurationError;
       
   298 			}
       
   299 		}
       
   300 	
       
   301 	if(pTestPipeBulkIn != NULL)
       
   302 		{
       
   303 		err = GetEndpointAddress(*pTestInterface,0,KTransferTypeBulk,KEpDirectionIn,endpointAddress);
       
   304 		if(err != KErrNone)
       
   305 			{
       
   306 			TBuf<256> msg;
       
   307 			msg.Format(_L("<Error %d> Address for bulk in endpoint could not be obtained"),err);
       
   308 			RDebug::Print(msg);
       
   309 			TTestCaseFailed request(err,msg);
       
   310 			return EDeviceConfigurationError;
       
   311 			}
       
   312 		
       
   313 		RDebug::Printf("IN Endpoint address %08x",endpointAddress);
       
   314 		
       
   315 		err = pTestInterface->OpenPipeForEndpoint(*pTestPipeBulkIn,endpointAddress,ETrue);
       
   316 		if(err != KErrNone)
       
   317 			{
       
   318 			TBuf<256> msg;
       
   319 			msg.Format(_L("<Error %d> Unable to open pipe for endpoint %08x"),err,endpointAddress);
       
   320 			RDebug::Print(msg);
       
   321 			TTestCaseFailed request(err,msg);
       
   322 			return EDeviceConfigurationError;
       
   323 			}
       
   324 		}
       
   325 		
       
   326 	if(pTestPipeBulkOut1 != NULL)
       
   327 		{
       
   328 		err = GetEndpointAddress(*pTestInterface,0,KTransferTypeBulk,KEpDirectionOut,endpointAddress);
       
   329 		if(err != KErrNone)
       
   330 			{
       
   331 			TBuf<256> msg;
       
   332 			msg.Format(_L("<Error %d> Address for(first) bulk out endpoint could not be obtained"),err);
       
   333 			RDebug::Print(msg);
       
   334 			TTestCaseFailed request(err,msg);
       
   335 			return EDeviceConfigurationError;
       
   336 			}
       
   337 		
       
   338 		RDebug::Printf("OUT Endpoint address %08x",endpointAddress);
       
   339 		
       
   340 		err = pTestInterface->OpenPipeForEndpoint(*pTestPipeBulkOut1,endpointAddress,ETrue);
       
   341 		if(err != KErrNone)
       
   342 			{
       
   343 			TBuf<256> msg;
       
   344 			msg.Format(_L("<Error %d> Unable to open pipe for endpoint %08x"),err,endpointAddress);
       
   345 			RDebug::Print(msg);
       
   346 			TTestCaseFailed request(err,msg);
       
   347 			return EDeviceConfigurationError;
       
   348 			}
       
   349 		}
       
   350 	
       
   351 	if(pTestPipeBulkOut2 != NULL)
       
   352 		{
       
   353 		err = GetEndpointAddress(*pTestInterface,0,KTransferTypeBulk,KEpDirectionOut,1,endpointAddress);
       
   354 		if(err != KErrNone)
       
   355 			{
       
   356 			TBuf<256> msg;
       
   357 			msg.Format(_L("<Error %d> Address for(second) bulk out endpoint could not be obtained"),err);
       
   358 			RDebug::Print(msg);
       
   359 			TTestCaseFailed request(err,msg);
       
   360 			return EDeviceConfigurationError;
       
   361 			}
       
   362 		
       
   363 		RDebug::Printf("OUT Endpoint address %08x",endpointAddress);
       
   364 		
       
   365 		err = pTestInterface->OpenPipeForEndpoint(*pTestPipeBulkOut2,endpointAddress,ETrue);
       
   366 		if(err != KErrNone)
       
   367 			{
       
   368 			TBuf<256> msg;
       
   369 			msg.Format(_L("<Error %d> Unable to open pipe for endpoint %08x"),err,endpointAddress);
       
   370 			RDebug::Print(msg);
       
   371 			TTestCaseFailed request(err,msg);
       
   372 			return EDeviceConfigurationError;
       
   373 			}
       
   374 		}
       
   375 
       
   376 	return ENone;
       
   377 	}
       
   378 	
       
   379 void CBaseBulkTestCase::CloseInterfaceAndPipes()
       
   380 	{
       
   381 	LOG_FUNC
       
   382 	
       
   383 	// Close the pipe(s) before interface(s)
       
   384 	iTestPipeInterface2BulkIn.Close();
       
   385 	iTestPipeInterface2BulkOut1.Close();
       
   386 	iTestPipeInterface2BulkOut2.Close();
       
   387 	iTestPipeInterface1BulkIn.Close();
       
   388 	iTestPipeInterface1BulkOut.Close();
       
   389 	
       
   390 	iUsbInterface2.Close();
       
   391 	iUsbInterface1.Close();
       
   392 	iUsbInterface0.Close();
       
   393 	}
       
   394 
       
   395 void CBaseBulkTestCase::DeviceRemovedL(TUint aDeviceHandle)
       
   396 	{
       
   397 	LOG_FUNC
       
   398 	
       
   399 	// The test device should not be removed until the test case has passed
       
   400 	// so this test case has not completed, and state this event as an error
       
   401 	
       
   402 	TestFailed(KErrDisconnected);
       
   403 	}
       
   404 	
       
   405 	
       
   406 void CBaseBulkTestCase::BusErrorL(TInt aError)
       
   407 	{
       
   408 	LOG_FUNC
       
   409 	
       
   410 	// This test case handles no failiures on the bus
       
   411 	
       
   412 	TestFailed(KErrCompletion);
       
   413 	}
       
   414 
       
   415 void CBaseBulkTestCase::HostRunL()
       
   416 	{
       
   417 	// Obtain the completion code
       
   418 	TInt completionCode(iStatus.Int());
       
   419 	
       
   420 	if(completionCode == KErrNone)
       
   421 		{
       
   422 		// Action timeout
       
   423 		RDebug::Printf("<Error> Action timeout");
       
   424 		TestFailed(KErrTimedOut);
       
   425 		}
       
   426 	else
       
   427 		{
       
   428 		RDebug::Printf("<Error %d> Timeout timer could not complete",completionCode);
       
   429 		TestFailed(completionCode);
       
   430 		}
       
   431 	}
       
   432 
       
   433 void CBaseBulkTestCase::DeviceRunL()
       
   434 	{
       
   435 	LOG_FUNC
       
   436 	
       
   437 	// Disconnect the device
       
   438 	iTestDevice->SoftwareDisconnect();
       
   439 	
       
   440 	// Complete the test case request
       
   441 	TestPolicy().SignalTestComplete(iStatus.Int());
       
   442 	}
       
   443 
       
   444 TBool CBaseBulkTestCase::ValidateData (const TDesC8& aDataToValidate, const TDesC8& aDataPattern)
       
   445 	{
       
   446 	return ValidateData(aDataToValidate, aDataPattern, aDataPattern.Length());
       
   447 	}
       
   448 
       
   449 TBool CBaseBulkTestCase::ValidateData (const TDesC8& aDataToValidate, const TDesC8& aDataPattern, const TUint aNumBytes)
       
   450 	{
       
   451 	return ValidateData(aDataToValidate, aDataPattern, 0, aNumBytes);
       
   452 	}
       
   453 
       
   454 TBool CBaseBulkTestCase::ValidateData (const TDesC8& aDataToValidate, const TDesC8& aDataPattern, const TUint aStartPoint, const TUint aNumBytes)
       
   455 	{
       
   456 	LOG_FUNC
       
   457 		
       
   458 	__ASSERT_DEBUG(aDataPattern.Length()!=0, User::Panic(_L("Trying to validate with ZERO LENGTH STRING"), KErrArgument));
       
   459 
       
   460 	if(aDataToValidate.Length()!=aNumBytes)
       
   461 		{
       
   462 		RDebug::Printf("ROUND TRIP VALIDATION: Length Match Failure, Sent = %d, Returned = %d", aNumBytes, aDataToValidate.Length());
       
   463 		return EFalse;
       
   464 		}
       
   465 	TUint startPoint = aStartPoint%aDataPattern.Length();
       
   466 	TUint numStartBytes = (aDataPattern.Length() - startPoint)%aDataPattern.Length();
       
   467 	numStartBytes = aNumBytes<numStartBytes?aNumBytes:numStartBytes; //never test for more than aNumBytes
       
   468 	TUint fullRepeats = (aNumBytes-numStartBytes)/aDataPattern.Length();
       
   469 	TUint startEndPoint = (fullRepeats*aDataPattern.Length()) + numStartBytes;
       
   470 	TUint numEndBytes = aNumBytes - startEndPoint;//fullRepeats*aDataPattern.Length() - numStartBytes;
       
   471 	if(numStartBytes)
       
   472 		{
       
   473 		if(aDataToValidate.Left(numStartBytes).Compare(aDataPattern.Mid(startPoint, numStartBytes)) != 0)
       
   474 			{
       
   475 			RDebug::Printf("ROUND TRIP VALIDATION: Start Bytes Match Failure");
       
   476 			RDebug::Printf("ROUND TRIP VALIDATION: numStartBytes = %d", numStartBytes);
       
   477 			RDebug::Printf("Start of EXPECTED data ...");
       
   478 			RDebug::RawPrint(aDataPattern.Mid(startPoint, numStartBytes));
       
   479 			RDebug::Printf("\n");
       
   480 			RDebug::Printf("Start of RETURNED data ...");				
       
   481 			RDebug::RawPrint(aDataToValidate.Left(numStartBytes));
       
   482 			RDebug::Printf("\n");
       
   483 			return EFalse;
       
   484 			}
       
   485 		}
       
   486 	if(numEndBytes)
       
   487 		{
       
   488 		if(aDataToValidate.Mid(startEndPoint,numEndBytes).Compare(aDataPattern.Left(numEndBytes)) != 0)
       
   489 			{
       
   490 			RDebug::Printf("ROUND TRIP VALIDATION: End Bytes Match Failure");
       
   491 			RDebug::Printf("ROUND TRIP VALIDATION: startEndPoint = %d, numEndBytes = %d", startEndPoint, numEndBytes);
       
   492 			RDebug::Printf("End of EXPECTED data ...");
       
   493 			RDebug::RawPrint(aDataPattern.Left(numEndBytes));
       
   494 			RDebug::Printf("\n");
       
   495 			RDebug::Printf("End of RETURNED data ...");				
       
   496 			RDebug::RawPrint(aDataToValidate.Mid(startEndPoint,numEndBytes));
       
   497 			RDebug::Printf("\n");
       
   498 			return EFalse;
       
   499 			}
       
   500 		}
       
   501 	for(TInt i=0; i<fullRepeats; i++)
       
   502 		{
       
   503 		if(aDataToValidate.Mid(numStartBytes + i*aDataPattern.Length(),aDataPattern.Length()).Compare(aDataPattern) != 0)
       
   504 			{
       
   505 			RDebug::Printf("ROUND TRIP VALIDATION: Repeated Bytes Match Failure, Repeat %d",i);
       
   506 			RDebug::Printf("Middle block of EXPECTED data ...");
       
   507 			RDebug::RawPrint(aDataPattern);
       
   508 			RDebug::Printf("\n");
       
   509 			RDebug::Printf("Middle block of RETURNED data ...");
       
   510 			RDebug::RawPrint(aDataToValidate.Mid(numStartBytes + i*aDataPattern.Length(),aDataPattern.Length()));
       
   511 			RDebug::Printf("\n");
       
   512 			return EFalse; //from 'for' loop
       
   513 			}
       
   514 		}
       
   515 	return ETrue;
       
   516 	}
       
   517 
       
   518 void CBaseBulkTestCase::RecordTime(const TUint8 aTimerIndex)
       
   519 	{
       
   520 	LOG_FUNC
       
   521 	if(aTimerIndex >= KMaxNumTimers)
       
   522 		{
       
   523 		RDebug::Printf("Record Timer with index %d called - index OUT OF RANGE", aTimerIndex);
       
   524 		User::Panic(_L("BAD TIMER INDEX"), KErrArgument);
       
   525 		}
       
   526 	iEndTime[aTimerIndex].HomeTime();
       
   527 	iTimeElapsed[aTimerIndex] = iEndTime[aTimerIndex].MicroSecondsFrom(iStartTime[aTimerIndex]);
       
   528 	RDebug::Printf("Timer with index %d completed in %d uSec", aTimerIndex, (TInt)(iTimeElapsed[aTimerIndex].Int64()));
       
   529 	}
       
   530 
       
   531 TInt CBaseBulkTestCase::CheckTimes(const TUint8 aFirstTimerIndex, const TUint8 aSecondTimerIndex, const TUint aPercentage)
       
   532 	{
       
   533 	LOG_FUNC
       
   534 	if(aFirstTimerIndex >= KMaxNumTimers)
       
   535 		{
       
   536 		RDebug::Printf("First timer with index %d called - index OUT OF RANGE", aFirstTimerIndex);
       
   537 		User::Panic(_L("BAD TIMER INDEX"), KErrArgument);
       
   538 		}
       
   539 	if(aSecondTimerIndex >= KMaxNumTimers)
       
   540 		{
       
   541 		RDebug::Printf("Second timer with index %d called - index OUT OF RANGE", aSecondTimerIndex);
       
   542 		User::Panic(_L("BAD TIMER INDEX"), KErrArgument);
       
   543 		}
       
   544 
       
   545 	TInt ret = KErrNone;
       
   546 	RDebug::Printf("Transfer %d completed in %d uSec\nTransfer %d completed in %d uSec", aFirstTimerIndex, (TInt)(iTimeElapsed[aFirstTimerIndex].Int64()), aSecondTimerIndex, (TInt)(iTimeElapsed[aSecondTimerIndex].Int64()));
       
   547 	if(aPercentage*iTimeElapsed[aFirstTimerIndex].Int64() > KPercent*iTimeElapsed[aSecondTimerIndex].Int64())
       
   548 		{
       
   549 		ret = KErrTooBig;
       
   550 		RDebug::Printf("Time %d too big", aFirstTimerIndex);
       
   551 		}
       
   552 	if(aPercentage*iTimeElapsed[aSecondTimerIndex].Int64() > KPercent*iTimeElapsed[aFirstTimerIndex].Int64())
       
   553 		{
       
   554 		ret = KErrTooBig;
       
   555 		RDebug::Printf("Time %d too big", aSecondTimerIndex);
       
   556 		}
       
   557 	
       
   558 	return ret;
       
   559 	}
       
   560 
       
   561 void CBaseBulkTestCase::ResetTimes(const TUint8 aTimerIndex)
       
   562 	{
       
   563 	iStartTime[aTimerIndex] = 0;
       
   564 	iEndTime[aTimerIndex] = 0;
       
   565 	iTimeElapsed[aTimerIndex] = 0;
       
   566 	}
       
   567 
       
   568 TInt CBaseBulkTestCase::CheckAndResetTimes(const TUint8 aFirstTimerIndex, const TUint8 aSecondTimerIndex, const TUint aPercentage)
       
   569 	{
       
   570 	LOG_FUNC
       
   571 	
       
   572 	TInt ret = CheckTimes(aFirstTimerIndex, aSecondTimerIndex, aPercentage);
       
   573 	ResetTimes(aFirstTimerIndex);
       
   574 	ResetTimes(aSecondTimerIndex);
       
   575 	
       
   576 	return ret;
       
   577 	}
       
   578 
       
   579 void CBaseBulkTestCase::HandleBulkTestTimerFired()
       
   580 	{
       
   581 	//do nothing here - leave to derived class if required
       
   582 	}
       
   583 
       
   584 	}//end namespace
       
   585