os/kernelhwsrv/kerneltest/e32test/dmav2/self_test.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/dmav2/self_test.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,665 @@
     1.4 +/*
     1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +* This file contains unit tests for the test framework itself.
    1.19 +* They should be run if changes have been made to
    1.20 +* to the user side test framework code ie. anything in the dmav2
    1.21 +* directory other than the d_* driver code, or test_cases.cpp
    1.22 +*
    1.23 +*/
    1.24 +
    1.25 +#include "d_dma2.h"
    1.26 +#include "u32std.h"
    1.27 +#include "t_dma2.h"
    1.28 +#include "cap_reqs.h"
    1.29 +
    1.30 +#define __E32TEST_EXTENSION__
    1.31 +#include <e32test.h>
    1.32 +#include <e32debug.h>
    1.33 +#include <e32svr.h>
    1.34 +
    1.35 +static RTest test(_L("t_dma2 test framework tests"));
    1.36 +
    1.37 +void RDmaSession::SelfTest()
    1.38 +	{
    1.39 +	test.Start(_L("Simple transfer test"));
    1.40 +	test.Next(_L("Open session"));
    1.41 +	RDmaSession session;
    1.42 +	TInt r = session.Open();
    1.43 +	test_KErrNone(r);
    1.44 +
    1.45 +	test.Next(_L("Get test info"));
    1.46 +	TDmaV2TestInfo testInfo;
    1.47 +	r = session.GetTestInfo(testInfo);
    1.48 +	test_KErrNone(r);
    1.49 +
    1.50 +	if(gVerboseOutput)
    1.51 +	{
    1.52 +	Print(testInfo);
    1.53 +	}
    1.54 +
    1.55 +	test.Next(_L("Channel open"));
    1.56 +	TUint channelCookie=0;
    1.57 +	r = session.ChannelOpen(16, channelCookie);
    1.58 +	test.Printf(_L("cookie recived = 0x%08x\n"), channelCookie);
    1.59 +	test_KErrNone(r);
    1.60 +
    1.61 +	test.Next(_L("Get Channel caps"));
    1.62 +	SDmacCaps channelCaps;
    1.63 +	r = session.ChannelCaps(channelCookie, channelCaps);
    1.64 +	test_KErrNone(r);
    1.65 +	if(gVerboseOutput)
    1.66 +	{
    1.67 +	PRINT(channelCaps.iChannelPriorities);
    1.68 +	PRINT(channelCaps.iChannelPauseAndResume);
    1.69 +	PRINT(channelCaps.iAddrAlignedToElementSize);
    1.70 +	PRINT(channelCaps.i1DIndexAddressing);
    1.71 +	PRINT(channelCaps.i2DIndexAddressing);
    1.72 +	PRINT(channelCaps.iSynchronizationTypes);
    1.73 +	PRINT(channelCaps.iBurstTransactions);
    1.74 +	PRINT(channelCaps.iDescriptorInterrupt);
    1.75 +	PRINT(channelCaps.iFrameInterrupt);
    1.76 +	PRINT(channelCaps.iLinkedListPausedInterrupt);
    1.77 +	PRINT(channelCaps.iEndiannessConversion);
    1.78 +	PRINT(channelCaps.iGraphicsOps);
    1.79 +	PRINT(channelCaps.iRepeatingTransfers);
    1.80 +	PRINT(channelCaps.iChannelLinking);
    1.81 +	PRINT(channelCaps.iHwDescriptors);
    1.82 +	PRINT(channelCaps.iSrcDstAsymmetry);
    1.83 +	PRINT(channelCaps.iAsymHwDescriptors);
    1.84 +	PRINT(channelCaps.iBalancedAsymSegments);
    1.85 +	PRINT(channelCaps.iAsymCompletionInterrupt);
    1.86 +	PRINT(channelCaps.iAsymDescriptorInterrupt);
    1.87 +	PRINT(channelCaps.iAsymFrameInterrupt);
    1.88 +	PRINT(channelCaps.iReserved[0]);
    1.89 +	PRINT(channelCaps.iReserved[1]);
    1.90 +	PRINT(channelCaps.iReserved[2]);
    1.91 +	PRINT(channelCaps.iReserved[3]);
    1.92 +	PRINT(channelCaps.iReserved[4]);	
    1.93 +	}
    1.94 +
    1.95 +	test.Next(_L("Get extended Channel caps (TDmacTestCaps)"));
    1.96 +	TDmacTestCaps extChannelCaps;
    1.97 +	r = session.ChannelCaps(channelCookie, extChannelCaps);
    1.98 +	test_KErrNone(r);
    1.99 +	test.Printf(_L("PIL version = %d\n"), extChannelCaps.iPILVersion);
   1.100 +
   1.101 +	const TBool newPil = (extChannelCaps.iPILVersion > 1);
   1.102 +
   1.103 +	test.Next(_L("Create Dma request - max fragment size 32K"));
   1.104 +	TUint reqCookie=0;
   1.105 +	r = session.RequestCreate(channelCookie, reqCookie, 32 * KKilo);
   1.106 +	test.Printf(_L("cookie recived = 0x%08x\n"), reqCookie);
   1.107 +	test_KErrNone(r);
   1.108 +
   1.109 +	if(newPil)
   1.110 +		{
   1.111 +		test.Next(_L("Create Dma request (with new-style callback)"));
   1.112 +		TUint reqCookieNewStyle=0;
   1.113 +		r = session.RequestCreateNew(channelCookie, reqCookieNewStyle);
   1.114 +		test.Printf(_L("cookie recived = 0x%08x\n"), reqCookieNewStyle );
   1.115 +		test_KErrNone(r);
   1.116 +
   1.117 +		test.Next(_L("Fragment for ISR callback"));
   1.118 +		const TInt size = 128 * KKilo;
   1.119 +		TDmaTransferArgs transferArgs(0, size, size, KDmaMemAddr, KDmaSyncAuto, KDmaRequestCallbackFromIsr);
   1.120 +		r = session.FragmentRequest(reqCookieNewStyle, transferArgs);
   1.121 +		test_KErrNone(r);
   1.122 +
   1.123 +		TIsrRequeArgs reque;
   1.124 +		test.Next(_L("Queue ISR callback - with default re-queue"));
   1.125 +		r = session.QueueRequestWithRequeue(reqCookieNewStyle, &reque, 1);
   1.126 +		test_KErrNone(r);
   1.127 +
   1.128 +		test.Next(_L("Destroy new-style Dma request"));
   1.129 +		r = session.RequestDestroy(reqCookieNewStyle);
   1.130 +		test_KErrNone(r);
   1.131 +
   1.132 +		test.Next(_L("Attempt to destroy request again "));
   1.133 +		r = session.RequestDestroy(reqCookieNewStyle);
   1.134 +		test_Equal(KErrNotFound, r);
   1.135 +		}
   1.136 +
   1.137 +	test.Next(_L("Open chunk handle"));
   1.138 +	RChunk chunk;
   1.139 +	r = session.OpenSharedChunk(chunk);
   1.140 +	test_KErrNone(r);
   1.141 +	if(gVerboseOutput)
   1.142 +	{
   1.143 +	test.Printf(_L("chunk base = 0x%08x\n"), chunk.Base());
   1.144 +	test.Printf(_L("chunk size = %d\n"), chunk.Size());
   1.145 +	}
   1.146 +	test(chunk.IsWritable());
   1.147 +	test(chunk.IsReadable());
   1.148 +
   1.149 +	test.Next(_L("Fragment(old style)"));
   1.150 +	const TInt size = 128 * KKilo;
   1.151 +	TInt i;
   1.152 +	for(i = 0; i<10; i++)
   1.153 +		{
   1.154 +		TUint64 time = 0;
   1.155 +		TDmaTransferArgs transferArgs(0, size, size, KDmaMemAddr);
   1.156 +		r = session.FragmentRequestOld(reqCookie, transferArgs, &time);
   1.157 +		test_KErrNone(r);
   1.158 +		if(gVerboseOutput)
   1.159 +			{
   1.160 +			test.Printf(_L("%lu us\n"), time);
   1.161 +			}
   1.162 +	}
   1.163 +
   1.164 +	test.Next(_L("Queue"));
   1.165 +	TRequestStatus status;
   1.166 +
   1.167 +	for(i = 0; i<10; i++)
   1.168 +		{
   1.169 +		TUint64 time = 0;
   1.170 +		r = session.QueueRequest(reqCookie, status, 0, &time);
   1.171 +		User::WaitForRequest(status);
   1.172 +		test_KErrNone(r);
   1.173 +		if(gVerboseOutput)
   1.174 +			{
   1.175 +			test.Printf(_L("%lu us\n"), time);
   1.176 +			}
   1.177 +		}
   1.178 +
   1.179 +	if(newPil)
   1.180 +		{
   1.181 +		test.Next(_L("Fragment(new style)"));
   1.182 +		TDmaTransferArgs transferArgs;
   1.183 +		transferArgs.iSrcConfig.iAddr = 0;
   1.184 +		transferArgs.iDstConfig.iAddr = size;
   1.185 +		transferArgs.iSrcConfig.iFlags = KDmaMemAddr;
   1.186 +		transferArgs.iDstConfig.iFlags = KDmaMemAddr;
   1.187 +		transferArgs.iTransferCount = size;
   1.188 +
   1.189 +		for(i = 0; i<10; i++)
   1.190 +			{
   1.191 +			TUint64 time = 0;
   1.192 +			r = session.FragmentRequest(reqCookie, transferArgs, &time);
   1.193 +			test_KErrNone(r);
   1.194 +			if(gVerboseOutput)
   1.195 +				{
   1.196 +				test.Printf(_L("%lu us\n"), time);
   1.197 +				}
   1.198 +			}
   1.199 +		}
   1.200 +
   1.201 +	test.Next(_L("Queue"));
   1.202 +	TCallbackRecord record;
   1.203 +	r = session.QueueRequest(reqCookie, &record);
   1.204 +	test_KErrNone(r);
   1.205 +
   1.206 +	test.Next(_L("check TCallbackRecord record"));
   1.207 +	if(gVerboseOutput)
   1.208 +	{
   1.209 +	record.Print();
   1.210 +	}
   1.211 +	const TCallbackRecord expected(TCallbackRecord::EThread, 1);
   1.212 +	if(!(record == expected))
   1.213 +		{
   1.214 +		test.Printf(_L("TCallbackRecords did not match"));
   1.215 +		if(gVerboseOutput)
   1.216 +			{
   1.217 +			test.Printf(_L("expected:"));
   1.218 +			expected.Print();
   1.219 +			}
   1.220 +		TEST_FAULT;
   1.221 +		}
   1.222 +
   1.223 +	test.Next(_L("Destroy Dma request"));
   1.224 +	r = session.RequestDestroy(reqCookie);
   1.225 +	test_KErrNone(r);
   1.226 +
   1.227 +	test.Next(_L("Close chunk handle"));
   1.228 +	chunk.Close();
   1.229 +
   1.230 +	test.Next(_L("Channel close"));
   1.231 +	r = session.ChannelClose(channelCookie);
   1.232 +	test_KErrNone(r);
   1.233 +
   1.234 +	test.Next(_L("Channel close (same again)"));
   1.235 +	r = session.ChannelClose(channelCookie);
   1.236 +	test_Equal(KErrNotFound, r);
   1.237 +
   1.238 +	test.Next(_L("Close session"));
   1.239 +	RTest::CloseHandleAndWaitForDestruction(session);
   1.240 +
   1.241 +	test.End();
   1.242 +
   1.243 +	}
   1.244 +
   1.245 +const SDmacCaps KTestCapSet =
   1.246 +	{6,										// TInt iChannelPriorities;
   1.247 +	 EFalse,								// TBool iChannelPauseAndResume;
   1.248 +	 ETrue,									// TBool iAddrAlignedToElementSize;
   1.249 +	 EFalse,								// TBool i1DIndexAddressing;
   1.250 +	 EFalse,								// TBool i2DIndexAddressing;
   1.251 +	 KDmaSyncSizeElement | KDmaSyncSizeFrame |
   1.252 +	 KDmaSyncSizeBlock,					   // TUint iSynchronizationTypes;
   1.253 +	 KDmaBurstSize4 | KDmaBurstSize8,	   // TUint iBurstTransactions;
   1.254 +	 EFalse,							   // TBool iDescriptorInterrupt;
   1.255 +	 EFalse,							   // TBool iFrameInterrupt;
   1.256 +	 EFalse,							   // TBool iLinkedListPausedInterrupt;
   1.257 +	 EFalse,							   // TBool iEndiannessConversion;
   1.258 +	 0,									   // TUint iGraphicsOps;
   1.259 +	 ETrue,								   // TBool iRepeatingTransfers;
   1.260 +	 EFalse,							   // TBool iChannelLinking;
   1.261 +	 ETrue,								   // TBool iHwDescriptors;
   1.262 +	 EFalse,							   // TBool iSrcDstAsymmetry;
   1.263 +	 EFalse,							   // TBool iAsymHwDescriptors;
   1.264 +	 EFalse,							   // TBool iBalancedAsymSegments;
   1.265 +	 EFalse,							   // TBool iAsymCompletionInterrupt;
   1.266 +	 EFalse,							   // TBool iAsymDescriptorInterrupt;
   1.267 +	 EFalse,							   // TBool iAsymFrameInterrupt;
   1.268 +	 {0, 0, 0, 0, 0}					   // TUint32 iReserved[5];
   1.269 +	};
   1.270 +
   1.271 +const TDmacTestCaps KDmacTestCapsV1(KTestCapSet, 1);
   1.272 +const TDmacTestCaps KDmacTestCapsV2(KTestCapSet, 2);
   1.273 +
   1.274 +void TDmaCapability::SelfTest()
   1.275 +	{
   1.276 +	test.Start(_L("Unit test_Value of TDmaCapability::CompareToDmaCaps\n"));
   1.277 +
   1.278 +	{
   1.279 +	test.Next(_L("ENone\n"));
   1.280 +	TResult t = none.CompareToDmaCaps(KTestCapSet);
   1.281 +	test_Value(t, t == ERun);
   1.282 +	}
   1.283 +
   1.284 +	{
   1.285 +	test.Next(_L("EChannelPauseAndResume - wanted\n"));
   1.286 +	TResult t = pauseRequired.CompareToDmaCaps(KTestCapSet);
   1.287 +	test_Value(t, t == EFail);
   1.288 +	}
   1.289 +	{
   1.290 +	test.Next(_L("EChannelPauseAndResume - wanted - Allow skip\n"));
   1.291 +	TResult t = pauseRequired_skip.CompareToDmaCaps(KTestCapSet);
   1.292 +	test_Value(t, t == ESkip);
   1.293 +	}
   1.294 +	{
   1.295 +	test.Next(_L("EChannelPauseAndResume - not wanted\n"));
   1.296 +	TResult t = pauseNotWanted.CompareToDmaCaps(KTestCapSet);
   1.297 +	test_Value(t, t == ERun);
   1.298 +	}
   1.299 +
   1.300 +	{
   1.301 +	test.Next(_L("EHwDescriptors - not wanted\n"));
   1.302 +	TResult t = hwDesNotWanted.CompareToDmaCaps(KTestCapSet);
   1.303 +	test_Value(t, t == EFail);
   1.304 +	}
   1.305 +
   1.306 +	{
   1.307 +	test.Next(_L("EHwDescriptors - not wanted - Allow skip\n"));
   1.308 +	TResult t = hwDesNotWanted_skip.CompareToDmaCaps(KTestCapSet);
   1.309 +	test_Value(t, t == ESkip);
   1.310 +	}
   1.311 +
   1.312 +	{
   1.313 +	test.Next(_L("EHwDescriptors - wanted\n"));
   1.314 +	TResult t = hwDesWanted.CompareToDmaCaps(KTestCapSet);
   1.315 +	test_Value(t, t == ERun);
   1.316 +	}
   1.317 +
   1.318 +
   1.319 +//TODO use this macro for the above tests
   1.320 +
   1.321 +// Note: The construction of the test description message
   1.322 +// is horribly confusing. The _L macro will make the
   1.323 +// *first* string token wide, but not the next two.
   1.324 +// Therefore these must be made wide or compilier
   1.325 +// will complain about concatination of narrow and wide string
   1.326 +// literals
   1.327 +#define CAP_TEST(CAP, CAPSET, EXPCT)\
   1.328 +	{\
   1.329 +	test.Next(_L(#CAP L" against " L ## #CAPSET));\
   1.330 +	TResult t = (CAP).CompareToDmaCaps(CAPSET);\
   1.331 +	test_Equal(EXPCT, t);\
   1.332 +	}
   1.333 +
   1.334 +
   1.335 +	CAP_TEST(capEqualV1, KDmacTestCapsV1, ERun);
   1.336 +	CAP_TEST(capEqualV2, KDmacTestCapsV2, ERun);
   1.337 +	CAP_TEST(capEqualV1, KDmacTestCapsV2, ESkip);
   1.338 +	CAP_TEST(capEqualV2, KDmacTestCapsV1, ESkip);
   1.339 +	CAP_TEST(capEqualV2Fatal, KDmacTestCapsV1, EFail);
   1.340 +
   1.341 +	CAP_TEST(capAboveV1, KDmacTestCapsV2, ERun);
   1.342 +	CAP_TEST(capBelowV2, KDmacTestCapsV1, ERun);
   1.343 +	CAP_TEST(capAboveV1, KDmacTestCapsV1, ESkip);
   1.344 +	CAP_TEST(capBelowV2, KDmacTestCapsV2, ESkip);
   1.345 +
   1.346 +	test.End();
   1.347 +	}
   1.348 +
   1.349 +void TTestCase::SelfTest()
   1.350 +	{
   1.351 +	//TODO should use macros for these tests
   1.352 +	test.Start(_L("Unit test of TTestCase::TestCaseValid\n"));
   1.353 +
   1.354 +	TTestCase testCase(NULL, EFalse, pauseRequired, hwDesNotWanted);
   1.355 +	test.Next(_L("pauseRequired, hwDesNotWanted\n"));
   1.356 +	TResult t = testCase.TestCaseValid(KTestCapSet);
   1.357 +	test_Value(t, t == EFail);
   1.358 +
   1.359 +	test.Next(_L("pauseRequired_skip, hwDesNotWanted\n"));
   1.360 +	testCase.iChannelCaps[0] = pauseRequired_skip;
   1.361 +	t = testCase.TestCaseValid(KTestCapSet);
   1.362 +	test_Value(t, t == EFail);
   1.363 +
   1.364 +	test.Next(_L("pauseRequired_skip, hwDesNotWanted_skip\n"));
   1.365 +	testCase.iChannelCaps[1] = hwDesNotWanted_skip;
   1.366 +	t = testCase.TestCaseValid(KTestCapSet);
   1.367 +	test_Value(t, t == ESkip);
   1.368 +
   1.369 +	test.Next(_L("pauseNotWanted, hwDesNotWanted_skip\n"));
   1.370 +	testCase.iChannelCaps[0] = pauseNotWanted;
   1.371 +	t = testCase.TestCaseValid(KTestCapSet);
   1.372 +	test_Value(t, t == ESkip);
   1.373 +
   1.374 +	test.Next(_L("pauseNotWanted, hwDesWanted\n"));
   1.375 +	testCase.iChannelCaps[1] = hwDesWanted;
   1.376 +	t = testCase.TestCaseValid(KTestCapSet);
   1.377 +	test_Value(t, t == ERun);
   1.378 +
   1.379 +	test.Next(_L("pauseNotWanted\n"));
   1.380 +	testCase.iChannelCaps[1] = none;
   1.381 +	t = testCase.TestCaseValid(KTestCapSet);
   1.382 +	test_Value(t, t == ERun);
   1.383 +
   1.384 +	test.Next(_L("pauseNotWanted + V1 PIL required\n"));
   1.385 +	testCase.iChannelCaps[1] = capAboveV1;
   1.386 +	test.Next(_L("Against KDmacTestCapsV1"));
   1.387 +	t = testCase.TestCaseValid(KDmacTestCapsV1);
   1.388 +	test_Equal(ESkip, t);
   1.389 +	test.Next(_L("Against KDmacTestCapsV2"));
   1.390 +	t = testCase.TestCaseValid(KDmacTestCapsV2);
   1.391 +	test_Equal(ERun, t);
   1.392 +
   1.393 +	test.Next(_L("pauseNotWanted + >V1 PIL required\n"));
   1.394 +	testCase.iChannelCaps[1] = capBelowV2;
   1.395 +	test.Next(_L("Against KDmacTestCapsV1"));
   1.396 +	t = testCase.TestCaseValid(KDmacTestCapsV1);
   1.397 +	test_Equal(ERun, t);
   1.398 +	test.Next(_L("Against KDmacTestCapsV2"));
   1.399 +	t = testCase.TestCaseValid(KDmacTestCapsV2);
   1.400 +	test_Equal(ESkip, t);
   1.401 +
   1.402 +	test.End();
   1.403 +	test.Close();
   1.404 +	}
   1.405 +
   1.406 +
   1.407 +void TTransferIter::SelfTest()
   1.408 +	{
   1.409 +	test.Start(_L("No skip"));
   1.410 +
   1.411 +	const TUint8 src[9] = {
   1.412 +			1 ,2, 3,
   1.413 +			4, 5, 6,
   1.414 +			7, 8, 9
   1.415 +	};
   1.416 +
   1.417 +	const TUint32 addr = (TUint32)src;
   1.418 +	const TUint elementSize = 1;
   1.419 +	const TUint elementSkip = 0;
   1.420 +	const TUint elementsPerFrame = 3;
   1.421 +	const TUint frameSkip = 0;
   1.422 +	const TUint framesPerTransfer = 3;
   1.423 +	TDmaTransferConfig cfg(addr, elementSize, elementsPerFrame, framesPerTransfer,
   1.424 +			elementSkip, frameSkip, KDmaMemAddr
   1.425 +			);
   1.426 +
   1.427 +	TTransferIter iter(cfg, 0);
   1.428 +	TTransferIter end;
   1.429 +	TInt i;
   1.430 +	for(i = 0; i<9; i++, ++iter)
   1.431 +		{
   1.432 +		test_Equal(src[i],*iter);
   1.433 +		};
   1.434 +
   1.435 +
   1.436 +	test.Next(_L("90 degree rotation"));
   1.437 +	// Now imagine that we wanted to perform a rotation
   1.438 +	// as we write, so that we wrote out the following
   1.439 +
   1.440 +	const TUint8 expected[9] = {
   1.441 +		7, 4, 1,
   1.442 +		8, 5, 2,
   1.443 +		9, 6, 3
   1.444 +	};
   1.445 +
   1.446 +	TUint8 dst[9] = {0};
   1.447 +	TDmaTransferConfig dst_cfg(cfg);
   1.448 +	dst_cfg.iAddr = (TUint32)&dst[2];
   1.449 +	dst_cfg.iElementSkip = 2;
   1.450 +	dst_cfg.iFrameSkip = -8;
   1.451 +
   1.452 +	TTransferIter dst_iter(dst_cfg, 0);
   1.453 +	for(i=0; dst_iter != end; i++, ++dst_iter)
   1.454 +		{
   1.455 +		TEST_ASSERT(i<9);
   1.456 +		*dst_iter=src[i];
   1.457 +		};
   1.458 +
   1.459 +	for(i=0; i<9; i++)
   1.460 +		{
   1.461 +		test_Equal(expected[i],dst[i]);
   1.462 +		}
   1.463 +	}
   1.464 +
   1.465 +void TCallbackRecord::SelfTest()
   1.466 +	{
   1.467 +	test.Start(_L("SeltTest of TCallbackRecord"));
   1.468 +
   1.469 +	test.Next(_L("create default TCallbackRecord record, record2"));
   1.470 +	TCallbackRecord record;
   1.471 +	const TCallbackRecord record2;
   1.472 +	if(gVerboseOutput)
   1.473 +	{
   1.474 +	test.Next(_L("Print record"));
   1.475 +	record.Print();
   1.476 +	}
   1.477 +
   1.478 +	test.Next(_L("test (record == record2)"));
   1.479 +	if(!(record == record2))
   1.480 +		{
   1.481 +		if(gVerboseOutput)
   1.482 +			{
   1.483 +			record2.Print();
   1.484 +			}
   1.485 +		TEST_FAULT;
   1.486 +		}
   1.487 +
   1.488 +	//A series of callback masks
   1.489 +	//Note these combinations do not necessarily represent
   1.490 +	//possible callback combinations
   1.491 +	TUint callbacks[]  =
   1.492 +		{
   1.493 +		EDmaCallbackDescriptorCompletion,
   1.494 +		EDmaCallbackDescriptorCompletion,
   1.495 +		EDmaCallbackDescriptorCompletion,
   1.496 +		EDmaCallbackDescriptorCompletion,
   1.497 +		EDmaCallbackFrameCompletion_Src,
   1.498 +		EDmaCallbackFrameCompletion_Dst,
   1.499 +		EDmaCallbackDescriptorCompletion_Src | EDmaCallbackDescriptorCompletion_Dst,
   1.500 +		EDmaCallbackDescriptorCompletion_Src | EDmaCallbackFrameCompletion_Src | EDmaCallbackLinkedListPaused_Dst,
   1.501 +		EDmaCallbackRequestCompletion | EDmaCallbackRequestCompletion_Src,
   1.502 +		EDmaCallbackDescriptorCompletion_Dst
   1.503 +		};
   1.504 +	test.Next(_L("Feed a series of callback masks in to record"));
   1.505 +	const TInt length = ARRAY_LENGTH(callbacks);
   1.506 +	for(TInt i = 0; i < length; i++)
   1.507 +		{
   1.508 +		record.ProcessCallback(callbacks[i], EDmaResultOK);
   1.509 +		}
   1.510 +	
   1.511 +	if(gVerboseOutput)
   1.512 +	{
   1.513 +	test.Next(_L("Print record"));
   1.514 +	record.Print();
   1.515 +	}
   1.516 +
   1.517 +	test.Next(_L("test GetCount"));
   1.518 +	test_Equal(1, record.GetCount(EDmaCallbackRequestCompletion));
   1.519 +	test_Equal(1, record.GetCount(EDmaCallbackRequestCompletion_Src));
   1.520 +	test_Equal(0, record.GetCount(EDmaCallbackRequestCompletion_Dst));
   1.521 +	test_Equal(4, record.GetCount(EDmaCallbackDescriptorCompletion));
   1.522 +	test_Equal(2, record.GetCount(EDmaCallbackDescriptorCompletion_Src));
   1.523 +	test_Equal(2, record.GetCount(EDmaCallbackDescriptorCompletion_Dst));
   1.524 +	test_Equal(0, record.GetCount(EDmaCallbackFrameCompletion));
   1.525 +	test_Equal(2, record.GetCount(EDmaCallbackFrameCompletion_Src));
   1.526 +	test_Equal(1, record.GetCount(EDmaCallbackFrameCompletion_Dst));
   1.527 +	test_Equal(0, record.GetCount(EDmaCallbackLinkedListPaused));
   1.528 +	test_Equal(0, record.GetCount(EDmaCallbackLinkedListPaused_Src));
   1.529 +	test_Equal(1, record.GetCount(EDmaCallbackLinkedListPaused_Dst));
   1.530 +
   1.531 +	test.Next(_L("test expected == record"));
   1.532 +	const TCallbackRecord expected(TCallbackRecord::EThread, 1, 1, 0, 4, 2, 2, 0, 2, 1, 0, 0, 1);
   1.533 +	if(!(expected == record))
   1.534 +		{
   1.535 +		if(gVerboseOutput)
   1.536 +			{
   1.537 +			expected.Print();
   1.538 +			}
   1.539 +		TEST_FAULT;
   1.540 +		}
   1.541 +
   1.542 +	test.Next(_L("modify record: test expected != record"));
   1.543 +	record.SetCount(EDmaCallbackFrameCompletion, 10);
   1.544 +	if(expected == record)
   1.545 +		{
   1.546 +		if(gVerboseOutput)
   1.547 +			{
   1.548 +			expected.Print();
   1.549 +			}
   1.550 +		TEST_FAULT;
   1.551 +		}
   1.552 +
   1.553 +	test.Next(_L("test Reset()"));
   1.554 +	record.Reset();
   1.555 +	test(record == record2);
   1.556 +
   1.557 +	test.End();
   1.558 +	}
   1.559 +
   1.560 +void CDmaBenchmark::SelfTest()
   1.561 +	{
   1.562 +	test.Start(_L("SelfTest of CDmaBenchmark"));
   1.563 +	test.Next(_L("MeanResult()"));
   1.564 +
   1.565 +	TUint64 results[] = {8, 12, 1, 19, 3, 17, 10};
   1.566 +	const TInt count = ARRAY_LENGTH(results);
   1.567 +
   1.568 +	CDmaBmFragmentation fragTest(_L("SelfTest"), count, TDmaTransferArgs(), 0);
   1.569 +
   1.570 +	for(TInt i = 0; i < count; i++)
   1.571 +		{
   1.572 +		fragTest.iResultArray.Append(results[i]);
   1.573 +		}
   1.574 +	test_Equal(10, fragTest.MeanResult());
   1.575 +
   1.576 +	test.End();
   1.577 +	}
   1.578 +
   1.579 +void TAddrRange::SelfTest()
   1.580 +	{
   1.581 +	test.Start(_L("SelfTest of TAddrRange"));
   1.582 +	TAddrRange a(0, 8);
   1.583 +	TAddrRange b(8, 8);
   1.584 +
   1.585 +	test_Equal(7, a.End());
   1.586 +	test_Equal(15, b.End());
   1.587 +
   1.588 +	test(!a.Overlaps(b));
   1.589 +	test(!b.Overlaps(a));
   1.590 +	test(a.Overlaps(a));
   1.591 +	test(b.Overlaps(b));
   1.592 +
   1.593 +	TAddrRange c(7, 2);
   1.594 +	test_Equal(8, c.End());
   1.595 +
   1.596 +	test(a.Overlaps(c));
   1.597 +	test(c.Overlaps(a));
   1.598 +	test(b.Overlaps(c));
   1.599 +	test(c.Overlaps(b));
   1.600 +
   1.601 +	TAddrRange d(0, 24);
   1.602 +	test(a.Overlaps(d));
   1.603 +	test(d.Overlaps(a));
   1.604 +
   1.605 +	test(b.Overlaps(d));
   1.606 +	test(d.Overlaps(b));
   1.607 +
   1.608 +	test(d.Contains(d));
   1.609 +
   1.610 +	test(d.Contains(a));
   1.611 +	test(!a.Contains(d));
   1.612 +
   1.613 +	test(d.Contains(b));
   1.614 +	test(!b.Contains(d));
   1.615 +
   1.616 +	test(!a.Contains(b));
   1.617 +	test(!b.Contains(a));
   1.618 +	test.End();
   1.619 +	}
   1.620 +
   1.621 +void TAddressParms::SelfTest()
   1.622 +	{
   1.623 +	test.Start(_L("SelfTest of TAddressParms"));
   1.624 +	const TAddressParms pA(0, 32, 8);
   1.625 +	test(pA == pA);
   1.626 +	test(pA.Overlaps(pA));
   1.627 +
   1.628 +	const TAddrRange rA(4, 8);
   1.629 +	const TAddrRange rB(16, 8);
   1.630 +	const TAddrRange rC(28, 8);
   1.631 +	const TAddrRange rD(4, 32);
   1.632 +
   1.633 +	test(pA.Overlaps(rA));
   1.634 +	test(!pA.Overlaps(rB));
   1.635 +	test(pA.Overlaps(rC));
   1.636 +	test(pA.Overlaps(rD));
   1.637 +
   1.638 +	const TAddressParms pB(8, 16, 8);
   1.639 +	test(!(pA == pB));
   1.640 +	test(!(pB == pA));
   1.641 +	test(!pA.Overlaps(pB));
   1.642 +	test(!pB.Overlaps(pA));
   1.643 +
   1.644 +	const TAddressParms pC(8, 28, 8);
   1.645 +	test(pC.Overlaps(pA));
   1.646 +	test(pC.Overlaps(pB));
   1.647 +
   1.648 +	const TAddressParms pD(0, 128, 64);
   1.649 +	test(pD.Overlaps(pA));
   1.650 +	test(pD.Overlaps(pB));
   1.651 +	test(pD.Overlaps(pC));
   1.652 +	test.End();
   1.653 +	}
   1.654 +
   1.655 +void SelfTests()
   1.656 +	{
   1.657 +	test.Next(_L("Running framework unit tests"));
   1.658 +	RDmaSession::SelfTest();
   1.659 +	TDmaCapability::SelfTest();
   1.660 +	TTestCase::SelfTest();
   1.661 +	TTransferIter::SelfTest();
   1.662 +	TCallbackRecord::SelfTest();
   1.663 +	CDmaBmFragmentation::SelfTest();
   1.664 +	TAddrRange::SelfTest();
   1.665 +	TAddressParms::SelfTest();
   1.666 +	test.End();
   1.667 +	test.Close();
   1.668 +	}