695 } |
699 } |
696 |
700 |
697 void CPauseResumeTest::PrintTestType() const |
701 void CPauseResumeTest::PrintTestType() const |
698 { |
702 { |
699 RDebug::RawPrint(_L("Pause and Resume API Test")); |
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")); |
700 } |
857 } |
701 |
858 |
702 ////////////////////////////////////////////////////////////////////// |
859 ////////////////////////////////////////////////////////////////////// |
703 // COpenCloseTest |
860 // COpenCloseTest |
704 ////////////////////////////////////////////////////////////////////// |
861 ////////////////////////////////////////////////////////////////////// |
1997 case EFrameInterrupt: |
2154 case EFrameInterrupt: |
1998 case ELinkedListPausedInterrupt: |
2155 case ELinkedListPausedInterrupt: |
1999 case EEndiannessConversion: |
2156 case EEndiannessConversion: |
2000 case EGraphicsOps: |
2157 case EGraphicsOps: |
2001 case ERepeatingTransfers: |
2158 case ERepeatingTransfers: |
2002 case EChannelLinking: |
2159 case EChannelLinking: |
2003 TEST_FAULT; |
2160 return aChannelCaps.iChannelLinking == (TBool)iValue; |
2004 case EHwDescriptors: |
2161 case EHwDescriptors: |
2005 return aChannelCaps.iHwDescriptors == (TBool)iValue; |
2162 return aChannelCaps.iHwDescriptors == (TBool)iValue; |
2006 case ESrcDstAsymmetry: |
2163 case ESrcDstAsymmetry: |
2007 case EAsymHwDescriptors: |
2164 case EAsymHwDescriptors: |
2008 TEST_FAULT; |
2165 TEST_FAULT; |
2500 else |
2657 else |
2501 { |
2658 { |
2502 testRunner.AddTestCases(TestArray);//Add all test cases |
2659 testRunner.AddTestCases(TestArray);//Add all test cases |
2503 } |
2660 } |
2504 |
2661 |
2505 |
|
2506 test.Next(_L("call TTestRunner::RunTests()\n")); |
2662 test.Next(_L("call TTestRunner::RunTests()\n")); |
2507 testRunner.RunTests(); |
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); |
2508 |
2733 |
2509 test.End(); |
2734 test.End(); |
2510 } |
2735 } |
2511 |
2736 |
2512 TInt E32Main() |
2737 TInt E32Main() |
2565 else |
2789 else |
2566 { |
2790 { |
2567 test.Printf(_L("The ROM contains %S and %S - only one should be present\n"), &KDma, &KDma2Compat); |
2791 test.Printf(_L("The ROM contains %S and %S - only one should be present\n"), &KDma, &KDma2Compat); |
2568 TEST_FAULT; |
2792 TEST_FAULT; |
2569 } |
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 |
2570 // Turn off evil lazy dll unloading |
2811 // Turn off evil lazy dll unloading |
2571 RLoader l; |
2812 RLoader l; |
2572 test(l.Connect()==KErrNone); |
2813 test(l.Connect()==KErrNone); |
2573 test(l.CancelLazyDllUnload()==KErrNone); |
2814 test(l.CancelLazyDllUnload()==KErrNone); |
2574 RTest::CloseHandleAndWaitForDestruction(l); |
2815 RTest::CloseHandleAndWaitForDestruction(l); |
2575 |
2816 |
2576 __KHEAP_MARK; |
2817 __KHEAP_MARK; |
2577 |
2818 |
2578 if (gSelfTest) //Run self tests if specified on command line |
2819 if (gSelfTest) //Run self tests if specified on command line |
2579 { |
2820 { |
2580 SelfTests(); |
2821 SelfTests(); |
2581 } |
2822 } |
2582 |
2823 |
2583 RunDMATests(); |
2824 RunSimDMATests(); |
|
2825 if (dmaHwPresent) |
|
2826 { |
|
2827 RunDMATests(); |
|
2828 } |
2584 |
2829 |
2585 // Wait for the supervisor thread to run and perform asynchronous |
2830 // Wait for the supervisor thread to run and perform asynchronous |
2586 // cleanup, so that kernel heap space will be freed |
2831 // cleanup, so that kernel heap space will be freed |
2587 r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0); |
2832 r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0); |
2588 test_KErrNone(r); |
2833 test_KErrNone(r); |
2589 __KHEAP_MARKEND; |
2834 __KHEAP_MARKEND; |
2590 |
2835 |
2591 r = User::FreeLogicalDevice(KTestDmaLddName); |
2836 if(dmaHwPresent) |
|
2837 { |
|
2838 r = User::FreeLogicalDevice(KTestDmaLddNameHw); |
|
2839 test_KErrNone(r); |
|
2840 } |
|
2841 r = User::FreeLogicalDevice(KTestDmaLddNameSim); |
2592 test_KErrNone(r); |
2842 test_KErrNone(r); |
|
2843 |
2593 test.End(); |
2844 test.End(); |
2594 test.Close(); |
2845 test.Close(); |
2595 |
2846 |
2596 delete cleanup; |
2847 delete cleanup; |
2597 |
2848 |