sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* This file contains unit tests for the test framework itself.
|
sl@0
|
16 |
* They should be run if changes have been made to
|
sl@0
|
17 |
* to the user side test framework code ie. anything in the dmav2
|
sl@0
|
18 |
* directory other than the d_* driver code, or test_cases.cpp
|
sl@0
|
19 |
*
|
sl@0
|
20 |
*/
|
sl@0
|
21 |
|
sl@0
|
22 |
#include "d_dma2.h"
|
sl@0
|
23 |
#include "u32std.h"
|
sl@0
|
24 |
#include "t_dma2.h"
|
sl@0
|
25 |
#include "cap_reqs.h"
|
sl@0
|
26 |
|
sl@0
|
27 |
#define __E32TEST_EXTENSION__
|
sl@0
|
28 |
#include <e32test.h>
|
sl@0
|
29 |
#include <e32debug.h>
|
sl@0
|
30 |
#include <e32svr.h>
|
sl@0
|
31 |
|
sl@0
|
32 |
static RTest test(_L("t_dma2 test framework tests"));
|
sl@0
|
33 |
|
sl@0
|
34 |
void RDmaSession::SelfTest()
|
sl@0
|
35 |
{
|
sl@0
|
36 |
test.Start(_L("Simple transfer test"));
|
sl@0
|
37 |
test.Next(_L("Open session"));
|
sl@0
|
38 |
RDmaSession session;
|
sl@0
|
39 |
TInt r = session.Open();
|
sl@0
|
40 |
test_KErrNone(r);
|
sl@0
|
41 |
|
sl@0
|
42 |
test.Next(_L("Get test info"));
|
sl@0
|
43 |
TDmaV2TestInfo testInfo;
|
sl@0
|
44 |
r = session.GetTestInfo(testInfo);
|
sl@0
|
45 |
test_KErrNone(r);
|
sl@0
|
46 |
|
sl@0
|
47 |
if(gVerboseOutput)
|
sl@0
|
48 |
{
|
sl@0
|
49 |
Print(testInfo);
|
sl@0
|
50 |
}
|
sl@0
|
51 |
|
sl@0
|
52 |
test.Next(_L("Channel open"));
|
sl@0
|
53 |
TUint channelCookie=0;
|
sl@0
|
54 |
r = session.ChannelOpen(16, channelCookie);
|
sl@0
|
55 |
test.Printf(_L("cookie recived = 0x%08x\n"), channelCookie);
|
sl@0
|
56 |
test_KErrNone(r);
|
sl@0
|
57 |
|
sl@0
|
58 |
test.Next(_L("Get Channel caps"));
|
sl@0
|
59 |
SDmacCaps channelCaps;
|
sl@0
|
60 |
r = session.ChannelCaps(channelCookie, channelCaps);
|
sl@0
|
61 |
test_KErrNone(r);
|
sl@0
|
62 |
if(gVerboseOutput)
|
sl@0
|
63 |
{
|
sl@0
|
64 |
PRINT(channelCaps.iChannelPriorities);
|
sl@0
|
65 |
PRINT(channelCaps.iChannelPauseAndResume);
|
sl@0
|
66 |
PRINT(channelCaps.iAddrAlignedToElementSize);
|
sl@0
|
67 |
PRINT(channelCaps.i1DIndexAddressing);
|
sl@0
|
68 |
PRINT(channelCaps.i2DIndexAddressing);
|
sl@0
|
69 |
PRINT(channelCaps.iSynchronizationTypes);
|
sl@0
|
70 |
PRINT(channelCaps.iBurstTransactions);
|
sl@0
|
71 |
PRINT(channelCaps.iDescriptorInterrupt);
|
sl@0
|
72 |
PRINT(channelCaps.iFrameInterrupt);
|
sl@0
|
73 |
PRINT(channelCaps.iLinkedListPausedInterrupt);
|
sl@0
|
74 |
PRINT(channelCaps.iEndiannessConversion);
|
sl@0
|
75 |
PRINT(channelCaps.iGraphicsOps);
|
sl@0
|
76 |
PRINT(channelCaps.iRepeatingTransfers);
|
sl@0
|
77 |
PRINT(channelCaps.iChannelLinking);
|
sl@0
|
78 |
PRINT(channelCaps.iHwDescriptors);
|
sl@0
|
79 |
PRINT(channelCaps.iSrcDstAsymmetry);
|
sl@0
|
80 |
PRINT(channelCaps.iAsymHwDescriptors);
|
sl@0
|
81 |
PRINT(channelCaps.iBalancedAsymSegments);
|
sl@0
|
82 |
PRINT(channelCaps.iAsymCompletionInterrupt);
|
sl@0
|
83 |
PRINT(channelCaps.iAsymDescriptorInterrupt);
|
sl@0
|
84 |
PRINT(channelCaps.iAsymFrameInterrupt);
|
sl@0
|
85 |
PRINT(channelCaps.iReserved[0]);
|
sl@0
|
86 |
PRINT(channelCaps.iReserved[1]);
|
sl@0
|
87 |
PRINT(channelCaps.iReserved[2]);
|
sl@0
|
88 |
PRINT(channelCaps.iReserved[3]);
|
sl@0
|
89 |
PRINT(channelCaps.iReserved[4]);
|
sl@0
|
90 |
}
|
sl@0
|
91 |
|
sl@0
|
92 |
test.Next(_L("Get extended Channel caps (TDmacTestCaps)"));
|
sl@0
|
93 |
TDmacTestCaps extChannelCaps;
|
sl@0
|
94 |
r = session.ChannelCaps(channelCookie, extChannelCaps);
|
sl@0
|
95 |
test_KErrNone(r);
|
sl@0
|
96 |
test.Printf(_L("PIL version = %d\n"), extChannelCaps.iPILVersion);
|
sl@0
|
97 |
|
sl@0
|
98 |
const TBool newPil = (extChannelCaps.iPILVersion > 1);
|
sl@0
|
99 |
|
sl@0
|
100 |
test.Next(_L("Create Dma request - max fragment size 32K"));
|
sl@0
|
101 |
TUint reqCookie=0;
|
sl@0
|
102 |
r = session.RequestCreate(channelCookie, reqCookie, 32 * KKilo);
|
sl@0
|
103 |
test.Printf(_L("cookie recived = 0x%08x\n"), reqCookie);
|
sl@0
|
104 |
test_KErrNone(r);
|
sl@0
|
105 |
|
sl@0
|
106 |
if(newPil)
|
sl@0
|
107 |
{
|
sl@0
|
108 |
test.Next(_L("Create Dma request (with new-style callback)"));
|
sl@0
|
109 |
TUint reqCookieNewStyle=0;
|
sl@0
|
110 |
r = session.RequestCreateNew(channelCookie, reqCookieNewStyle);
|
sl@0
|
111 |
test.Printf(_L("cookie recived = 0x%08x\n"), reqCookieNewStyle );
|
sl@0
|
112 |
test_KErrNone(r);
|
sl@0
|
113 |
|
sl@0
|
114 |
test.Next(_L("Fragment for ISR callback"));
|
sl@0
|
115 |
const TInt size = 128 * KKilo;
|
sl@0
|
116 |
TDmaTransferArgs transferArgs(0, size, size, KDmaMemAddr, KDmaSyncAuto, KDmaRequestCallbackFromIsr);
|
sl@0
|
117 |
r = session.FragmentRequest(reqCookieNewStyle, transferArgs);
|
sl@0
|
118 |
test_KErrNone(r);
|
sl@0
|
119 |
|
sl@0
|
120 |
TIsrRequeArgs reque;
|
sl@0
|
121 |
test.Next(_L("Queue ISR callback - with default re-queue"));
|
sl@0
|
122 |
r = session.QueueRequestWithRequeue(reqCookieNewStyle, &reque, 1);
|
sl@0
|
123 |
test_KErrNone(r);
|
sl@0
|
124 |
|
sl@0
|
125 |
test.Next(_L("Destroy new-style Dma request"));
|
sl@0
|
126 |
r = session.RequestDestroy(reqCookieNewStyle);
|
sl@0
|
127 |
test_KErrNone(r);
|
sl@0
|
128 |
|
sl@0
|
129 |
test.Next(_L("Attempt to destroy request again "));
|
sl@0
|
130 |
r = session.RequestDestroy(reqCookieNewStyle);
|
sl@0
|
131 |
test_Equal(KErrNotFound, r);
|
sl@0
|
132 |
}
|
sl@0
|
133 |
|
sl@0
|
134 |
test.Next(_L("Open chunk handle"));
|
sl@0
|
135 |
RChunk chunk;
|
sl@0
|
136 |
r = session.OpenSharedChunk(chunk);
|
sl@0
|
137 |
test_KErrNone(r);
|
sl@0
|
138 |
if(gVerboseOutput)
|
sl@0
|
139 |
{
|
sl@0
|
140 |
test.Printf(_L("chunk base = 0x%08x\n"), chunk.Base());
|
sl@0
|
141 |
test.Printf(_L("chunk size = %d\n"), chunk.Size());
|
sl@0
|
142 |
}
|
sl@0
|
143 |
test(chunk.IsWritable());
|
sl@0
|
144 |
test(chunk.IsReadable());
|
sl@0
|
145 |
|
sl@0
|
146 |
test.Next(_L("Fragment(old style)"));
|
sl@0
|
147 |
const TInt size = 128 * KKilo;
|
sl@0
|
148 |
TInt i;
|
sl@0
|
149 |
for(i = 0; i<10; i++)
|
sl@0
|
150 |
{
|
sl@0
|
151 |
TUint64 time = 0;
|
sl@0
|
152 |
TDmaTransferArgs transferArgs(0, size, size, KDmaMemAddr);
|
sl@0
|
153 |
r = session.FragmentRequestOld(reqCookie, transferArgs, &time);
|
sl@0
|
154 |
test_KErrNone(r);
|
sl@0
|
155 |
if(gVerboseOutput)
|
sl@0
|
156 |
{
|
sl@0
|
157 |
test.Printf(_L("%lu us\n"), time);
|
sl@0
|
158 |
}
|
sl@0
|
159 |
}
|
sl@0
|
160 |
|
sl@0
|
161 |
test.Next(_L("Queue"));
|
sl@0
|
162 |
TRequestStatus status;
|
sl@0
|
163 |
|
sl@0
|
164 |
for(i = 0; i<10; i++)
|
sl@0
|
165 |
{
|
sl@0
|
166 |
TUint64 time = 0;
|
sl@0
|
167 |
r = session.QueueRequest(reqCookie, status, 0, &time);
|
sl@0
|
168 |
User::WaitForRequest(status);
|
sl@0
|
169 |
test_KErrNone(r);
|
sl@0
|
170 |
if(gVerboseOutput)
|
sl@0
|
171 |
{
|
sl@0
|
172 |
test.Printf(_L("%lu us\n"), time);
|
sl@0
|
173 |
}
|
sl@0
|
174 |
}
|
sl@0
|
175 |
|
sl@0
|
176 |
if(newPil)
|
sl@0
|
177 |
{
|
sl@0
|
178 |
test.Next(_L("Fragment(new style)"));
|
sl@0
|
179 |
TDmaTransferArgs transferArgs;
|
sl@0
|
180 |
transferArgs.iSrcConfig.iAddr = 0;
|
sl@0
|
181 |
transferArgs.iDstConfig.iAddr = size;
|
sl@0
|
182 |
transferArgs.iSrcConfig.iFlags = KDmaMemAddr;
|
sl@0
|
183 |
transferArgs.iDstConfig.iFlags = KDmaMemAddr;
|
sl@0
|
184 |
transferArgs.iTransferCount = size;
|
sl@0
|
185 |
|
sl@0
|
186 |
for(i = 0; i<10; i++)
|
sl@0
|
187 |
{
|
sl@0
|
188 |
TUint64 time = 0;
|
sl@0
|
189 |
r = session.FragmentRequest(reqCookie, transferArgs, &time);
|
sl@0
|
190 |
test_KErrNone(r);
|
sl@0
|
191 |
if(gVerboseOutput)
|
sl@0
|
192 |
{
|
sl@0
|
193 |
test.Printf(_L("%lu us\n"), time);
|
sl@0
|
194 |
}
|
sl@0
|
195 |
}
|
sl@0
|
196 |
}
|
sl@0
|
197 |
|
sl@0
|
198 |
test.Next(_L("Queue"));
|
sl@0
|
199 |
TCallbackRecord record;
|
sl@0
|
200 |
r = session.QueueRequest(reqCookie, &record);
|
sl@0
|
201 |
test_KErrNone(r);
|
sl@0
|
202 |
|
sl@0
|
203 |
test.Next(_L("check TCallbackRecord record"));
|
sl@0
|
204 |
if(gVerboseOutput)
|
sl@0
|
205 |
{
|
sl@0
|
206 |
record.Print();
|
sl@0
|
207 |
}
|
sl@0
|
208 |
const TCallbackRecord expected(TCallbackRecord::EThread, 1);
|
sl@0
|
209 |
if(!(record == expected))
|
sl@0
|
210 |
{
|
sl@0
|
211 |
test.Printf(_L("TCallbackRecords did not match"));
|
sl@0
|
212 |
if(gVerboseOutput)
|
sl@0
|
213 |
{
|
sl@0
|
214 |
test.Printf(_L("expected:"));
|
sl@0
|
215 |
expected.Print();
|
sl@0
|
216 |
}
|
sl@0
|
217 |
TEST_FAULT;
|
sl@0
|
218 |
}
|
sl@0
|
219 |
|
sl@0
|
220 |
test.Next(_L("Destroy Dma request"));
|
sl@0
|
221 |
r = session.RequestDestroy(reqCookie);
|
sl@0
|
222 |
test_KErrNone(r);
|
sl@0
|
223 |
|
sl@0
|
224 |
test.Next(_L("Close chunk handle"));
|
sl@0
|
225 |
chunk.Close();
|
sl@0
|
226 |
|
sl@0
|
227 |
test.Next(_L("Channel close"));
|
sl@0
|
228 |
r = session.ChannelClose(channelCookie);
|
sl@0
|
229 |
test_KErrNone(r);
|
sl@0
|
230 |
|
sl@0
|
231 |
test.Next(_L("Channel close (same again)"));
|
sl@0
|
232 |
r = session.ChannelClose(channelCookie);
|
sl@0
|
233 |
test_Equal(KErrNotFound, r);
|
sl@0
|
234 |
|
sl@0
|
235 |
test.Next(_L("Close session"));
|
sl@0
|
236 |
RTest::CloseHandleAndWaitForDestruction(session);
|
sl@0
|
237 |
|
sl@0
|
238 |
test.End();
|
sl@0
|
239 |
|
sl@0
|
240 |
}
|
sl@0
|
241 |
|
sl@0
|
242 |
const SDmacCaps KTestCapSet =
|
sl@0
|
243 |
{6, // TInt iChannelPriorities;
|
sl@0
|
244 |
EFalse, // TBool iChannelPauseAndResume;
|
sl@0
|
245 |
ETrue, // TBool iAddrAlignedToElementSize;
|
sl@0
|
246 |
EFalse, // TBool i1DIndexAddressing;
|
sl@0
|
247 |
EFalse, // TBool i2DIndexAddressing;
|
sl@0
|
248 |
KDmaSyncSizeElement | KDmaSyncSizeFrame |
|
sl@0
|
249 |
KDmaSyncSizeBlock, // TUint iSynchronizationTypes;
|
sl@0
|
250 |
KDmaBurstSize4 | KDmaBurstSize8, // TUint iBurstTransactions;
|
sl@0
|
251 |
EFalse, // TBool iDescriptorInterrupt;
|
sl@0
|
252 |
EFalse, // TBool iFrameInterrupt;
|
sl@0
|
253 |
EFalse, // TBool iLinkedListPausedInterrupt;
|
sl@0
|
254 |
EFalse, // TBool iEndiannessConversion;
|
sl@0
|
255 |
0, // TUint iGraphicsOps;
|
sl@0
|
256 |
ETrue, // TBool iRepeatingTransfers;
|
sl@0
|
257 |
EFalse, // TBool iChannelLinking;
|
sl@0
|
258 |
ETrue, // TBool iHwDescriptors;
|
sl@0
|
259 |
EFalse, // TBool iSrcDstAsymmetry;
|
sl@0
|
260 |
EFalse, // TBool iAsymHwDescriptors;
|
sl@0
|
261 |
EFalse, // TBool iBalancedAsymSegments;
|
sl@0
|
262 |
EFalse, // TBool iAsymCompletionInterrupt;
|
sl@0
|
263 |
EFalse, // TBool iAsymDescriptorInterrupt;
|
sl@0
|
264 |
EFalse, // TBool iAsymFrameInterrupt;
|
sl@0
|
265 |
{0, 0, 0, 0, 0} // TUint32 iReserved[5];
|
sl@0
|
266 |
};
|
sl@0
|
267 |
|
sl@0
|
268 |
const TDmacTestCaps KDmacTestCapsV1(KTestCapSet, 1);
|
sl@0
|
269 |
const TDmacTestCaps KDmacTestCapsV2(KTestCapSet, 2);
|
sl@0
|
270 |
|
sl@0
|
271 |
void TDmaCapability::SelfTest()
|
sl@0
|
272 |
{
|
sl@0
|
273 |
test.Start(_L("Unit test_Value of TDmaCapability::CompareToDmaCaps\n"));
|
sl@0
|
274 |
|
sl@0
|
275 |
{
|
sl@0
|
276 |
test.Next(_L("ENone\n"));
|
sl@0
|
277 |
TResult t = none.CompareToDmaCaps(KTestCapSet);
|
sl@0
|
278 |
test_Value(t, t == ERun);
|
sl@0
|
279 |
}
|
sl@0
|
280 |
|
sl@0
|
281 |
{
|
sl@0
|
282 |
test.Next(_L("EChannelPauseAndResume - wanted\n"));
|
sl@0
|
283 |
TResult t = pauseRequired.CompareToDmaCaps(KTestCapSet);
|
sl@0
|
284 |
test_Value(t, t == EFail);
|
sl@0
|
285 |
}
|
sl@0
|
286 |
{
|
sl@0
|
287 |
test.Next(_L("EChannelPauseAndResume - wanted - Allow skip\n"));
|
sl@0
|
288 |
TResult t = pauseRequired_skip.CompareToDmaCaps(KTestCapSet);
|
sl@0
|
289 |
test_Value(t, t == ESkip);
|
sl@0
|
290 |
}
|
sl@0
|
291 |
{
|
sl@0
|
292 |
test.Next(_L("EChannelPauseAndResume - not wanted\n"));
|
sl@0
|
293 |
TResult t = pauseNotWanted.CompareToDmaCaps(KTestCapSet);
|
sl@0
|
294 |
test_Value(t, t == ERun);
|
sl@0
|
295 |
}
|
sl@0
|
296 |
|
sl@0
|
297 |
{
|
sl@0
|
298 |
test.Next(_L("EHwDescriptors - not wanted\n"));
|
sl@0
|
299 |
TResult t = hwDesNotWanted.CompareToDmaCaps(KTestCapSet);
|
sl@0
|
300 |
test_Value(t, t == EFail);
|
sl@0
|
301 |
}
|
sl@0
|
302 |
|
sl@0
|
303 |
{
|
sl@0
|
304 |
test.Next(_L("EHwDescriptors - not wanted - Allow skip\n"));
|
sl@0
|
305 |
TResult t = hwDesNotWanted_skip.CompareToDmaCaps(KTestCapSet);
|
sl@0
|
306 |
test_Value(t, t == ESkip);
|
sl@0
|
307 |
}
|
sl@0
|
308 |
|
sl@0
|
309 |
{
|
sl@0
|
310 |
test.Next(_L("EHwDescriptors - wanted\n"));
|
sl@0
|
311 |
TResult t = hwDesWanted.CompareToDmaCaps(KTestCapSet);
|
sl@0
|
312 |
test_Value(t, t == ERun);
|
sl@0
|
313 |
}
|
sl@0
|
314 |
|
sl@0
|
315 |
|
sl@0
|
316 |
//TODO use this macro for the above tests
|
sl@0
|
317 |
|
sl@0
|
318 |
// Note: The construction of the test description message
|
sl@0
|
319 |
// is horribly confusing. The _L macro will make the
|
sl@0
|
320 |
// *first* string token wide, but not the next two.
|
sl@0
|
321 |
// Therefore these must be made wide or compilier
|
sl@0
|
322 |
// will complain about concatination of narrow and wide string
|
sl@0
|
323 |
// literals
|
sl@0
|
324 |
#define CAP_TEST(CAP, CAPSET, EXPCT)\
|
sl@0
|
325 |
{\
|
sl@0
|
326 |
test.Next(_L(#CAP L" against " L ## #CAPSET));\
|
sl@0
|
327 |
TResult t = (CAP).CompareToDmaCaps(CAPSET);\
|
sl@0
|
328 |
test_Equal(EXPCT, t);\
|
sl@0
|
329 |
}
|
sl@0
|
330 |
|
sl@0
|
331 |
|
sl@0
|
332 |
CAP_TEST(capEqualV1, KDmacTestCapsV1, ERun);
|
sl@0
|
333 |
CAP_TEST(capEqualV2, KDmacTestCapsV2, ERun);
|
sl@0
|
334 |
CAP_TEST(capEqualV1, KDmacTestCapsV2, ESkip);
|
sl@0
|
335 |
CAP_TEST(capEqualV2, KDmacTestCapsV1, ESkip);
|
sl@0
|
336 |
CAP_TEST(capEqualV2Fatal, KDmacTestCapsV1, EFail);
|
sl@0
|
337 |
|
sl@0
|
338 |
CAP_TEST(capAboveV1, KDmacTestCapsV2, ERun);
|
sl@0
|
339 |
CAP_TEST(capBelowV2, KDmacTestCapsV1, ERun);
|
sl@0
|
340 |
CAP_TEST(capAboveV1, KDmacTestCapsV1, ESkip);
|
sl@0
|
341 |
CAP_TEST(capBelowV2, KDmacTestCapsV2, ESkip);
|
sl@0
|
342 |
|
sl@0
|
343 |
test.End();
|
sl@0
|
344 |
}
|
sl@0
|
345 |
|
sl@0
|
346 |
void TTestCase::SelfTest()
|
sl@0
|
347 |
{
|
sl@0
|
348 |
//TODO should use macros for these tests
|
sl@0
|
349 |
test.Start(_L("Unit test of TTestCase::TestCaseValid\n"));
|
sl@0
|
350 |
|
sl@0
|
351 |
TTestCase testCase(NULL, EFalse, pauseRequired, hwDesNotWanted);
|
sl@0
|
352 |
test.Next(_L("pauseRequired, hwDesNotWanted\n"));
|
sl@0
|
353 |
TResult t = testCase.TestCaseValid(KTestCapSet);
|
sl@0
|
354 |
test_Value(t, t == EFail);
|
sl@0
|
355 |
|
sl@0
|
356 |
test.Next(_L("pauseRequired_skip, hwDesNotWanted\n"));
|
sl@0
|
357 |
testCase.iChannelCaps[0] = pauseRequired_skip;
|
sl@0
|
358 |
t = testCase.TestCaseValid(KTestCapSet);
|
sl@0
|
359 |
test_Value(t, t == EFail);
|
sl@0
|
360 |
|
sl@0
|
361 |
test.Next(_L("pauseRequired_skip, hwDesNotWanted_skip\n"));
|
sl@0
|
362 |
testCase.iChannelCaps[1] = hwDesNotWanted_skip;
|
sl@0
|
363 |
t = testCase.TestCaseValid(KTestCapSet);
|
sl@0
|
364 |
test_Value(t, t == ESkip);
|
sl@0
|
365 |
|
sl@0
|
366 |
test.Next(_L("pauseNotWanted, hwDesNotWanted_skip\n"));
|
sl@0
|
367 |
testCase.iChannelCaps[0] = pauseNotWanted;
|
sl@0
|
368 |
t = testCase.TestCaseValid(KTestCapSet);
|
sl@0
|
369 |
test_Value(t, t == ESkip);
|
sl@0
|
370 |
|
sl@0
|
371 |
test.Next(_L("pauseNotWanted, hwDesWanted\n"));
|
sl@0
|
372 |
testCase.iChannelCaps[1] = hwDesWanted;
|
sl@0
|
373 |
t = testCase.TestCaseValid(KTestCapSet);
|
sl@0
|
374 |
test_Value(t, t == ERun);
|
sl@0
|
375 |
|
sl@0
|
376 |
test.Next(_L("pauseNotWanted\n"));
|
sl@0
|
377 |
testCase.iChannelCaps[1] = none;
|
sl@0
|
378 |
t = testCase.TestCaseValid(KTestCapSet);
|
sl@0
|
379 |
test_Value(t, t == ERun);
|
sl@0
|
380 |
|
sl@0
|
381 |
test.Next(_L("pauseNotWanted + V1 PIL required\n"));
|
sl@0
|
382 |
testCase.iChannelCaps[1] = capAboveV1;
|
sl@0
|
383 |
test.Next(_L("Against KDmacTestCapsV1"));
|
sl@0
|
384 |
t = testCase.TestCaseValid(KDmacTestCapsV1);
|
sl@0
|
385 |
test_Equal(ESkip, t);
|
sl@0
|
386 |
test.Next(_L("Against KDmacTestCapsV2"));
|
sl@0
|
387 |
t = testCase.TestCaseValid(KDmacTestCapsV2);
|
sl@0
|
388 |
test_Equal(ERun, t);
|
sl@0
|
389 |
|
sl@0
|
390 |
test.Next(_L("pauseNotWanted + >V1 PIL required\n"));
|
sl@0
|
391 |
testCase.iChannelCaps[1] = capBelowV2;
|
sl@0
|
392 |
test.Next(_L("Against KDmacTestCapsV1"));
|
sl@0
|
393 |
t = testCase.TestCaseValid(KDmacTestCapsV1);
|
sl@0
|
394 |
test_Equal(ERun, t);
|
sl@0
|
395 |
test.Next(_L("Against KDmacTestCapsV2"));
|
sl@0
|
396 |
t = testCase.TestCaseValid(KDmacTestCapsV2);
|
sl@0
|
397 |
test_Equal(ESkip, t);
|
sl@0
|
398 |
|
sl@0
|
399 |
test.End();
|
sl@0
|
400 |
test.Close();
|
sl@0
|
401 |
}
|
sl@0
|
402 |
|
sl@0
|
403 |
|
sl@0
|
404 |
void TTransferIter::SelfTest()
|
sl@0
|
405 |
{
|
sl@0
|
406 |
test.Start(_L("No skip"));
|
sl@0
|
407 |
|
sl@0
|
408 |
const TUint8 src[9] = {
|
sl@0
|
409 |
1 ,2, 3,
|
sl@0
|
410 |
4, 5, 6,
|
sl@0
|
411 |
7, 8, 9
|
sl@0
|
412 |
};
|
sl@0
|
413 |
|
sl@0
|
414 |
const TUint32 addr = (TUint32)src;
|
sl@0
|
415 |
const TUint elementSize = 1;
|
sl@0
|
416 |
const TUint elementSkip = 0;
|
sl@0
|
417 |
const TUint elementsPerFrame = 3;
|
sl@0
|
418 |
const TUint frameSkip = 0;
|
sl@0
|
419 |
const TUint framesPerTransfer = 3;
|
sl@0
|
420 |
TDmaTransferConfig cfg(addr, elementSize, elementsPerFrame, framesPerTransfer,
|
sl@0
|
421 |
elementSkip, frameSkip, KDmaMemAddr
|
sl@0
|
422 |
);
|
sl@0
|
423 |
|
sl@0
|
424 |
TTransferIter iter(cfg, 0);
|
sl@0
|
425 |
TTransferIter end;
|
sl@0
|
426 |
TInt i;
|
sl@0
|
427 |
for(i = 0; i<9; i++, ++iter)
|
sl@0
|
428 |
{
|
sl@0
|
429 |
test_Equal(src[i],*iter);
|
sl@0
|
430 |
};
|
sl@0
|
431 |
|
sl@0
|
432 |
|
sl@0
|
433 |
test.Next(_L("90 degree rotation"));
|
sl@0
|
434 |
// Now imagine that we wanted to perform a rotation
|
sl@0
|
435 |
// as we write, so that we wrote out the following
|
sl@0
|
436 |
|
sl@0
|
437 |
const TUint8 expected[9] = {
|
sl@0
|
438 |
7, 4, 1,
|
sl@0
|
439 |
8, 5, 2,
|
sl@0
|
440 |
9, 6, 3
|
sl@0
|
441 |
};
|
sl@0
|
442 |
|
sl@0
|
443 |
TUint8 dst[9] = {0};
|
sl@0
|
444 |
TDmaTransferConfig dst_cfg(cfg);
|
sl@0
|
445 |
dst_cfg.iAddr = (TUint32)&dst[2];
|
sl@0
|
446 |
dst_cfg.iElementSkip = 2;
|
sl@0
|
447 |
dst_cfg.iFrameSkip = -8;
|
sl@0
|
448 |
|
sl@0
|
449 |
TTransferIter dst_iter(dst_cfg, 0);
|
sl@0
|
450 |
for(i=0; dst_iter != end; i++, ++dst_iter)
|
sl@0
|
451 |
{
|
sl@0
|
452 |
TEST_ASSERT(i<9);
|
sl@0
|
453 |
*dst_iter=src[i];
|
sl@0
|
454 |
};
|
sl@0
|
455 |
|
sl@0
|
456 |
for(i=0; i<9; i++)
|
sl@0
|
457 |
{
|
sl@0
|
458 |
test_Equal(expected[i],dst[i]);
|
sl@0
|
459 |
}
|
sl@0
|
460 |
}
|
sl@0
|
461 |
|
sl@0
|
462 |
void TCallbackRecord::SelfTest()
|
sl@0
|
463 |
{
|
sl@0
|
464 |
test.Start(_L("SeltTest of TCallbackRecord"));
|
sl@0
|
465 |
|
sl@0
|
466 |
test.Next(_L("create default TCallbackRecord record, record2"));
|
sl@0
|
467 |
TCallbackRecord record;
|
sl@0
|
468 |
const TCallbackRecord record2;
|
sl@0
|
469 |
if(gVerboseOutput)
|
sl@0
|
470 |
{
|
sl@0
|
471 |
test.Next(_L("Print record"));
|
sl@0
|
472 |
record.Print();
|
sl@0
|
473 |
}
|
sl@0
|
474 |
|
sl@0
|
475 |
test.Next(_L("test (record == record2)"));
|
sl@0
|
476 |
if(!(record == record2))
|
sl@0
|
477 |
{
|
sl@0
|
478 |
if(gVerboseOutput)
|
sl@0
|
479 |
{
|
sl@0
|
480 |
record2.Print();
|
sl@0
|
481 |
}
|
sl@0
|
482 |
TEST_FAULT;
|
sl@0
|
483 |
}
|
sl@0
|
484 |
|
sl@0
|
485 |
//A series of callback masks
|
sl@0
|
486 |
//Note these combinations do not necessarily represent
|
sl@0
|
487 |
//possible callback combinations
|
sl@0
|
488 |
TUint callbacks[] =
|
sl@0
|
489 |
{
|
sl@0
|
490 |
EDmaCallbackDescriptorCompletion,
|
sl@0
|
491 |
EDmaCallbackDescriptorCompletion,
|
sl@0
|
492 |
EDmaCallbackDescriptorCompletion,
|
sl@0
|
493 |
EDmaCallbackDescriptorCompletion,
|
sl@0
|
494 |
EDmaCallbackFrameCompletion_Src,
|
sl@0
|
495 |
EDmaCallbackFrameCompletion_Dst,
|
sl@0
|
496 |
EDmaCallbackDescriptorCompletion_Src | EDmaCallbackDescriptorCompletion_Dst,
|
sl@0
|
497 |
EDmaCallbackDescriptorCompletion_Src | EDmaCallbackFrameCompletion_Src | EDmaCallbackLinkedListPaused_Dst,
|
sl@0
|
498 |
EDmaCallbackRequestCompletion | EDmaCallbackRequestCompletion_Src,
|
sl@0
|
499 |
EDmaCallbackDescriptorCompletion_Dst
|
sl@0
|
500 |
};
|
sl@0
|
501 |
test.Next(_L("Feed a series of callback masks in to record"));
|
sl@0
|
502 |
const TInt length = ARRAY_LENGTH(callbacks);
|
sl@0
|
503 |
for(TInt i = 0; i < length; i++)
|
sl@0
|
504 |
{
|
sl@0
|
505 |
record.ProcessCallback(callbacks[i], EDmaResultOK);
|
sl@0
|
506 |
}
|
sl@0
|
507 |
|
sl@0
|
508 |
if(gVerboseOutput)
|
sl@0
|
509 |
{
|
sl@0
|
510 |
test.Next(_L("Print record"));
|
sl@0
|
511 |
record.Print();
|
sl@0
|
512 |
}
|
sl@0
|
513 |
|
sl@0
|
514 |
test.Next(_L("test GetCount"));
|
sl@0
|
515 |
test_Equal(1, record.GetCount(EDmaCallbackRequestCompletion));
|
sl@0
|
516 |
test_Equal(1, record.GetCount(EDmaCallbackRequestCompletion_Src));
|
sl@0
|
517 |
test_Equal(0, record.GetCount(EDmaCallbackRequestCompletion_Dst));
|
sl@0
|
518 |
test_Equal(4, record.GetCount(EDmaCallbackDescriptorCompletion));
|
sl@0
|
519 |
test_Equal(2, record.GetCount(EDmaCallbackDescriptorCompletion_Src));
|
sl@0
|
520 |
test_Equal(2, record.GetCount(EDmaCallbackDescriptorCompletion_Dst));
|
sl@0
|
521 |
test_Equal(0, record.GetCount(EDmaCallbackFrameCompletion));
|
sl@0
|
522 |
test_Equal(2, record.GetCount(EDmaCallbackFrameCompletion_Src));
|
sl@0
|
523 |
test_Equal(1, record.GetCount(EDmaCallbackFrameCompletion_Dst));
|
sl@0
|
524 |
test_Equal(0, record.GetCount(EDmaCallbackLinkedListPaused));
|
sl@0
|
525 |
test_Equal(0, record.GetCount(EDmaCallbackLinkedListPaused_Src));
|
sl@0
|
526 |
test_Equal(1, record.GetCount(EDmaCallbackLinkedListPaused_Dst));
|
sl@0
|
527 |
|
sl@0
|
528 |
test.Next(_L("test expected == record"));
|
sl@0
|
529 |
const TCallbackRecord expected(TCallbackRecord::EThread, 1, 1, 0, 4, 2, 2, 0, 2, 1, 0, 0, 1);
|
sl@0
|
530 |
if(!(expected == record))
|
sl@0
|
531 |
{
|
sl@0
|
532 |
if(gVerboseOutput)
|
sl@0
|
533 |
{
|
sl@0
|
534 |
expected.Print();
|
sl@0
|
535 |
}
|
sl@0
|
536 |
TEST_FAULT;
|
sl@0
|
537 |
}
|
sl@0
|
538 |
|
sl@0
|
539 |
test.Next(_L("modify record: test expected != record"));
|
sl@0
|
540 |
record.SetCount(EDmaCallbackFrameCompletion, 10);
|
sl@0
|
541 |
if(expected == record)
|
sl@0
|
542 |
{
|
sl@0
|
543 |
if(gVerboseOutput)
|
sl@0
|
544 |
{
|
sl@0
|
545 |
expected.Print();
|
sl@0
|
546 |
}
|
sl@0
|
547 |
TEST_FAULT;
|
sl@0
|
548 |
}
|
sl@0
|
549 |
|
sl@0
|
550 |
test.Next(_L("test Reset()"));
|
sl@0
|
551 |
record.Reset();
|
sl@0
|
552 |
test(record == record2);
|
sl@0
|
553 |
|
sl@0
|
554 |
test.End();
|
sl@0
|
555 |
}
|
sl@0
|
556 |
|
sl@0
|
557 |
void CDmaBenchmark::SelfTest()
|
sl@0
|
558 |
{
|
sl@0
|
559 |
test.Start(_L("SelfTest of CDmaBenchmark"));
|
sl@0
|
560 |
test.Next(_L("MeanResult()"));
|
sl@0
|
561 |
|
sl@0
|
562 |
TUint64 results[] = {8, 12, 1, 19, 3, 17, 10};
|
sl@0
|
563 |
const TInt count = ARRAY_LENGTH(results);
|
sl@0
|
564 |
|
sl@0
|
565 |
CDmaBmFragmentation fragTest(_L("SelfTest"), count, TDmaTransferArgs(), 0);
|
sl@0
|
566 |
|
sl@0
|
567 |
for(TInt i = 0; i < count; i++)
|
sl@0
|
568 |
{
|
sl@0
|
569 |
fragTest.iResultArray.Append(results[i]);
|
sl@0
|
570 |
}
|
sl@0
|
571 |
test_Equal(10, fragTest.MeanResult());
|
sl@0
|
572 |
|
sl@0
|
573 |
test.End();
|
sl@0
|
574 |
}
|
sl@0
|
575 |
|
sl@0
|
576 |
void TAddrRange::SelfTest()
|
sl@0
|
577 |
{
|
sl@0
|
578 |
test.Start(_L("SelfTest of TAddrRange"));
|
sl@0
|
579 |
TAddrRange a(0, 8);
|
sl@0
|
580 |
TAddrRange b(8, 8);
|
sl@0
|
581 |
|
sl@0
|
582 |
test_Equal(7, a.End());
|
sl@0
|
583 |
test_Equal(15, b.End());
|
sl@0
|
584 |
|
sl@0
|
585 |
test(!a.Overlaps(b));
|
sl@0
|
586 |
test(!b.Overlaps(a));
|
sl@0
|
587 |
test(a.Overlaps(a));
|
sl@0
|
588 |
test(b.Overlaps(b));
|
sl@0
|
589 |
|
sl@0
|
590 |
TAddrRange c(7, 2);
|
sl@0
|
591 |
test_Equal(8, c.End());
|
sl@0
|
592 |
|
sl@0
|
593 |
test(a.Overlaps(c));
|
sl@0
|
594 |
test(c.Overlaps(a));
|
sl@0
|
595 |
test(b.Overlaps(c));
|
sl@0
|
596 |
test(c.Overlaps(b));
|
sl@0
|
597 |
|
sl@0
|
598 |
TAddrRange d(0, 24);
|
sl@0
|
599 |
test(a.Overlaps(d));
|
sl@0
|
600 |
test(d.Overlaps(a));
|
sl@0
|
601 |
|
sl@0
|
602 |
test(b.Overlaps(d));
|
sl@0
|
603 |
test(d.Overlaps(b));
|
sl@0
|
604 |
|
sl@0
|
605 |
test(d.Contains(d));
|
sl@0
|
606 |
|
sl@0
|
607 |
test(d.Contains(a));
|
sl@0
|
608 |
test(!a.Contains(d));
|
sl@0
|
609 |
|
sl@0
|
610 |
test(d.Contains(b));
|
sl@0
|
611 |
test(!b.Contains(d));
|
sl@0
|
612 |
|
sl@0
|
613 |
test(!a.Contains(b));
|
sl@0
|
614 |
test(!b.Contains(a));
|
sl@0
|
615 |
test.End();
|
sl@0
|
616 |
}
|
sl@0
|
617 |
|
sl@0
|
618 |
void TAddressParms::SelfTest()
|
sl@0
|
619 |
{
|
sl@0
|
620 |
test.Start(_L("SelfTest of TAddressParms"));
|
sl@0
|
621 |
const TAddressParms pA(0, 32, 8);
|
sl@0
|
622 |
test(pA == pA);
|
sl@0
|
623 |
test(pA.Overlaps(pA));
|
sl@0
|
624 |
|
sl@0
|
625 |
const TAddrRange rA(4, 8);
|
sl@0
|
626 |
const TAddrRange rB(16, 8);
|
sl@0
|
627 |
const TAddrRange rC(28, 8);
|
sl@0
|
628 |
const TAddrRange rD(4, 32);
|
sl@0
|
629 |
|
sl@0
|
630 |
test(pA.Overlaps(rA));
|
sl@0
|
631 |
test(!pA.Overlaps(rB));
|
sl@0
|
632 |
test(pA.Overlaps(rC));
|
sl@0
|
633 |
test(pA.Overlaps(rD));
|
sl@0
|
634 |
|
sl@0
|
635 |
const TAddressParms pB(8, 16, 8);
|
sl@0
|
636 |
test(!(pA == pB));
|
sl@0
|
637 |
test(!(pB == pA));
|
sl@0
|
638 |
test(!pA.Overlaps(pB));
|
sl@0
|
639 |
test(!pB.Overlaps(pA));
|
sl@0
|
640 |
|
sl@0
|
641 |
const TAddressParms pC(8, 28, 8);
|
sl@0
|
642 |
test(pC.Overlaps(pA));
|
sl@0
|
643 |
test(pC.Overlaps(pB));
|
sl@0
|
644 |
|
sl@0
|
645 |
const TAddressParms pD(0, 128, 64);
|
sl@0
|
646 |
test(pD.Overlaps(pA));
|
sl@0
|
647 |
test(pD.Overlaps(pB));
|
sl@0
|
648 |
test(pD.Overlaps(pC));
|
sl@0
|
649 |
test.End();
|
sl@0
|
650 |
}
|
sl@0
|
651 |
|
sl@0
|
652 |
void SelfTests()
|
sl@0
|
653 |
{
|
sl@0
|
654 |
test.Next(_L("Running framework unit tests"));
|
sl@0
|
655 |
RDmaSession::SelfTest();
|
sl@0
|
656 |
TDmaCapability::SelfTest();
|
sl@0
|
657 |
TTestCase::SelfTest();
|
sl@0
|
658 |
TTransferIter::SelfTest();
|
sl@0
|
659 |
TCallbackRecord::SelfTest();
|
sl@0
|
660 |
CDmaBmFragmentation::SelfTest();
|
sl@0
|
661 |
TAddrRange::SelfTest();
|
sl@0
|
662 |
TAddressParms::SelfTest();
|
sl@0
|
663 |
test.End();
|
sl@0
|
664 |
test.Close();
|
sl@0
|
665 |
}
|