sl@0: /* sl@0: * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * This file contains unit tests for the test framework itself. sl@0: * They should be run if changes have been made to sl@0: * to the user side test framework code ie. anything in the dmav2 sl@0: * directory other than the d_* driver code, or test_cases.cpp sl@0: * sl@0: */ sl@0: sl@0: #include "d_dma2.h" sl@0: #include "u32std.h" sl@0: #include "t_dma2.h" sl@0: #include "cap_reqs.h" sl@0: sl@0: #define __E32TEST_EXTENSION__ sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: static RTest test(_L("t_dma2 test framework tests")); sl@0: sl@0: void RDmaSession::SelfTest() sl@0: { sl@0: test.Start(_L("Simple transfer test")); sl@0: test.Next(_L("Open session")); sl@0: RDmaSession session; sl@0: TInt r = session.Open(); sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("Get test info")); sl@0: TDmaV2TestInfo testInfo; sl@0: r = session.GetTestInfo(testInfo); sl@0: test_KErrNone(r); sl@0: sl@0: if(gVerboseOutput) sl@0: { sl@0: Print(testInfo); sl@0: } sl@0: sl@0: test.Next(_L("Channel open")); sl@0: TUint channelCookie=0; sl@0: r = session.ChannelOpen(16, channelCookie); sl@0: test.Printf(_L("cookie recived = 0x%08x\n"), channelCookie); sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("Get Channel caps")); sl@0: SDmacCaps channelCaps; sl@0: r = session.ChannelCaps(channelCookie, channelCaps); sl@0: test_KErrNone(r); sl@0: if(gVerboseOutput) sl@0: { sl@0: PRINT(channelCaps.iChannelPriorities); sl@0: PRINT(channelCaps.iChannelPauseAndResume); sl@0: PRINT(channelCaps.iAddrAlignedToElementSize); sl@0: PRINT(channelCaps.i1DIndexAddressing); sl@0: PRINT(channelCaps.i2DIndexAddressing); sl@0: PRINT(channelCaps.iSynchronizationTypes); sl@0: PRINT(channelCaps.iBurstTransactions); sl@0: PRINT(channelCaps.iDescriptorInterrupt); sl@0: PRINT(channelCaps.iFrameInterrupt); sl@0: PRINT(channelCaps.iLinkedListPausedInterrupt); sl@0: PRINT(channelCaps.iEndiannessConversion); sl@0: PRINT(channelCaps.iGraphicsOps); sl@0: PRINT(channelCaps.iRepeatingTransfers); sl@0: PRINT(channelCaps.iChannelLinking); sl@0: PRINT(channelCaps.iHwDescriptors); sl@0: PRINT(channelCaps.iSrcDstAsymmetry); sl@0: PRINT(channelCaps.iAsymHwDescriptors); sl@0: PRINT(channelCaps.iBalancedAsymSegments); sl@0: PRINT(channelCaps.iAsymCompletionInterrupt); sl@0: PRINT(channelCaps.iAsymDescriptorInterrupt); sl@0: PRINT(channelCaps.iAsymFrameInterrupt); sl@0: PRINT(channelCaps.iReserved[0]); sl@0: PRINT(channelCaps.iReserved[1]); sl@0: PRINT(channelCaps.iReserved[2]); sl@0: PRINT(channelCaps.iReserved[3]); sl@0: PRINT(channelCaps.iReserved[4]); sl@0: } sl@0: sl@0: test.Next(_L("Get extended Channel caps (TDmacTestCaps)")); sl@0: TDmacTestCaps extChannelCaps; sl@0: r = session.ChannelCaps(channelCookie, extChannelCaps); sl@0: test_KErrNone(r); sl@0: test.Printf(_L("PIL version = %d\n"), extChannelCaps.iPILVersion); sl@0: sl@0: const TBool newPil = (extChannelCaps.iPILVersion > 1); sl@0: sl@0: test.Next(_L("Create Dma request - max fragment size 32K")); sl@0: TUint reqCookie=0; sl@0: r = session.RequestCreate(channelCookie, reqCookie, 32 * KKilo); sl@0: test.Printf(_L("cookie recived = 0x%08x\n"), reqCookie); sl@0: test_KErrNone(r); sl@0: sl@0: if(newPil) sl@0: { sl@0: test.Next(_L("Create Dma request (with new-style callback)")); sl@0: TUint reqCookieNewStyle=0; sl@0: r = session.RequestCreateNew(channelCookie, reqCookieNewStyle); sl@0: test.Printf(_L("cookie recived = 0x%08x\n"), reqCookieNewStyle ); sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("Fragment for ISR callback")); sl@0: const TInt size = 128 * KKilo; sl@0: TDmaTransferArgs transferArgs(0, size, size, KDmaMemAddr, KDmaSyncAuto, KDmaRequestCallbackFromIsr); sl@0: r = session.FragmentRequest(reqCookieNewStyle, transferArgs); sl@0: test_KErrNone(r); sl@0: sl@0: TIsrRequeArgs reque; sl@0: test.Next(_L("Queue ISR callback - with default re-queue")); sl@0: r = session.QueueRequestWithRequeue(reqCookieNewStyle, &reque, 1); sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("Destroy new-style Dma request")); sl@0: r = session.RequestDestroy(reqCookieNewStyle); sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("Attempt to destroy request again ")); sl@0: r = session.RequestDestroy(reqCookieNewStyle); sl@0: test_Equal(KErrNotFound, r); sl@0: } sl@0: sl@0: test.Next(_L("Open chunk handle")); sl@0: RChunk chunk; sl@0: r = session.OpenSharedChunk(chunk); sl@0: test_KErrNone(r); sl@0: if(gVerboseOutput) sl@0: { sl@0: test.Printf(_L("chunk base = 0x%08x\n"), chunk.Base()); sl@0: test.Printf(_L("chunk size = %d\n"), chunk.Size()); sl@0: } sl@0: test(chunk.IsWritable()); sl@0: test(chunk.IsReadable()); sl@0: sl@0: test.Next(_L("Fragment(old style)")); sl@0: const TInt size = 128 * KKilo; sl@0: TInt i; sl@0: for(i = 0; i<10; i++) sl@0: { sl@0: TUint64 time = 0; sl@0: TDmaTransferArgs transferArgs(0, size, size, KDmaMemAddr); sl@0: r = session.FragmentRequestOld(reqCookie, transferArgs, &time); sl@0: test_KErrNone(r); sl@0: if(gVerboseOutput) sl@0: { sl@0: test.Printf(_L("%lu us\n"), time); sl@0: } sl@0: } sl@0: sl@0: test.Next(_L("Queue")); sl@0: TRequestStatus status; sl@0: sl@0: for(i = 0; i<10; i++) sl@0: { sl@0: TUint64 time = 0; sl@0: r = session.QueueRequest(reqCookie, status, 0, &time); sl@0: User::WaitForRequest(status); sl@0: test_KErrNone(r); sl@0: if(gVerboseOutput) sl@0: { sl@0: test.Printf(_L("%lu us\n"), time); sl@0: } sl@0: } sl@0: sl@0: if(newPil) sl@0: { sl@0: test.Next(_L("Fragment(new style)")); sl@0: TDmaTransferArgs transferArgs; sl@0: transferArgs.iSrcConfig.iAddr = 0; sl@0: transferArgs.iDstConfig.iAddr = size; sl@0: transferArgs.iSrcConfig.iFlags = KDmaMemAddr; sl@0: transferArgs.iDstConfig.iFlags = KDmaMemAddr; sl@0: transferArgs.iTransferCount = size; sl@0: sl@0: for(i = 0; i<10; i++) sl@0: { sl@0: TUint64 time = 0; sl@0: r = session.FragmentRequest(reqCookie, transferArgs, &time); sl@0: test_KErrNone(r); sl@0: if(gVerboseOutput) sl@0: { sl@0: test.Printf(_L("%lu us\n"), time); sl@0: } sl@0: } sl@0: } sl@0: sl@0: test.Next(_L("Queue")); sl@0: TCallbackRecord record; sl@0: r = session.QueueRequest(reqCookie, &record); sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("check TCallbackRecord record")); sl@0: if(gVerboseOutput) sl@0: { sl@0: record.Print(); sl@0: } sl@0: const TCallbackRecord expected(TCallbackRecord::EThread, 1); sl@0: if(!(record == expected)) sl@0: { sl@0: test.Printf(_L("TCallbackRecords did not match")); sl@0: if(gVerboseOutput) sl@0: { sl@0: test.Printf(_L("expected:")); sl@0: expected.Print(); sl@0: } sl@0: TEST_FAULT; sl@0: } sl@0: sl@0: test.Next(_L("Destroy Dma request")); sl@0: r = session.RequestDestroy(reqCookie); sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("Close chunk handle")); sl@0: chunk.Close(); sl@0: sl@0: test.Next(_L("Channel close")); sl@0: r = session.ChannelClose(channelCookie); sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("Channel close (same again)")); sl@0: r = session.ChannelClose(channelCookie); sl@0: test_Equal(KErrNotFound, r); sl@0: sl@0: test.Next(_L("Close session")); sl@0: RTest::CloseHandleAndWaitForDestruction(session); sl@0: sl@0: test.End(); sl@0: sl@0: } sl@0: sl@0: const SDmacCaps KTestCapSet = sl@0: {6, // TInt iChannelPriorities; sl@0: EFalse, // TBool iChannelPauseAndResume; sl@0: ETrue, // TBool iAddrAlignedToElementSize; sl@0: EFalse, // TBool i1DIndexAddressing; sl@0: EFalse, // TBool i2DIndexAddressing; sl@0: KDmaSyncSizeElement | KDmaSyncSizeFrame | sl@0: KDmaSyncSizeBlock, // TUint iSynchronizationTypes; sl@0: KDmaBurstSize4 | KDmaBurstSize8, // TUint iBurstTransactions; sl@0: EFalse, // TBool iDescriptorInterrupt; sl@0: EFalse, // TBool iFrameInterrupt; sl@0: EFalse, // TBool iLinkedListPausedInterrupt; sl@0: EFalse, // TBool iEndiannessConversion; sl@0: 0, // TUint iGraphicsOps; sl@0: ETrue, // TBool iRepeatingTransfers; sl@0: EFalse, // TBool iChannelLinking; sl@0: ETrue, // TBool iHwDescriptors; sl@0: EFalse, // TBool iSrcDstAsymmetry; sl@0: EFalse, // TBool iAsymHwDescriptors; sl@0: EFalse, // TBool iBalancedAsymSegments; sl@0: EFalse, // TBool iAsymCompletionInterrupt; sl@0: EFalse, // TBool iAsymDescriptorInterrupt; sl@0: EFalse, // TBool iAsymFrameInterrupt; sl@0: {0, 0, 0, 0, 0} // TUint32 iReserved[5]; sl@0: }; sl@0: sl@0: const TDmacTestCaps KDmacTestCapsV1(KTestCapSet, 1); sl@0: const TDmacTestCaps KDmacTestCapsV2(KTestCapSet, 2); sl@0: sl@0: void TDmaCapability::SelfTest() sl@0: { sl@0: test.Start(_L("Unit test_Value of TDmaCapability::CompareToDmaCaps\n")); sl@0: sl@0: { sl@0: test.Next(_L("ENone\n")); sl@0: TResult t = none.CompareToDmaCaps(KTestCapSet); sl@0: test_Value(t, t == ERun); sl@0: } sl@0: sl@0: { sl@0: test.Next(_L("EChannelPauseAndResume - wanted\n")); sl@0: TResult t = pauseRequired.CompareToDmaCaps(KTestCapSet); sl@0: test_Value(t, t == EFail); sl@0: } sl@0: { sl@0: test.Next(_L("EChannelPauseAndResume - wanted - Allow skip\n")); sl@0: TResult t = pauseRequired_skip.CompareToDmaCaps(KTestCapSet); sl@0: test_Value(t, t == ESkip); sl@0: } sl@0: { sl@0: test.Next(_L("EChannelPauseAndResume - not wanted\n")); sl@0: TResult t = pauseNotWanted.CompareToDmaCaps(KTestCapSet); sl@0: test_Value(t, t == ERun); sl@0: } sl@0: sl@0: { sl@0: test.Next(_L("EHwDescriptors - not wanted\n")); sl@0: TResult t = hwDesNotWanted.CompareToDmaCaps(KTestCapSet); sl@0: test_Value(t, t == EFail); sl@0: } sl@0: sl@0: { sl@0: test.Next(_L("EHwDescriptors - not wanted - Allow skip\n")); sl@0: TResult t = hwDesNotWanted_skip.CompareToDmaCaps(KTestCapSet); sl@0: test_Value(t, t == ESkip); sl@0: } sl@0: sl@0: { sl@0: test.Next(_L("EHwDescriptors - wanted\n")); sl@0: TResult t = hwDesWanted.CompareToDmaCaps(KTestCapSet); sl@0: test_Value(t, t == ERun); sl@0: } sl@0: sl@0: sl@0: //TODO use this macro for the above tests sl@0: sl@0: // Note: The construction of the test description message sl@0: // is horribly confusing. The _L macro will make the sl@0: // *first* string token wide, but not the next two. sl@0: // Therefore these must be made wide or compilier sl@0: // will complain about concatination of narrow and wide string sl@0: // literals sl@0: #define CAP_TEST(CAP, CAPSET, EXPCT)\ sl@0: {\ sl@0: test.Next(_L(#CAP L" against " L ## #CAPSET));\ sl@0: TResult t = (CAP).CompareToDmaCaps(CAPSET);\ sl@0: test_Equal(EXPCT, t);\ sl@0: } sl@0: sl@0: sl@0: CAP_TEST(capEqualV1, KDmacTestCapsV1, ERun); sl@0: CAP_TEST(capEqualV2, KDmacTestCapsV2, ERun); sl@0: CAP_TEST(capEqualV1, KDmacTestCapsV2, ESkip); sl@0: CAP_TEST(capEqualV2, KDmacTestCapsV1, ESkip); sl@0: CAP_TEST(capEqualV2Fatal, KDmacTestCapsV1, EFail); sl@0: sl@0: CAP_TEST(capAboveV1, KDmacTestCapsV2, ERun); sl@0: CAP_TEST(capBelowV2, KDmacTestCapsV1, ERun); sl@0: CAP_TEST(capAboveV1, KDmacTestCapsV1, ESkip); sl@0: CAP_TEST(capBelowV2, KDmacTestCapsV2, ESkip); sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: void TTestCase::SelfTest() sl@0: { sl@0: //TODO should use macros for these tests sl@0: test.Start(_L("Unit test of TTestCase::TestCaseValid\n")); sl@0: sl@0: TTestCase testCase(NULL, EFalse, pauseRequired, hwDesNotWanted); sl@0: test.Next(_L("pauseRequired, hwDesNotWanted\n")); sl@0: TResult t = testCase.TestCaseValid(KTestCapSet); sl@0: test_Value(t, t == EFail); sl@0: sl@0: test.Next(_L("pauseRequired_skip, hwDesNotWanted\n")); sl@0: testCase.iChannelCaps[0] = pauseRequired_skip; sl@0: t = testCase.TestCaseValid(KTestCapSet); sl@0: test_Value(t, t == EFail); sl@0: sl@0: test.Next(_L("pauseRequired_skip, hwDesNotWanted_skip\n")); sl@0: testCase.iChannelCaps[1] = hwDesNotWanted_skip; sl@0: t = testCase.TestCaseValid(KTestCapSet); sl@0: test_Value(t, t == ESkip); sl@0: sl@0: test.Next(_L("pauseNotWanted, hwDesNotWanted_skip\n")); sl@0: testCase.iChannelCaps[0] = pauseNotWanted; sl@0: t = testCase.TestCaseValid(KTestCapSet); sl@0: test_Value(t, t == ESkip); sl@0: sl@0: test.Next(_L("pauseNotWanted, hwDesWanted\n")); sl@0: testCase.iChannelCaps[1] = hwDesWanted; sl@0: t = testCase.TestCaseValid(KTestCapSet); sl@0: test_Value(t, t == ERun); sl@0: sl@0: test.Next(_L("pauseNotWanted\n")); sl@0: testCase.iChannelCaps[1] = none; sl@0: t = testCase.TestCaseValid(KTestCapSet); sl@0: test_Value(t, t == ERun); sl@0: sl@0: test.Next(_L("pauseNotWanted + V1 PIL required\n")); sl@0: testCase.iChannelCaps[1] = capAboveV1; sl@0: test.Next(_L("Against KDmacTestCapsV1")); sl@0: t = testCase.TestCaseValid(KDmacTestCapsV1); sl@0: test_Equal(ESkip, t); sl@0: test.Next(_L("Against KDmacTestCapsV2")); sl@0: t = testCase.TestCaseValid(KDmacTestCapsV2); sl@0: test_Equal(ERun, t); sl@0: sl@0: test.Next(_L("pauseNotWanted + >V1 PIL required\n")); sl@0: testCase.iChannelCaps[1] = capBelowV2; sl@0: test.Next(_L("Against KDmacTestCapsV1")); sl@0: t = testCase.TestCaseValid(KDmacTestCapsV1); sl@0: test_Equal(ERun, t); sl@0: test.Next(_L("Against KDmacTestCapsV2")); sl@0: t = testCase.TestCaseValid(KDmacTestCapsV2); sl@0: test_Equal(ESkip, t); sl@0: sl@0: test.End(); sl@0: test.Close(); sl@0: } sl@0: sl@0: sl@0: void TTransferIter::SelfTest() sl@0: { sl@0: test.Start(_L("No skip")); sl@0: sl@0: const TUint8 src[9] = { sl@0: 1 ,2, 3, sl@0: 4, 5, 6, sl@0: 7, 8, 9 sl@0: }; sl@0: sl@0: const TUint32 addr = (TUint32)src; sl@0: const TUint elementSize = 1; sl@0: const TUint elementSkip = 0; sl@0: const TUint elementsPerFrame = 3; sl@0: const TUint frameSkip = 0; sl@0: const TUint framesPerTransfer = 3; sl@0: TDmaTransferConfig cfg(addr, elementSize, elementsPerFrame, framesPerTransfer, sl@0: elementSkip, frameSkip, KDmaMemAddr sl@0: ); sl@0: sl@0: TTransferIter iter(cfg, 0); sl@0: TTransferIter end; sl@0: TInt i; sl@0: for(i = 0; i<9; i++, ++iter) sl@0: { sl@0: test_Equal(src[i],*iter); sl@0: }; sl@0: sl@0: sl@0: test.Next(_L("90 degree rotation")); sl@0: // Now imagine that we wanted to perform a rotation sl@0: // as we write, so that we wrote out the following sl@0: sl@0: const TUint8 expected[9] = { sl@0: 7, 4, 1, sl@0: 8, 5, 2, sl@0: 9, 6, 3 sl@0: }; sl@0: sl@0: TUint8 dst[9] = {0}; sl@0: TDmaTransferConfig dst_cfg(cfg); sl@0: dst_cfg.iAddr = (TUint32)&dst[2]; sl@0: dst_cfg.iElementSkip = 2; sl@0: dst_cfg.iFrameSkip = -8; sl@0: sl@0: TTransferIter dst_iter(dst_cfg, 0); sl@0: for(i=0; dst_iter != end; i++, ++dst_iter) sl@0: { sl@0: TEST_ASSERT(i<9); sl@0: *dst_iter=src[i]; sl@0: }; sl@0: sl@0: for(i=0; i<9; i++) sl@0: { sl@0: test_Equal(expected[i],dst[i]); sl@0: } sl@0: } sl@0: sl@0: void TCallbackRecord::SelfTest() sl@0: { sl@0: test.Start(_L("SeltTest of TCallbackRecord")); sl@0: sl@0: test.Next(_L("create default TCallbackRecord record, record2")); sl@0: TCallbackRecord record; sl@0: const TCallbackRecord record2; sl@0: if(gVerboseOutput) sl@0: { sl@0: test.Next(_L("Print record")); sl@0: record.Print(); sl@0: } sl@0: sl@0: test.Next(_L("test (record == record2)")); sl@0: if(!(record == record2)) sl@0: { sl@0: if(gVerboseOutput) sl@0: { sl@0: record2.Print(); sl@0: } sl@0: TEST_FAULT; sl@0: } sl@0: sl@0: //A series of callback masks sl@0: //Note these combinations do not necessarily represent sl@0: //possible callback combinations sl@0: TUint callbacks[] = sl@0: { sl@0: EDmaCallbackDescriptorCompletion, sl@0: EDmaCallbackDescriptorCompletion, sl@0: EDmaCallbackDescriptorCompletion, sl@0: EDmaCallbackDescriptorCompletion, sl@0: EDmaCallbackFrameCompletion_Src, sl@0: EDmaCallbackFrameCompletion_Dst, sl@0: EDmaCallbackDescriptorCompletion_Src | EDmaCallbackDescriptorCompletion_Dst, sl@0: EDmaCallbackDescriptorCompletion_Src | EDmaCallbackFrameCompletion_Src | EDmaCallbackLinkedListPaused_Dst, sl@0: EDmaCallbackRequestCompletion | EDmaCallbackRequestCompletion_Src, sl@0: EDmaCallbackDescriptorCompletion_Dst sl@0: }; sl@0: test.Next(_L("Feed a series of callback masks in to record")); sl@0: const TInt length = ARRAY_LENGTH(callbacks); sl@0: for(TInt i = 0; i < length; i++) sl@0: { sl@0: record.ProcessCallback(callbacks[i], EDmaResultOK); sl@0: } sl@0: sl@0: if(gVerboseOutput) sl@0: { sl@0: test.Next(_L("Print record")); sl@0: record.Print(); sl@0: } sl@0: sl@0: test.Next(_L("test GetCount")); sl@0: test_Equal(1, record.GetCount(EDmaCallbackRequestCompletion)); sl@0: test_Equal(1, record.GetCount(EDmaCallbackRequestCompletion_Src)); sl@0: test_Equal(0, record.GetCount(EDmaCallbackRequestCompletion_Dst)); sl@0: test_Equal(4, record.GetCount(EDmaCallbackDescriptorCompletion)); sl@0: test_Equal(2, record.GetCount(EDmaCallbackDescriptorCompletion_Src)); sl@0: test_Equal(2, record.GetCount(EDmaCallbackDescriptorCompletion_Dst)); sl@0: test_Equal(0, record.GetCount(EDmaCallbackFrameCompletion)); sl@0: test_Equal(2, record.GetCount(EDmaCallbackFrameCompletion_Src)); sl@0: test_Equal(1, record.GetCount(EDmaCallbackFrameCompletion_Dst)); sl@0: test_Equal(0, record.GetCount(EDmaCallbackLinkedListPaused)); sl@0: test_Equal(0, record.GetCount(EDmaCallbackLinkedListPaused_Src)); sl@0: test_Equal(1, record.GetCount(EDmaCallbackLinkedListPaused_Dst)); sl@0: sl@0: test.Next(_L("test expected == record")); sl@0: const TCallbackRecord expected(TCallbackRecord::EThread, 1, 1, 0, 4, 2, 2, 0, 2, 1, 0, 0, 1); sl@0: if(!(expected == record)) sl@0: { sl@0: if(gVerboseOutput) sl@0: { sl@0: expected.Print(); sl@0: } sl@0: TEST_FAULT; sl@0: } sl@0: sl@0: test.Next(_L("modify record: test expected != record")); sl@0: record.SetCount(EDmaCallbackFrameCompletion, 10); sl@0: if(expected == record) sl@0: { sl@0: if(gVerboseOutput) sl@0: { sl@0: expected.Print(); sl@0: } sl@0: TEST_FAULT; sl@0: } sl@0: sl@0: test.Next(_L("test Reset()")); sl@0: record.Reset(); sl@0: test(record == record2); sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: void CDmaBenchmark::SelfTest() sl@0: { sl@0: test.Start(_L("SelfTest of CDmaBenchmark")); sl@0: test.Next(_L("MeanResult()")); sl@0: sl@0: TUint64 results[] = {8, 12, 1, 19, 3, 17, 10}; sl@0: const TInt count = ARRAY_LENGTH(results); sl@0: sl@0: CDmaBmFragmentation fragTest(_L("SelfTest"), count, TDmaTransferArgs(), 0); sl@0: sl@0: for(TInt i = 0; i < count; i++) sl@0: { sl@0: fragTest.iResultArray.Append(results[i]); sl@0: } sl@0: test_Equal(10, fragTest.MeanResult()); sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: void TAddrRange::SelfTest() sl@0: { sl@0: test.Start(_L("SelfTest of TAddrRange")); sl@0: TAddrRange a(0, 8); sl@0: TAddrRange b(8, 8); sl@0: sl@0: test_Equal(7, a.End()); sl@0: test_Equal(15, b.End()); sl@0: sl@0: test(!a.Overlaps(b)); sl@0: test(!b.Overlaps(a)); sl@0: test(a.Overlaps(a)); sl@0: test(b.Overlaps(b)); sl@0: sl@0: TAddrRange c(7, 2); sl@0: test_Equal(8, c.End()); sl@0: sl@0: test(a.Overlaps(c)); sl@0: test(c.Overlaps(a)); sl@0: test(b.Overlaps(c)); sl@0: test(c.Overlaps(b)); sl@0: sl@0: TAddrRange d(0, 24); sl@0: test(a.Overlaps(d)); sl@0: test(d.Overlaps(a)); sl@0: sl@0: test(b.Overlaps(d)); sl@0: test(d.Overlaps(b)); sl@0: sl@0: test(d.Contains(d)); sl@0: sl@0: test(d.Contains(a)); sl@0: test(!a.Contains(d)); sl@0: sl@0: test(d.Contains(b)); sl@0: test(!b.Contains(d)); sl@0: sl@0: test(!a.Contains(b)); sl@0: test(!b.Contains(a)); sl@0: test.End(); sl@0: } sl@0: sl@0: void TAddressParms::SelfTest() sl@0: { sl@0: test.Start(_L("SelfTest of TAddressParms")); sl@0: const TAddressParms pA(0, 32, 8); sl@0: test(pA == pA); sl@0: test(pA.Overlaps(pA)); sl@0: sl@0: const TAddrRange rA(4, 8); sl@0: const TAddrRange rB(16, 8); sl@0: const TAddrRange rC(28, 8); sl@0: const TAddrRange rD(4, 32); sl@0: sl@0: test(pA.Overlaps(rA)); sl@0: test(!pA.Overlaps(rB)); sl@0: test(pA.Overlaps(rC)); sl@0: test(pA.Overlaps(rD)); sl@0: sl@0: const TAddressParms pB(8, 16, 8); sl@0: test(!(pA == pB)); sl@0: test(!(pB == pA)); sl@0: test(!pA.Overlaps(pB)); sl@0: test(!pB.Overlaps(pA)); sl@0: sl@0: const TAddressParms pC(8, 28, 8); sl@0: test(pC.Overlaps(pA)); sl@0: test(pC.Overlaps(pB)); sl@0: sl@0: const TAddressParms pD(0, 128, 64); sl@0: test(pD.Overlaps(pA)); sl@0: test(pD.Overlaps(pB)); sl@0: test(pD.Overlaps(pC)); sl@0: test.End(); sl@0: } sl@0: sl@0: void SelfTests() sl@0: { sl@0: test.Next(_L("Running framework unit tests")); sl@0: RDmaSession::SelfTest(); sl@0: TDmaCapability::SelfTest(); sl@0: TTestCase::SelfTest(); sl@0: TTransferIter::SelfTest(); sl@0: TCallbackRecord::SelfTest(); sl@0: CDmaBmFragmentation::SelfTest(); sl@0: TAddrRange::SelfTest(); sl@0: TAddressParms::SelfTest(); sl@0: test.End(); sl@0: test.Close(); sl@0: }