kerneltest/e32test/demandpaging/t_datapaging.cpp
branchRCL_3
changeset 110 c734af59ce98
parent 33 0173bcd7697c
child 256 c1f20ce4abcf
--- a/kerneltest/e32test/demandpaging/t_datapaging.cpp	Tue Apr 27 18:02:57 2010 +0300
+++ b/kerneltest/e32test/demandpaging/t_datapaging.cpp	Tue May 11 17:28:22 2010 +0300
@@ -44,9 +44,10 @@
 #include "../mmu/d_memorytest.h"
 #include "../mmu/paging_info.h"
 
-RTest test(_L("T_DATAPAGING"));
+_LIT(KChunkName, "t_datapaging chunk");
 
-_LIT(KChunkName, "t_datapaging chunk");
+RTest test(_L("T_DATAPAGING"));
+SVMSwapInfo InitialSwapInfo;
 
 class TRandom
 	{
@@ -235,7 +236,7 @@
 		CLOSE_AND_WAIT(thread);
 		}
 	CLOSE_AND_WAIT(gChunk);
-	User::After(1000000);
+	UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0);
 	__KHEAP_MARKEND;
 	}
 
@@ -330,8 +331,8 @@
 	if (aActual != aExpected)
 		{
 		StopSoakTest(aMsgQueue);
-		RDebug::Printf("  thread %d failure reading page %d at iteration %d address %08x: expected %08x but got %08x",
-					   aThread, aPage, aIteration, aPtr, aExpected, aActual);
+		RDebug::Printf("  thread %d failure reading page %d at iteration %d address %08x line %d: expected %08x but got %08x",
+					   aThread, aPage, aIteration, aPtr, aLine, aExpected, aActual);
 		return EFalse;
 		}
 	return ETrue;
@@ -341,7 +342,6 @@
 	{
 	SSoakTestArgs* args = (SSoakTestArgs*)aArg;
 
-	
 	RMsgQueue<TInt> msgQueue;
 	TInt r = msgQueue.OpenGlobal(KMsgQueueName, EOwnerThread);
 	if (r != KErrNone)
@@ -595,41 +595,35 @@
 	test(swapInfo.iSwapFree <= swapInfo.iSwapSize);
 	test.Printf(_L("  Swap size == 0x%x bytes\n"), swapInfo.iSwapSize);
 	test.Printf(_L("  Swap free == 0x%x bytes\n"), swapInfo.iSwapFree);
-	if (!gDataPagingSupported)
-		{
-		test_Equal(0, swapInfo.iSwapSize);
-		}
-	else
-		{
-		test(swapInfo.iSwapSize != 0);
+	test(swapInfo.iSwapSize != 0);
+	InitialSwapInfo = swapInfo;
 		
-		CommitPage(chunk, 0);
-		SVMSwapInfo swapInfo2;
-		test_KErrNone(UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, &swapInfo2, 0));
-		test_Equal(swapInfo.iSwapSize, swapInfo2.iSwapSize);
-		test_Equal(swapInfo.iSwapFree - gPageSize, swapInfo2.iSwapFree);
+	CommitPage(chunk, 0);
+	SVMSwapInfo swapInfo2;
+	test_KErrNone(UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, &swapInfo2, 0));
+	test_Equal(swapInfo.iSwapSize, swapInfo2.iSwapSize);
+	test_Equal(swapInfo.iSwapFree - gPageSize, swapInfo2.iSwapFree);
 		
-		DecommitPage(chunk, 0);
-		test_KErrNone(UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, &swapInfo2, 0));
-		test_Equal(swapInfo.iSwapSize, swapInfo2.iSwapSize);
-		test_Equal(swapInfo.iSwapFree, swapInfo2.iSwapFree);
+	DecommitPage(chunk, 0);
+	test_KErrNone(UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, &swapInfo2, 0));
+	test_Equal(swapInfo.iSwapSize, swapInfo2.iSwapSize);
+	test_Equal(swapInfo.iSwapFree, swapInfo2.iSwapFree);
 
-		// Test that closing the chunk releases the swap page.
-		CommitPage(chunk, 0);
-		test_KErrNone(UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, &swapInfo2, 0));
-		test_Equal(swapInfo.iSwapSize, swapInfo2.iSwapSize);
-		test_Equal(swapInfo.iSwapFree - gPageSize, swapInfo2.iSwapFree);
+	// Test that closing the chunk releases the swap page.
+	CommitPage(chunk, 0);
+	test_KErrNone(UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, &swapInfo2, 0));
+	test_Equal(swapInfo.iSwapSize, swapInfo2.iSwapSize);
+	test_Equal(swapInfo.iSwapFree - gPageSize, swapInfo2.iSwapFree);
 		
-		chunk.Close();
-		test_KErrNone(UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, &swapInfo2, 0));
-		test_Equal(swapInfo.iSwapSize, swapInfo2.iSwapSize);
-		test_Equal(swapInfo.iSwapFree, swapInfo2.iSwapFree);
+	chunk.Close();
+	test_KErrNone(UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, &swapInfo2, 0));
+	test_Equal(swapInfo.iSwapSize, swapInfo2.iSwapSize);
+	test_Equal(swapInfo.iSwapFree, swapInfo2.iSwapFree);
 
-		// Chunk must be created for rest of testing.
-		test_KErrNone(chunk.Create(createInfo));
-		if (gDataPagingSupported)
-			test(chunk.IsPaged());
-		}
+	// Chunk must be created for rest of testing.
+	test_KErrNone(chunk.Create(createInfo));
+	if (gDataPagingSupported)
+		test(chunk.IsPaged());
 	
 	//	EVMHalSetSwapThresholds,
 	test.Next(_L("Test EVMHalSetSwapThresholds"));
@@ -690,6 +684,16 @@
 	CLOSE_AND_WAIT(chunk);
 	}
 
+void TestSwapInfoUnchanged()
+	{
+	SVMSwapInfo swapInfo;
+	test_KErrNone(UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, &swapInfo, 0));
+	test.Printf(_L("  Swap size == 0x%x bytes\n"), swapInfo.iSwapSize);
+	test.Printf(_L("  Swap free == 0x%x bytes\n"), swapInfo.iSwapFree);
+	test_Equal(InitialSwapInfo.iSwapSize, swapInfo.iSwapSize);
+	test_Equal(InitialSwapInfo.iSwapFree, swapInfo.iSwapFree);
+	}
+
 void TestSwapHalNotSupported()
 	{
 	test_Equal(KErrNotSupported, UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, 0, 0));
@@ -779,6 +783,9 @@
 	test_KErrNone(timeoutStatus.Int());
 	
 	CLOSE_AND_WAIT(gChunk);
+	
+	UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0);
+	
 	__KHEAP_MARKEND;
 	}
 
@@ -1241,15 +1248,18 @@
 					for (TUint pin = 0 ; pin <= 1 ; ++pin)
 						{
 						test.Printf(_L("processes=%d threads=%d pages=%d maxcachesize=%d pin=%d\r\n"),processes, threads, pages, gMaxCacheSize,pin);
-						SoakTest(processes, threads, pages, pin, 3);
+						SoakTest(processes, threads, pages, pin, 5);
 						}
 					}
 				}
 			}
 
-			//Reset the cache size to normal
-			test.Next(_L("Soak test: Reset cache size to normal"));
-			test_KErrNone(DPTest::SetCacheSize(cacheOriginalMin, cacheOriginalMax)); 
+		//Reset the cache size to normal
+		test.Next(_L("Soak test: Reset cache size to normal"));
+		test_KErrNone(DPTest::SetCacheSize(cacheOriginalMin, cacheOriginalMax)); 
+
+		test.Next(_L("Check we haven't leaked any swap in the course of the test"));
+		TestSwapInfoUnchanged();
 		}
 
 	test.End();