kerneltest/f32test/demandpaging/t_nandpaging.cpp
changeset 109 b3a1d9898418
parent 33 0173bcd7697c
child 132 e4a7b1cbe40c
child 210 b592f7984442
equal deleted inserted replaced
102:ef2a444a7410 109:b3a1d9898418
    26 //! @SYMTestActions			001 Check that the rom is paged
    26 //! @SYMTestActions			001 Check that the rom is paged
    27 //! @SYMTestExpectedResults All tests should pass.
    27 //! @SYMTestExpectedResults All tests should pass.
    28 //! @SYMTestPriority        High
    28 //! @SYMTestPriority        High
    29 //! @SYMTestStatus          Implemented
    29 //! @SYMTestStatus          Implemented
    30 
    30 
       
    31 #define __E32TEST_EXTENSION__
    31 #include <e32test.h>
    32 #include <e32test.h>
    32 RTest test(_L("T_NANDPAGING"));
    33 RTest test(_L("T_NANDPAGING"));
    33 
    34 
    34 #include <e32rom.h>
    35 #include <e32rom.h>
    35 #include <e32svr.h>
    36 #include <e32svr.h>
    36 #include <u32hal.h>
    37 #include <u32hal.h>
    37 #include <f32file.h>
    38 #include <f32file.h>
    38 #include <f32dbg.h>
    39 #include <f32dbg.h>
    39 #include "testdefs.h"
    40 #include "testdefs.h"
    40 #include <hal.h>
    41 #include <hal.h>
       
    42 #include "nfe.h"
    41 
    43 
    42 
    44 
    43 TInt DriveNumber=-1;   // Parameter - Which drive?  -1 = autodetect.
    45 TInt DriveNumber=-1;   // Parameter - Which drive?  -1 = autodetect.
    44 TInt locDriveNumber;
    46 TInt locDriveNumber;
    45 
    47 
   542 		{
   544 		{
   543 		test.Next(_L("Defering test - Skipped!"));
   545 		test.Next(_L("Defering test - Skipped!"));
   544 		return;
   546 		return;
   545 		}
   547 		}
   546 		
   548 		
       
   549 	// If the NFE test media driver extension is present, ALL the drive is encrypted;
       
   550 	// this means that there will be very few free blocks in the free block reservoir: this effectively 
       
   551 	// disables background garbage collection and all block erasing needs to happen on the fly...
       
   552 	TNfeDeviceInfo nfeDeviceinfo;
       
   553 	TPtr8 nfeDeviceInfoBuf((TUint8*) &nfeDeviceinfo, sizeof(nfeDeviceinfo));
       
   554 	nfeDeviceInfoBuf.FillZ();
       
   555 	TInt r = Drive.QueryDevice((RLocalDrive::TQueryDevice) EQueryNfeDeviceInfo, nfeDeviceInfoBuf);
       
   556 /*
       
   557 	if (r == KErrNone)
       
   558 		{
       
   559 		test.Printf(_L("NFE device detected, aborting garbage collection test for now\n"));
       
   560 		return;
       
   561 		}
       
   562 */
       
   563 	// Create some free blocks by creating a huge file and then deleting it....
       
   564 	if (r == KErrNone)
       
   565 		{
       
   566 		test.Printf(_L("NFE device detected\n"));
       
   567 		RFile file;
       
   568 
       
   569 		TBuf<256> tempFileName = _L("?:\\f32-tst\\");
       
   570 		tempFileName[0] = 'A'+DriveNumber;
       
   571 
       
   572 		r = TheFs.MkDirAll(tempFileName);
       
   573 		test(r==KErrNone || r== KErrAlreadyExists);
       
   574 
       
   575 		tempFileName+= _L("TEMP.TXT");
       
   576 
       
   577 		r = file.Replace(TheFs, tempFileName, EFileWrite);
       
   578 		test_KErrNone(r);
       
   579 		
       
   580 		for (TInt fileSize = KMaxTInt; fileSize > 0; fileSize >>= 1)
       
   581 			{
       
   582 			r = file.SetSize(fileSize);
       
   583 			test.Printf(_L("Setting file size to %d, r %d\n"), fileSize, r);
       
   584 			if (r == KErrNone)
       
   585 				break;
       
   586 			}
       
   587 		file.Close();
       
   588 		r = TheFs.Delete(tempFileName);
       
   589 		test_KErrNone(r);
       
   590 		}
       
   591 
       
   592 
       
   593 
   547 	TInt timeout;
   594 	TInt timeout;
   548 	TInt writesNeeded=100;
   595 	TInt writesNeeded=100;
   549 	TInt r = KErrNone;
       
   550 	RFile tempFile;
   596 	RFile tempFile;
   551 	TInt i;
   597 	TInt i;
   552 	TInt ii;
   598 	TInt ii;
   553 	TInt runs=0;
   599 	TInt runs=0;
   554 
   600 
   591 	CreateFile(tempFile,_L("nandpage.txt"));
   637 	CreateFile(tempFile,_L("nandpage.txt"));
   592 		
   638 		
   593 	 	
   639 	 	
   594 	for (ii=0; ii<MaxDeferLoops; ii++)  // Repeat the test, 'MaxDeferLoops' number of times.  This can be set on cammand line.
   640 	for (ii=0; ii<MaxDeferLoops; ii++)  // Repeat the test, 'MaxDeferLoops' number of times.  This can be set on cammand line.
   595 		{
   641 		{
       
   642 		writesNeeded=100;
   596 		timeout=20;
   643 		timeout=20;
   597 		do  // while ((pageGarbageCount==0) && (timeout>0));
   644 		do  // while ((pageGarbageCount==0) && (timeout>0));
   598 			// ie, while garbage collection hasn't happened, or timed out
   645 			// ie, while garbage collection hasn't happened, or timed out
   599 			{
   646 			{
   600 			timeout--;
   647 			timeout--;