kerneltest/f32test/manager/t_oom.cpp
changeset 109 b3a1d9898418
parent 0 a41df078684a
child 257 3e88ff8f41d5
equal deleted inserted replaced
102:ef2a444a7410 109:b3a1d9898418
    13 // Description:
    13 // Description:
    14 // f32test\manager\t_oom.cpp
    14 // f32test\manager\t_oom.cpp
    15 // 
    15 // 
    16 //
    16 //
    17 
    17 
       
    18 #define	__E32TEST_EXTENSION__
    18 #include <hal.h>
    19 #include <hal.h>
    19 #include <f32file.h>
    20 #include <f32file.h>
    20 #include <e32test.h>
    21 #include <e32test.h>
    21 #include "../server/t_server.h"
    22 #include "../server/t_server.h"
    22 
    23 
    30 
    31 
    31 	test.Next(_L("Format the disk"));
    32 	test.Next(_L("Format the disk"));
    32 	RFormat format;
    33 	RFormat format;
    33 	TFileName sessionPath;
    34 	TFileName sessionPath;
    34 	TInt r=TheFs.SessionPath(sessionPath);
    35 	TInt r=TheFs.SessionPath(sessionPath);
    35 	test(r==KErrNone);
    36 	test_KErrNone(r);
    36 	TInt count;
    37 	TInt count;
    37 	r=format.Open(TheFs,sessionPath,EHighDensity,count);
    38 	r=format.Open(TheFs,sessionPath,EHighDensity,count);
    38 	test(r==KErrNone);
    39 	test_KErrNone(r);
    39 //	test(count==100);
    40 //	test(count==100);
    40 //	TRequestStatus status;
    41 //	TRequestStatus status;
    41 //	TPckgBuf<TInt> step;
    42 //	TPckgBuf<TInt> step;
    42 //	do 	{
    43 //	do 	{
    43 //		format.Next(step,status);
    44 //		format.Next(step,status);
    65 	TUint size=0x340000; // 3.25MB
    66 	TUint size=0x340000; // 3.25MB
    66 	
    67 	
    67 	test.Printf(_L("FileSize = 0x%x\n"),size);
    68 	test.Printf(_L("FileSize = 0x%x\n"),size);
    68 	RFile file;
    69 	RFile file;
    69 	TInt r=file.Replace(TheFs,_L("\\F32-TST\\GOBBLE.DAT"),EFileRead);
    70 	TInt r=file.Replace(TheFs,_L("\\F32-TST\\GOBBLE.DAT"),EFileRead);
    70 	test(r==KErrNone);
    71 	test_KErrNone(r);
    71 	r=file.SetSize(size);
    72 	r=file.SetSize(size);
    72 	test(r==KErrNone || r==KErrDiskFull);
    73 	test_Value(r, r == KErrNone || r==KErrDiskFull);
    73 	if (r==KErrDiskFull)
    74 	if (r==KErrDiskFull)
    74 		{
    75 		{
    75 		TFileName sessionPath;
    76 		TFileName sessionPath;
    76 		r=TheFs.SessionPath(sessionPath);
    77 		r=TheFs.SessionPath(sessionPath);
    77 		test(r==KErrNone);
    78 		test_KErrNone(r);
    78 		test.Printf(_L("Error %S diskfull\n"),&sessionPath);
    79 		test.Printf(_L("Error %S diskfull\n"),&sessionPath);
    79 // Reintroduce when we can detect that the test is being run manually
    80 // Reintroduce when we can detect that the test is being run manually
    80 //		test.Getch();
    81 //		test.Getch();
    81 		}
    82 		}
    82 	file.Close();
    83 	file.Close();
   123 			bfDir.Append(bfDrv);
   124 			bfDir.Append(bfDrv);
   124 			_LIT(KTstDir, "t\\");
   125 			_LIT(KTstDir, "t\\");
   125 			bfDir.Append(KTstDir);
   126 			bfDir.Append(KTstDir);
   126 			test.Printf(_L("creating directory \"%S\".\n"), &bfDir);
   127 			test.Printf(_L("creating directory \"%S\".\n"), &bfDir);
   127 			r = TheFs.MkDir(bfDir);
   128 			r = TheFs.MkDir(bfDir);
   128 			test(r == KErrNone);
   129 			test_KErrNone(r);
   129 
   130 
   130 			TBuf<3 + 3 + 8 + 1 + 3> bfFlNm(bfDir);
   131 			TBuf<3 + 3 + 8 + 1 + 3> bfFlNm(bfDir);
   131 			TInt ctr = 0;						// create files until KErrDiskFull
   132 			TInt ctr = 0;						// create files until KErrDiskFull
   132 			do
   133 			do
   133 				{
   134 				{
   138 					_L("\rcreating %S @ %08x (total %08x)"),
   139 					_L("\rcreating %S @ %08x (total %08x)"),
   139 					&bfFlNm, KFileSize, ctr * KFileSize);
   140 					&bfFlNm, KFileSize, ctr * KFileSize);
   140 
   141 
   141 				RFile f;
   142 				RFile f;
   142 				r = f.Create(TheFs, bfFlNm, EFileShareExclusive | EFileStream | EFileWrite);
   143 				r = f.Create(TheFs, bfFlNm, EFileShareExclusive | EFileStream | EFileWrite);
   143 				test(r == KErrNone || r == KErrDiskFull);
   144 				test_Value(r, r == KErrNone || r == KErrDiskFull);
   144 				if (r == KErrNone)
   145 				if (r == KErrNone)
   145 					{
   146 					{
   146 					r = f.SetSize(KFileSize);
   147 					r = f.SetSize(KFileSize);
   147 					test(r == KErrNone || r == KErrDiskFull);
   148 					test_Value(r, r == KErrNone || r == KErrDiskFull);
   148 					}
   149 					}
   149 				f.Close();
   150 				f.Close();
   150 
   151 
   151 				++ctr;
   152 				++ctr;
   152 				} while (r != KErrDiskFull);
   153 				} while (r != KErrDiskFull);
   182 	test.Title();
   183 	test.Title();
   183 	test.Start(_L("Starting T_OOM test"));
   184 	test.Start(_L("Starting T_OOM test"));
   184 
   185 
   185 	TDriveInfo driveInfo;
   186 	TDriveInfo driveInfo;
   186 	TInt r=TheFs.Drive(driveInfo);
   187 	TInt r=TheFs.Drive(driveInfo);
   187 	test(r==KErrNone);
   188 	test_KErrNone(r);
   188 	if (driveInfo.iType==EMediaNotPresent)
   189 	if (driveInfo.iType==EMediaNotPresent)
   189 		{
   190 		{
   190 		test.Printf(_L("ERROR: MEDIA NOT PRESENT\n"));
   191 		test.Printf(_L("ERROR: MEDIA NOT PRESENT\n"));
   191 // Reintroduce when we can detect that the test is being run manually
   192 // Reintroduce when we can detect that the test is being run manually
   192 //		test.Getch();
   193 //		test.Getch();
   193 		return;
   194 		return;
   194 		}
   195 		}
   195 
   196 
   196 	TFileName sessionPath;
   197 	TFileName sessionPath;
   197 	r=TheFs.SessionPath(sessionPath);
   198 	r=TheFs.SessionPath(sessionPath);
   198 	test(r==KErrNone);
   199 	test_KErrNone(r);
   199 	r=TheFs.MkDirAll(sessionPath);
   200 	r=TheFs.MkDirAll(sessionPath);
   200 	test(r==KErrCorrupt || r==KErrAlreadyExists || r==KErrNone);
   201 	test_Value(r, r == KErrCorrupt || r==KErrAlreadyExists || r==KErrNone);
   201 	if (r==KErrCorrupt)
   202 	if (r==KErrCorrupt)
   202 		FormatFat();
   203 		FormatFat();
   203 	if (r==KErrAlreadyExists)
   204 	if (r==KErrAlreadyExists)
   204 		{
   205 		{
   205 		test.Next(_L("Remove test directory"));
   206 		test.Next(_L("Remove test directory"));
   206 		CFileMan* fman=CFileMan::NewL(TheFs);
   207 		CFileMan* fman=CFileMan::NewL(TheFs);
   207 		TInt ret=fman->RmDir(sessionPath);
   208 		TInt ret=fman->RmDir(sessionPath);
   208 		test(ret==KErrNone);
   209 		test_KErrNone(ret);
   209 		delete fman;
   210 		delete fman;
   210 		}
   211 		}
   211 	if (r!=KErrNone)
   212 	if (r!=KErrNone)
   212 		{
   213 		{
   213 		r=TheFs.MkDirAll(sessionPath);
   214 		r=TheFs.MkDirAll(sessionPath);
   214 		test(r==KErrNone);
   215 		test_KErrNone(r);
   215 		}
   216 		}
   216 
   217 
   217 	Test1();
   218 	Test1();
   218 
   219 
   219 	TestRAMDriveLimit();
   220 	TestRAMDriveLimit();