42 |
41 |
43 TUint8* bufPtr=(TUint8*)testBuf.Ptr(); |
42 TUint8* bufPtr=(TUint8*)testBuf.Ptr(); |
44 testBuf.SetLength(testBuf.MaxSize()); |
43 testBuf.SetLength(testBuf.MaxSize()); |
45 Mem::Fill(bufPtr,testBuf.MaxSize(),aCluster); |
44 Mem::Fill(bufPtr,testBuf.MaxSize(),aCluster); |
46 TInt r=aFile.Write(testBuf); |
45 TInt r=aFile.Write(testBuf); |
47 test_KErrNone(r); |
46 test(r==KErrNone); |
48 } |
47 } |
49 |
48 |
50 LOCAL_C void SeekToCluster(RFile& aFile,TInt aCluster) |
49 LOCAL_C void SeekToCluster(RFile& aFile,TInt aCluster) |
51 // |
50 // |
52 // Seek to aCluster and check it is found correctly |
51 // Seek to aCluster and check it is found correctly |
53 // |
52 // |
54 { |
53 { |
55 TBuf8<508> seekBuf(508); |
54 TBuf8<508> seekBuf(508); |
56 TInt r=aFile.Read(aCluster*testBuf.MaxSize(),seekBuf); |
55 TInt r=aFile.Read(aCluster*testBuf.MaxSize(),seekBuf); |
57 test_KErrNone(r); |
56 test(r==KErrNone); |
58 test(seekBuf[0]==(TUint8)aCluster && seekBuf[507]==(TUint8)aCluster); |
57 test(seekBuf[0]==(TUint8)aCluster && seekBuf[507]==(TUint8)aCluster); |
59 } |
58 } |
60 |
59 |
61 LOCAL_C void SeekToCluster(RFile& aFile,TInt aCluster1,TInt aCluster2) |
60 LOCAL_C void SeekToCluster(RFile& aFile,TInt aCluster1,TInt aCluster2) |
62 // |
61 // |
63 // Seek to aCluster and check it is found correctly |
62 // Seek to aCluster and check it is found correctly |
64 // |
63 // |
65 { |
64 { |
66 TBuf8<508> seekBuf(508); |
65 TBuf8<508> seekBuf(508); |
67 TInt r=aFile.Read(aCluster1*testBuf.MaxSize(),seekBuf); |
66 TInt r=aFile.Read(aCluster1*testBuf.MaxSize(),seekBuf); |
68 test_KErrNone(r); |
67 test(r==KErrNone); |
69 test(seekBuf[0]==(TUint8)aCluster1 && seekBuf[507]==(TUint8)aCluster1); |
68 test(seekBuf[0]==(TUint8)aCluster1 && seekBuf[507]==(TUint8)aCluster1); |
70 r=aFile.Read(aCluster2*testBuf.MaxSize(),seekBuf); |
69 r=aFile.Read(aCluster2*testBuf.MaxSize(),seekBuf); |
71 test_KErrNone(r); |
70 test(r==KErrNone); |
72 test(seekBuf[0]==(TUint8)aCluster2 && seekBuf[507]==(TUint8)aCluster2); |
71 test(seekBuf[0]==(TUint8)aCluster2 && seekBuf[507]==(TUint8)aCluster2); |
73 } |
72 } |
74 |
73 |
75 LOCAL_C void ExhaustiveTest(RFile& aFile,TInt aCount1) |
74 LOCAL_C void ExhaustiveTest(RFile& aFile,TInt aCount1) |
76 // |
75 // |
99 |
98 |
100 test.Next(_L("Create interleaved files")); |
99 test.Next(_L("Create interleaved files")); |
101 RFile f1,f2; |
100 RFile f1,f2; |
102 // |
101 // |
103 TInt r=f1.Replace(TheFs,_L("BIGFILE1.TST"),EFileWrite); |
102 TInt r=f1.Replace(TheFs,_L("BIGFILE1.TST"),EFileWrite); |
104 test_KErrNone(r); |
103 test(r==KErrNone); |
105 r=f2.Replace(TheFs,_L("BIGFILE2.TST"),EFileWrite); |
104 r=f2.Replace(TheFs,_L("BIGFILE2.TST"),EFileWrite); |
106 test_KErrNone(r); |
105 test(r==KErrNone); |
107 // |
106 // |
108 TInt maxListLength=4; |
107 TInt maxListLength=4; |
109 TInt i=0,k=0; |
108 TInt i=0,k=0; |
110 TInt countf1=0; |
109 TInt countf1=0; |
111 TInt countf2=0; |
110 TInt countf2=0; |
162 |
161 |
163 test.Next(_L("Regression Protection")); |
162 test.Next(_L("Regression Protection")); |
164 RFile f1,f2; |
163 RFile f1,f2; |
165 // |
164 // |
166 TInt r=f1.Replace(TheFs,_L("BIGFILE1.TST"),EFileWrite); |
165 TInt r=f1.Replace(TheFs,_L("BIGFILE1.TST"),EFileWrite); |
167 test_KErrNone(r); |
166 test(r==KErrNone); |
168 r=f2.Replace(TheFs,_L("BIGFILE2.TST"),EFileWrite); |
167 r=f2.Replace(TheFs,_L("BIGFILE2.TST"),EFileWrite); |
169 test_KErrNone(r); |
168 test(r==KErrNone); |
170 // |
169 // |
171 WriteCluster(f1,0); |
170 WriteCluster(f1,0); |
172 WriteCluster(f1,1); |
171 WriteCluster(f1,1); |
173 WriteCluster(f1,2); |
172 WriteCluster(f1,2); |
174 WriteCluster(f1,3); |
173 WriteCluster(f1,3); |
216 SeekToCluster(f1,cluster2,cluster1); |
215 SeekToCluster(f1,cluster2,cluster1); |
217 } |
216 } |
218 |
217 |
219 test.Next(_L("Increase Size")); |
218 test.Next(_L("Increase Size")); |
220 r=f1.SetSize(1048577); |
219 r=f1.SetSize(1048577); |
221 test_Value(r, r == KErrNone || r==KErrDiskFull); |
220 test(r==KErrNone || r==KErrDiskFull); |
222 if (r==KErrDiskFull) |
221 if (r==KErrDiskFull) |
223 { |
222 { |
224 test.Printf(_L("File too big\n")); |
223 test.Printf(_L("File too big\n")); |
225 f1.Close(); |
224 f1.Close(); |
226 return; |
225 return; |
250 SeekToCluster(f1,cluster2,cluster1); |
249 SeekToCluster(f1,cluster2,cluster1); |
251 } |
250 } |
252 |
251 |
253 test.Next(_L("Reduce file size")); |
252 test.Next(_L("Reduce file size")); |
254 r=f1.SetSize(135000); |
253 r=f1.SetSize(135000); |
255 test_KErrNone(r); |
254 test(r==KErrNone); |
256 |
255 |
257 test.Next(_L("Test data still present")); |
256 test.Next(_L("Test data still present")); |
258 for (j=0;j<200;j++) |
257 for (j=0;j<200;j++) |
259 { |
258 { |
260 TInt cluster1=Math::Rand(TheSeed)%31; |
259 TInt cluster1=Math::Rand(TheSeed)%31; |
283 // |
282 // |
284 : iFile(*aFile), iPos(0) |
283 : iFile(*aFile), iPos(0) |
285 { |
284 { |
286 |
285 |
287 TInt r=iFile.Read(0,iData); |
286 TInt r=iFile.Read(0,iData); |
288 test_KErrNone(r); |
287 test(r==KErrNone); |
289 } |
288 } |
290 |
289 |
291 void TFileReader::Next(TUint8& aVal,TInt& aLength) |
290 void TFileReader::Next(TUint8& aVal,TInt& aLength) |
292 // |
291 // |
293 // Read aLength contiguous bytes with aVal |
292 // Read aLength contiguous bytes with aVal |
425 |
424 |
426 RFile f[KMaxFiles]; |
425 RFile f[KMaxFiles]; |
427 HBufC8* dataBuf=HBufC8::NewL(KMaxBufferLength); |
426 HBufC8* dataBuf=HBufC8::NewL(KMaxBufferLength); |
428 |
427 |
429 TInt r=f[0].Replace(TheFs,_L("TEST1.DAT"),EFileWrite); |
428 TInt r=f[0].Replace(TheFs,_L("TEST1.DAT"),EFileWrite); |
430 test_KErrNone(r); |
429 test(r==KErrNone); |
431 r=f[1].Replace(TheFs,_L("TEST2.DAT"),EFileWrite); |
430 r=f[1].Replace(TheFs,_L("TEST2.DAT"),EFileWrite); |
432 test_KErrNone(r); |
431 test(r==KErrNone); |
433 r=f[2].Replace(TheFs,_L("TEST3.DAT"),EFileWrite); |
432 r=f[2].Replace(TheFs,_L("TEST3.DAT"),EFileWrite); |
434 test_KErrNone(r); |
433 test(r==KErrNone); |
435 r=f[3].Replace(TheFs,_L("TEST4.DAT"),EFileWrite); |
434 r=f[3].Replace(TheFs,_L("TEST4.DAT"),EFileWrite); |
436 test_KErrNone(r); |
435 test(r==KErrNone); |
437 |
436 |
438 TInt size=0; |
437 TInt size=0; |
439 TInt iteration=0; |
438 TInt iteration=0; |
440 |
439 |
441 FOREVER |
440 FOREVER |
456 { |
455 { |
457 TInt fileNum=(order+i)%KMaxFiles; |
456 TInt fileNum=(order+i)%KMaxFiles; |
458 TInt s=len*mult[fileNum]; |
457 TInt s=len*mult[fileNum]; |
459 TInt filePos=pos*mult[fileNum]; |
458 TInt filePos=pos*mult[fileNum]; |
460 r=f[fileNum].Seek(ESeekStart,filePos); |
459 r=f[fileNum].Seek(ESeekStart,filePos); |
461 test_KErrNone(r); |
460 test(r==KErrNone); |
462 |
461 |
463 while(s>0) |
462 while(s>0) |
464 { |
463 { |
465 TInt l=(s>KMaxBufferLength) ? KMaxBufferLength : s; |
464 TInt l=(s>KMaxBufferLength) ? KMaxBufferLength : s; |
466 dataBuf->Des().SetLength(l); |
465 dataBuf->Des().SetLength(l); |
491 test.Printf(_L("\nReduceSize newsize=%d\n"),size); |
490 test.Printf(_L("\nReduceSize newsize=%d\n"),size); |
492 for (TInt i=0;i<KMaxFiles;i++) |
491 for (TInt i=0;i<KMaxFiles;i++) |
493 { |
492 { |
494 TInt fileNum=(order+i)%KMaxFiles; |
493 TInt fileNum=(order+i)%KMaxFiles; |
495 r=f[fileNum].SetSize(size*mult[fileNum]); |
494 r=f[fileNum].SetSize(size*mult[fileNum]); |
496 test_KErrNone(r); |
495 test(r==KErrNone); |
497 } |
496 } |
498 CheckFileContents(&f[0]); |
497 CheckFileContents(&f[0]); |
499 } |
498 } |
500 } |
499 } |
501 End: |
500 End: |