1116 TheTest.Printf(_L("\r\n")); |
1120 TheTest.Printf(_L("\r\n")); |
1117 } |
1121 } |
1118 TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt); |
1122 TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt); |
1119 } |
1123 } |
1120 |
1124 |
|
1125 /** |
|
1126 @SYMTestCaseID PDS-SQL-UT-4207 |
|
1127 @SYMTestCaseDesc RFileBuf64::Write() OOM test. |
|
1128 The test calls RFileBuf64:Write() in an OOM |
|
1129 simulation loop and verifies that no memory is leaked. |
|
1130 The test also check that RFileBuf::DoSetCapacity() correctly operates in |
|
1131 "out of memory" situation. |
|
1132 @SYMTestActions RFileBuf64::Write() OOM test. |
|
1133 @SYMTestExpectedResults Test must not fail |
|
1134 @SYMTestPriority High |
|
1135 @SYMDEF 380056 |
|
1136 */ |
|
1137 void WriteOomTest() |
|
1138 { |
|
1139 HBufC8* databuf = HBufC8::New(KPageSize); |
|
1140 TEST(databuf != NULL); |
|
1141 TPtr8 dataptr = databuf->Des(); |
|
1142 dataptr.SetLength(KPageSize); |
|
1143 dataptr.Fill(TChar(KChar)); |
|
1144 |
|
1145 TInt err = KErrNoMemory; |
|
1146 TInt failingAllocationNo = 0; |
|
1147 TheTest.Printf(_L("Iteration:\r\n")); |
|
1148 while(err == KErrNoMemory) |
|
1149 { |
|
1150 TheTest.Printf(_L(" %d"), ++failingAllocationNo); |
|
1151 |
|
1152 (void)TheFs.Delete(KTestFile); |
|
1153 |
|
1154 MarkHandles(); |
|
1155 MarkAllocatedCells(); |
|
1156 |
|
1157 __UHEAP_MARK; |
|
1158 __UHEAP_SETBURSTFAIL(RAllocator::EBurstFailNext, failingAllocationNo, KBurstRate); |
|
1159 |
|
1160 const TInt KDefaultBufCapacity = 1024; |
|
1161 RFileBuf64 fbuf(KDefaultBufCapacity); |
|
1162 err = fbuf.Create(TheFs, KTestFile, EFileWrite | EFileRead); |
|
1163 if(err == KErrNone) |
|
1164 { |
|
1165 err = fbuf.Write(0LL, dataptr); |
|
1166 } |
|
1167 fbuf.Close(); |
|
1168 |
|
1169 __UHEAP_RESET; |
|
1170 __UHEAP_MARKEND; |
|
1171 |
|
1172 CheckAllocatedCells(); |
|
1173 CheckHandles(); |
|
1174 } |
|
1175 TEST2(err, KErrNone); |
|
1176 RFile64 file; |
|
1177 err = file.Open(TheFs, KTestFile, EFileRead); |
|
1178 TEST2(err, KErrNone); |
|
1179 dataptr.Zero(); |
|
1180 err = file.Read(dataptr); |
|
1181 TEST2(err, KErrNone); |
|
1182 file.Close(); |
|
1183 TEST2(dataptr.Length(), KPageSize); |
|
1184 for(TInt i=0;i<KPageSize;++i) |
|
1185 { |
|
1186 TEST(dataptr[i] == KChar); |
|
1187 } |
|
1188 TheTest.Printf(_L("\r\n=== OOM Test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo); |
|
1189 |
|
1190 //The file is left undeleted - to be used in ReadOomTest(). |
|
1191 delete databuf; |
|
1192 } |
|
1193 |
|
1194 /** |
|
1195 @SYMTestCaseID PDS-SQL-UT-4208 |
|
1196 @SYMTestCaseDesc RFileBuf64::Read() OOM test. |
|
1197 The test calls RFileBuf64:Read() in an OOM |
|
1198 simulation loop and verifies that no memory is leaked. |
|
1199 The test also check that RFileBuf::DoSetCapacity() correctly operates in |
|
1200 "out of memory" situation. |
|
1201 @SYMTestActions RFileBuf64::Read() OOM test. |
|
1202 @SYMTestExpectedResults Test must not fail |
|
1203 @SYMTestPriority High |
|
1204 @SYMDEF 380056 |
|
1205 */ |
|
1206 void ReadOomTest() |
|
1207 { |
|
1208 HBufC8* databuf = HBufC8::New(KPageSize); |
|
1209 TEST(databuf != NULL); |
|
1210 TPtr8 dataptr = databuf->Des(); |
|
1211 |
|
1212 TInt err = KErrNoMemory; |
|
1213 TInt failingAllocationNo = 0; |
|
1214 TheTest.Printf(_L("Iteration:\r\n")); |
|
1215 while(err == KErrNoMemory) |
|
1216 { |
|
1217 TheTest.Printf(_L(" %d"), ++failingAllocationNo); |
|
1218 |
|
1219 MarkHandles(); |
|
1220 MarkAllocatedCells(); |
|
1221 |
|
1222 __UHEAP_MARK; |
|
1223 __UHEAP_SETBURSTFAIL(RAllocator::EBurstFailNext, failingAllocationNo, KBurstRate); |
|
1224 |
|
1225 const TInt KDefaultBufCapacity = 1024; |
|
1226 RFileBuf64 fbuf(KDefaultBufCapacity); |
|
1227 err = fbuf.Open(TheFs, KTestFile, EFileRead); |
|
1228 if(err == KErrNone) |
|
1229 { |
|
1230 err = fbuf.Read(0LL, dataptr); |
|
1231 } |
|
1232 fbuf.Close(); |
|
1233 |
|
1234 __UHEAP_RESET; |
|
1235 __UHEAP_MARKEND; |
|
1236 |
|
1237 CheckAllocatedCells(); |
|
1238 CheckHandles(); |
|
1239 } |
|
1240 TEST2(err, KErrNone); |
|
1241 RFile64 file; |
|
1242 err = file.Open(TheFs, KTestFile, EFileRead); |
|
1243 TEST2(err, KErrNone); |
|
1244 dataptr.Zero(); |
|
1245 err = file.Read(dataptr); |
|
1246 TEST2(err, KErrNone); |
|
1247 file.Close(); |
|
1248 TEST2(dataptr.Length(), KPageSize); |
|
1249 for(TInt i=0;i<KPageSize;++i) |
|
1250 { |
|
1251 TEST(dataptr[i] == KChar); |
|
1252 } |
|
1253 TheTest.Printf(_L("\r\n=== OOM Test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo); |
|
1254 |
|
1255 (void)TheFs.Delete(KTestFile); |
|
1256 delete databuf; |
|
1257 } |
|
1258 |
1121 void DoTests() |
1259 void DoTests() |
1122 { |
1260 { |
1123 TheTest.Start(_L(" @SYMTestCaseID:PDS-SQL-UT-4132 RFileBuf64 write test 1")); |
1261 TheTest.Start(_L(" @SYMTestCaseID:PDS-SQL-UT-4132 RFileBuf64 write test 1")); |
1124 WriteTest1(); |
1262 WriteTest1(); |
1125 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4133 RFileBuf64 write test 2")); |
1263 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4133 RFileBuf64 write test 2")); |
1150 OomTest(EOomCreateTest); |
1288 OomTest(EOomCreateTest); |
1151 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4142 RFileBuf64::Open() OOM test")); |
1289 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4142 RFileBuf64::Open() OOM test")); |
1152 OomTest(EOomOpenTest); |
1290 OomTest(EOomOpenTest); |
1153 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4142 RFileBuf64::Temp() OOM test")); |
1291 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4142 RFileBuf64::Temp() OOM test")); |
1154 OomTest(EOomTempTest); |
1292 OomTest(EOomTempTest); |
|
1293 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4207 RFileBuf64::Write() OOM test")); |
|
1294 WriteOomTest(); |
|
1295 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4208 RFileBuf64::Read() OOM test")); |
|
1296 ReadOomTest(); |
1155 |
1297 |
1156 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4195 RFileBuf64::Create() file I/O error simulation test")); |
1298 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4195 RFileBuf64::Create() file I/O error simulation test")); |
1157 CreateFileIoErrTest(); |
1299 CreateFileIoErrTest(); |
1158 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4196 RFileBuf64::Open() file I/O error simulation test")); |
1300 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4196 RFileBuf64::Open() file I/O error simulation test")); |
1159 OpenFileIoErrTest(); |
1301 OpenFileIoErrTest(); |