129 // Only open a new session if one |
129 // Only open a new session if one |
130 // was not already supplied |
130 // was not already supplied |
131 if(iDmaSession.Handle() == KNullHandle) |
131 if(iDmaSession.Handle() == KNullHandle) |
132 { |
132 { |
133 TInt r = iDmaSession.Open(); |
133 TInt r = iDmaSession.Open(); |
|
134 RDebug::Printf("CDmaTest::OpenDmaSession = %d\n", r); |
134 TEST_ASSERT(r == KErrNone); |
135 TEST_ASSERT(r == KErrNone); |
135 r = iDmaSession.OpenSharedChunk(iChunk); |
136 r = iDmaSession.OpenSharedChunk(iChunk); |
136 TEST_ASSERT(r == KErrNone); |
137 TEST_ASSERT(r == KErrNone); |
137 } |
138 } |
138 } |
139 } |
695 } |
696 } |
696 |
697 |
697 void CPauseResumeTest::PrintTestType() const |
698 void CPauseResumeTest::PrintTestType() const |
698 { |
699 { |
699 RDebug::RawPrint(_L("Pause and Resume API Test")); |
700 RDebug::RawPrint(_L("Pause and Resume API Test")); |
|
701 } |
|
702 |
|
703 ////////////////////////////////////////////////////////////////////// |
|
704 // CPauseResumeNegTest |
|
705 // |
|
706 // -Open DMA Channel |
|
707 // -Pause and Resume DMA channel |
|
708 // -Check that KErrNotSupported is returned |
|
709 // -Close DMA Channel |
|
710 ////////////////////////////////////////////////////////////////////// |
|
711 CPauseResumeNegTest::~CPauseResumeNegTest() |
|
712 { |
|
713 } |
|
714 |
|
715 void CPauseResumeNegTest::RunTest() |
|
716 { |
|
717 OpenDmaSession(); |
|
718 |
|
719 //Open a single DMA channel for a transfer |
|
720 OpenChannel(); |
|
721 |
|
722 RDebug::Printf("Resume unpaused idle channel"); |
|
723 TInt r = iDmaSession.ChannelResume(iChannelSessionCookie); |
|
724 TEST_ASSERT(KErrNotSupported == r); |
|
725 |
|
726 RDebug::Printf("Pause idle channel"); |
|
727 r = iDmaSession.ChannelPause(iChannelSessionCookie); |
|
728 TEST_ASSERT(KErrNotSupported == r); |
|
729 |
|
730 RDebug::Printf("Pause paused idle Channel"); |
|
731 r = iDmaSession.ChannelPause(iChannelSessionCookie); |
|
732 TEST_ASSERT(KErrNotSupported == r); |
|
733 |
|
734 RDebug::Printf("Resume paused idle channel"); |
|
735 r = iDmaSession.ChannelResume(iChannelSessionCookie); |
|
736 TEST_ASSERT(KErrNotSupported == r); |
|
737 |
|
738 CloseChannel(); |
|
739 CloseDmaSession(); |
|
740 } |
|
741 |
|
742 void CPauseResumeNegTest::PrintTestType() const |
|
743 { |
|
744 RDebug::RawPrint(_L("Pause and Resume API Test - Negative Test")); |
|
745 } |
|
746 |
|
747 ////////////////////////////////////////////////////////////////////// |
|
748 // CLinkChannelTest |
|
749 // |
|
750 // -Open DMA Channel |
|
751 // -Link and Unlink DMA channel |
|
752 // -Check that KErrNotSupported is returned |
|
753 // -Close DMA Channel |
|
754 // |
|
755 ////////////////////////////////////////////////////////////////////// |
|
756 CLinkChannelTest::~CLinkChannelTest() |
|
757 { |
|
758 } |
|
759 |
|
760 void CLinkChannelTest::RunTest() |
|
761 { |
|
762 OpenDmaSession(); |
|
763 |
|
764 //Open a single DMA channel for a transfer |
|
765 OpenChannel(); |
|
766 |
|
767 RDebug::Printf("Linking DMA channels"); |
|
768 TInt r = iDmaSession.ChannelLinking(iChannelSessionCookie); |
|
769 TEST_ASSERT(KErrNotSupported == r); |
|
770 |
|
771 RDebug::Printf("Unlinking DMA channels"); |
|
772 r = iDmaSession.ChannelUnLinking(iChannelSessionCookie); |
|
773 TEST_ASSERT(KErrNotSupported == r); |
|
774 |
|
775 CloseChannel(); |
|
776 CloseDmaSession(); |
|
777 } |
|
778 |
|
779 void CLinkChannelTest::PrintTestType() const |
|
780 { |
|
781 RDebug::RawPrint(_L("Channel Linking API Test - Negative Test")); |
700 } |
782 } |
701 |
783 |
702 ////////////////////////////////////////////////////////////////////// |
784 ////////////////////////////////////////////////////////////////////// |
703 // COpenCloseTest |
785 // COpenCloseTest |
704 ////////////////////////////////////////////////////////////////////// |
786 ////////////////////////////////////////////////////////////////////// |
1997 case EFrameInterrupt: |
2079 case EFrameInterrupt: |
1998 case ELinkedListPausedInterrupt: |
2080 case ELinkedListPausedInterrupt: |
1999 case EEndiannessConversion: |
2081 case EEndiannessConversion: |
2000 case EGraphicsOps: |
2082 case EGraphicsOps: |
2001 case ERepeatingTransfers: |
2083 case ERepeatingTransfers: |
2002 case EChannelLinking: |
2084 case EChannelLinking: |
2003 TEST_FAULT; |
2085 return aChannelCaps.iChannelLinking == (TBool)iValue; |
2004 case EHwDescriptors: |
2086 case EHwDescriptors: |
2005 return aChannelCaps.iHwDescriptors == (TBool)iValue; |
2087 return aChannelCaps.iHwDescriptors == (TBool)iValue; |
2006 case ESrcDstAsymmetry: |
2088 case ESrcDstAsymmetry: |
2007 case EAsymHwDescriptors: |
2089 case EAsymHwDescriptors: |
2008 TEST_FAULT; |
2090 TEST_FAULT; |
2500 else |
2582 else |
2501 { |
2583 { |
2502 testRunner.AddTestCases(TestArray);//Add all test cases |
2584 testRunner.AddTestCases(TestArray);//Add all test cases |
2503 } |
2585 } |
2504 |
2586 |
2505 |
|
2506 test.Next(_L("call TTestRunner::RunTests()\n")); |
2587 test.Next(_L("call TTestRunner::RunTests()\n")); |
2507 testRunner.RunTests(); |
2588 testRunner.RunTests(); |
|
2589 |
|
2590 test.End(); |
|
2591 } |
|
2592 |
|
2593 |
|
2594 struct TSimTest |
|
2595 { |
|
2596 TUint iPslId; |
|
2597 TBool iFragment; |
|
2598 }; |
|
2599 |
|
2600 const TSimTest KSimTests[] = |
|
2601 { |
|
2602 {0, EFalse}, |
|
2603 {1, EFalse}, |
|
2604 {2, ETrue}, |
|
2605 {3, ETrue}, |
|
2606 }; |
|
2607 |
|
2608 const TInt KSimTestsCount = ARRAY_LENGTH(KSimTests); |
|
2609 |
|
2610 void RunSimDMATests() |
|
2611 { |
|
2612 test.Start(_L("Run simulated DMAC tests\n")); |
|
2613 |
|
2614 test.Next(_L("Open session")); |
|
2615 RDmaSession session; |
|
2616 TInt r = session.OpenSim(); |
|
2617 test_KErrNone(r); |
|
2618 |
|
2619 for(TInt i=0; i<KSimTestsCount; i++) |
|
2620 { |
|
2621 TUint pslId = KSimTests[i].iPslId; |
|
2622 TBool doFrag = KSimTests[i].iFragment; |
|
2623 |
|
2624 test.Start(_L("Open channel")); |
|
2625 TUint channelCookie=0; |
|
2626 r = session.ChannelOpen(pslId, channelCookie); |
|
2627 test.Printf(_L("Open channel %d, cookie recived = 0x%08x\n"), pslId, channelCookie); |
|
2628 test_KErrNone(r); |
|
2629 |
|
2630 test.Next(_L("Create Dma request")); |
|
2631 |
|
2632 TUint reqCookie=0; |
|
2633 r = session.RequestCreate(channelCookie, reqCookie); |
|
2634 test.Printf(_L("cookie recived = 0x%08x\n"), reqCookie ); |
|
2635 test_KErrNone(r); |
|
2636 |
|
2637 if(doFrag) |
|
2638 { |
|
2639 test.Next(_L("Fragment request")); |
|
2640 const TInt size = 128 * KKilo; |
|
2641 TDmaTransferArgs transferArgs(0, size, size, KDmaMemAddr); |
|
2642 r = session.FragmentRequest(reqCookie, transferArgs); |
|
2643 test_KErrNone(r); |
|
2644 } |
|
2645 |
|
2646 test.Next(_L("Destroy Dma request")); |
|
2647 r = session.RequestDestroy(reqCookie); |
|
2648 test_KErrNone(r); |
|
2649 |
|
2650 test.Next(_L("Channel close")); |
|
2651 r = session.ChannelClose(channelCookie); |
|
2652 test_KErrNone(r); |
|
2653 test.End(); |
|
2654 } |
|
2655 |
|
2656 test.Next(_L("Close session")); |
|
2657 RTest::CloseHandleAndWaitForDestruction(session); |
2508 |
2658 |
2509 test.End(); |
2659 test.End(); |
2510 } |
2660 } |
2511 |
2661 |
2512 TInt E32Main() |
2662 TInt E32Main() |
2549 r = User::LoadLogicalDevice(KDma2Compat); |
2699 r = User::LoadLogicalDevice(KDma2Compat); |
2550 const TBool dma2CompatLoaded = ((r == KErrNone) || (r == KErrAlreadyExists)); |
2700 const TBool dma2CompatLoaded = ((r == KErrNone) || (r == KErrAlreadyExists)); |
2551 |
2701 |
2552 if (!(dma2Loaded || dma2CompatLoaded)) |
2702 if (!(dma2Loaded || dma2CompatLoaded)) |
2553 { |
2703 { |
2554 test.Printf(_L("DMA test driver not found - test skipped\n")); |
2704 test.Printf(_L("Hardware DMA test driver not found - will run tests on simulated DMAC only\n")); |
2555 return 0; |
|
2556 } |
2705 } |
2557 else if (dma2Loaded && !dma2CompatLoaded) |
2706 else if (dma2Loaded && !dma2CompatLoaded) |
2558 { |
2707 { |
2559 test.Printf(_L("Loaded %S\n"), &KDma); |
2708 test.Printf(_L("Loaded %S\n"), &KDma); |
2560 } |
2709 } |
2565 else |
2714 else |
2566 { |
2715 { |
2567 test.Printf(_L("The ROM contains %S and %S - only one should be present\n"), &KDma, &KDma2Compat); |
2716 test.Printf(_L("The ROM contains %S and %S - only one should be present\n"), &KDma, &KDma2Compat); |
2568 TEST_FAULT; |
2717 TEST_FAULT; |
2569 } |
2718 } |
|
2719 |
|
2720 const TBool dmaHwPresent = (dma2Loaded || dma2CompatLoaded); |
|
2721 |
|
2722 _LIT(KDma2Sim, "D_DMA2_SIM.LDD"); |
|
2723 |
|
2724 r = User::LoadLogicalDevice(KDma2Sim); |
|
2725 const TBool dma2SimLoaded = ((r == KErrNone) || (r == KErrAlreadyExists)); |
|
2726 if (dma2SimLoaded) |
|
2727 { |
|
2728 test.Printf(_L("Loaded %S\n"), &KDma2Sim); |
|
2729 } |
|
2730 else |
|
2731 { |
|
2732 test.Printf(_L("Failed to load %S, r=%d\n"), &KDma2Sim, r); |
|
2733 test(EFalse); |
|
2734 } |
|
2735 |
2570 // Turn off evil lazy dll unloading |
2736 // Turn off evil lazy dll unloading |
2571 RLoader l; |
2737 RLoader l; |
2572 test(l.Connect()==KErrNone); |
2738 test(l.Connect()==KErrNone); |
2573 test(l.CancelLazyDllUnload()==KErrNone); |
2739 test(l.CancelLazyDllUnload()==KErrNone); |
2574 RTest::CloseHandleAndWaitForDestruction(l); |
2740 RTest::CloseHandleAndWaitForDestruction(l); |
2575 |
2741 |
2576 __KHEAP_MARK; |
2742 __KHEAP_MARK; |
2577 |
2743 |
2578 if (gSelfTest) //Run self tests if specified on command line |
2744 if (gSelfTest) //Run self tests if specified on command line |
2579 { |
2745 { |
2580 SelfTests(); |
2746 SelfTests(); |
2581 } |
2747 } |
2582 |
2748 |
2583 RunDMATests(); |
2749 RunSimDMATests(); |
|
2750 if (dmaHwPresent) |
|
2751 { |
|
2752 RunDMATests(); |
|
2753 } |
2584 |
2754 |
2585 // Wait for the supervisor thread to run and perform asynchronous |
2755 // Wait for the supervisor thread to run and perform asynchronous |
2586 // cleanup, so that kernel heap space will be freed |
2756 // cleanup, so that kernel heap space will be freed |
2587 r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0); |
2757 r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0); |
2588 test_KErrNone(r); |
2758 test_KErrNone(r); |
2589 __KHEAP_MARKEND; |
2759 __KHEAP_MARKEND; |
2590 |
2760 |
2591 r = User::FreeLogicalDevice(KTestDmaLddName); |
2761 if(dmaHwPresent) |
|
2762 { |
|
2763 r = User::FreeLogicalDevice(KTestDmaLddNameHw); |
|
2764 test_KErrNone(r); |
|
2765 } |
|
2766 r = User::FreeLogicalDevice(KTestDmaLddNameSim); |
2592 test_KErrNone(r); |
2767 test_KErrNone(r); |
|
2768 |
2593 test.End(); |
2769 test.End(); |
2594 test.Close(); |
2770 test.Close(); |
2595 |
2771 |
2596 delete cleanup; |
2772 delete cleanup; |
2597 |
2773 |