kerneltest/f32test/server/t_falsespace.cpp
changeset 139 95f71bcdcdb7
parent 109 b3a1d9898418
child 152 657f875b013e
equal deleted inserted replaced
109:b3a1d9898418 139:95f71bcdcdb7
  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()
       
  1058 	{
       
  1059 	test.Next(_L("Verifying RFs::ReserveDriveSpace() triggers RFs::NotifyDiskSpace() events"));
       
  1060 
       
  1061 	TInt64 freeSpace;
       
  1062 	GetFreeDiskSpace(freeSpace);
       
  1063 	test.Printf(_L("free space: 0x%Lx bytes\n"), freeSpace);
       
  1064 
       
  1065 	// set a notification on half the amount we plan to reserve
       
  1066 	TInt reserve = 4096;
       
  1067 	TInt64 trigger = freeSpace - 2048;
       
  1068 	test.Printf(_L("setting notification for space to fall below: 0x%Lx bytes ... "), trigger);
       
  1069 	TRequestStatus stat;
       
  1070 	TheFs.NotifyDiskSpace(trigger, gTestDrive, stat);
       
  1071 	test_Value(stat.Int(), stat == KRequestPending);
       
  1072 	test.Printf(_L("ok\n"));
       
  1073 
       
  1074 	// reserve the space and validate that this triggers the notification
       
  1075 	test.Printf(_L("reserving 0x%x bytes ..."), reserve);
       
  1076 	TInt r = TheFs.ReserveDriveSpace(gTestDrive, reserve);
       
  1077 	test_KErrNone(r);
       
  1078 	test.Printf(_L("ok\n"));
       
  1079 
       
  1080 	test.Printf(_L("validating that the disk space notification triggered ... "));
       
  1081 	User::After(2000000);	// 2 seconds should be enough to cause the trigger
       
  1082 	test_Value(stat.Int(), stat == KErrNone);
       
  1083 	test.Printf(_L("ok\n"));
       
  1084 	}
       
  1085 
       
  1086 
       
  1087 
  1057 //-----------------------------------------------------------------------------
  1088 //-----------------------------------------------------------------------------
  1058 
  1089 
  1059 GLDEF_C void CallTestsL()
  1090 GLDEF_C void CallTestsL()
  1060 //
  1091 //
  1061 // Do tests relative to session path
  1092 // Do tests relative to session path
  1062 //
  1093 //
  1063 	{
  1094 	{
  1064     //-- set up console output 
  1095 	//-- set up console output 
  1065     Fat_Test_Utils::SetConsole(test.Console()); 
  1096 	Fat_Test_Utils::SetConsole(test.Console()); 
  1066 	
  1097 	
  1067 	if (UserSvr::DebugMask(2)&0x00000002) // TESTFAST mode set? (for automated test builds)
  1098 	// If TESTFAST mode (for automated test builds) is set, don't run LFFS tests.
  1068 		if(IsTestingLFFS())
  1099 	if ((UserSvr::DebugMask(2) & 0x00000002) && IsTestingLFFS())
  1069 			{
  1100 		{
  1070 			// Don't run on LFFS (to increase speed of automated testing)
  1101 		test.Printf(_L("TEST NOT RUN FOR LFFS DRIVE"));
  1071 			test.Printf(_L("TEST NOT RUN FOR THIS DRIVE"));
  1102 		return;
  1072 			return;
  1103 		}
  1073 			}
       
  1074 
  1104 
  1075 	//get the number of the drive we are currently testing
  1105 	//get the number of the drive we are currently testing
  1076 	TInt r=0;
  1106 	TInt r=0;
  1077 	r=RFs::CharToDrive(gSessionPath[0],gTestDrive);
  1107 	r=RFs::CharToDrive(gSessionPath[0],gTestDrive);
  1078     test_KErrNone(r);
  1108 	test_KErrNone(r);
  1079 
  1109 
  1080 	r=RFs::DriveToChar(gTestDrive,gCh);
  1110 	r=RFs::DriveToChar(gTestDrive,gCh);
  1081 	test_KErrNone(r);
  1111 	test_KErrNone(r);
  1082 
  1112 
  1083     TDriveInfo drv;
  1113 	TDriveInfo drv;
  1084     r = TheFs.Drive(drv, gTestDrive);
  1114 	r = TheFs.Drive(drv, gTestDrive);
  1085     test_KErrNone(r);
  1115 	test_KErrNone(r);
  1086 
  1116 
  1087     if (Is_Win32(TheFs, gTestDrive))
  1117 
  1088         {
  1118 	//-- print drive information
  1089         test.Printf(_L("Skipping on emulator %C: drive\n"), gSessionPath[0]);
  1119 	PrintDrvInfo(TheFs, gTestDrive);
  1090         return;
  1120 
  1091         }
  1121 
  1092 
  1122 	// do not run the remainder of this test on RAM drive
  1093     // do not run this test on RAM drive
  1123 	if (drv.iType == EMediaRam)
  1094     if (drv.iType == EMediaRam)
  1124 		{
  1095         {
  1125 		TestRAMDriveNotification();	// Test drive space reservations trigger disk space notifications
  1096         test.Printf(_L("Test can't run on RAM drive %C:\n"), gSessionPath[0]);
  1126 		test.Printf(_L("Main tests can't run on RAM drive %C:\n"), gSessionPath[0]);
  1097         return;
  1127 		return;
  1098         }
  1128 		}
  1099 
  1129 
  1100     //-- print drive information
  1130 	if (Is_Win32(TheFs, gTestDrive))
  1101     PrintDrvInfo(TheFs, gTestDrive);
  1131 		{
  1102 
  1132 		test.Printf(_L("Skipping on emulator %C: drive\n"), gSessionPath[0]);
  1103 	Test1();	//General test for new APIs
  1133 		return;
  1104 	Test2();	//Test to ensure drive and session reserve limits are not exceeded
  1134 		}
       
  1135 
       
  1136 	Test1();	// General test for new APIs
       
  1137 	Test2();	// Test to ensure drive and session reserve limits are not exceeded
  1105 	Test3();
  1138 	Test3();
  1106 	Test4();	//test filling the drive and that each checked API fails
  1139 	Test4();	// test filling the drive and that each checked API fails
  1107 	Test5();
  1140 	Test5();
  1108 	Test6();
  1141 	Test6();
  1109 	Test7();
  1142 	Test7();
  1110 	TestForDEF142554();
  1143 	TestForDEF142554();
  1111 	Test2();	//run this test to check reserves are being cleared correctly
  1144 	Test2();	// run this test to check reserves are being cleared correctly
  1112 
  1145 
  1113 	TestFAT4G_Boundary();
  1146 	TestFAT4G_Boundary();
  1114     
  1147     
  1115     TurnAllocFailureOff();
  1148 	TurnAllocFailureOff();
  1116 	}
  1149 	}
  1117 
       
  1118 
       
  1119 
       
  1120