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