|
1 // Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32test\dmav2\t_dma2.cpp |
|
15 |
|
16 #include "d_dma2.h" |
|
17 #include "u32std.h" |
|
18 #include "t_dma2.h" |
|
19 #include "cap_reqs.h" |
|
20 |
|
21 #define __E32TEST_EXTENSION__ |
|
22 #include <e32test.h> |
|
23 #include <e32debug.h> |
|
24 #include <e32svr.h> |
|
25 #include <e32def_private.h> |
|
26 |
|
27 // DMA test framework command parameter options |
|
28 |
|
29 // SelfTest option |
|
30 _LIT(KArgSelfTest, "/SELFTEST"); |
|
31 _LIT(KArgSelfTest2, "/S"); |
|
32 |
|
33 //Verbose option |
|
34 _LIT(KArgVerboseOutput, "/VERBOSE"); |
|
35 _LIT(KArgVerboseOutput2, "/V"); |
|
36 |
|
37 //Simple transfer test option |
|
38 _LIT(KArgSimpleTest, "/simple"); |
|
39 |
|
40 //Callback test option |
|
41 _LIT(KArgCallBackTest, "/callback"); |
|
42 |
|
43 //Suspend test option |
|
44 _LIT(KArgSuspendTest, "/suspend"); |
|
45 |
|
46 //Multipart transfer tests |
|
47 _LIT(KArgMultiPartTest, "/multi"); |
|
48 |
|
49 //Isr and dfc test option |
|
50 _LIT(KArgIsrDfcTest, "/isrdfc"); |
|
51 |
|
52 //Isr reque test option |
|
53 _LIT(KArgIsrequeTest, "/isreque"); |
|
54 |
|
55 //Benchmark test option |
|
56 _LIT(KArgBenchmarkTest, "/bench"); |
|
57 |
|
58 //Graphics test option |
|
59 _LIT(KArgGraphicTest, "/graphic"); |
|
60 |
|
61 //DMA channel (opening and closing) test option |
|
62 _LIT(KArgChannelTest, "/channel"); |
|
63 |
|
64 //Queue test option |
|
65 _LIT(KArgQueueTest, "/queue"); |
|
66 |
|
67 //Fragment test option |
|
68 _LIT(KArgFragmentTest, "/fragment"); |
|
69 |
|
70 //Request test option |
|
71 _LIT(KArgRequestTest, "/request"); |
|
72 |
|
73 |
|
74 |
|
75 TBool gHelpRequested; // print usage |
|
76 TBool gVerboseOutput; // enable verbose output |
|
77 TBool gSelfTest; // run SelfTest |
|
78 TBool gSimpleTest; // run only Simple transfer test |
|
79 TBool gCallBack; // run only Callback test |
|
80 TBool gSuspend; // run only Pause and resume tests |
|
81 TBool gIsrReque; // run only IsrReque tests |
|
82 TBool gMultiPart; // run only Multipart tests |
|
83 TBool gIsrAndDfc; // run only IsrAndDfc tests |
|
84 TBool gBenchmark; // run only Benchmark tests |
|
85 TBool gGraphic; // run only Graphic tests |
|
86 TBool gFragment; // run only Fragment related tests |
|
87 TBool gChannel; // run only Channel(open/close)tests |
|
88 TBool gQueue; // run only Queue related tests |
|
89 TBool gRequest; // run only Request related tests |
|
90 |
|
91 /** |
|
92 This function prints out the PSL test Information |
|
93 */ |
|
94 void Print(const TDmaV2TestInfo& aInfo) |
|
95 { |
|
96 PRINT(aInfo.iMaxTransferSize); |
|
97 PRINT(aInfo.iMemAlignMask); |
|
98 PRINT(aInfo.iMemMemPslInfo); |
|
99 PRINT(aInfo.iMaxSbChannels); |
|
100 for(TInt i=0; i<aInfo.iMaxSbChannels; i++) |
|
101 { |
|
102 PRINT(aInfo.iSbChannels[i]); |
|
103 } |
|
104 PRINT(aInfo.iMaxDbChannels); |
|
105 for(TInt j=0; j<aInfo.iMaxDbChannels; j++) |
|
106 { |
|
107 PRINT(aInfo.iDbChannels[j]); |
|
108 } |
|
109 PRINT(aInfo.iMaxSgChannels); |
|
110 for(TInt k=0; k<aInfo.iMaxSgChannels; k++) |
|
111 { |
|
112 PRINT(aInfo.iSgChannels[k]); |
|
113 } |
|
114 } |
|
115 |
|
116 void CDmaTest::PrintTestInfo() const |
|
117 { |
|
118 TBuf<32> buf; |
|
119 buf.AppendFormat(_L("DMA channel %d"), iChannelCookie); |
|
120 RDebug::RawPrint(buf); |
|
121 } |
|
122 |
|
123 ////////////////////////////////////////////////////////////////////// |
|
124 // CDmaTest |
|
125 ////////////////////////////////////////////////////////////////////// |
|
126 |
|
127 void CDmaTest::OpenDmaSession() |
|
128 { |
|
129 // Only open a new session if one |
|
130 // was not already supplied |
|
131 if(iDmaSession.Handle() == KNullHandle) |
|
132 { |
|
133 TInt r = iDmaSession.Open(); |
|
134 if(KErrNone != r) |
|
135 { |
|
136 RDebug::Printf("CDmaTest::OpenDmaSession = %d\n", r); |
|
137 } |
|
138 TEST_ASSERT(r == KErrNone); |
|
139 r = iDmaSession.OpenSharedChunk(iChunk); |
|
140 TEST_ASSERT(r == KErrNone); |
|
141 } |
|
142 } |
|
143 |
|
144 // Open another handle to the test driver |
|
145 void CDmaTest::OpenDmaSession(const RDmaSession& aSession) |
|
146 { |
|
147 iDmaSession = aSession; |
|
148 TInt r = iDmaSession.Duplicate(RThread(), EOwnerThread); |
|
149 TEST_ASSERT(r == KErrNone); |
|
150 |
|
151 // open another handle to the test driver chunk |
|
152 r = iDmaSession.OpenSharedChunk(iChunk); |
|
153 TEST_ASSERT(r == KErrNone); |
|
154 } |
|
155 |
|
156 void CDmaTest::CloseDmaSession() |
|
157 { |
|
158 iChunk.Close(); |
|
159 iDmaSession.Close(); |
|
160 } |
|
161 |
|
162 void CDmaTest::PreTransferSetup() |
|
163 { |
|
164 } |
|
165 |
|
166 TInt CDmaTest::DoPostTransferCheck() |
|
167 { |
|
168 return KErrNotSupported; |
|
169 } |
|
170 |
|
171 void CDmaTest::ChannelPause(TUint aChannelSessionCookie) |
|
172 { |
|
173 TInt r = iDmaSession.ChannelPause(aChannelSessionCookie); |
|
174 TEST_ASSERT(r == KErrNone); |
|
175 } |
|
176 |
|
177 void CDmaTest::ChannelResume(TUint aChannelSessionCookie) |
|
178 { |
|
179 TInt r = iDmaSession.ChannelResume(aChannelSessionCookie); |
|
180 TEST_ASSERT(r == KErrNone); |
|
181 } |
|
182 ////////////////////////////////////////////////////////////////////// |
|
183 // CSingleTransferTest |
|
184 ////////////////////////////////////////////////////////////////////// |
|
185 void CSingleTransferTest::RunTest() |
|
186 { |
|
187 OpenDmaSession(); |
|
188 PreTransferSetup(); |
|
189 |
|
190 OpenChannel(); |
|
191 CreateDmaRequest(); |
|
192 Fragment(); |
|
193 Queue(); |
|
194 FreeRequest(); |
|
195 CloseChannel(); |
|
196 PostTransferCheck(); |
|
197 |
|
198 CloseDmaSession(); |
|
199 } |
|
200 |
|
201 void CSingleTransferTest::OpenChannel() |
|
202 { |
|
203 iActual.iChannelOpenResult = |
|
204 iDmaSession.ChannelOpen(iChannelCookie, iChannelSessionCookie); |
|
205 } |
|
206 |
|
207 void CSingleTransferTest::CreateDmaRequest() |
|
208 { |
|
209 if(iUseNewRequest) |
|
210 { |
|
211 if(gVerboseOutput) |
|
212 { |
|
213 RDebug::Printf("Calling New Request API\n"); |
|
214 } |
|
215 iActual.iRequestResult.iCreate = |
|
216 iDmaSession.RequestCreate(iChannelSessionCookie, iRequestSessionCookie, iMaxFragmentSize); |
|
217 } |
|
218 else |
|
219 { |
|
220 if(gVerboseOutput) |
|
221 { |
|
222 RDebug::Printf("Calling Old Request API\n"); |
|
223 } |
|
224 iActual.iRequestResult.iCreate = |
|
225 iDmaSession.RequestCreateOld(iChannelSessionCookie, iRequestSessionCookie, iMaxFragmentSize); |
|
226 } |
|
227 } |
|
228 |
|
229 void CSingleTransferTest::Fragment() |
|
230 { |
|
231 if(iActual.iRequestResult.iCreate != KErrNone) |
|
232 return; |
|
233 |
|
234 if(iUseNewFragment) |
|
235 { |
|
236 if(gVerboseOutput) |
|
237 { |
|
238 RDebug::Printf("Calling New Fragment API\n"); |
|
239 } |
|
240 iActual.iRequestResult.iFragmentationResult = |
|
241 iDmaSession.FragmentRequest(iRequestSessionCookie, iTransferArgs); |
|
242 } |
|
243 else |
|
244 { |
|
245 if(gVerboseOutput) |
|
246 { |
|
247 RDebug::Printf("Calling Old Fragment API\n"); |
|
248 } |
|
249 iActual.iRequestResult.iFragmentationResult = |
|
250 iDmaSession.FragmentRequestOld(iRequestSessionCookie, iTransferArgs); |
|
251 } |
|
252 |
|
253 const TInt fragmentCount = iDmaSession.RequestFragmentCount(iRequestSessionCookie); |
|
254 |
|
255 // Record the fragment count if a non-zero value was expected, |
|
256 // or if it was an error value |
|
257 if(iExpected.iRequestResult.iFragmentCount != 0 || fragmentCount < 0) |
|
258 iActual.iRequestResult.iFragmentCount = fragmentCount; |
|
259 } |
|
260 |
|
261 void CSingleTransferTest::Queue() |
|
262 { |
|
263 if(iActual.iRequestResult.iFragmentationResult == KErrNone) |
|
264 { |
|
265 iActual.iRequestResult.iQueueResult = iDmaSession.QueueRequest(iRequestSessionCookie, &iActual.iCallbackRecord); |
|
266 } |
|
267 } |
|
268 |
|
269 void CSingleTransferTest::PostTransferCheck() |
|
270 { |
|
271 if(iPostTransferCheck) |
|
272 iActual.iPostTransferCheck = DoPostTransferCheck(); |
|
273 } |
|
274 |
|
275 TInt CSingleTransferTest::DoPostTransferCheck() |
|
276 { |
|
277 return iPostTransferCheck->Check(*this); |
|
278 } |
|
279 |
|
280 void CSingleTransferTest::FreeRequest() |
|
281 { |
|
282 if(iActual.iRequestResult.iCreate == KErrNone) |
|
283 { |
|
284 TInt r = iDmaSession.RequestDestroy(iRequestSessionCookie); |
|
285 TEST_ASSERT(r == KErrNone); |
|
286 } |
|
287 } |
|
288 |
|
289 void CSingleTransferTest::CloseChannel() |
|
290 { |
|
291 if(iActual.iChannelOpenResult == KErrNone) |
|
292 { |
|
293 TInt r = iDmaSession.ChannelClose(iChannelSessionCookie); |
|
294 TEST_ASSERT(r == KErrNone); |
|
295 } |
|
296 } |
|
297 |
|
298 void CSingleTransferTest::PrintTestType() const |
|
299 { |
|
300 RDebug::RawPrint(_L("Single transfer")); |
|
301 } |
|
302 |
|
303 void CSingleTransferTest::PrintTestInfo() const |
|
304 { |
|
305 CDmaTest::PrintTestInfo(); |
|
306 |
|
307 // State which API versions are being used |
|
308 if(iUseNewFragment) |
|
309 RDebug::RawPrint(_L(", Fragment v2,")); |
|
310 else |
|
311 RDebug::RawPrint(_L(", Fragment v1,")); |
|
312 |
|
313 if(iUseNewRequest) |
|
314 RDebug::RawPrint(_L(" DDmaRequest v2")); |
|
315 else |
|
316 RDebug::RawPrint(_L(" DDmaRequest v1")); |
|
317 } |
|
318 |
|
319 void CSingleTransferTest::PreTransferSetup() |
|
320 { |
|
321 if(iPreTransfer) |
|
322 iPreTransfer->Setup(*this); //initialize test |
|
323 } |
|
324 |
|
325 TBool CSingleTransferTest::Result() |
|
326 { |
|
327 const TBool result = iExpected == iActual; |
|
328 if(!result) |
|
329 { |
|
330 RDebug::Printf("TResultSets do not match"); |
|
331 } |
|
332 if(!result || gVerboseOutput) |
|
333 { |
|
334 RDebug::Printf("\nExpected error codes:"); |
|
335 iExpected.Print(); |
|
336 RDebug::Printf("Expected callback record:"); |
|
337 iExpected.iCallbackRecord.Print(); |
|
338 |
|
339 RDebug::Printf("\nActual error codes:"); |
|
340 iActual.Print(); |
|
341 RDebug::Printf("Actual callback record:"); |
|
342 iActual.iCallbackRecord.Print(); |
|
343 } |
|
344 return result; |
|
345 } |
|
346 |
|
347 ////////////////////////////////////////////////////////////////////// |
|
348 // CDmaTestDecorator |
|
349 ////////////////////////////////////////////////////////////////////// |
|
350 |
|
351 CDmaTestDecorator::CDmaTestDecorator(CDmaTest* aDecoratedTest) |
|
352 : CDmaTest(_L("Decorated Test"), 1, NULL, NULL), iDecoratedTest(aDecoratedTest) |
|
353 {} |
|
354 |
|
355 CDmaTestDecorator::CDmaTestDecorator(const CDmaTestDecorator& aOther) |
|
356 : CDmaTest(aOther), iDecoratedTest( static_cast<CDmaTest*>( aOther.iDecoratedTest->Clone() ) ) |
|
357 // Need cast because Clone does not have a covariant return type, |
|
358 // as not all compillers allow it |
|
359 {} |
|
360 |
|
361 ////////////////////////////////////////////////////////////////////// |
|
362 // CMultiVersionTest |
|
363 ////////////////////////////////////////////////////////////////////// |
|
364 |
|
365 CMultiVersionTest::CMultiVersionTest(CSingleTransferTest* aDmaTest) |
|
366 : CDmaTestDecorator(aDmaTest), iNewVersionTest(NULL) |
|
367 { |
|
368 } |
|
369 |
|
370 CMultiVersionTest::CMultiVersionTest(const CMultiVersionTest& aOther) |
|
371 : CDmaTestDecorator(aOther), iNewVersionTest( aOther.iNewVersionTest ? static_cast<CSingleTransferTest*>(aOther.iNewVersionTest->Clone()) : NULL) |
|
372 { |
|
373 } |
|
374 |
|
375 CMultiVersionTest::~CMultiVersionTest() |
|
376 { |
|
377 delete iDecoratedTest; |
|
378 delete iNewVersionTest; |
|
379 } |
|
380 |
|
381 void CMultiVersionTest::SetupL() |
|
382 { |
|
383 // Open a tempory dma session to find out the |
|
384 // capabilities of the dma channel. |
|
385 OpenDmaSession(); |
|
386 Configure(); |
|
387 CloseDmaSession(); |
|
388 } |
|
389 |
|
390 void CMultiVersionTest::Announce() const |
|
391 { |
|
392 CTest::Announce(); |
|
393 |
|
394 iDecoratedTest->Announce(); |
|
395 |
|
396 if(iNewVersionTest) |
|
397 iNewVersionTest->Announce(); |
|
398 } |
|
399 |
|
400 void CMultiVersionTest::PrintTestType() const |
|
401 { |
|
402 RDebug::RawPrint(_L("Multi version test wrapper")); |
|
403 } |
|
404 |
|
405 void CMultiVersionTest::PrintTestInfo() const |
|
406 { |
|
407 if(iNewVersionTest) |
|
408 { |
|
409 RDebug::RawPrint(_L("Running tests using Version 2 PIL")); |
|
410 } |
|
411 else |
|
412 { |
|
413 RDebug::RawPrint(_L("Running tests using Version 1 PIL")); |
|
414 } |
|
415 } |
|
416 |
|
417 void CMultiVersionTest::RunTest() |
|
418 { |
|
419 OpenDmaSession(); |
|
420 |
|
421 // iDecoratedTest is the test, in the old configuration |
|
422 // iNewVersionTest is the same test, configured |
|
423 // to use the new APIs |
|
424 // |
|
425 // 2 objects are needed since they can each store |
|
426 // their own results |
|
427 |
|
428 iDecoratedTest->OpenDmaSession(iDmaSession); |
|
429 (*iDecoratedTest)(); |
|
430 |
|
431 if(iNewVersionTest) |
|
432 { |
|
433 iNewVersionTest->OpenDmaSession(iDmaSession); |
|
434 (*iNewVersionTest)(); |
|
435 } |
|
436 |
|
437 CloseDmaSession(); |
|
438 } |
|
439 |
|
440 /** |
|
441 Maybe create another test object to run with new API |
|
442 |
|
443 Pass on the cookie for the channel they must test |
|
444 */ |
|
445 void CMultiVersionTest::Configure() |
|
446 { |
|
447 static_cast<CSingleTransferTest*>(iDecoratedTest)->UseNewDmaApi(EFalse); |
|
448 iDecoratedTest->SetChannelCookie(iChannelCookie); |
|
449 |
|
450 if(Version2PILAvailable()) |
|
451 { |
|
452 iNewVersionTest = static_cast<CSingleTransferTest*>(iDecoratedTest->Clone()); |
|
453 TEST_ASSERT(iNewVersionTest != NULL); |
|
454 |
|
455 iNewVersionTest->UseNewDmaApi(ETrue); |
|
456 iNewVersionTest->SetChannelCookie(iChannelCookie); |
|
457 } |
|
458 } |
|
459 |
|
460 /** |
|
461 Discover from DMA channel what PIL versions are available. |
|
462 In practice V1 APIs will always be available, V2 may be. |
|
463 */ |
|
464 TBool CMultiVersionTest::Version2PILAvailable() |
|
465 { |
|
466 TUint channelSessionCookie; |
|
467 TInt r = iDmaSession.ChannelOpen(iChannelCookie, channelSessionCookie); |
|
468 TEST_ASSERT(r == KErrNone); |
|
469 |
|
470 TDmacTestCaps channelCaps; |
|
471 r = iDmaSession.ChannelCaps(channelSessionCookie, channelCaps); |
|
472 TEST_ASSERT(r == KErrNone); |
|
473 |
|
474 r = iDmaSession.ChannelClose(channelSessionCookie); |
|
475 TEST_ASSERT(r == KErrNone); |
|
476 |
|
477 return channelCaps.iPILVersion >= 2; |
|
478 } |
|
479 |
|
480 TBool CMultiVersionTest::Result() |
|
481 { |
|
482 TBool v1Result = iDecoratedTest->Result(); |
|
483 if(gVerboseOutput || !v1Result) |
|
484 RDebug::Printf("V1 API result: %s", v1Result ? "success" : "failure"); |
|
485 |
|
486 TBool v2Result = iNewVersionTest ? iNewVersionTest->Result() : ETrue; |
|
487 if(gVerboseOutput || !v1Result) |
|
488 RDebug::Printf("V2 API result: %s", v2Result ? "success" : "failure"); |
|
489 return v1Result && v2Result; |
|
490 } |
|
491 |
|
492 ////////////////////////////////////////////////////////////////////// |
|
493 // CDmaBenchmark |
|
494 ////////////////////////////////////////////////////////////////////// |
|
495 CDmaBenchmark::CDmaBenchmark(const TDesC& aName, TInt aIterations, const TResultSet& aExpectedResults, const TDmaTransferArgs& aTransferArgs, TUint aMaxFragmentSize) |
|
496 :CSingleTransferTest(aName, aIterations, aTransferArgs, aExpectedResults, aMaxFragmentSize, NULL, NULL) |
|
497 { |
|
498 UseNewDmaApi(EFalse); |
|
499 } |
|
500 |
|
501 CDmaBenchmark::CDmaBenchmark(const CDmaBenchmark& aOriginal) |
|
502 :CSingleTransferTest(aOriginal) |
|
503 { |
|
504 CopyL(aOriginal.iResultArray, iResultArray); |
|
505 } |
|
506 |
|
507 CDmaBenchmark::~CDmaBenchmark() |
|
508 { |
|
509 iResultArray.Close(); |
|
510 } |
|
511 |
|
512 TUint64 CDmaBenchmark::MeanResult() |
|
513 { |
|
514 if(gVerboseOutput) |
|
515 RDebug::Printf("CDmaBenchmark::MeanResult\n"); |
|
516 |
|
517 const TInt count = iResultArray.Count(); |
|
518 |
|
519 TEST_ASSERT(count > 0); |
|
520 TEST_ASSERT(count == iIterations); |
|
521 |
|
522 TUint64 sum = 0; |
|
523 |
|
524 for(TInt i = 0; i < count; i++) |
|
525 { |
|
526 const TUint64 value = iResultArray[i]; |
|
527 if(gVerboseOutput) |
|
528 RDebug::Printf("iResultArray[%d]: %lu", i, value); |
|
529 |
|
530 sum += value; |
|
531 } |
|
532 |
|
533 return sum / count; |
|
534 } |
|
535 |
|
536 TBool CDmaBenchmark::Result() |
|
537 { |
|
538 const TBool result = CSingleTransferTest::Result(); |
|
539 if(result) |
|
540 { |
|
541 RDebug::Printf(" Mean time: %lu us", MeanResult()); |
|
542 } |
|
543 |
|
544 return result; |
|
545 } |
|
546 |
|
547 ////////////////////////////////////////////////////////////////////// |
|
548 // CDmaBmFragmentation |
|
549 ////////////////////////////////////////////////////////////////////// |
|
550 CDmaBmFragmentation::CDmaBmFragmentation(const TDesC& aName, TInt aIterations, const TDmaTransferArgs& aTransferArgs, TUint aMaxFragmentSize) |
|
551 :CDmaBenchmark(aName, aIterations, ExpectedResults, aTransferArgs, aMaxFragmentSize) |
|
552 {} |
|
553 |
|
554 const TResultSet CDmaBmFragmentation::ExpectedResults(KErrNone, |
|
555 TRequestResults(KErrNone, 0, KErrNone, KErrUnknown), |
|
556 KErrUnknown, |
|
557 TCallbackRecord::Empty() |
|
558 ); |
|
559 |
|
560 void CDmaBmFragmentation::Fragment() |
|
561 { |
|
562 TUint64 time; |
|
563 iActual.iRequestResult.iFragmentationResult = |
|
564 iDmaSession.FragmentRequestOld(iRequestSessionCookie, iTransferArgs, &time); |
|
565 iResultArray.Append(time); |
|
566 } |
|
567 |
|
568 void CDmaBmFragmentation::PrintTestType() const |
|
569 { |
|
570 RDebug::RawPrint(_L("Fragmentation Benchmark")); |
|
571 } |
|
572 |
|
573 void CDmaBmFragmentation::RunTest() |
|
574 { |
|
575 OpenDmaSession(); |
|
576 |
|
577 OpenChannel(); |
|
578 CreateDmaRequest(); |
|
579 Fragment(); |
|
580 FreeRequest(); |
|
581 CloseChannel(); |
|
582 CloseDmaSession(); |
|
583 } |
|
584 |
|
585 ////////////////////////////////////////////////////////////////////// |
|
586 // CPauseResumeTest |
|
587 // |
|
588 // -Time how long a given transfer takes |
|
589 // -Pause the channel |
|
590 // -repeat the transfer (queued asynchronously) |
|
591 // -wait for some time (say, 3 times the time measured) |
|
592 // -read the value of the TRequestStatus object, to check it is still pending |
|
593 // -resume the channel |
|
594 // -Wait on the request |
|
595 // -Confirm that the request completed |
|
596 ////////////////////////////////////////////////////////////////////// |
|
597 CPauseResumeTest::~CPauseResumeTest() |
|
598 { |
|
599 } |
|
600 |
|
601 void CPauseResumeTest::RunTest() |
|
602 { |
|
603 OpenDmaSession(); |
|
604 |
|
605 //Open a single DMA channel for a transfer |
|
606 OpenChannel(); |
|
607 |
|
608 RDebug::Printf("Resume unpaused idle channel"); |
|
609 TInt r = iDmaSession.ChannelResume(iChannelSessionCookie); |
|
610 TEST_ASSERT(KErrCompletion == r); |
|
611 |
|
612 RDebug::Printf("Pause idle channel"); |
|
613 r = iDmaSession.ChannelPause(iChannelSessionCookie); |
|
614 TEST_ASSERT(KErrNone == r); |
|
615 |
|
616 RDebug::Printf("Pause paused idle Channel"); |
|
617 r = iDmaSession.ChannelPause(iChannelSessionCookie); |
|
618 TEST_ASSERT(KErrCompletion == r); |
|
619 |
|
620 RDebug::Printf("Resume paused idle channel"); |
|
621 r = iDmaSession.ChannelResume(iChannelSessionCookie); |
|
622 TEST_ASSERT(KErrNone == r); |
|
623 |
|
624 //Setup a DMA request and Fragment the request. |
|
625 CreateDmaRequest(); |
|
626 Fragment(); |
|
627 |
|
628 //Queue the DMA request and time how long a transfer takes |
|
629 TUint64 queueTime; |
|
630 DoCalibrationTransfer(queueTime); |
|
631 |
|
632 RDebug::Printf("Calibration transfer completed in %Lu us",queueTime); |
|
633 TUint32 waitQueueReqTime = I64LOW(queueTime*3); //3 times the time measured in DoCalibrationTransfer |
|
634 TEST_ASSERT(I64HIGH(queueTime*3) == 0); // If transfer takes over an hour, something has gone wrong anyway |
|
635 |
|
636 // Initialise buffers, after calibration transfer |
|
637 PreTransferSetup(); |
|
638 |
|
639 RDebug::Printf("Resume unpaused channel"); |
|
640 r = iDmaSession.ChannelResume(iChannelSessionCookie); |
|
641 TEST_ASSERT(KErrCompletion == r); |
|
642 |
|
643 //Pause DMA Transfer |
|
644 RDebug::Printf("Pausing DMA Channel"); |
|
645 r = iDmaSession.ChannelPause(iChannelSessionCookie); |
|
646 TEST_ASSERT(KErrNone == r); |
|
647 |
|
648 RDebug::Printf("Pause paused Channel"); |
|
649 r = iDmaSession.ChannelPause(iChannelSessionCookie); |
|
650 TEST_ASSERT(KErrCompletion == r); |
|
651 |
|
652 //Repeat the transfer (queued asynchronously) |
|
653 TRequestStatus queueRequestStatus; |
|
654 iActual.iRequestResult.iQueueResult = QueueAsyncRequest(queueRequestStatus,queueTime); |
|
655 RDebug::Printf("Queue a DMA Request and wait for %u us ", waitQueueReqTime); |
|
656 |
|
657 User::After(waitQueueReqTime); |
|
658 RDebug::Printf("Finished waiting"); |
|
659 TEST_ASSERT(queueRequestStatus.Int() == KRequestPending); |
|
660 |
|
661 TBool queueEmpty = ETrue; |
|
662 r = iDmaSession.ChannelIsQueueEmpty(iChannelSessionCookie,queueEmpty); |
|
663 TEST_ASSERT(r == KErrNone); |
|
664 TEST_ASSERT(!queueEmpty); |
|
665 |
|
666 //Resume DMA channel |
|
667 RDebug::Printf("Resuming paused DMA Channel"); |
|
668 r = iDmaSession.ChannelResume(iChannelSessionCookie); |
|
669 TEST_ASSERT(KErrNone == r); |
|
670 |
|
671 //Wait for transfer to complete |
|
672 User::WaitForRequest(queueRequestStatus); |
|
673 if (queueRequestStatus.Int() == KErrNone) |
|
674 { |
|
675 RDebug::Printf("DMA QueueAsyncRequest completed"); |
|
676 } |
|
677 |
|
678 FreeRequest(); |
|
679 CloseChannel(); |
|
680 |
|
681 PostTransferCheck(); |
|
682 CloseDmaSession(); |
|
683 } |
|
684 |
|
685 /** |
|
686 Time how long transfer takes, with no pausing |
|
687 */ |
|
688 void CPauseResumeTest::DoCalibrationTransfer(TUint64 &atime) |
|
689 { |
|
690 //Queue the DMA request. |
|
691 TCallbackRecord pCallbackRecord; |
|
692 TInt r = iDmaSession.QueueRequest(iRequestSessionCookie,&pCallbackRecord,&atime); |
|
693 TEST_ASSERT(r == KErrNone); |
|
694 } |
|
695 |
|
696 TInt CPauseResumeTest::QueueAsyncRequest(TRequestStatus &aRequestState, TUint64 &atime) |
|
697 { |
|
698 return iDmaSession.QueueRequest(iRequestSessionCookie,aRequestState, &iActual.iCallbackRecord, &atime); |
|
699 } |
|
700 |
|
701 void CPauseResumeTest::PrintTestType() const |
|
702 { |
|
703 RDebug::RawPrint(_L("Pause and Resume API Test")); |
|
704 } |
|
705 |
|
706 ////////////////////////////////////////////////////////////////////// |
|
707 // CPauseResumeNegTest |
|
708 // |
|
709 // -Open DMA Channel |
|
710 // -Pause and Resume DMA channel |
|
711 // -Check that KErrNotSupported is returned |
|
712 // -Close DMA Channel |
|
713 ////////////////////////////////////////////////////////////////////// |
|
714 CPauseResumeNegTest::~CPauseResumeNegTest() |
|
715 { |
|
716 } |
|
717 |
|
718 void CPauseResumeNegTest::RunTest() |
|
719 { |
|
720 OpenDmaSession(); |
|
721 |
|
722 //Open a single DMA channel for a transfer |
|
723 OpenChannel(); |
|
724 |
|
725 RDebug::Printf("Resume unpaused idle channel"); |
|
726 TInt r = iDmaSession.ChannelResume(iChannelSessionCookie); |
|
727 TEST_ASSERT(KErrNotSupported == r); |
|
728 |
|
729 RDebug::Printf("Pause idle channel"); |
|
730 r = iDmaSession.ChannelPause(iChannelSessionCookie); |
|
731 TEST_ASSERT(KErrNotSupported == r); |
|
732 |
|
733 RDebug::Printf("Pause paused idle Channel"); |
|
734 r = iDmaSession.ChannelPause(iChannelSessionCookie); |
|
735 TEST_ASSERT(KErrNotSupported == r); |
|
736 |
|
737 RDebug::Printf("Resume paused idle channel"); |
|
738 r = iDmaSession.ChannelResume(iChannelSessionCookie); |
|
739 TEST_ASSERT(KErrNotSupported == r); |
|
740 |
|
741 CloseChannel(); |
|
742 CloseDmaSession(); |
|
743 } |
|
744 |
|
745 void CPauseResumeNegTest::PrintTestType() const |
|
746 { |
|
747 RDebug::RawPrint(_L("Pause and Resume API Test - Negative Test")); |
|
748 } |
|
749 |
|
750 ////////////////////////////////////////////////////////////////////// |
|
751 // CLinkChannelTest |
|
752 // |
|
753 // -Open DMA Channel |
|
754 // -Link and Unlink DMA channel |
|
755 // -Check that KErrNotSupported is returned |
|
756 // -Close DMA Channel |
|
757 // |
|
758 ////////////////////////////////////////////////////////////////////// |
|
759 CLinkChannelTest::~CLinkChannelTest() |
|
760 { |
|
761 } |
|
762 |
|
763 void CLinkChannelTest::RunTest() |
|
764 { |
|
765 OpenDmaSession(); |
|
766 |
|
767 //Open a single DMA channel for a transfer |
|
768 OpenChannel(); |
|
769 |
|
770 RDebug::Printf("Linking DMA channels"); |
|
771 TInt r = iDmaSession.ChannelLinking(iChannelSessionCookie); |
|
772 TEST_ASSERT(KErrNotSupported == r); |
|
773 |
|
774 RDebug::Printf("Unlinking DMA channels"); |
|
775 r = iDmaSession.ChannelUnLinking(iChannelSessionCookie); |
|
776 TEST_ASSERT(KErrNotSupported == r); |
|
777 |
|
778 CloseChannel(); |
|
779 CloseDmaSession(); |
|
780 } |
|
781 |
|
782 void CLinkChannelTest::PrintTestType() const |
|
783 { |
|
784 RDebug::RawPrint(_L("Channel Linking API Test - Negative Test")); |
|
785 } |
|
786 |
|
787 ////////////////////////////////////////////////////////////////////// |
|
788 // CElementCountingTest |
|
789 // |
|
790 // -Open DMA Channel |
|
791 // -Create Request |
|
792 // -Fragment and Make calls to Element Counting APIs |
|
793 // -Check that TotalNumDstElementsTransferred() and TotalNumSrcElementsTransferred() |
|
794 // return non zero values |
|
795 // -Check that KErrNone(from test driver) returned for other API calls |
|
796 // -Queue Request |
|
797 // -Close DMA Channel |
|
798 ////////////////////////////////////////////////////////////////////// |
|
799 CElementCountingTest::~CElementCountingTest() |
|
800 { |
|
801 } |
|
802 |
|
803 void CElementCountingTest::RunTest() |
|
804 { |
|
805 OpenDmaSession(); |
|
806 PreTransferSetup(); |
|
807 |
|
808 //Open a single DMA channel for a transfer |
|
809 OpenChannel(); |
|
810 |
|
811 //Setup a DMA request and Fragment the request. |
|
812 RDebug::Printf("Create and Fragment DMA Request"); |
|
813 CreateDmaRequest(); |
|
814 Fragment(); |
|
815 |
|
816 //Enable src/dst counting |
|
817 RDebug::Printf("Enable DstElementCounting"); |
|
818 TInt r = iDmaSession.RequestEnableDstElementCounting(iRequestSessionCookie); |
|
819 TEST_ASSERT(KErrNone == r); |
|
820 |
|
821 RDebug::Printf("Enable SrcElementCounting"); |
|
822 r = iDmaSession.RequestEnableSrcElementCounting(iRequestSessionCookie); |
|
823 TEST_ASSERT(KErrNone == r); |
|
824 |
|
825 //Queue request |
|
826 RDebug::Printf("Queue DMA Request"); |
|
827 Queue(); |
|
828 |
|
829 //Disable src/dst counting |
|
830 RDebug::Printf("Disable DstElementCounting"); |
|
831 r = iDmaSession.RequestDisableDstElementCounting(iRequestSessionCookie); |
|
832 TEST_ASSERT(KErrNone == r); |
|
833 |
|
834 RDebug::Printf("Disable SrcElementCounting"); |
|
835 r = iDmaSession.RequestDisableSrcElementCounting(iRequestSessionCookie); |
|
836 TEST_ASSERT(KErrNone == r); |
|
837 |
|
838 //check total src/dst elements transferred |
|
839 RDebug::Printf("Get Total Number of DstElementsTransferred"); |
|
840 r = iDmaSession.RequestTotalNumDstElementsTransferred(iRequestSessionCookie); |
|
841 TEST_ASSERT(r >= 0); |
|
842 |
|
843 RDebug::Printf("Get Total Number of SrcElementsTransferred"); |
|
844 r = iDmaSession.RequestTotalNumSrcElementsTransferred(iRequestSessionCookie); |
|
845 TEST_ASSERT(r >= 0); |
|
846 |
|
847 FreeRequest(); |
|
848 CloseChannel(); |
|
849 |
|
850 PostTransferCheck(); |
|
851 CloseDmaSession(); |
|
852 } |
|
853 |
|
854 void CElementCountingTest::PrintTestType() const |
|
855 { |
|
856 RDebug::RawPrint(_L("Element Counting Tests")); |
|
857 } |
|
858 |
|
859 ////////////////////////////////////////////////////////////////////// |
|
860 // COpenCloseTest |
|
861 ////////////////////////////////////////////////////////////////////// |
|
862 COpenCloseTest::~COpenCloseTest() |
|
863 { |
|
864 } |
|
865 |
|
866 TBool COpenCloseTest::DoRunClose() |
|
867 { |
|
868 // For storing cookie during neagtive test i,e open channel twice |
|
869 TUint testChannelSessionCookie = 0; |
|
870 |
|
871 // Open a single DMA channel |
|
872 TInt r = iDmaSession.ChannelOpen(iChannelCookie, iChannelSessionCookie); |
|
873 if (r == KErrNone)//Check that DMA channel opened with no errors |
|
874 { |
|
875 RDebug::Printf("DMA channel opened"); |
|
876 } |
|
877 else |
|
878 { |
|
879 RDebug::Printf("Open DMA channel failed"); |
|
880 return EFalse; |
|
881 } |
|
882 |
|
883 // Open DMA channel again and check that opening DMA channel again fails |
|
884 r = iDmaSession.ChannelOpen(iChannelCookie, testChannelSessionCookie); |
|
885 if (r == KErrInUse) |
|
886 { |
|
887 RDebug::Printf("Opening DMA channel again fails as expected"); |
|
888 } |
|
889 else |
|
890 { |
|
891 RDebug::Printf("Open DMA channel again failed"); |
|
892 return EFalse; |
|
893 } |
|
894 |
|
895 // Close the DMA channel and check that DMA channel closes with no errors |
|
896 r =iDmaSession.ChannelClose(iChannelSessionCookie); |
|
897 if (r == KErrNone) |
|
898 { |
|
899 RDebug::Printf("DMA channel closes with no errors"); |
|
900 } |
|
901 else |
|
902 { |
|
903 RDebug::Printf("Close the DMA channel failed"); |
|
904 return EFalse; |
|
905 } |
|
906 |
|
907 // Verify that the DMA channel was actually closed by opening DMA channel |
|
908 r = iDmaSession.ChannelOpen(iChannelCookie, iChannelSessionCookie); |
|
909 if (r == KErrNone) |
|
910 { |
|
911 RDebug::Printf("DMA channel opened after a previous close operation"); |
|
912 return ETrue; |
|
913 } |
|
914 else |
|
915 { |
|
916 RDebug::Printf("Open DMA channel to verify that the DMA channel closed failed"); |
|
917 return EFalse; |
|
918 } |
|
919 } |
|
920 |
|
921 TBool COpenCloseTest::DoRunOpen() |
|
922 { |
|
923 // Open a single DMA channel |
|
924 TInt r = iDmaSession.ChannelOpen(iChannelCookie, iChannelSessionCookie); |
|
925 if (r == KErrNone)//Check that DMA channel opened with no errors |
|
926 { |
|
927 RDebug::Printf("DoRunOpen:DMA channel opened"); |
|
928 } |
|
929 else |
|
930 { |
|
931 RDebug::Printf("DoRunOpenDMA channel failed to open"); |
|
932 return EFalse; |
|
933 } |
|
934 |
|
935 // Verify that channel is really open by closing DMA channel |
|
936 // and checking that DMA channel closes with no errors |
|
937 r = iDmaSession.ChannelClose(iChannelSessionCookie); |
|
938 if (r == KErrNone) |
|
939 { |
|
940 RDebug::Printf("DoRunOpen:DMA channel closes with no errors"); |
|
941 return ETrue; |
|
942 } |
|
943 else |
|
944 { |
|
945 RDebug::Printf("DoRunOpen:DMA channel failed to close"); |
|
946 return EFalse; |
|
947 } |
|
948 } |
|
949 |
|
950 TBool COpenCloseTest::DoRunOpenExposed() |
|
951 { |
|
952 SCreateInfoTest TOpenInfo; |
|
953 TOpenInfo.iCookie =iChannelCookie; |
|
954 TOpenInfo.iDfcPriority = 3; |
|
955 |
|
956 const TInt desCount[3] = {0,1,128}; |
|
957 const TBool dynChannel[3] = {EFalse,EFalse,ETrue}; |
|
958 const TInt expectedResults[3] = {KErrArgument,KErrNone,KErrInUse}; |
|
959 TInt actualResults[3] = {1, 1, 1}; |
|
960 |
|
961 for (TInt i =0; i<3; i++) |
|
962 { |
|
963 TOpenInfo.iDesCount = desCount[i]; |
|
964 TOpenInfo.iDynChannel = dynChannel[i]; |
|
965 |
|
966 // Open a single DMA channel |
|
967 RDebug::Printf("DoRunOpenExposed:Trying to open DMA channel using iDesCount(%d) and iDynChannel(%d) ", TOpenInfo.iDesCount,TOpenInfo.iDynChannel); |
|
968 actualResults[i] = iDmaSession.ChannelOpen(iChannelSessionCookie, TOpenInfo); |
|
969 if (actualResults[i] == KErrNone)// Verify that channel is really open by closing DMA channel |
|
970 { |
|
971 TInt err = iDmaSession.ChannelClose(iChannelSessionCookie); |
|
972 TEST_ASSERT(err == KErrNone)//Check that DMA channel closed with no errors |
|
973 } |
|
974 } |
|
975 |
|
976 // This case should fail if idesCount = 0. |
|
977 // PIL has been changed to return KErrArgument instead of using an assertion check |
|
978 if (expectedResults[0] == actualResults[0]) |
|
979 { |
|
980 RDebug::Printf("DoRunOpenExposed:DMA channel failed to open as expected as for iDesCount = 0 "); |
|
981 } |
|
982 else |
|
983 { |
|
984 RDebug::Printf("DoRunOpenExposed:Error code returned (%d), expected KErrArgument as iDesCount= 0) ", actualResults[0]); |
|
985 return EFalse; |
|
986 } |
|
987 |
|
988 // For this case( idesCount = 1), DMA channel should open with no issues |
|
989 if (expectedResults[1] == actualResults[1]) |
|
990 { |
|
991 RDebug::Printf("DoRunOpenExposed:DMA channel closes with no errors as expected for iDesCount = 1 "); |
|
992 } |
|
993 else |
|
994 { |
|
995 RDebug::Printf("DoRunOpenExposed:Failed to open DMA channel with error code (%d)", actualResults[1]); |
|
996 return EFalse; |
|
997 } |
|
998 |
|
999 // For this case(dynaChannel=ETrue), DMA channel now returns KErrInUse. dynaChannel is not supported in the PSL. |
|
1000 // PSL now returns a NULL pointer when dynaChannel is requested. The PIL interprets a NULL |
|
1001 // pointer being returned from opening a DMA channel as a channel in use. Hence, KErrInUse is returned. |
|
1002 if (expectedResults[2] == actualResults[2]) |
|
1003 { |
|
1004 RDebug::Printf("DoRunOpenExposed:DMA channel failed to open as expected as dynamic channel is not supported"); |
|
1005 } |
|
1006 else |
|
1007 { |
|
1008 RDebug::Printf("DoRunOpenExposed:Error code returned (%d), expected KErrInUse as as dynamic channel is not supported", actualResults[2]); |
|
1009 return EFalse; |
|
1010 } |
|
1011 |
|
1012 return ETrue; |
|
1013 } |
|
1014 |
|
1015 void COpenCloseTest::RunTest() |
|
1016 { |
|
1017 OpenDmaSession(); |
|
1018 |
|
1019 if (iRunOpen) |
|
1020 { // Run Open() API test |
|
1021 iOpenCloseResult = DoRunOpenExposed(); |
|
1022 if(iOpenCloseResult) |
|
1023 iOpenCloseResult = DoRunOpen(); |
|
1024 } |
|
1025 else |
|
1026 { |
|
1027 // Run Close() API test |
|
1028 iOpenCloseResult = DoRunClose(); |
|
1029 } |
|
1030 |
|
1031 CloseDmaSession(); |
|
1032 } |
|
1033 |
|
1034 void COpenCloseTest::PrintTestType() const |
|
1035 { |
|
1036 RDebug::RawPrint(_L("Close/Open API Test")); |
|
1037 |
|
1038 } |
|
1039 |
|
1040 TBool COpenCloseTest::Result() |
|
1041 { |
|
1042 if(gVerboseOutput) |
|
1043 { |
|
1044 RDebug::Printf("Results for Close/Open API Test"); |
|
1045 } |
|
1046 |
|
1047 if(!iOpenCloseResult) |
|
1048 { |
|
1049 RDebug::Printf("Open/Close test sequence failed"); |
|
1050 } |
|
1051 |
|
1052 return iOpenCloseResult; |
|
1053 } |
|
1054 ////////////////////////////////////////////////////////////////////// |
|
1055 // CDmaBmTransfer |
|
1056 ////////////////////////////////////////////////////////////////////// |
|
1057 CDmaBmTransfer::CDmaBmTransfer(const TDesC& aName, TInt aIterations, const TDmaTransferArgs& aTransferArgs, TUint aMaxFragmentSize) |
|
1058 :CDmaBenchmark(aName, aIterations, |
|
1059 TResultSet(KErrNone, TRequestResults(), KErrUnknown, TCallbackRecord(TCallbackRecord::EThread,1)), |
|
1060 aTransferArgs, aMaxFragmentSize) |
|
1061 {} |
|
1062 |
|
1063 void CDmaBmTransfer::PrintTestType() const |
|
1064 { |
|
1065 RDebug::RawPrint(_L("Transfer Benchmark")); |
|
1066 } |
|
1067 |
|
1068 void CDmaBmTransfer::RunTest() |
|
1069 { |
|
1070 OpenDmaSession(); |
|
1071 |
|
1072 OpenChannel(); |
|
1073 CreateDmaRequest(); |
|
1074 Fragment(); |
|
1075 Queue(); |
|
1076 FreeRequest(); |
|
1077 CloseChannel(); |
|
1078 |
|
1079 CloseDmaSession(); |
|
1080 } |
|
1081 |
|
1082 void CDmaBmTransfer::Queue() |
|
1083 { |
|
1084 if(iActual.iRequestResult.iFragmentationResult == KErrNone) |
|
1085 { |
|
1086 TUint64 time; |
|
1087 iActual.iRequestResult.iQueueResult = iDmaSession.QueueRequest(iRequestSessionCookie, &iActual.iCallbackRecord, &time); |
|
1088 iResultArray.Append(time); |
|
1089 } |
|
1090 } |
|
1091 |
|
1092 /* |
|
1093 1. Open a DMA channel for a transfer. |
|
1094 2. Queue multiple request on the DMA channel. |
|
1095 3. Call CancelAll () on the DMA channel. |
|
1096 4. Verify that all transfers have been cancelled. |
|
1097 5. Open a DMA channel for a transfer. This channel should support pause and resume. |
|
1098 6. Call Pause () on the channel. |
|
1099 7. Queue multiple request on the DMA channel. |
|
1100 8. Call CancelAll () on the channel. |
|
1101 9. Verify that all transfers have been cancelled. |
|
1102 |
|
1103 Note: This check does not add results to TResultSet like some |
|
1104 other tests as its operation is different. The test checks for |
|
1105 the the cancelllation of all transfers queued on a channel by |
|
1106 calling iDmaSession.ChannelIsQueueEmpty(); |
|
1107 */ |
|
1108 |
|
1109 ////////////////////////////////////////////////////////////////////// |
|
1110 // CCancelAllTest |
|
1111 ////////////////////////////////////////////////////////////////////// |
|
1112 |
|
1113 |
|
1114 CCancelAllTest::CCancelAllTest(const TDesC& aName, TInt aIterations, |
|
1115 const TDmaTransferArgs* aTransferArgs, const TResultSet* aResultSets, |
|
1116 TInt aCount) |
|
1117 :CMultiTransferTest(aName, aIterations, aTransferArgs, aResultSets, aCount) |
|
1118 {} |
|
1119 |
|
1120 void CCancelAllTest::RunTest() |
|
1121 { |
|
1122 OpenDmaSession(); |
|
1123 PreTransferSetup(); |
|
1124 |
|
1125 // Open a DMA channel for a transfer.This channel should support pause and resume. |
|
1126 OpenChannel(); |
|
1127 |
|
1128 //Call Pause () on the channel |
|
1129 RDebug::Printf("Pausing DMA Channel"); |
|
1130 ChannelPause(iChannelSessionCookie); |
|
1131 |
|
1132 // Queue multiple request on the DMA channel. |
|
1133 CreateDmaRequests(); |
|
1134 Fragment(); |
|
1135 |
|
1136 QueueRequestsAsync(); |
|
1137 |
|
1138 // Call CancelAll () on the DMA channel and Verify that all transfers have been cancelled. |
|
1139 TInt r = CancelAllRequests(); |
|
1140 TEST_ASSERT(r == KErrNone); |
|
1141 |
|
1142 //Call Resume () on the channel. |
|
1143 RDebug::Printf("Cancel should clear Pause state: resuming channel should fail"); |
|
1144 ChannelResume(iChannelSessionCookie); |
|
1145 //TEST_ASSERT(r == KErrCompletion); |
|
1146 |
|
1147 r = DoPostTransferCheck(); |
|
1148 TEST_ASSERT(r == KErrNone); |
|
1149 //Destroy request |
|
1150 for(TInt i=0; i<2; i++) |
|
1151 { |
|
1152 r = iDmaSession.RequestDestroy(iRequestCookies[i]); |
|
1153 TEST_ASSERT(r == KErrNone); |
|
1154 } |
|
1155 |
|
1156 //Close DMA channel |
|
1157 CloseChannel(); |
|
1158 |
|
1159 CloseDmaSession(); |
|
1160 } |
|
1161 |
|
1162 TInt CCancelAllTest::CancelAllRequests() |
|
1163 { |
|
1164 if(gVerboseOutput) |
|
1165 { |
|
1166 RDebug::Printf("CCancelAllTest::CancelAllRequests()"); |
|
1167 } |
|
1168 TInt r = KErrGeneral; |
|
1169 r = iDmaSession.ChannelCancelAll(iChannelSessionCookie); |
|
1170 if (r != KErrNone) |
|
1171 return r; |
|
1172 |
|
1173 TBool queueEmpty; |
|
1174 r = iDmaSession.ChannelIsQueueEmpty(iChannelSessionCookie,queueEmpty); |
|
1175 if (r != KErrNone) |
|
1176 return r; |
|
1177 |
|
1178 if(!queueEmpty) |
|
1179 return KErrGeneral; |
|
1180 |
|
1181 if(gVerboseOutput) |
|
1182 { |
|
1183 RDebug::Printf("Both current and pending requests cancelled"); |
|
1184 } |
|
1185 return KErrNone; |
|
1186 } |
|
1187 |
|
1188 void CCancelAllTest::PrintTestType() const |
|
1189 { |
|
1190 RDebug::RawPrint(_L("CCancelAllTest")); |
|
1191 } |
|
1192 |
|
1193 void CCancelAllTest::QueueRequestsAsync() |
|
1194 { |
|
1195 if(iPauseWhileQueuing) |
|
1196 { |
|
1197 TInt r = iDmaSession.ChannelPause(iChannelSessionCookie); |
|
1198 TEST_ASSERT(r == KErrNone); |
|
1199 } |
|
1200 |
|
1201 // Queue all the DMA requests asynchronously |
|
1202 TEST_ASSERT(iActualResults.Count() == iTransferArgsCount); |
|
1203 for(TInt i=0; i<iTransferArgsCount; i++) |
|
1204 { |
|
1205 TResultSet& resultSet = iActualResults[i]; |
|
1206 if(resultSet.iRequestResult.iFragmentationResult != KErrNone) |
|
1207 continue; |
|
1208 |
|
1209 TInt r = iDmaSession.QueueRequest(iRequestCookies[i], iDummyRequestStatus, &resultSet.iCallbackRecord, NULL); |
|
1210 resultSet.iRequestResult.iQueueResult = r; |
|
1211 } |
|
1212 |
|
1213 if(iPauseWhileQueuing) |
|
1214 { |
|
1215 TInt r = iDmaSession.ChannelResume(iChannelSessionCookie); |
|
1216 TEST_ASSERT(r == KErrNone); |
|
1217 } |
|
1218 } |
|
1219 |
|
1220 ////////////////////////////////////////////////////////////////////// |
|
1221 // CIsQueueEmptyTest |
|
1222 ////////////////////////////////////////////////////////////////////// |
|
1223 CIsQueueEmptyTest::CIsQueueEmptyTest(const TDesC& aName, TInt aIterations, const TDmaTransferArgs* aTransferArgs, |
|
1224 const TResultSet* aResultSets, TInt aCount) |
|
1225 :CMultiTransferTest(aName, aIterations, aTransferArgs, aResultSets, aCount) |
|
1226 {} |
|
1227 |
|
1228 CIsQueueEmptyTest::CIsQueueEmptyTest(const CIsQueueEmptyTest& aOther) |
|
1229 :CMultiTransferTest(aOther) |
|
1230 {} |
|
1231 |
|
1232 CIsQueueEmptyTest::~CIsQueueEmptyTest() |
|
1233 { |
|
1234 } |
|
1235 |
|
1236 void CIsQueueEmptyTest::RunTest() |
|
1237 { |
|
1238 OpenDmaSession(); |
|
1239 PreTransferSetup(); |
|
1240 |
|
1241 OpenChannel(); |
|
1242 |
|
1243 CreateDmaRequests(); |
|
1244 Fragment(); |
|
1245 QueueRequests(); |
|
1246 |
|
1247 TInt r = DoPostTransferCheck(); |
|
1248 TEST_ASSERT(r == KErrNone); |
|
1249 |
|
1250 CloseDmaSession(); |
|
1251 } |
|
1252 |
|
1253 void CIsQueueEmptyTest::DoIsQueueEmpty() |
|
1254 { |
|
1255 TBool queueEmpty; |
|
1256 TInt r = iDmaSession.ChannelIsQueueEmpty(iChannelSessionCookie,queueEmpty); |
|
1257 TEST_ASSERT(r == KErrNone); |
|
1258 |
|
1259 if(queueEmpty) |
|
1260 { |
|
1261 RDebug::Printf("Verified that calling IsQueueEmpty() returns ETrue before calling Queue()"); |
|
1262 } |
|
1263 else |
|
1264 { |
|
1265 RDebug::Printf("IsQueueEmpty() fails to return ETrue before calling Queue()"); |
|
1266 TEST_ASSERT(queueEmpty); |
|
1267 } |
|
1268 } |
|
1269 |
|
1270 void CIsQueueEmptyTest::DoQueueNotEmpty() |
|
1271 { |
|
1272 TBool queueEmpty; |
|
1273 TInt r = iDmaSession.ChannelIsQueueEmpty(iChannelSessionCookie,queueEmpty); |
|
1274 TEST_ASSERT(r == KErrNone); |
|
1275 |
|
1276 if (!queueEmpty) |
|
1277 { |
|
1278 RDebug::Printf("Verified that calling IsQueueEmpty() returns EFalse after calling Queue()"); |
|
1279 } |
|
1280 else |
|
1281 { |
|
1282 RDebug::Printf("IsQueueEmpty() fails to return EFalse after calling Queue()"); |
|
1283 TEST_ASSERT(!queueEmpty); |
|
1284 } |
|
1285 } |
|
1286 |
|
1287 void CIsQueueEmptyTest::PrintTestType() const |
|
1288 { |
|
1289 RDebug::RawPrint(_L("IsQueue Empty Test using Multi Transfer")); |
|
1290 } |
|
1291 |
|
1292 void CIsQueueEmptyTest::QueueRequests() |
|
1293 { |
|
1294 // Queue all the DMA requests asynchronously |
|
1295 TInt i; |
|
1296 RArray<TRequestStatus> requestStates; |
|
1297 |
|
1298 ChannelPause(iChannelSessionCookie); |
|
1299 DoIsQueueEmpty(); |
|
1300 |
|
1301 TEST_ASSERT(iActualResults.Count() == iTransferArgsCount); |
|
1302 for(i=0; i<iTransferArgsCount; i++) |
|
1303 { |
|
1304 TResultSet& resultSet = iActualResults[i]; |
|
1305 if(resultSet.iRequestResult.iFragmentationResult != KErrNone) |
|
1306 continue; |
|
1307 |
|
1308 TInt r = requestStates.Append(TRequestStatus()); |
|
1309 TEST_ASSERT(r == KErrNone); |
|
1310 |
|
1311 r = iDmaSession.QueueRequest(iRequestCookies[i], requestStates[i], &resultSet.iCallbackRecord, NULL); |
|
1312 resultSet.iRequestResult.iQueueResult = r; |
|
1313 |
|
1314 DoQueueNotEmpty(); |
|
1315 } |
|
1316 |
|
1317 ChannelResume(iChannelSessionCookie); |
|
1318 |
|
1319 // wait for all transfers to complete |
|
1320 const TInt count = requestStates.Count(); |
|
1321 |
|
1322 for(i=0; i<count; i++) |
|
1323 { |
|
1324 User::WaitForRequest(requestStates[i]); |
|
1325 } |
|
1326 |
|
1327 requestStates.Close(); |
|
1328 } |
|
1329 |
|
1330 ////////////////////////////////////////////////////////////////////// |
|
1331 // CMultiTransferTest |
|
1332 ////////////////////////////////////////////////////////////////////// |
|
1333 CMultiTransferTest::CMultiTransferTest(const TDesC& aName, TInt aIterations, const TDmaTransferArgs* aTransferArgs, |
|
1334 const TResultSet* aResultSets, TInt aCount) |
|
1335 : CDmaTest(aName, aIterations, NULL, NULL), iTransferArgs(aTransferArgs), iTransferArgsCount(aCount), iNewDmaApi(ETrue), |
|
1336 iChannelSessionCookie(0), iExpectedArray(aResultSets), iPauseWhileQueuing(EFalse) |
|
1337 {} |
|
1338 |
|
1339 CMultiTransferTest::CMultiTransferTest(const CMultiTransferTest& aOther) |
|
1340 : CDmaTest(aOther), iTransferArgs(aOther.iTransferArgs), iTransferArgsCount(aOther.iTransferArgsCount), |
|
1341 iNewDmaApi(aOther.iNewDmaApi), |
|
1342 iExpectedArray(aOther.iExpectedArray), iPauseWhileQueuing(aOther.iPauseWhileQueuing) |
|
1343 { |
|
1344 CopyL(aOther.iRequestCookies, iRequestCookies); |
|
1345 } |
|
1346 |
|
1347 CMultiTransferTest::~CMultiTransferTest() |
|
1348 { |
|
1349 iRequestCookies.Close(); |
|
1350 iActualResults.Close(); |
|
1351 } |
|
1352 |
|
1353 TBool CMultiTransferTest::Result() |
|
1354 { |
|
1355 if(gVerboseOutput) |
|
1356 { |
|
1357 RDebug::Printf("Results for %d transfers:", iTransferArgsCount); |
|
1358 } |
|
1359 |
|
1360 TBool result = EFalse; |
|
1361 for(TInt i=0; i<iTransferArgsCount; i++) |
|
1362 { |
|
1363 result = Result(i); |
|
1364 if(!result) |
|
1365 break; |
|
1366 } |
|
1367 return result; |
|
1368 } |
|
1369 |
|
1370 TBool CMultiTransferTest::Result(TInt aTransfer) |
|
1371 { |
|
1372 const TResultSet& expected = iExpectedArray[aTransfer]; |
|
1373 const TResultSet& actual = iActualResults[aTransfer]; |
|
1374 const TBool result = expected == actual; |
|
1375 if(!result || gVerboseOutput) |
|
1376 { |
|
1377 RDebug::Printf("Compairing results for transfer %d", aTransfer); |
|
1378 } |
|
1379 |
|
1380 if(!result) |
|
1381 { |
|
1382 RDebug::Printf("TResultSets do not match"); |
|
1383 } |
|
1384 if(!result || gVerboseOutput) |
|
1385 { |
|
1386 RDebug::Printf("\nExpected error codes:"); |
|
1387 expected.Print(); |
|
1388 RDebug::Printf("Expected callback record:"); |
|
1389 expected.iCallbackRecord.Print(); |
|
1390 |
|
1391 RDebug::Printf("\nActual error codes:"); |
|
1392 actual.Print(); |
|
1393 RDebug::Printf("Actual callback record:"); |
|
1394 actual.iCallbackRecord.Print(); |
|
1395 } |
|
1396 return result; |
|
1397 } |
|
1398 void CMultiTransferTest::RunTest() |
|
1399 { |
|
1400 OpenDmaSession(); |
|
1401 |
|
1402 PreTransferSetup(); |
|
1403 OpenChannel(); |
|
1404 |
|
1405 CreateDmaRequests(); |
|
1406 Fragment(); |
|
1407 |
|
1408 QueueRequests(); |
|
1409 |
|
1410 TInt r = DoPostTransferCheck(); |
|
1411 TEST_ASSERT(r == KErrNone); |
|
1412 |
|
1413 CloseDmaSession(); |
|
1414 } |
|
1415 |
|
1416 void CMultiTransferTest::PrintTestType() const |
|
1417 { |
|
1418 RDebug::RawPrint(_L("Multi Transfer")); |
|
1419 } |
|
1420 |
|
1421 const TDmaTransferArgs& CMultiTransferTest::TransferArgs(TInt aIndex) const |
|
1422 { |
|
1423 TEST_ASSERT(Rng(0, aIndex, iTransferArgsCount-1)); |
|
1424 |
|
1425 return iTransferArgs[aIndex]; |
|
1426 } |
|
1427 |
|
1428 void CMultiTransferTest::SetPostTransferResult(TInt aIndex, TInt aErrorCode) |
|
1429 { |
|
1430 TEST_ASSERT(Rng(0, aIndex, iTransferArgsCount-1)); |
|
1431 |
|
1432 iActualResults[aIndex].iPostTransferCheck = aErrorCode; |
|
1433 } |
|
1434 |
|
1435 void CMultiTransferTest::OpenChannel() |
|
1436 { |
|
1437 if(gVerboseOutput) |
|
1438 { |
|
1439 RDebug::Printf("CMultiTransferTest::OpenChannel()"); |
|
1440 } |
|
1441 TInt r = iDmaSession.ChannelOpen(iChannelCookie, iChannelSessionCookie); |
|
1442 |
|
1443 TEST_ASSERT(iActualResults.Count() == iTransferArgsCount); |
|
1444 for(TInt i=0; i<iTransferArgsCount; i++) |
|
1445 { |
|
1446 // In a multi transfer test a series of requests are created and queued. |
|
1447 // They all use the same channel, is opened here at the beginning of the test |
|
1448 // |
|
1449 // Each transfer has a TResultSet which holds a result for the channel opening, |
|
1450 // which we store here. Although in this case it is redundant, |
|
1451 // in future it might be that different transfers open |
|
1452 // different channels. |
|
1453 iActualResults[i].iChannelOpenResult = r; |
|
1454 } |
|
1455 } |
|
1456 |
|
1457 TInt CMultiTransferTest::CloseChannel() |
|
1458 { |
|
1459 return iDmaSession.ChannelClose(iChannelSessionCookie); |
|
1460 } |
|
1461 |
|
1462 void CMultiTransferTest::CreateDmaRequests() |
|
1463 { |
|
1464 if(gVerboseOutput) |
|
1465 { |
|
1466 RDebug::Printf("CMultiTransferTest::CreateDmaRequests() %d", iTransferArgsCount); |
|
1467 } |
|
1468 TEST_ASSERT(iActualResults.Count() == iTransferArgsCount); |
|
1469 //create a DMA request for each transfer arg struct |
|
1470 for(TInt i=0; i<iTransferArgsCount; i++) |
|
1471 { |
|
1472 if(iActualResults[i].iChannelOpenResult != KErrNone) |
|
1473 continue; |
|
1474 |
|
1475 TUint cookie = 0; |
|
1476 TInt r = KErrGeneral; |
|
1477 |
|
1478 if(iNewDmaApi) |
|
1479 { |
|
1480 r = iDmaSession.RequestCreate(iChannelSessionCookie, cookie); |
|
1481 } |
|
1482 else |
|
1483 { |
|
1484 r = iDmaSession.RequestCreateOld(iChannelSessionCookie, cookie); |
|
1485 } |
|
1486 iActualResults[i].iRequestResult.iCreate = r; |
|
1487 |
|
1488 if(r == KErrNone) |
|
1489 { |
|
1490 r = iRequestCookies.Append(cookie); |
|
1491 TEST_ASSERT(r == KErrNone); |
|
1492 } |
|
1493 } |
|
1494 } |
|
1495 |
|
1496 void CMultiTransferTest::Fragment() |
|
1497 { |
|
1498 if(gVerboseOutput) |
|
1499 { |
|
1500 RDebug::Printf("CMultiTransferTest::Fragment() %d", iTransferArgsCount); |
|
1501 } |
|
1502 TEST_ASSERT(iActualResults.Count() == iTransferArgsCount); |
|
1503 // Fragment each dma request |
|
1504 for(TInt i=0; i<iTransferArgsCount; i++) |
|
1505 { |
|
1506 TRequestResults& result = iActualResults[i].iRequestResult; |
|
1507 if(result.iCreate != KErrNone) |
|
1508 continue; |
|
1509 |
|
1510 TInt r = KErrGeneral; |
|
1511 if(iNewDmaApi) |
|
1512 r = iDmaSession.FragmentRequest(iRequestCookies[i], iTransferArgs[i]); |
|
1513 else |
|
1514 r = iDmaSession.FragmentRequestOld(iRequestCookies[i], iTransferArgs[i]); |
|
1515 |
|
1516 result.iFragmentationResult = r; |
|
1517 } |
|
1518 } |
|
1519 |
|
1520 void CMultiTransferTest::QueueRequests() |
|
1521 { |
|
1522 if(iPauseWhileQueuing) |
|
1523 { |
|
1524 TInt r = iDmaSession.ChannelPause(iChannelSessionCookie); |
|
1525 TEST_ASSERT(r == KErrNone); |
|
1526 } |
|
1527 |
|
1528 // Queue all the DMA requests asynchronously |
|
1529 TInt i; |
|
1530 RArray<TRequestStatus> requestStates; |
|
1531 |
|
1532 TEST_ASSERT(iActualResults.Count() == iTransferArgsCount); |
|
1533 for(i=0; i<iTransferArgsCount; i++) |
|
1534 { |
|
1535 TResultSet& resultSet = iActualResults[i]; |
|
1536 if(resultSet.iRequestResult.iFragmentationResult != KErrNone) |
|
1537 continue; |
|
1538 |
|
1539 TInt r = requestStates.Append(TRequestStatus()); |
|
1540 TEST_ASSERT(r == KErrNone); |
|
1541 |
|
1542 r = iDmaSession.QueueRequest(iRequestCookies[i], requestStates[i], &resultSet.iCallbackRecord, NULL); |
|
1543 resultSet.iRequestResult.iQueueResult = r; |
|
1544 } |
|
1545 |
|
1546 if(iPauseWhileQueuing) |
|
1547 { |
|
1548 TInt r = iDmaSession.ChannelResume(iChannelSessionCookie); |
|
1549 TEST_ASSERT(r == KErrNone); |
|
1550 } |
|
1551 |
|
1552 // wait for all transfers to complete |
|
1553 const TInt count = requestStates.Count(); |
|
1554 |
|
1555 for(i=0; i<count; i++) |
|
1556 { |
|
1557 User::WaitForRequest(requestStates[i]); |
|
1558 } |
|
1559 |
|
1560 requestStates.Close(); |
|
1561 } |
|
1562 |
|
1563 void CMultiTransferTest::PreTransferSetup() |
|
1564 { |
|
1565 // TODO this is the wrong place to do this! |
|
1566 for(TInt i=0; i<iTransferArgsCount; i++) |
|
1567 { |
|
1568 //pre-fill actual results with error values |
|
1569 TInt r = iActualResults.Append(TResultSet(EFalse)); |
|
1570 TEST_ASSERT(r == KErrNone); |
|
1571 } |
|
1572 if(iPreTransfer) |
|
1573 iPreTransfer->Setup(*this); //initialize test |
|
1574 } |
|
1575 |
|
1576 TInt CMultiTransferTest::DoPostTransferCheck() |
|
1577 { |
|
1578 if(iPostTransferCheck) |
|
1579 return iPostTransferCheck->Check(*this); |
|
1580 else |
|
1581 return KErrNone; |
|
1582 } |
|
1583 ////////////////////////////////////////////////////////////////////// |
|
1584 // CIsrRequeTest |
|
1585 ////////////////////////////////////////////////////////////////////// |
|
1586 CIsrRequeTest::CIsrRequeTest(const TDesC& aName, TInt aIterations, const TDmaTransferArgs& aArgs, |
|
1587 TIsrRequeArgs* aRequeueArgs, TInt aCount, |
|
1588 const TResultSet& aExpected,const MPreTransfer* aPreTfer,const MPostTransferCheck* aPostTferChk, TUint aMaxFragmentSize) |
|
1589 :CSingleTransferTest(aName, aIterations, aArgs, aExpected, aMaxFragmentSize, aPostTferChk, aPreTfer), iRequeArgSet(aRequeueArgs, aCount) |
|
1590 {} |
|
1591 |
|
1592 void CIsrRequeTest::Queue() |
|
1593 { |
|
1594 if(iActual.iRequestResult.iFragmentationResult == KErrNone) |
|
1595 { |
|
1596 iActual.iRequestResult.iQueueResult = iDmaSession.QueueRequestWithRequeue(iRequestSessionCookie, iRequeArgSet.iRequeArgs, iRequeArgSet.iCount, &iActual.iCallbackRecord); |
|
1597 } |
|
1598 } |
|
1599 |
|
1600 void CIsrRequeTest::PrintTestType() const |
|
1601 { |
|
1602 RDebug::RawPrint(_L("ISR Requeue")); |
|
1603 } |
|
1604 |
|
1605 void CIsrRequeTest::PreTransferSetup() |
|
1606 { |
|
1607 if(iPreTransfer) |
|
1608 iPreTransfer->Setup(*this); //initialize test |
|
1609 } |
|
1610 |
|
1611 TInt CIsrRequeTest::DoPostTransferCheck() |
|
1612 { |
|
1613 return iPostTransferCheck->Check(*this); |
|
1614 } |
|
1615 |
|
1616 ////////////////////////////////////////////////////////////////////// |
|
1617 // TResultSet |
|
1618 ////////////////////////////////////////////////////////////////////// |
|
1619 void TResultSet::Print() const |
|
1620 { |
|
1621 PRINT(iChannelOpenResult); |
|
1622 PRINT(iRequestResult.iCreate); |
|
1623 PRINT(iRequestResult.iFragmentCount); |
|
1624 PRINT(iRequestResult.iFragmentationResult); |
|
1625 PRINT(iRequestResult.iQueueResult); |
|
1626 PRINT(iPostTransferCheck); |
|
1627 } |
|
1628 |
|
1629 TBool TResultSet::operator == (const TResultSet& aOther) const |
|
1630 { |
|
1631 return (memcompare((TUint8*)this, sizeof(*this), (TUint8*)&aOther, sizeof(aOther)) == 0); |
|
1632 } |
|
1633 |
|
1634 ////////////////////////////////////////////////////////////////////// |
|
1635 // MPostTransferCheck classes |
|
1636 ////////////////////////////////////////////////////////////////////// |
|
1637 TInt TCompareSrcDst::Check(const CSingleTransferTest& aTest) const |
|
1638 { |
|
1639 if(gVerboseOutput) |
|
1640 { |
|
1641 RDebug::Printf("Comparing CSingleTransferTest buffers"); |
|
1642 } |
|
1643 return Check(aTest.TransferArgs(), aTest.Chunk().Base()); |
|
1644 } |
|
1645 |
|
1646 // Note: this check will not deal correctly with transfers were subsequent |
|
1647 // requeues overlap previous sources or destinations |
|
1648 // or where the source of transfer depends on a previous transfer. |
|
1649 // This is because it simply compares the source and destination |
|
1650 // pairwise for each transfer |
|
1651 // |
|
1652 // If TPreTransferIncrBytes is used for the pre-test then the transfers |
|
1653 // will be checked however. |
|
1654 TInt TCompareSrcDst::Check(const CIsrRequeTest& aTest) const |
|
1655 { |
|
1656 if(gVerboseOutput) |
|
1657 { |
|
1658 RDebug::Printf("Comparing CIsrRequeTest buffers"); |
|
1659 } |
|
1660 TUint8* chunkBase = aTest.Chunk().Base(); |
|
1661 const TDmaTransferArgs& transferArgs = aTest.TransferArgs(); |
|
1662 // check first transfer |
|
1663 TInt r = Check(transferArgs, chunkBase); |
|
1664 |
|
1665 if(r != KErrNone) |
|
1666 return r; |
|
1667 |
|
1668 // check re-queued transfers |
|
1669 const TIsrRequeArgsSet& requeueArgs = aTest.GetRequeueArgs(); |
|
1670 return Check(requeueArgs, chunkBase, transferArgs); |
|
1671 } |
|
1672 |
|
1673 TInt TCompareSrcDst::Check(const TDmaTransferArgs& aTransferArgs, TUint8* aChunkBase) const |
|
1674 { |
|
1675 const TUint32 srcOffset = aTransferArgs.iSrcConfig.iAddr; |
|
1676 const TUint32 dstOffset = aTransferArgs.iDstConfig.iAddr; |
|
1677 const TInt size = aTransferArgs.iTransferCount; |
|
1678 |
|
1679 const TUint8* src = srcOffset + aChunkBase; |
|
1680 const TUint8* dst = dstOffset + aChunkBase; |
|
1681 |
|
1682 if(gVerboseOutput) |
|
1683 { |
|
1684 RDebug::Printf("Comparing TDmaTransferArgs buffers src=0x%08x dst=0x%08x size=0x%08x", |
|
1685 src, dst, size); |
|
1686 } |
|
1687 |
|
1688 return memcompare(src, size, dst, size); |
|
1689 } |
|
1690 |
|
1691 TInt TCompareSrcDst::Check(const TIsrRequeArgsSet& aRequeueArgSet, TUint8* aChunkBase, const TDmaTransferArgs& aTferArgs) const |
|
1692 { |
|
1693 TIsrRequeArgsSet argSet(aRequeueArgSet); //copy since Fixup will mutate object |
|
1694 |
|
1695 argSet.Substitute(aTferArgs); // replace any default (0) values with the values in aTferArgs |
|
1696 |
|
1697 argSet.Fixup((TLinAddr)aChunkBase); //convert address offsets to virtual user mode addresses |
|
1698 |
|
1699 TInt r = KErrCorrupt; |
|
1700 while(!argSet.IsEmpty()) |
|
1701 { |
|
1702 r = Check(argSet.GetArgs()); |
|
1703 if(r != KErrNone) |
|
1704 break; |
|
1705 } |
|
1706 return r; |
|
1707 } |
|
1708 |
|
1709 TInt TCompareSrcDst::Check(const TIsrRequeArgs& aRequeueArgs) const |
|
1710 { |
|
1711 const TUint8* src = (TUint8*)aRequeueArgs.iSrcAddr; |
|
1712 const TUint8* dst = (TUint8*)aRequeueArgs.iDstAddr; |
|
1713 const TInt size = aRequeueArgs.iTransferCount; |
|
1714 |
|
1715 if(gVerboseOutput) |
|
1716 { |
|
1717 RDebug::Printf("Comparing TIsrRequeArgs: src=0x%08x dst=0x%08x size=0x%08x", |
|
1718 src, dst, size); |
|
1719 } |
|
1720 |
|
1721 return memcompare(src, size, dst, size); |
|
1722 } |
|
1723 |
|
1724 // Note: this check will not deal correctly with transfers were subsequent |
|
1725 // requeues overlap previous sources or destinations |
|
1726 // or where the source of trasnfer depends on a previous trasnfer. |
|
1727 // This is because it simply compares the source and destination |
|
1728 // pairwise for each transfer |
|
1729 // |
|
1730 // If TCompareSrcDst is used for the pre-test then the transfers |
|
1731 // will be checked however. |
|
1732 TInt TCompareSrcDst::Check(CMultiTransferTest& aTest) const |
|
1733 { |
|
1734 if(gVerboseOutput) |
|
1735 { |
|
1736 RDebug::Printf("Comparing CMultiTransferTest buffers"); |
|
1737 } |
|
1738 |
|
1739 const TInt transferCount = aTest.TransferCount(); |
|
1740 TUint8* const chunkBase = aTest.Chunk().Base(); |
|
1741 |
|
1742 // check buffers for each transfer |
|
1743 for(TInt i=0; i<transferCount; i++) |
|
1744 { |
|
1745 TInt r = Check(aTest.TransferArgs(i), chunkBase); |
|
1746 aTest.SetPostTransferResult(i, r); |
|
1747 } |
|
1748 // CMultiTransferTest is handled differently to the others. |
|
1749 // Whereas CSingleTransferTest logs just the return value |
|
1750 // of the check, here, we write back a result for each transfer |
|
1751 // so the return value from this function is not important |
|
1752 return KErrNone; |
|
1753 } |
|
1754 |
|
1755 TInt TCompare2D::Check(const CSingleTransferTest& aTest) const |
|
1756 { |
|
1757 const TDmaTransferArgs& args = aTest.TransferArgs(); |
|
1758 TUint8* const chunkBase = aTest.Chunk().Base(); |
|
1759 |
|
1760 TInt ret = KErrNone; |
|
1761 |
|
1762 TTransferIter src_iter(args.iSrcConfig, chunkBase); |
|
1763 TTransferIter dst_iter(args.iDstConfig, chunkBase); |
|
1764 TTransferIter end; |
|
1765 for (; (src_iter != end) && (dst_iter !=end); ++src_iter, ++dst_iter) |
|
1766 { |
|
1767 if(*src_iter != *dst_iter) |
|
1768 { |
|
1769 ret = KErrCorrupt; |
|
1770 break; |
|
1771 } |
|
1772 } |
|
1773 return ret; |
|
1774 } |
|
1775 |
|
1776 TInt TCompare2D::Check(const CIsrRequeTest&) const |
|
1777 { |
|
1778 return KErrNotSupported; |
|
1779 } |
|
1780 |
|
1781 TInt TCompare2D::Check(CMultiTransferTest&) const |
|
1782 { |
|
1783 return KErrNotSupported; |
|
1784 } |
|
1785 |
|
1786 |
|
1787 TInt TCheckNoTransfer::Check(const CSingleTransferTest&) const |
|
1788 { |
|
1789 return KErrNotSupported; |
|
1790 } |
|
1791 |
|
1792 TInt TCheckNoTransfer::Check(const CIsrRequeTest&) const |
|
1793 { |
|
1794 return KErrNotSupported; |
|
1795 } |
|
1796 |
|
1797 TInt TCheckNoTransfer::Check(CMultiTransferTest& aTest) const |
|
1798 { |
|
1799 if(gVerboseOutput) |
|
1800 { |
|
1801 RDebug::Printf("TCheckNoTransfer Comparing CMultiTransferTest buffers"); |
|
1802 } |
|
1803 |
|
1804 const TInt transferCount = aTest.TransferCount(); |
|
1805 TUint8* const chunkBase = aTest.Chunk().Base(); |
|
1806 |
|
1807 // check buffers for each transfer |
|
1808 for(TInt i=0; i<transferCount; i++) |
|
1809 { |
|
1810 TInt r = KErrCorrupt; |
|
1811 if(IsZeroed(aTest.TransferArgs(i), chunkBase)) |
|
1812 { |
|
1813 r = KErrNone; |
|
1814 } |
|
1815 |
|
1816 aTest.SetPostTransferResult(i, r); |
|
1817 } |
|
1818 // CMultiTransferTest is handled differently to the others. |
|
1819 // Whereas CSingleTransferTest logs just the return value |
|
1820 // of the check, here, we write back a result for each transfer |
|
1821 // so the return value from this function is not important |
|
1822 return KErrNone; |
|
1823 } |
|
1824 |
|
1825 TBool TCheckNoTransfer::IsZeroed(const TDmaTransferArgs& aTransferArgs, TUint8* aChunkBase) const |
|
1826 { |
|
1827 TAddressParms parms = GetAddrParms(aTransferArgs); |
|
1828 parms.Fixup(reinterpret_cast<TLinAddr>(aChunkBase)); |
|
1829 const TAddrRange destination = parms.DestRange(); |
|
1830 |
|
1831 return destination.IsFilled(0); |
|
1832 } |
|
1833 ////////////////////////////////////////////////////////////////////// |
|
1834 // MPreTransfer classes |
|
1835 ////////////////////////////////////////////////////////////////////// |
|
1836 void TPreTransferIncrBytes::Setup(const CSingleTransferTest& aTest) const |
|
1837 { |
|
1838 if(gVerboseOutput) |
|
1839 { |
|
1840 RDebug::Printf("TPreTransferIncrBytes(CSingleTransferTest)"); |
|
1841 } |
|
1842 TAddressParms params = GetAddrParms(aTest.TransferArgs()); |
|
1843 |
|
1844 TUint8* const chunkBase = aTest.Chunk().Base(); |
|
1845 params.Fixup((TLinAddr)chunkBase); |
|
1846 |
|
1847 |
|
1848 Setup(params); |
|
1849 } |
|
1850 |
|
1851 void TPreTransferIncrBytes::Setup(const TAddressParms& aParams) const |
|
1852 { |
|
1853 if(gVerboseOutput) |
|
1854 { |
|
1855 RDebug::Printf("TPreTransferIncrBytes: setup memory buffers: src=0x%08x dst=0x%08x size=0x%08x", |
|
1856 aParams.iSrcAddr, aParams.iDstAddr, aParams.iTransferCount); |
|
1857 } |
|
1858 TUint8* const src = (TUint8*) aParams.iSrcAddr; |
|
1859 const TInt size = aParams.iTransferCount; |
|
1860 |
|
1861 for(TInt i=0; i<size; i++) |
|
1862 {src[i] = (TUint8)i;} //each src byte holds its own offset (mod 256) |
|
1863 |
|
1864 TUint8* const dst = (TUint8*) aParams.iDstAddr; |
|
1865 memclr(dst, size); //clear destination |
|
1866 } |
|
1867 |
|
1868 void TPreTransferIncrBytes::Setup(const CIsrRequeTest& aTest) const |
|
1869 { |
|
1870 if(gVerboseOutput) |
|
1871 { |
|
1872 RDebug::Printf("TPreTransferIncrBytes(CIsrRequeTest)"); |
|
1873 } |
|
1874 if(!CheckBuffers(aTest)) |
|
1875 { |
|
1876 RDebug::Printf("Successive transfer destinations may not overlap previous src or dst buffers"); |
|
1877 RDebug::Printf("unless the whole transfer is an exact repeat of a previous one"); |
|
1878 TEST_FAULT; |
|
1879 } |
|
1880 |
|
1881 Setup(static_cast<CSingleTransferTest>(aTest)); // prepare the CSingleTransferTest parts |
|
1882 |
|
1883 TIsrRequeArgsSet requeSet(aTest.GetRequeueArgs()); |
|
1884 |
|
1885 requeSet.Substitute(aTest.TransferArgs()); |
|
1886 |
|
1887 const TLinAddr chunkBase = (TLinAddr) aTest.Chunk().Base(); |
|
1888 requeSet.Fixup(chunkBase); |
|
1889 |
|
1890 while(!requeSet.IsEmpty()) |
|
1891 { |
|
1892 TIsrRequeArgs args = requeSet.GetArgs(); |
|
1893 Setup(args); // perform the setup operation for each TIsrRequeArgs |
|
1894 } |
|
1895 } |
|
1896 |
|
1897 void TPreTransferIncrBytes::Setup(const CMultiTransferTest& aTest) const |
|
1898 { |
|
1899 if(gVerboseOutput) |
|
1900 { |
|
1901 RDebug::Printf("TPreTransferIncrBytes(CMultiTransferTest)"); |
|
1902 } |
|
1903 |
|
1904 if(!CheckBuffers(aTest)) |
|
1905 { |
|
1906 RDebug::Printf("Successive transfer destinations may not overlap previous src or dst buffers"); |
|
1907 TEST_FAULT; |
|
1908 } |
|
1909 |
|
1910 TUint8* const chunkBase = aTest.Chunk().Base(); |
|
1911 const TInt transferCount = aTest.TransferCount(); |
|
1912 |
|
1913 // initialise buffers for each transfer |
|
1914 for(TInt i=0; i<transferCount; i++) |
|
1915 { |
|
1916 TAddressParms params = GetAddrParms(aTest.TransferArgs(i)); |
|
1917 |
|
1918 params.Fixup((TLinAddr)chunkBase); |
|
1919 |
|
1920 Setup(params); |
|
1921 } |
|
1922 } |
|
1923 |
|
1924 TBool TPreTransferIncrBytes::CheckBuffers(const CIsrRequeTest& aTest) const |
|
1925 { |
|
1926 RArray<const TAddressParms> array; |
|
1927 array.AppendL(TAddressParms(aTest.TransferArgs())); |
|
1928 |
|
1929 TIsrRequeArgsSet requeSet(aTest.GetRequeueArgs()); |
|
1930 requeSet.Substitute(aTest.TransferArgs()); |
|
1931 |
|
1932 const TLinAddr chunkBase = (TLinAddr) aTest.Chunk().Base(); |
|
1933 requeSet.Fixup(chunkBase); |
|
1934 while(!requeSet.IsEmpty()) |
|
1935 { |
|
1936 const TIsrRequeArgs requeArgs = requeSet.GetArgs(); |
|
1937 array.AppendL(requeArgs); |
|
1938 } |
|
1939 |
|
1940 const TBool result = CheckBuffers(array); |
|
1941 |
|
1942 array.Close(); |
|
1943 return result; |
|
1944 } |
|
1945 |
|
1946 /** |
|
1947 A CMultiTransferTest will wait for all transfers to complete |
|
1948 before comapairing source and destination buffers. For this to be successful |
|
1949 each transfer must be independent ie. no destination or source may be |
|
1950 overwritten by another transfer and source buffers may not depend on an |
|
1951 earlier transfer |
|
1952 */ |
|
1953 TBool TPreTransferIncrBytes::CheckBuffers(const CMultiTransferTest& aTest) const |
|
1954 { |
|
1955 TUint8* const chunkBase = aTest.Chunk().Base(); |
|
1956 const TInt transferCount = aTest.TransferCount(); |
|
1957 |
|
1958 // assemble an array of TAddressParams from aTest, that |
|
1959 // can then be passed to CheckBuffers(RArray<TAddressParms>) |
|
1960 RArray<const TAddressParms> array; |
|
1961 |
|
1962 for(TInt i=0; i<transferCount; i++) |
|
1963 { |
|
1964 TAddressParms params = GetAddrParms(aTest.TransferArgs(i)); |
|
1965 params.Fixup((TLinAddr)chunkBase); |
|
1966 |
|
1967 array.AppendL(params); |
|
1968 } |
|
1969 |
|
1970 // 2nd arg EFalse as there is no need to permit exact repeats |
|
1971 const TBool r = CheckBuffers(array, EFalse); |
|
1972 |
|
1973 array.Close(); |
|
1974 return r; |
|
1975 } |
|
1976 |
|
1977 /** |
|
1978 Check that the destination of each TAddressParms does not overlap with |
|
1979 any previous source or destination or that if it does the whole transfer |
|
1980 matches. |
|
1981 This is so that successive transfers do not overwrite the destinations or |
|
1982 sources of preceeding ones. |
|
1983 |
|
1984 If aAllowExactRepeat is true then exactly matching transfers are allowed |
|
1985 to test the case where a repeat transfer is required - though it can't |
|
1986 then be determined just from looking at the buffers that the repeat was |
|
1987 successful |
|
1988 */ |
|
1989 TBool TPreTransferIncrBytes::CheckBuffers(const RArray<const TAddressParms>& aTransferParams, TBool aAllowExactRepeat) const |
|
1990 { |
|
1991 |
|
1992 const TInt count = aTransferParams.Count(); |
|
1993 |
|
1994 if(gVerboseOutput) |
|
1995 { |
|
1996 RDebug::Printf("CheckBuffers, %d transfers", count); |
|
1997 } |
|
1998 |
|
1999 TBuf<128> buf; |
|
2000 for(TInt i=1; i<count; i++) |
|
2001 { |
|
2002 const TAddressParms& current = aTransferParams[i]; |
|
2003 |
|
2004 if(gVerboseOutput) |
|
2005 { |
|
2006 buf.Zero(); |
|
2007 current.AppendString(buf); |
|
2008 RDebug::Print(_L("Check current: %S, against:"), &buf); |
|
2009 } |
|
2010 |
|
2011 for(TInt j=0; j<i; j++) |
|
2012 { |
|
2013 const TAddressParms& previous = aTransferParams[j]; |
|
2014 if(gVerboseOutput) |
|
2015 { |
|
2016 buf.Zero(); |
|
2017 previous.AppendString(buf); |
|
2018 RDebug::Print(_L("Previous: %S"), &buf); |
|
2019 } |
|
2020 |
|
2021 const TBool curDstOverlapsPrevTfer = previous.Overlaps(current.DestRange()); |
|
2022 const TBool curSrcDependsOnPrevDest = current.SourceRange().Overlaps(previous.DestRange()); |
|
2023 const TBool permitExactRepeat = aAllowExactRepeat && (current == previous); |
|
2024 |
|
2025 const TBool ok = !(curDstOverlapsPrevTfer || curSrcDependsOnPrevDest) || permitExactRepeat; |
|
2026 if(!ok) |
|
2027 return EFalse; |
|
2028 } |
|
2029 } |
|
2030 return ETrue; |
|
2031 } |
|
2032 ////////////////////////////////////////////////////////////////////// |
|
2033 // TTransferIter class |
|
2034 ////////////////////////////////////////////////////////////////////// |
|
2035 void TTransferIter::operator++ () |
|
2036 { |
|
2037 iPtr++; //the standard post increment |
|
2038 if(iElem < (iCfg->iElementsPerFrame-1)) |
|
2039 { |
|
2040 iPtr += iCfg->iElementSkip; |
|
2041 iElem++; |
|
2042 iBytes++; |
|
2043 } |
|
2044 else |
|
2045 { |
|
2046 TEST_ASSERT(iElem == iCfg->iElementsPerFrame-1); |
|
2047 if(iFrame < iCfg->iFramesPerTransfer-1) |
|
2048 { |
|
2049 iPtr += iCfg->iFrameSkip; |
|
2050 iFrame++; |
|
2051 iBytes++; |
|
2052 iElem = 0; |
|
2053 } |
|
2054 else |
|
2055 { |
|
2056 //we have reached the end |
|
2057 TEST_ASSERT(iFrame == iCfg->iFramesPerTransfer-1); |
|
2058 iPtr = NULL; |
|
2059 } |
|
2060 } |
|
2061 |
|
2062 Invariant(); |
|
2063 } |
|
2064 |
|
2065 void TTransferIter::Invariant() const |
|
2066 { |
|
2067 const TInt elemSize = iCfg->iElementSize; |
|
2068 RTest test(_L("TTransferIter invariant")); |
|
2069 const TUint bytesTransfered = ( |
|
2070 elemSize * (iFrame * iCfg->iElementsPerFrame + iElem) |
|
2071 + ((TUint)iPtr % (elemSize)) |
|
2072 ); |
|
2073 test_Equal(iBytes, bytesTransfered); |
|
2074 test.Close(); |
|
2075 } |
|
2076 |
|
2077 /////////////////////////////////////////////////////////// |
|
2078 // TTestCase |
|
2079 /////////////////////////////////////////////////////////// |
|
2080 TTestCase::TTestCase(CDmaTest* aTest, |
|
2081 TBool aConcurrent, |
|
2082 const TDmaCapability aCap1, |
|
2083 const TDmaCapability aCap2, |
|
2084 const TDmaCapability aCap3, |
|
2085 const TDmaCapability aCap4, |
|
2086 const TDmaCapability aCap5 |
|
2087 ) |
|
2088 : |
|
2089 iTest(aTest), iConcurrentTest(aConcurrent) |
|
2090 { |
|
2091 iChannelCaps[0] = aCap1; |
|
2092 iChannelCaps[1] = aCap2; |
|
2093 iChannelCaps[2] = aCap3; |
|
2094 iChannelCaps[3] = aCap4; |
|
2095 iChannelCaps[4] = aCap5; |
|
2096 } |
|
2097 |
|
2098 TResult TTestCase::TestCaseValid(const SDmacCaps& aChannelCaps) const |
|
2099 { |
|
2100 const TDmaCapability* cap = &iChannelCaps[0]; |
|
2101 |
|
2102 TResult ret = ERun; |
|
2103 //We assume that the array is empty at the first ENone found |
|
2104 //any caps after this wil be ignored |
|
2105 while(cap->iCapsReq != ENone) |
|
2106 { |
|
2107 TResult t = cap->CompareToDmaCaps(aChannelCaps); |
|
2108 if(t > ret) //this relies on the enum ordering |
|
2109 ret = t; |
|
2110 cap++; |
|
2111 } |
|
2112 return ret; |
|
2113 } |
|
2114 |
|
2115 TResult TTestCase::TestCaseValid(const TDmacTestCaps& aChannelCaps) const |
|
2116 { |
|
2117 const TDmaCapability* cap = &iChannelCaps[0]; |
|
2118 |
|
2119 TResult ret = ERun; |
|
2120 //We assume that the array is empty at the first ENone found |
|
2121 //any caps after this wil be ignored |
|
2122 while(cap->iCapsReq != ENone) |
|
2123 { |
|
2124 TResult t = cap->CompareToDmaCaps(aChannelCaps); |
|
2125 if(t > ret) //this relies on the enum ordering |
|
2126 ret = t; |
|
2127 cap++; |
|
2128 } |
|
2129 return ret; |
|
2130 } |
|
2131 /** |
|
2132 Will report whether a value held in aChannelCaps satisfies a |
|
2133 requirement specfied by this object |
|
2134 */ |
|
2135 TBool TDmaCapability::RequirementSatisfied(const SDmacCaps& aChannelCaps) const |
|
2136 { |
|
2137 switch(iCapsReq) |
|
2138 { |
|
2139 case ENone: |
|
2140 return ETrue; |
|
2141 case EChannelPriorities: |
|
2142 TEST_FAULT; |
|
2143 case EChannelPauseAndResume: |
|
2144 return aChannelCaps.iChannelPauseAndResume == (TBool)iValue; |
|
2145 case EAddrAlignedToElementSize: |
|
2146 TEST_FAULT; |
|
2147 case E1DAddressing: |
|
2148 return aChannelCaps.i1DIndexAddressing == (TBool)iValue; |
|
2149 case E2DAddressing: |
|
2150 return aChannelCaps.i2DIndexAddressing == (TBool)iValue; |
|
2151 case ESynchronizationTypes: |
|
2152 case EBurstTransactions: |
|
2153 case EDescriptorInterrupt: |
|
2154 case EFrameInterrupt: |
|
2155 case ELinkedListPausedInterrupt: |
|
2156 case EEndiannessConversion: |
|
2157 case EGraphicsOps: |
|
2158 case ERepeatingTransfers: |
|
2159 case EChannelLinking: |
|
2160 return aChannelCaps.iChannelLinking == (TBool)iValue; |
|
2161 case EHwDescriptors: |
|
2162 return aChannelCaps.iHwDescriptors == (TBool)iValue; |
|
2163 case ESrcDstAsymmetry: |
|
2164 case EAsymHwDescriptors: |
|
2165 TEST_FAULT; |
|
2166 case EBalancedAsymSegments: |
|
2167 return aChannelCaps.iBalancedAsymSegments == (TBool)iValue; |
|
2168 case EAsymCompletionInterrupt: |
|
2169 return aChannelCaps.iAsymCompletionInterrupt == (TBool)iValue; |
|
2170 case EAsymDescriptorInterrupt: |
|
2171 return aChannelCaps.iAsymDescriptorInterrupt == (TBool)iValue; |
|
2172 case EAsymFrameInterrupt: |
|
2173 return aChannelCaps.iAsymFrameInterrupt == (TBool)iValue; |
|
2174 default: |
|
2175 TEST_FAULT; |
|
2176 } |
|
2177 |
|
2178 return EFalse; |
|
2179 } |
|
2180 |
|
2181 /** |
|
2182 Will report whether a value held in aChannelCaps satisfies a |
|
2183 requirement specfied by this object |
|
2184 */ |
|
2185 TBool TDmaCapability::RequirementSatisfied(const TDmacTestCaps& aChannelCaps) const |
|
2186 { |
|
2187 switch(iCapsReq) |
|
2188 { |
|
2189 case EPilVersion: |
|
2190 return TestValue(aChannelCaps.iPILVersion); |
|
2191 default: |
|
2192 return RequirementSatisfied(static_cast<SDmacCaps>(aChannelCaps)); |
|
2193 } |
|
2194 } |
|
2195 |
|
2196 TResult TDmaCapability::CompareToDmaCaps(const SDmacCaps& aChannelCaps) const |
|
2197 { |
|
2198 const TBool reqSatisfied = RequirementSatisfied(aChannelCaps); |
|
2199 if(reqSatisfied) |
|
2200 { |
|
2201 return ERun; |
|
2202 } |
|
2203 else |
|
2204 { |
|
2205 return iFail ? EFail : ESkip; |
|
2206 } |
|
2207 } |
|
2208 |
|
2209 TResult TDmaCapability::CompareToDmaCaps(const TDmacTestCaps& aChannelCaps) const |
|
2210 { |
|
2211 const TBool reqSatisfied = RequirementSatisfied(aChannelCaps); |
|
2212 if(reqSatisfied) |
|
2213 { |
|
2214 return ERun; |
|
2215 } |
|
2216 else |
|
2217 { |
|
2218 return iFail ? EFail : ESkip; |
|
2219 } |
|
2220 } |
|
2221 /** |
|
2222 Test that aValue satisfies the comparrison (iCapsReqType) with the |
|
2223 reference value held in iValue |
|
2224 */ |
|
2225 TBool TDmaCapability::TestValue(TUint aValue) const |
|
2226 { |
|
2227 switch(iCapsReqType) |
|
2228 { |
|
2229 case EEqual: |
|
2230 return aValue == iValue; |
|
2231 case EGTE: |
|
2232 return aValue >= iValue; |
|
2233 case ELTE: |
|
2234 return aValue <= iValue; |
|
2235 case EBitsSet: |
|
2236 case EBitsClear: |
|
2237 default: |
|
2238 TEST_FAULT; |
|
2239 } |
|
2240 return EFalse; |
|
2241 } |
|
2242 |
|
2243 static RTest test(_L("DMAv2 test")); |
|
2244 |
|
2245 ////////////////////////////////////////////////////////////////////// |
|
2246 // TTestRunner |
|
2247 ////////////////////////////////////////////////////////////////////// |
|
2248 TTestRunner::TTestRunner() |
|
2249 { |
|
2250 // Open RDmaSession handle |
|
2251 TInt r = iDmaSession.Open(); |
|
2252 TEST_ASSERT(r == KErrNone); |
|
2253 |
|
2254 // Get PSI Test info |
|
2255 r = iDmaSession.GetTestInfo(iPslTestInfo); |
|
2256 TEST_ASSERT(r == KErrNone); |
|
2257 |
|
2258 //Retrieve PSL cookies |
|
2259 GetPslCookie(); |
|
2260 |
|
2261 //Generate the DMA channel records |
|
2262 GenerateChannelRecord(); |
|
2263 } |
|
2264 |
|
2265 TTestRunner::~TTestRunner() |
|
2266 { |
|
2267 RTest::CloseHandleAndWaitForDestruction(iDmaSession); |
|
2268 iTestCases.Close(); //TestRunner does not own test cases |
|
2269 iChannelRecords.Close(); |
|
2270 iPslCookies.Close(); |
|
2271 } |
|
2272 |
|
2273 void TTestRunner::AddTestCases(RPointerArray<TTestCase>& aTTestCases) |
|
2274 { |
|
2275 const TInt count = aTTestCases.Count(); |
|
2276 for(TInt i=0; i < count; i++) |
|
2277 { |
|
2278 iTestCases.AppendL(aTTestCases[i]); |
|
2279 } |
|
2280 } |
|
2281 |
|
2282 void TTestRunner::RunTests() |
|
2283 { |
|
2284 //Print PslTestInfo |
|
2285 if(gVerboseOutput) |
|
2286 { |
|
2287 Print(iPslTestInfo); |
|
2288 } |
|
2289 |
|
2290 //iterate through the test case array |
|
2291 const TInt testCaseCount = iTestCases.Count(); |
|
2292 for(TInt i=0; i < testCaseCount; i++) |
|
2293 { |
|
2294 const TTestCase& testCase = *iTestCases[i]; |
|
2295 |
|
2296 //Here, we must create a test thread for each channel |
|
2297 RPointerArray<CTest> concurrentTests; |
|
2298 |
|
2299 const TInt chanRecCount = iChannelRecords.Count(); |
|
2300 for(TInt j=0; j < chanRecCount; j++) |
|
2301 { |
|
2302 const TChannelRecord& record = iChannelRecords[j]; |
|
2303 const TDmacTestCaps& caps = record.iChannelCaps; |
|
2304 |
|
2305 const TResult t = testCase.TestCaseValid(caps); |
|
2306 |
|
2307 switch(t) |
|
2308 { |
|
2309 case ERun: |
|
2310 { |
|
2311 CDmaTest* dmaTest = static_cast<CDmaTest*>(testCase.iTest->Clone()); |
|
2312 TEST_ASSERT(dmaTest != NULL); |
|
2313 |
|
2314 dmaTest->SetChannelCookie(record.iCookie); |
|
2315 dmaTest->SetupL(); |
|
2316 if(testCase.iConcurrentTest) |
|
2317 { |
|
2318 //Add test to array to be run concurrently |
|
2319 TInt r = concurrentTests.Append(dmaTest); |
|
2320 TEST_ASSERT(r == KErrNone); |
|
2321 } |
|
2322 else |
|
2323 { |
|
2324 dmaTest->Announce(); |
|
2325 //Run test in this thread |
|
2326 (*dmaTest)(); |
|
2327 TBool result = dmaTest->Result(); |
|
2328 TEST_ASSERT(result); |
|
2329 |
|
2330 delete dmaTest; |
|
2331 } |
|
2332 |
|
2333 break; |
|
2334 } |
|
2335 case ESkip: |
|
2336 if(gVerboseOutput) |
|
2337 { |
|
2338 RDebug::Printf("Skipping test-case %S, PSL channel %d", &testCase.iTest->Name(), record.iCookie); |
|
2339 } |
|
2340 break; |
|
2341 case EFail: |
|
2342 if(gVerboseOutput) |
|
2343 { |
|
2344 RDebug::Printf("Failling test-case %S, PSL channel %d", &testCase.iTest->Name(), record.iCookie); |
|
2345 } |
|
2346 TEST_FAULT; |
|
2347 default: |
|
2348 TEST_FAULT; |
|
2349 } |
|
2350 //Depending on the value of iConcurrentTest the test runner will either block until the thread has completed or |
|
2351 //alternatively run the current test case on the next channel: |
|
2352 |
|
2353 //if the test case has been run on all channels it will then wait for all threads to complete. |
|
2354 } |
|
2355 |
|
2356 // Run the tests which should happen concurrently |
|
2357 const TInt count = concurrentTests.Count(); |
|
2358 if(count>0) |
|
2359 { |
|
2360 RDebug::Printf("== Begin concurrent test run =="); |
|
2361 |
|
2362 TInt i; // VC++ |
|
2363 for(i=0; i<count; i++) |
|
2364 { |
|
2365 concurrentTests[i]->Announce(); |
|
2366 } |
|
2367 |
|
2368 MultipleTestRun(concurrentTests); |
|
2369 for(i=0; i<count; i++) |
|
2370 { |
|
2371 TBool result = static_cast<CDmaTest*>(concurrentTests[i])->Result(); |
|
2372 TEST_ASSERT(result); |
|
2373 } |
|
2374 RDebug::Printf("== End concurrent test run =="); |
|
2375 } |
|
2376 |
|
2377 concurrentTests.ResetAndDestroy(); |
|
2378 } |
|
2379 } |
|
2380 |
|
2381 void TTestRunner::GetPslCookie() |
|
2382 { |
|
2383 //Get Sb Channel cookies |
|
2384 for(TInt sb_channelcount=0; sb_channelcount<iPslTestInfo.iMaxSbChannels; sb_channelcount++) |
|
2385 { |
|
2386 iPslCookies.AppendL(iPslTestInfo.iSbChannels[sb_channelcount]); |
|
2387 } |
|
2388 |
|
2389 //Get Db Channel cookies |
|
2390 for(TInt db_channelcount=0; db_channelcount<iPslTestInfo.iMaxDbChannels; db_channelcount++) |
|
2391 { |
|
2392 iPslCookies.AppendL(iPslTestInfo.iDbChannels[db_channelcount]); |
|
2393 } |
|
2394 |
|
2395 //Get Sg Channel cookies |
|
2396 for(TInt sg_channelcount=0; sg_channelcount<iPslTestInfo.iMaxSgChannels; sg_channelcount++) |
|
2397 { |
|
2398 iPslCookies.AppendL(iPslTestInfo.iSgChannels[sg_channelcount]); |
|
2399 } |
|
2400 } |
|
2401 |
|
2402 void TTestRunner::GenerateChannelRecord() |
|
2403 { |
|
2404 //for each PSL cookie |
|
2405 for(TInt count=0; count<iPslCookies.Count(); count++) |
|
2406 { |
|
2407 //Get channel cookie |
|
2408 const TUint pslCookie = iPslCookies[count]; |
|
2409 TUint sessionCookie; |
|
2410 TInt r = iDmaSession.ChannelOpen(pslCookie, sessionCookie); |
|
2411 TEST_ASSERT(r == KErrNone); |
|
2412 if(gVerboseOutput) |
|
2413 { |
|
2414 RDebug::Printf("Channel PSL Cookie[%d] :0x%08x",count,pslCookie); |
|
2415 } |
|
2416 |
|
2417 TChannelRecord dmaChannelRecord; |
|
2418 dmaChannelRecord.iCookie = pslCookie; |
|
2419 |
|
2420 //Get Channel Caps |
|
2421 r = iDmaSession.ChannelCaps(sessionCookie, dmaChannelRecord.iChannelCaps); |
|
2422 TEST_ASSERT(r == KErrNone); |
|
2423 |
|
2424 r = iDmaSession.ChannelClose(sessionCookie); |
|
2425 TEST_ASSERT(r == KErrNone); |
|
2426 |
|
2427 //Append array |
|
2428 iChannelRecords.AppendL(dmaChannelRecord); |
|
2429 } |
|
2430 } |
|
2431 ////////////////////////////////////////////////////////////////////// |
|
2432 // Global test functions and E32Main |
|
2433 ////////////////////////////////////////////////////////////////////// |
|
2434 |
|
2435 /** |
|
2436 Displayed if used supplied no parameters, garbage, or a ? in the parameters |
|
2437 */ |
|
2438 void PrintUsage() |
|
2439 { |
|
2440 test.Printf(_L("*** DMA TEST FRAMEWORK ***\n")); |
|
2441 test.Printf(_L("Usage : t_dma2.exe [/option]\n")); |
|
2442 test.Printf(_L(" /V or /VERBOSE = Control test output\n")); |
|
2443 test.Printf(_L(" /S or /SELFTEST = Run DMA self tests\n")); |
|
2444 test.Printf(_L(" /simple = Run only simple transfer tests\n")); |
|
2445 test.Printf(_L(" /callback = Run only callback tests\n")); |
|
2446 test.Printf(_L(" /multi = Run only multipart transfer tests\n")); |
|
2447 test.Printf(_L(" /isrdfc = Run only isr and dfc tests\n")); |
|
2448 test.Printf(_L(" /isreque = Run only isr reque tests\n")); |
|
2449 test.Printf(_L(" /bench = Run only benchmark tests\n")); |
|
2450 test.Printf(_L(" /suspend = Run only pause and resume tests\n")); |
|
2451 test.Printf(_L(" /graphic = Run only graphic tests\n")); |
|
2452 test.Printf(_L(" /channel = Run only DMA channel (opening and closing) tests\n")); |
|
2453 test.Printf(_L(" /queue = Run only queue tests\n")); |
|
2454 test.Printf(_L(" /fragment = Run only fragmentation related tests\n")); |
|
2455 test.Printf(_L(" /request = Run only requests tests related tests\n")); |
|
2456 test.Printf(_L("\n")); |
|
2457 } |
|
2458 |
|
2459 void ProcessCommandLineL() |
|
2460 { |
|
2461 test.Printf(_L("Process command line arguments\n")); |
|
2462 |
|
2463 TInt cmdLineLength(User::CommandLineLength()); |
|
2464 HBufC* cmdLine = HBufC::NewMaxLC(cmdLineLength); |
|
2465 TPtr cmdLinePtr = cmdLine->Des(); |
|
2466 User::CommandLine(cmdLinePtr); |
|
2467 TBool tokenParsed(EFalse); |
|
2468 |
|
2469 TLex args(*cmdLine); |
|
2470 args.SkipSpace(); // args are separated by spaces |
|
2471 |
|
2472 // first arg is the exe name, skip it |
|
2473 TPtrC cmdToken = args.NextToken(); |
|
2474 HBufC* tc = HBufC::NewLC(KParameterTextLenMax); |
|
2475 *tc = cmdToken; |
|
2476 while (tc->Length()) |
|
2477 { |
|
2478 tokenParsed = EFalse; |
|
2479 |
|
2480 // '/?' help wanted flag '?' or /? parameter |
|
2481 if ((0== tc->FindF(_L("?"))) || (0==tc->FindF(_L("/?")))) |
|
2482 { |
|
2483 gHelpRequested = ETrue; |
|
2484 tokenParsed = ETrue; |
|
2485 } |
|
2486 |
|
2487 // '/SELFTEST' |
|
2488 if ((0== tc->FindF(KArgSelfTest)) || (0==tc->FindF(KArgSelfTest2))) |
|
2489 { |
|
2490 // Run self test |
|
2491 test.Printf(_L("Command Line Options:Selftest option specified.\n")); |
|
2492 gSelfTest = ETrue; |
|
2493 tokenParsed = ETrue; |
|
2494 } |
|
2495 |
|
2496 // '/VERBOSE' option |
|
2497 if ((0== tc->FindF(KArgVerboseOutput)) || (0==tc->FindF(KArgVerboseOutput2))) |
|
2498 { |
|
2499 test.Printf(_L("Command Line Options:Verbose option specified.\n")); |
|
2500 gVerboseOutput = ETrue; |
|
2501 tokenParsed = ETrue; |
|
2502 } |
|
2503 |
|
2504 // '/suspend' option |
|
2505 if ((0== tc->FindF(KArgSuspendTest))) |
|
2506 { |
|
2507 gSuspend = ETrue; |
|
2508 tokenParsed = ETrue; |
|
2509 } |
|
2510 |
|
2511 // '/simple' option |
|
2512 if ((0== tc->FindF(KArgSimpleTest))) |
|
2513 { |
|
2514 gSimpleTest = ETrue; |
|
2515 tokenParsed = ETrue; |
|
2516 } |
|
2517 |
|
2518 // '/multi' option |
|
2519 if ((0== tc->FindF(KArgMultiPartTest))) |
|
2520 { |
|
2521 gMultiPart = ETrue; |
|
2522 tokenParsed = ETrue; |
|
2523 } |
|
2524 |
|
2525 // '/callback' option |
|
2526 if ((0== tc->FindF(KArgCallBackTest))) |
|
2527 { |
|
2528 gCallBack = ETrue; |
|
2529 tokenParsed = ETrue; |
|
2530 } |
|
2531 |
|
2532 // '/IsrAndDfc' option |
|
2533 if ((0== tc->FindF(KArgIsrDfcTest))) |
|
2534 { |
|
2535 gIsrAndDfc = ETrue; |
|
2536 tokenParsed = ETrue; |
|
2537 } |
|
2538 |
|
2539 // '/IsrReque' option |
|
2540 if ((0== tc->FindF(KArgIsrequeTest))) |
|
2541 { |
|
2542 gIsrReque = ETrue; |
|
2543 tokenParsed = ETrue; |
|
2544 } |
|
2545 |
|
2546 // '/Benchmark' option |
|
2547 if ((0== tc->FindF(KArgBenchmarkTest))) |
|
2548 { |
|
2549 gBenchmark = ETrue; |
|
2550 tokenParsed = ETrue; |
|
2551 } |
|
2552 |
|
2553 // '/Queue' option |
|
2554 if ((0== tc->FindF(KArgQueueTest))) |
|
2555 { |
|
2556 gQueue = ETrue; |
|
2557 tokenParsed = ETrue; |
|
2558 } |
|
2559 |
|
2560 // '/Fragment' option |
|
2561 if ((0== tc->FindF(KArgFragmentTest))) |
|
2562 { |
|
2563 gFragment = ETrue; |
|
2564 tokenParsed = ETrue; |
|
2565 } |
|
2566 |
|
2567 // '/Channel' option |
|
2568 if ((0== tc->FindF(KArgChannelTest))) |
|
2569 { |
|
2570 gChannel = ETrue; |
|
2571 tokenParsed = ETrue; |
|
2572 } |
|
2573 |
|
2574 // '/Graphic' option |
|
2575 if ((0== tc->FindF(KArgGraphicTest))) |
|
2576 { |
|
2577 gGraphic = ETrue; |
|
2578 tokenParsed = ETrue; |
|
2579 } |
|
2580 |
|
2581 // '/Request' option |
|
2582 if ((0== tc->FindF(KArgRequestTest))) |
|
2583 { |
|
2584 gRequest = ETrue; |
|
2585 tokenParsed = ETrue; |
|
2586 } |
|
2587 |
|
2588 if (!tokenParsed) |
|
2589 { |
|
2590 // warn about unparsed parameter |
|
2591 test.Printf(_L("Warning: '%lS'??? not parsed\n"), tc); |
|
2592 gHelpRequested = ETrue; |
|
2593 } |
|
2594 |
|
2595 // next parameter |
|
2596 *tc = args.NextToken(); |
|
2597 } |
|
2598 CleanupStack::PopAndDestroy(tc); |
|
2599 CleanupStack::PopAndDestroy(cmdLine); |
|
2600 } |
|
2601 |
|
2602 void RunDMATests() |
|
2603 { |
|
2604 test.Start(_L("Creating test runner\n")); |
|
2605 TTestRunner testRunner; |
|
2606 |
|
2607 test.Next(_L("Add global test cases to test runner\n")); |
|
2608 |
|
2609 if (gSimpleTest) //Add only simple tranfer test cases |
|
2610 { |
|
2611 testRunner.AddTestCases(TestArraySimple); |
|
2612 } |
|
2613 else if (gCallBack) //Add only callback test cases |
|
2614 { |
|
2615 testRunner.AddTestCases(TestArrayCallback); |
|
2616 } |
|
2617 else if (gIsrReque) //Add only ISR Reque test cases |
|
2618 { |
|
2619 testRunner.AddTestCases(TestArrayIsrReque); |
|
2620 } |
|
2621 else if (gMultiPart) //Add only Multipart test cases |
|
2622 { |
|
2623 testRunner.AddTestCases(TestArrayMultiPart); |
|
2624 } |
|
2625 else if (gIsrAndDfc) //Add only IsrAndDfc test cases |
|
2626 { |
|
2627 testRunner.AddTestCases(TestArrayIsrAndDfc); |
|
2628 } |
|
2629 else if (gBenchmark) //Add only Benchmark test cases |
|
2630 { |
|
2631 testRunner.AddTestCases(TestArrayBenchmark); |
|
2632 } |
|
2633 else if (gGraphic) //Add only 2D test cases |
|
2634 { |
|
2635 testRunner.AddTestCases(TestArray2DTest); |
|
2636 } |
|
2637 else if (gFragment) //Add only Fragment test cases |
|
2638 { |
|
2639 testRunner.AddTestCases(TestArrayFragment); |
|
2640 } |
|
2641 else if (gChannel) //Add only Channel test cases |
|
2642 { |
|
2643 testRunner.AddTestCases(TestArrayChannel); |
|
2644 } |
|
2645 else if (gSuspend) //Add only Suspend test cases |
|
2646 { |
|
2647 testRunner.AddTestCases(TestArraySuspend); |
|
2648 } |
|
2649 else if (gQueue) //Add only queue test cases |
|
2650 { |
|
2651 testRunner.AddTestCases(TestArrayQueue); |
|
2652 } |
|
2653 else if (gRequest) //Add only request test cases |
|
2654 { |
|
2655 testRunner.AddTestCases(TestArrayRequest); |
|
2656 } |
|
2657 else |
|
2658 { |
|
2659 testRunner.AddTestCases(TestArray);//Add all test cases |
|
2660 } |
|
2661 |
|
2662 test.Next(_L("call TTestRunner::RunTests()\n")); |
|
2663 testRunner.RunTests(); |
|
2664 |
|
2665 test.End(); |
|
2666 } |
|
2667 |
|
2668 |
|
2669 struct TSimTest |
|
2670 { |
|
2671 TUint iPslId; |
|
2672 TBool iFragment; |
|
2673 }; |
|
2674 |
|
2675 const TSimTest KSimTests[] = |
|
2676 { |
|
2677 {0, EFalse}, |
|
2678 {1, EFalse}, |
|
2679 {2, ETrue}, |
|
2680 {3, ETrue}, |
|
2681 }; |
|
2682 |
|
2683 const TInt KSimTestsCount = ARRAY_LENGTH(KSimTests); |
|
2684 |
|
2685 void RunSimDMATests() |
|
2686 { |
|
2687 test.Start(_L("Run simulated DMAC tests\n")); |
|
2688 |
|
2689 test.Next(_L("Open session")); |
|
2690 RDmaSession session; |
|
2691 TInt r = session.OpenSim(); |
|
2692 test_KErrNone(r); |
|
2693 |
|
2694 for(TInt i=0; i<KSimTestsCount; i++) |
|
2695 { |
|
2696 TUint pslId = KSimTests[i].iPslId; |
|
2697 TBool doFrag = KSimTests[i].iFragment; |
|
2698 |
|
2699 test.Start(_L("Open channel")); |
|
2700 TUint channelCookie=0; |
|
2701 r = session.ChannelOpen(pslId, channelCookie); |
|
2702 test.Printf(_L("Open channel %d, cookie recived = 0x%08x\n"), pslId, channelCookie); |
|
2703 test_KErrNone(r); |
|
2704 |
|
2705 test.Next(_L("Create Dma request")); |
|
2706 |
|
2707 TUint reqCookie=0; |
|
2708 r = session.RequestCreate(channelCookie, reqCookie); |
|
2709 test.Printf(_L("cookie recived = 0x%08x\n"), reqCookie ); |
|
2710 test_KErrNone(r); |
|
2711 |
|
2712 if(doFrag) |
|
2713 { |
|
2714 test.Next(_L("Fragment request")); |
|
2715 const TInt size = 128 * KKilo; |
|
2716 TDmaTransferArgs transferArgs(0, size, size, KDmaMemAddr); |
|
2717 r = session.FragmentRequest(reqCookie, transferArgs); |
|
2718 test_KErrNone(r); |
|
2719 } |
|
2720 |
|
2721 test.Next(_L("Destroy Dma request")); |
|
2722 r = session.RequestDestroy(reqCookie); |
|
2723 test_KErrNone(r); |
|
2724 |
|
2725 test.Next(_L("Channel close")); |
|
2726 r = session.ChannelClose(channelCookie); |
|
2727 test_KErrNone(r); |
|
2728 test.End(); |
|
2729 } |
|
2730 |
|
2731 test.Next(_L("Close session")); |
|
2732 RTest::CloseHandleAndWaitForDestruction(session); |
|
2733 |
|
2734 test.End(); |
|
2735 } |
|
2736 |
|
2737 TInt E32Main() |
|
2738 { |
|
2739 __UHEAP_MARK; |
|
2740 test.Title(); |
|
2741 |
|
2742 gHelpRequested = EFalse; |
|
2743 TInt r; |
|
2744 |
|
2745 // Create the new trap-cleanup mechanism |
|
2746 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
2747 |
|
2748 if (cleanup == NULL) |
|
2749 { |
|
2750 return KErrNoMemory; |
|
2751 } |
|
2752 |
|
2753 // Process the command line parameters for batch/etc |
|
2754 TRAPD(err, ProcessCommandLineL()); |
|
2755 if (err != KErrNone) |
|
2756 { |
|
2757 User::Panic(_L("DMA test run memory failure"), KErrNoMemory); |
|
2758 } |
|
2759 |
|
2760 if (gHelpRequested) |
|
2761 { |
|
2762 PrintUsage(); |
|
2763 User::Leave(-2); // nothing to do! |
|
2764 } |
|
2765 test.Start(_L("Loading test LDD")); |
|
2766 //load either the new test ldd, d_dma2.ldd, |
|
2767 //or d_dma2_compat.ldd - an ldd linked against |
|
2768 //the old DMA framework |
|
2769 _LIT(KDma, "D_DMA2.LDD"); |
|
2770 r = User::LoadLogicalDevice(KDma); |
|
2771 const TBool dma2Loaded = ((r == KErrNone) || (r == KErrAlreadyExists)); |
|
2772 |
|
2773 _LIT(KDma2Compat, "D_DMA2_COMPAT.LDD"); |
|
2774 r = User::LoadLogicalDevice(KDma2Compat); |
|
2775 const TBool dma2CompatLoaded = ((r == KErrNone) || (r == KErrAlreadyExists)); |
|
2776 |
|
2777 if (!(dma2Loaded || dma2CompatLoaded)) |
|
2778 { |
|
2779 test.Printf(_L("Hardware DMA test driver not found - will run tests on simulated DMAC only\n")); |
|
2780 } |
|
2781 else if (dma2Loaded && !dma2CompatLoaded) |
|
2782 { |
|
2783 test.Printf(_L("Loaded %S\n"), &KDma); |
|
2784 } |
|
2785 else if (!dma2Loaded && dma2CompatLoaded) |
|
2786 { |
|
2787 test.Printf(_L("Loaded %S\n"), &KDma2Compat); |
|
2788 } |
|
2789 else |
|
2790 { |
|
2791 test.Printf(_L("The ROM contains %S and %S - only one should be present\n"), &KDma, &KDma2Compat); |
|
2792 TEST_FAULT; |
|
2793 } |
|
2794 |
|
2795 const TBool dmaHwPresent = (dma2Loaded || dma2CompatLoaded); |
|
2796 |
|
2797 _LIT(KDma2Sim, "D_DMA2_SIM.LDD"); |
|
2798 |
|
2799 r = User::LoadLogicalDevice(KDma2Sim); |
|
2800 const TBool dma2SimLoaded = ((r == KErrNone) || (r == KErrAlreadyExists)); |
|
2801 if (dma2SimLoaded) |
|
2802 { |
|
2803 test.Printf(_L("Loaded %S\n"), &KDma2Sim); |
|
2804 } |
|
2805 else |
|
2806 { |
|
2807 test.Printf(_L("Failed to load %S, r=%d\n"), &KDma2Sim, r); |
|
2808 test(EFalse); |
|
2809 } |
|
2810 |
|
2811 // Turn off evil lazy dll unloading |
|
2812 RLoader l; |
|
2813 test(l.Connect()==KErrNone); |
|
2814 test(l.CancelLazyDllUnload()==KErrNone); |
|
2815 RTest::CloseHandleAndWaitForDestruction(l); |
|
2816 |
|
2817 __KHEAP_MARK; |
|
2818 |
|
2819 if (gSelfTest) //Run self tests if specified on command line |
|
2820 { |
|
2821 SelfTests(); |
|
2822 } |
|
2823 |
|
2824 RunSimDMATests(); |
|
2825 if (dmaHwPresent) |
|
2826 { |
|
2827 RunDMATests(); |
|
2828 } |
|
2829 |
|
2830 // Wait for the supervisor thread to run and perform asynchronous |
|
2831 // cleanup, so that kernel heap space will be freed |
|
2832 r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0); |
|
2833 test_KErrNone(r); |
|
2834 __KHEAP_MARKEND; |
|
2835 |
|
2836 if(dmaHwPresent) |
|
2837 { |
|
2838 r = User::FreeLogicalDevice(KTestDmaLddNameHw); |
|
2839 test_KErrNone(r); |
|
2840 } |
|
2841 r = User::FreeLogicalDevice(KTestDmaLddNameSim); |
|
2842 test_KErrNone(r); |
|
2843 |
|
2844 test.End(); |
|
2845 test.Close(); |
|
2846 |
|
2847 delete cleanup; |
|
2848 |
|
2849 __UHEAP_MARKEND; |
|
2850 return 0; |
|
2851 } |