kerneltest/f32test/demandpaging/t_nandpaging.cpp
changeset 109 b3a1d9898418
parent 33 0173bcd7697c
child 132 e4a7b1cbe40c
child 210 b592f7984442
--- a/kerneltest/f32test/demandpaging/t_nandpaging.cpp	Mon May 03 13:47:38 2010 +0300
+++ b/kerneltest/f32test/demandpaging/t_nandpaging.cpp	Fri May 14 17:13:29 2010 +0300
@@ -28,6 +28,7 @@
 //! @SYMTestPriority        High
 //! @SYMTestStatus          Implemented
 
+#define __E32TEST_EXTENSION__
 #include <e32test.h>
 RTest test(_L("T_NANDPAGING"));
 
@@ -38,6 +39,7 @@
 #include <f32dbg.h>
 #include "testdefs.h"
 #include <hal.h>
+#include "nfe.h"
 
 
 TInt DriveNumber=-1;   // Parameter - Which drive?  -1 = autodetect.
@@ -544,9 +546,53 @@
 		return;
 		}
 		
+	// If the NFE test media driver extension is present, ALL the drive is encrypted;
+	// this means that there will be very few free blocks in the free block reservoir: this effectively 
+	// disables background garbage collection and all block erasing needs to happen on the fly...
+	TNfeDeviceInfo nfeDeviceinfo;
+	TPtr8 nfeDeviceInfoBuf((TUint8*) &nfeDeviceinfo, sizeof(nfeDeviceinfo));
+	nfeDeviceInfoBuf.FillZ();
+	TInt r = Drive.QueryDevice((RLocalDrive::TQueryDevice) EQueryNfeDeviceInfo, nfeDeviceInfoBuf);
+/*
+	if (r == KErrNone)
+		{
+		test.Printf(_L("NFE device detected, aborting garbage collection test for now\n"));
+		return;
+		}
+*/
+	// Create some free blocks by creating a huge file and then deleting it....
+	if (r == KErrNone)
+		{
+		test.Printf(_L("NFE device detected\n"));
+		RFile file;
+
+		TBuf<256> tempFileName = _L("?:\\f32-tst\\");
+		tempFileName[0] = 'A'+DriveNumber;
+
+		r = TheFs.MkDirAll(tempFileName);
+		test(r==KErrNone || r== KErrAlreadyExists);
+
+		tempFileName+= _L("TEMP.TXT");
+
+		r = file.Replace(TheFs, tempFileName, EFileWrite);
+		test_KErrNone(r);
+		
+		for (TInt fileSize = KMaxTInt; fileSize > 0; fileSize >>= 1)
+			{
+			r = file.SetSize(fileSize);
+			test.Printf(_L("Setting file size to %d, r %d\n"), fileSize, r);
+			if (r == KErrNone)
+				break;
+			}
+		file.Close();
+		r = TheFs.Delete(tempFileName);
+		test_KErrNone(r);
+		}
+
+
+
 	TInt timeout;
 	TInt writesNeeded=100;
-	TInt r = KErrNone;
 	RFile tempFile;
 	TInt i;
 	TInt ii;
@@ -593,6 +639,7 @@
 	 	
 	for (ii=0; ii<MaxDeferLoops; ii++)  // Repeat the test, 'MaxDeferLoops' number of times.  This can be set on cammand line.
 		{
+		writesNeeded=100;
 		timeout=20;
 		do  // while ((pageGarbageCount==0) && (timeout>0));
 			// ie, while garbage collection hasn't happened, or timed out