sl@0
|
1 |
// Copyright (c) 2002-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 "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 |
// e32test\dma\dma_api_tests.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
// Overview:
|
sl@0
|
17 |
// This file contains API tests for the new DMA framework
|
sl@0
|
18 |
//
|
sl@0
|
19 |
|
sl@0
|
20 |
#define __E32TEST_EXTENSION__
|
sl@0
|
21 |
#include "d_dma2.h"
|
sl@0
|
22 |
#include "u32std.h"
|
sl@0
|
23 |
#include "t_dma2.h"
|
sl@0
|
24 |
#include "cap_reqs.h"
|
sl@0
|
25 |
|
sl@0
|
26 |
#include <e32test.h>
|
sl@0
|
27 |
#include <e32debug.h>
|
sl@0
|
28 |
#include <e32svr.h>
|
sl@0
|
29 |
|
sl@0
|
30 |
static RTest test(_L("DMA Test Framework API"));
|
sl@0
|
31 |
//----------------------------------------------------------------------------------------------
|
sl@0
|
32 |
//! @SYMTestCaseID KBASE-DMA-2564
|
sl@0
|
33 |
//! @SYMTestType CIT
|
sl@0
|
34 |
//! @SYMPREQ REQ
|
sl@0
|
35 |
//! @SYMTestCaseDesc This test checks the correct behaviour of Open API in the new DMA framework
|
sl@0
|
36 |
//!
|
sl@0
|
37 |
//! @SYMTestActions
|
sl@0
|
38 |
//! 1. Open a DMA channel
|
sl@0
|
39 |
//! 2. Verify that channel is really open.
|
sl@0
|
40 |
//!
|
sl@0
|
41 |
//! @SYMTestExpectedResults
|
sl@0
|
42 |
//! 1. DMA channel opens and KErrNone returned
|
sl@0
|
43 |
//! 2. Call to ChannelIsOpened() return as ETrue.
|
sl@0
|
44 |
//!
|
sl@0
|
45 |
//! @SYMTestPriority High
|
sl@0
|
46 |
//! @SYMTestStatus Implemented
|
sl@0
|
47 |
//----------------------------------------------------------------------------------------------
|
sl@0
|
48 |
void test_open_api()
|
sl@0
|
49 |
{
|
sl@0
|
50 |
//TO DO : Expose TInt Open(const SCreateInfo& aInfo, TDmaChannel*& aChannel)
|
sl@0
|
51 |
//TO DO : Implement more test cases
|
sl@0
|
52 |
test.Start(_L("*** Testing Open() API ***"));
|
sl@0
|
53 |
|
sl@0
|
54 |
test.Next(_L("Open session"));
|
sl@0
|
55 |
RDmaSession session;
|
sl@0
|
56 |
TInt r = session.Open();
|
sl@0
|
57 |
test_KErrNone(r);
|
sl@0
|
58 |
|
sl@0
|
59 |
TUint channelCookie_open_api=0;
|
sl@0
|
60 |
|
sl@0
|
61 |
test.Next(_L("Open DMA Channel"));
|
sl@0
|
62 |
channelCookie_open_api=0;
|
sl@0
|
63 |
r = session.ChannelOpen(16, channelCookie_open_api);
|
sl@0
|
64 |
test.Printf(_L("cookie recieved = 0x%08x\n"), channelCookie_open_api);
|
sl@0
|
65 |
test_KErrNone(r);
|
sl@0
|
66 |
|
sl@0
|
67 |
//Check if channel is open
|
sl@0
|
68 |
// test.Printf(_L("Verify that the specified DMA channel is opened\n"));
|
sl@0
|
69 |
// TBool channelOpened;
|
sl@0
|
70 |
// TBool channelNotOpened = EFalse;
|
sl@0
|
71 |
// r = session.ChannelIsOpened(channelCookie_open_api, channelOpened);
|
sl@0
|
72 |
// test_KErrNone(r);
|
sl@0
|
73 |
// TEST_ASSERT(channelOpened != channelNotOpened)
|
sl@0
|
74 |
|
sl@0
|
75 |
//close channel
|
sl@0
|
76 |
test.Next(_L("Channel close"));
|
sl@0
|
77 |
r = session.ChannelClose(channelCookie_open_api);
|
sl@0
|
78 |
test_KErrNone(r);
|
sl@0
|
79 |
|
sl@0
|
80 |
RTest::CloseHandleAndWaitForDestruction(session);
|
sl@0
|
81 |
test.End();
|
sl@0
|
82 |
}
|
sl@0
|
83 |
|
sl@0
|
84 |
//----------------------------------------------------------------------------------------------
|
sl@0
|
85 |
//! @SYMTestCaseID KBASE-DMA-2568
|
sl@0
|
86 |
//! @SYMTestType CIT
|
sl@0
|
87 |
//! @SYMPREQ REQ
|
sl@0
|
88 |
//! @SYMTestCaseDesc This test checks the correct behaviour of Close API in the new DMA framework
|
sl@0
|
89 |
//!
|
sl@0
|
90 |
//! @SYMTestActions
|
sl@0
|
91 |
//! 1. Open a DMA channel
|
sl@0
|
92 |
//! 2. Open DMA Channel again
|
sl@0
|
93 |
//! 3 Close the DMA channel.
|
sl@0
|
94 |
//! 4 Open DMA channel to verify that the DMA channel closed.
|
sl@0
|
95 |
//! 5. Open DMA channel again.
|
sl@0
|
96 |
//! 6. Queue a request on the channel.
|
sl@0
|
97 |
//! 7. Close DMA channel while request is still queued on it.
|
sl@0
|
98 |
//!
|
sl@0
|
99 |
//! @SYMTestExpectedResults
|
sl@0
|
100 |
//! 1. DMA channel opens and KErrNone returned.
|
sl@0
|
101 |
//! 2. DMA Framework returns KErrInUse as channel is already open.
|
sl@0
|
102 |
//! 3. DMA channel closes and KErrNone returned.
|
sl@0
|
103 |
//! 4. DMA channel opens and KErrNone returned.
|
sl@0
|
104 |
//! 5. DMA Framework returns KErrInUse as channel is already open.
|
sl@0
|
105 |
//! 6. DMA request queued and KErrNone returned.
|
sl@0
|
106 |
//! 7. DMA channel closes and DMA framework flags an error.
|
sl@0
|
107 |
//!
|
sl@0
|
108 |
//!
|
sl@0
|
109 |
//! @SYMTestPriority High
|
sl@0
|
110 |
//! @SYMTestStatus Implemented
|
sl@0
|
111 |
//----------------------------------------------------------------------------------------------
|
sl@0
|
112 |
void test_close_api()
|
sl@0
|
113 |
{
|
sl@0
|
114 |
test.Start(_L("*** Testing Close() API ***"));
|
sl@0
|
115 |
|
sl@0
|
116 |
test.Next(_L("Open session"));
|
sl@0
|
117 |
RDmaSession session;
|
sl@0
|
118 |
TInt r = session.Open();
|
sl@0
|
119 |
test_KErrNone(r);
|
sl@0
|
120 |
|
sl@0
|
121 |
const TInt size = 64 * KKilo;
|
sl@0
|
122 |
TUint reqCookieNewStyle_close_api=0;
|
sl@0
|
123 |
TUint channelCookie_close_api=0;
|
sl@0
|
124 |
|
sl@0
|
125 |
test.Next(_L("Open a single DMA channel"));
|
sl@0
|
126 |
r = session.ChannelOpen(16, channelCookie_close_api);
|
sl@0
|
127 |
test.Printf(_L("cookie recieved = 0x%08x\n"), channelCookie_close_api);
|
sl@0
|
128 |
test_KErrNone(r);
|
sl@0
|
129 |
|
sl@0
|
130 |
// test.Next(_L("Open DMA channel again"));
|
sl@0
|
131 |
// TUint channelCookie_close_api_1=0;
|
sl@0
|
132 |
// r = session.ChannelOpen(16, channelCookie_close_api_1);
|
sl@0
|
133 |
// test.Printf(_L("Verify that DMA channel is already opened\n"));
|
sl@0
|
134 |
// test_Equal(KErrInUse,r);
|
sl@0
|
135 |
|
sl@0
|
136 |
test.Next(_L("Close the DMA channel"));
|
sl@0
|
137 |
r = session.ChannelClose(channelCookie_close_api);
|
sl@0
|
138 |
test_KErrNone(r);
|
sl@0
|
139 |
|
sl@0
|
140 |
test.Next(_L("Open DMA channel again"));
|
sl@0
|
141 |
r = session.ChannelOpen(16, channelCookie_close_api);
|
sl@0
|
142 |
test.Printf(_L("Verify that DMA channel was closed\n"));
|
sl@0
|
143 |
test_KErrNone(r);
|
sl@0
|
144 |
|
sl@0
|
145 |
//Fails if a request is created and cancel
|
sl@0
|
146 |
test.Next(_L("Queue a request on the channel"));
|
sl@0
|
147 |
r = session.RequestCreateNew(channelCookie_close_api, reqCookieNewStyle_close_api); //Create Dma request (with new-style callback)
|
sl@0
|
148 |
test.Printf(_L("cookie recieved for open channel = 0x%08x\n"), reqCookieNewStyle_close_api);
|
sl@0
|
149 |
test_KErrNone(r);
|
sl@0
|
150 |
|
sl@0
|
151 |
TDmaTransferArgs transferArgs_close_api;
|
sl@0
|
152 |
transferArgs_close_api.iSrcConfig.iAddr = 0;
|
sl@0
|
153 |
transferArgs_close_api.iDstConfig.iAddr = size;
|
sl@0
|
154 |
transferArgs_close_api.iSrcConfig.iFlags = KDmaMemAddr;
|
sl@0
|
155 |
transferArgs_close_api.iDstConfig.iFlags = KDmaMemAddr;
|
sl@0
|
156 |
transferArgs_close_api.iTransferCount = size;
|
sl@0
|
157 |
r = session.FragmentRequest(reqCookieNewStyle_close_api, transferArgs_close_api);
|
sl@0
|
158 |
test_KErrNone(r);
|
sl@0
|
159 |
|
sl@0
|
160 |
test.Next(_L("Queue DMA Request"));
|
sl@0
|
161 |
TCallbackRecord record_close_api;
|
sl@0
|
162 |
r = session.QueueRequest(reqCookieNewStyle_close_api, &record_close_api);
|
sl@0
|
163 |
test_KErrNone(r);
|
sl@0
|
164 |
|
sl@0
|
165 |
test.Next(_L("Destroy Dma request"));
|
sl@0
|
166 |
r = session.RequestDestroy(reqCookieNewStyle_close_api);
|
sl@0
|
167 |
test_KErrNone(r);
|
sl@0
|
168 |
|
sl@0
|
169 |
test.Next(_L("Close the DMA channel"));
|
sl@0
|
170 |
r = session.ChannelClose(channelCookie_close_api);
|
sl@0
|
171 |
test_KErrNone(r);
|
sl@0
|
172 |
|
sl@0
|
173 |
test.End();
|
sl@0
|
174 |
RTest::CloseHandleAndWaitForDestruction(session);
|
sl@0
|
175 |
}
|
sl@0
|
176 |
|
sl@0
|
177 |
void RDmaSession::ApiTest()
|
sl@0
|
178 |
{
|
sl@0
|
179 |
test_open_api(); // Verify that Open() opens a DMA channel
|
sl@0
|
180 |
test_close_api(); // Verify that Close() closes a DMA channel
|
sl@0
|
181 |
}
|
sl@0
|
182 |
|
sl@0
|
183 |
void ApiTests()
|
sl@0
|
184 |
{
|
sl@0
|
185 |
test.Next(_L("Running framework API tests"));
|
sl@0
|
186 |
RDmaSession::ApiTest();
|
sl@0
|
187 |
test.Close();
|
sl@0
|
188 |
}
|