kerneltest/e32test/dmav2/t_dma2.cpp
changeset 293 0659d0e1a03c
parent 243 c7a0ce20c48c
equal deleted inserted replaced
291:206a6eaaeb71 293:0659d0e1a03c
   570 	RDebug::RawPrint(_L("Fragmentation Benchmark"));
   570 	RDebug::RawPrint(_L("Fragmentation Benchmark"));
   571 	}
   571 	}
   572 
   572 
   573 void CDmaBmFragmentation::RunTest()
   573 void CDmaBmFragmentation::RunTest()
   574 	{
   574 	{
       
   575 	// This HAL call is here to make sure the chunk that was used for the
       
   576 	// previous test iteration has been freed by the time the next one gets
       
   577 	// created. (This was put in after T_DMA2INV OOM failures during the
       
   578 	// Fragmentation Benchmark tests.)
       
   579 	const TInt r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0);
       
   580 	TEST_ASSERT(r == KErrNone);
       
   581 
   575 	OpenDmaSession();
   582 	OpenDmaSession();
   576 
   583 
   577 	OpenChannel();
   584 	OpenChannel();
   578 	CreateDmaRequest();
   585 	CreateDmaRequest();
   579 	Fragment();
   586 	Fragment();
  1046 
  1053 
  1047 	if(!iOpenCloseResult)
  1054 	if(!iOpenCloseResult)
  1048 		{
  1055 		{
  1049 		RDebug::Printf("Open/Close test sequence failed"); 
  1056 		RDebug::Printf("Open/Close test sequence failed"); 
  1050 		}
  1057 		}
  1051 			
  1058 
  1052 	return iOpenCloseResult;
  1059 	return iOpenCloseResult;
  1053 	}
  1060 	}
       
  1061 
       
  1062 
  1054 //////////////////////////////////////////////////////////////////////
  1063 //////////////////////////////////////////////////////////////////////
  1055 // CDmaBmTransfer
  1064 // CDmaBmTransfer
  1056 //////////////////////////////////////////////////////////////////////
  1065 //////////////////////////////////////////////////////////////////////
  1057 CDmaBmTransfer::CDmaBmTransfer(const TDesC& aName, TInt aIterations, const TDmaTransferArgs& aTransferArgs, TUint aMaxFragmentSize)
  1066 CDmaBmTransfer::CDmaBmTransfer(const TDesC& aName, TInt aIterations, const TDmaTransferArgs& aTransferArgs, TUint aMaxFragmentSize)
  1058 	:CDmaBenchmark(aName, aIterations,
  1067 	:CDmaBenchmark(aName, aIterations,
  2238 		TEST_FAULT;
  2247 		TEST_FAULT;
  2239 		}
  2248 		}
  2240 	return EFalse;
  2249 	return EFalse;
  2241 	}
  2250 	}
  2242 
  2251 
  2243 static RTest test(_L("DMAv2 test"));
  2252 #if defined(DMA_INVERTED_THREAD_PRIORITIES)
       
  2253 static RTest test(_L("T_DMA2INV"));
       
  2254 #else
       
  2255 static RTest test(_L("T_DMA2"));
       
  2256 #endif
       
  2257 
  2244 
  2258 
  2245 //////////////////////////////////////////////////////////////////////
  2259 //////////////////////////////////////////////////////////////////////
  2246 // TTestRunner
  2260 // TTestRunner
  2247 //////////////////////////////////////////////////////////////////////
  2261 //////////////////////////////////////////////////////////////////////
  2248 TTestRunner::TTestRunner()
  2262 TTestRunner::TTestRunner()
  2345 				}
  2359 				}
  2346 				TEST_FAULT;
  2360 				TEST_FAULT;
  2347 			default:
  2361 			default:
  2348 				TEST_FAULT;
  2362 				TEST_FAULT;
  2349 				}
  2363 				}
  2350 			//Depending on the value of iConcurrentTest the test runner will either block until the thread has completed or
  2364 			//Depending on the value of iConcurrentTest the test runner will
  2351 			//alternatively run the current test case on the next channel:
  2365 			//either block until the thread has completed or alternatively run
  2352 
  2366 			//the current test case on the next channel: if the test case has
  2353 			//if the test case has been run on all channels it will then  wait for all threads to complete.
  2367 			//been run on all channels it will then wait for all threads to
       
  2368 			//complete.
  2354 			}
  2369 			}
  2355 
  2370 
  2356 		// Run the tests which should happen concurrently
  2371 		// Run the tests which should happen concurrently
  2357 		const TInt count = concurrentTests.Count();
  2372 		const TInt count = concurrentTests.Count();
  2358 		if(count>0)
  2373 		if(count>0)
  2697 		TBool doFrag = KSimTests[i].iFragment;
  2712 		TBool doFrag = KSimTests[i].iFragment;
  2698 
  2713 
  2699 		test.Start(_L("Open channel"));
  2714 		test.Start(_L("Open channel"));
  2700 		TUint channelCookie=0;
  2715 		TUint channelCookie=0;
  2701 		r = session.ChannelOpen(pslId, channelCookie);
  2716 		r = session.ChannelOpen(pslId, channelCookie);
  2702 		test.Printf(_L("Open channel %d, cookie recived = 0x%08x\n"), pslId, channelCookie);
  2717 		test.Printf(_L("Open channel %d, cookie received = 0x%08x\n"), pslId, channelCookie);
  2703 		test_KErrNone(r);
  2718 		test_KErrNone(r);
  2704 
  2719 
  2705 		test.Next(_L("Create Dma request"));
  2720 		test.Next(_L("Create Dma request"));
  2706 
  2721 
  2707 		TUint reqCookie=0;
  2722 		TUint reqCookie=0;
  2708 		r = session.RequestCreate(channelCookie, reqCookie);
  2723 		r = session.RequestCreate(channelCookie, reqCookie);
  2709 		test.Printf(_L("cookie recived = 0x%08x\n"), reqCookie );
  2724 		test.Printf(_L("cookie received = 0x%08x\n"), reqCookie );
  2710 		test_KErrNone(r);
  2725 		test_KErrNone(r);
  2711 
  2726 
  2712 		if(doFrag)
  2727 		if(doFrag)
  2713 			{
  2728 			{
  2714 			test.Next(_L("Fragment request"));
  2729 			test.Next(_L("Fragment request"));
  2734 	test.End();
  2749 	test.End();
  2735 	}
  2750 	}
  2736 
  2751 
  2737 TInt E32Main()
  2752 TInt E32Main()
  2738 	{
  2753 	{
       
  2754 	COMPLETE_POST_BOOT_SYSTEM_TASKS();
  2739 	__UHEAP_MARK;
  2755 	__UHEAP_MARK;
  2740 	test.Title();
  2756 	test.Title();
  2741 
  2757 
  2742 	gHelpRequested = EFalse;
  2758 	gHelpRequested = EFalse;
  2743 	TInt r;
  2759 	TInt r;
  2760 	if (gHelpRequested)
  2776 	if (gHelpRequested)
  2761 		{
  2777 		{
  2762 		PrintUsage();
  2778 		PrintUsage();
  2763 		User::Leave(-2);	// nothing to do!
  2779 		User::Leave(-2);	// nothing to do!
  2764 		}
  2780 		}
       
  2781 
       
  2782 	RProcess p;
       
  2783 	RThread t;
       
  2784 #if defined(DMA_INVERTED_THREAD_PRIORITIES)
       
  2785 	// Set the process priority to the maximum value allowed for normal apps.
       
  2786 	// This will increase the system's interpretation of the thread priority.
       
  2787 	test(p.SetPriority(EPriorityHigh) == KErrNone);
       
  2788 	t.SetPriority(EPriorityRealTime);
       
  2789 #else
       
  2790 	t.SetPriority(EPriorityLess);
       
  2791 #endif	// #if defined(DMA_INVERTED_THREAD_PRIORITIES)
       
  2792 	RDebug::Printf("Process priority:  %d", p.Priority());
       
  2793 
  2765 	test.Start(_L("Loading test LDD"));
  2794 	test.Start(_L("Loading test LDD"));
  2766 	//load either the new test ldd, d_dma2.ldd,
  2795 	//load either the new test ldd, d_dma2.ldd,
  2767 	//or d_dma2_compat.ldd - an ldd linked against
  2796 	//or d_dma2_compat.ldd - an ldd linked against
  2768 	//the old DMA framework
  2797 	//the old DMA framework
  2769 	_LIT(KDma, "D_DMA2.LDD");
  2798 	_LIT(KDma, "D_DMA2.LDD");
  2806 		{
  2835 		{
  2807 		test.Printf(_L("Failed to load %S, r=%d\n"), &KDma2Sim, r);
  2836 		test.Printf(_L("Failed to load %S, r=%d\n"), &KDma2Sim, r);
  2808 		test(EFalse);
  2837 		test(EFalse);
  2809 		}
  2838 		}
  2810 
  2839 
  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;
  2840 	__KHEAP_MARK;
  2818 
  2841 
  2819 	if (gSelfTest) //Run self tests if specified on command line
  2842 	if (gSelfTest) //Run self tests if specified on command line
  2820 		{
  2843 		{
  2821 		SelfTests();
  2844 		SelfTests();