kerneltest/f32test/server/t_falsespace.cpp
changeset 152 657f875b013e
parent 139 95f71bcdcdb7
child 200 73ea206103e6
equal deleted inserted replaced
139:95f71bcdcdb7 152:657f875b013e
  1047 	
  1047 	
  1048 	nRes = TheFs.Delete(KBaseFN);
  1048 	nRes = TheFs.Delete(KBaseFN);
  1049 	test_KErrNone(nRes);
  1049 	test_KErrNone(nRes);
  1050     for(i=0; i<MaxDummyFiles; ++i)
  1050     for(i=0; i<MaxDummyFiles; ++i)
  1051 	    {
  1051 	    {
  1052         nRes = DeleteFileX(KBaseFN, i); 
  1052         nRes = DeleteFileX(KBaseFN, i);
  1053         test_KErrNone(nRes);
  1053         test_KErrNone(nRes);
  1054 		}
  1054 		}
  1055 	}
  1055 	}
  1056 
  1056 
  1057 void TestRAMDriveNotification()
  1057 void TestRAMDriveNotification()
  1082 	test_Value(stat.Int(), stat == KErrNone);
  1082 	test_Value(stat.Int(), stat == KErrNone);
  1083 	test.Printf(_L("ok\n"));
  1083 	test.Printf(_L("ok\n"));
  1084 	}
  1084 	}
  1085 
  1085 
  1086 
  1086 
  1087 
       
  1088 //-----------------------------------------------------------------------------
  1087 //-----------------------------------------------------------------------------
       
  1088 /**
       
  1089     Test that the reserving some drive space does not takes more space than required.
       
  1090 */
       
  1091 void Test0()
       
  1092 {
       
  1093     test.Next(_L("test ReserveDriveSpace threshold"));
       
  1094 
       
  1095     TInt nRes;
       
  1096     TVolumeIOParamInfo volIop;
       
  1097     TInt64 freespace=0;
       
  1098 
       
  1099     //-- 1. format the volume
       
  1100     FormatDrive();
       
  1101 
       
  1102     GetFreeDiskSpace(freespace);
       
  1103     const TInt64 freeSpace1 = freespace; //-- initial amount of free space on the volume
       
  1104 
       
  1105     nRes = TheFs.VolumeIOParam(gTestDrive, volIop);
       
  1106     test_KErrNone(nRes);
       
  1107     const TInt KClusterSz = volIop.iClusterSize;
       
  1108     if(!IsPowerOf2(KClusterSz))
       
  1109         {
       
  1110         test.Next(_L("The FS hasn't reported a cluster size. The test is inconsistent, skipping"));
       
  1111         return;
       
  1112         }
       
  1113 
       
  1114     //-- reserve exactly 1 cluster worth drive space.
       
  1115     nRes = TheFs.ReserveDriveSpace(gTestDrive, KClusterSz);
       
  1116     test_KErrNone(nRes);
       
  1117 
       
  1118     GetFreeDiskSpace(freespace);
       
  1119     const TInt64 freeSpace2 = freespace;
       
  1120     test((freeSpace1 - freeSpace2) == KClusterSz);
       
  1121 
       
  1122     //-- fill up a drive (it has a reserved space)
       
  1123     FillUpDisk();
       
  1124 
       
  1125     //-- delete 1 file; 
       
  1126     nRes = DeleteFileX(KBaseName, 0);
       
  1127     test_KErrNone(nRes);
       
  1128 
       
  1129     //-- try to create a file with the size that is exacly the same as free space; it should succeed
       
  1130     GetFreeDiskSpace(freespace);
       
  1131     
       
  1132     nRes = CreateEmptyFile(TheFs, _L("\\aaa1"), freespace);
       
  1133     test_KErrNone(nRes);
       
  1134 
       
  1135     GetFreeDiskSpace(freespace);
       
  1136     test(freespace == 0);
       
  1137 
       
  1138     //-- return the drive space to the system
       
  1139 	nRes = TheFs.ReserveDriveSpace(gTestDrive,0);
       
  1140 	test_KErrNone(nRes); 
       
  1141 
       
  1142     //-- release drive space
       
  1143     nRes = TheFs.ReleaseReserveAccess(gTestDrive);
       
  1144     test_KErrNone(nRes);
       
  1145 
       
  1146     GetFreeDiskSpace(freespace);
       
  1147     test(freespace == KClusterSz);
       
  1148 
       
  1149     FormatDrive();
       
  1150 }
       
  1151 
       
  1152 //-----------------------------------------------------------------------------
  1089 
  1153 
  1090 GLDEF_C void CallTestsL()
  1154 GLDEF_C void CallTestsL()
  1091 //
  1155 //
  1092 // Do tests relative to session path
  1156 // Do tests relative to session path
  1093 //
  1157 //
  1094 	{
  1158 	{
  1095 	//-- set up console output 
  1159 	//-- set up console output
  1096 	Fat_Test_Utils::SetConsole(test.Console()); 
  1160 	Fat_Test_Utils::SetConsole(test.Console());
  1097 	
  1161 
  1098 	// If TESTFAST mode (for automated test builds) is set, don't run LFFS tests.
  1162 	// If TESTFAST mode (for automated test builds) is set, don't run LFFS tests.
  1099 	if ((UserSvr::DebugMask(2) & 0x00000002) && IsTestingLFFS())
  1163 	if ((UserSvr::DebugMask(2) & 0x00000002) && IsTestingLFFS())
  1100 		{
  1164 		{
  1101 		test.Printf(_L("TEST NOT RUN FOR LFFS DRIVE"));
  1165 		test.Printf(_L("TEST NOT RUN FOR LFFS DRIVE"));
  1102 		return;
  1166 		return;
  1131 		{
  1195 		{
  1132 		test.Printf(_L("Skipping on emulator %C: drive\n"), gSessionPath[0]);
  1196 		test.Printf(_L("Skipping on emulator %C: drive\n"), gSessionPath[0]);
  1133 		return;
  1197 		return;
  1134 		}
  1198 		}
  1135 
  1199 
       
  1200     Test0();
  1136 	Test1();	// General test for new APIs
  1201 	Test1();	// General test for new APIs
  1137 	Test2();	// Test to ensure drive and session reserve limits are not exceeded
  1202 	Test2();	// Test to ensure drive and session reserve limits are not exceeded
  1138 	Test3();
  1203 	Test3();
  1139 	Test4();	// test filling the drive and that each checked API fails
  1204 	Test4();	// test filling the drive and that each checked API fails
  1140 	Test5();
  1205 	Test5();
  1142 	Test7();
  1207 	Test7();
  1143 	TestForDEF142554();
  1208 	TestForDEF142554();
  1144 	Test2();	// run this test to check reserves are being cleared correctly
  1209 	Test2();	// run this test to check reserves are being cleared correctly
  1145 
  1210 
  1146 	TestFAT4G_Boundary();
  1211 	TestFAT4G_Boundary();
  1147     
  1212 
  1148 	TurnAllocFailureOff();
  1213 	TurnAllocFailureOff();
  1149 	}
  1214 	}