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