author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 11 Jun 2010 15:02:23 +0300 | |
changeset 152 | 657f875b013e |
parent 109 | b3a1d9898418 |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// f32test\server\t_rand.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
18 |
#define __E32TEST_EXTENSION__ |
0 | 19 |
#include <f32file.h> |
20 |
#include <e32test.h> |
|
21 |
#include <e32math.h> |
|
22 |
#include <e32hal.h> |
|
23 |
#include "t_server.h" |
|
24 |
||
25 |
GLDEF_D RTest test(_L("T_RAND")); |
|
26 |
||
27 |
LOCAL_D TBuf8<512> testBuf(512); |
|
28 |
LOCAL_D TInt64 TheSeed=917824; |
|
29 |
LOCAL_D TInt KMaxIteration; |
|
30 |
LOCAL_D const TInt KMaxFiles=4; |
|
31 |
LOCAL_D const TInt KMaxLengthIncrement=7770; |
|
32 |
LOCAL_D const TInt mult[] = { 1, 5, 13, 37}; |
|
33 |
LOCAL_D const TInt KReduceSizeFrequency=20; // 1 reduce in ?? iterations |
|
34 |
LOCAL_D const TInt KCheckFileFrequency=20000; // 1 check in ?? iterations |
|
35 |
LOCAL_D const TInt KMaxBufferLength=0x8000; |
|
36 |
||
37 |
LOCAL_C void WriteCluster(RFile& aFile,TInt aCluster) |
|
38 |
// |
|
39 |
// Extend aFile by 1 cluster |
|
40 |
// |
|
41 |
{ |
|
42 |
||
43 |
TUint8* bufPtr=(TUint8*)testBuf.Ptr(); |
|
44 |
testBuf.SetLength(testBuf.MaxSize()); |
|
45 |
Mem::Fill(bufPtr,testBuf.MaxSize(),aCluster); |
|
46 |
TInt r=aFile.Write(testBuf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
47 |
test_KErrNone(r); |
0 | 48 |
} |
49 |
||
50 |
LOCAL_C void SeekToCluster(RFile& aFile,TInt aCluster) |
|
51 |
// |
|
52 |
// Seek to aCluster and check it is found correctly |
|
53 |
// |
|
54 |
{ |
|
55 |
TBuf8<508> seekBuf(508); |
|
56 |
TInt r=aFile.Read(aCluster*testBuf.MaxSize(),seekBuf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
57 |
test_KErrNone(r); |
0 | 58 |
test(seekBuf[0]==(TUint8)aCluster && seekBuf[507]==(TUint8)aCluster); |
59 |
} |
|
60 |
||
61 |
LOCAL_C void SeekToCluster(RFile& aFile,TInt aCluster1,TInt aCluster2) |
|
62 |
// |
|
63 |
// Seek to aCluster and check it is found correctly |
|
64 |
// |
|
65 |
{ |
|
66 |
TBuf8<508> seekBuf(508); |
|
67 |
TInt r=aFile.Read(aCluster1*testBuf.MaxSize(),seekBuf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
68 |
test_KErrNone(r); |
0 | 69 |
test(seekBuf[0]==(TUint8)aCluster1 && seekBuf[507]==(TUint8)aCluster1); |
70 |
r=aFile.Read(aCluster2*testBuf.MaxSize(),seekBuf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
71 |
test_KErrNone(r); |
0 | 72 |
test(seekBuf[0]==(TUint8)aCluster2 && seekBuf[507]==(TUint8)aCluster2); |
73 |
} |
|
74 |
||
75 |
LOCAL_C void ExhaustiveTest(RFile& aFile,TInt aCount1) |
|
76 |
// |
|
77 |
// Test every possible seeking combination |
|
78 |
// |
|
79 |
{ |
|
80 |
||
81 |
TInt i=0,k=0; |
|
82 |
for(k=0;k<aCount1;k++) |
|
83 |
{ |
|
84 |
for(i=aCount1-1;i>0;i--) |
|
85 |
{ |
|
86 |
SeekToCluster(aFile,i); |
|
87 |
SeekToCluster(aFile,k); |
|
88 |
} |
|
89 |
test.Printf(_L("Seek from %d \r"),k); |
|
90 |
} |
|
91 |
test.Printf(_L("\n")); |
|
92 |
} |
|
93 |
||
94 |
LOCAL_C void Test1() |
|
95 |
// |
|
96 |
// Test openning a large file |
|
97 |
// |
|
98 |
{ |
|
99 |
||
100 |
test.Next(_L("Create interleaved files")); |
|
101 |
RFile f1,f2; |
|
102 |
// |
|
103 |
TInt r=f1.Replace(TheFs,_L("BIGFILE1.TST"),EFileWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
104 |
test_KErrNone(r); |
0 | 105 |
r=f2.Replace(TheFs,_L("BIGFILE2.TST"),EFileWrite); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
106 |
test_KErrNone(r); |
0 | 107 |
// |
108 |
TInt maxListLength=4; |
|
109 |
TInt i=0,k=0; |
|
110 |
TInt countf1=0; |
|
111 |
TInt countf2=0; |
|
112 |
for (k=0;k<maxListLength;k++) |
|
113 |
{ |
|
114 |
for (i=0;i<maxListLength;i++) |
|
115 |
{ |
|
116 |
TInt j; |
|
117 |
for (j=0;j<=i;j++) |
|
118 |
WriteCluster(f1,countf1++); |
|
119 |
for (j=0;j<=k;j++) |
|
120 |
WriteCluster(f2,countf2++); |
|
121 |
test.Printf(_L("Written %d to file1 %d to file2\n"),i+1,k+1); |
|
122 |
} |
|
123 |
} |
|
124 |
||
125 |
ExhaustiveTest(f1,countf1); |
|
126 |
ExhaustiveTest(f2,countf2); |
|
127 |
||
128 |
SeekToCluster(f1,1,10); |
|
129 |
SeekToCluster(f1,6,3); |
|
130 |
SeekToCluster(f1,8,4); |
|
131 |
SeekToCluster(f1,12,3); |
|
132 |
SeekToCluster(f1,23,32); |
|
133 |
SeekToCluster(f1,5,8); |
|
134 |
SeekToCluster(f1,7,9); |
|
135 |
SeekToCluster(f1,12,1); |
|
136 |
SeekToCluster(f1,2,32); |
|
137 |
SeekToCluster(f1,16,8); |
|
138 |
SeekToCluster(f1,9,5); |
|
139 |
SeekToCluster(f1,33,6); |
|
140 |
SeekToCluster(f1,13,7); |
|
141 |
SeekToCluster(f1,9,17); |
|
142 |
SeekToCluster(f1,4,5); |
|
143 |
SeekToCluster(f1,5,31); |
|
144 |
SeekToCluster(f1,11,10); |
|
145 |
SeekToCluster(f1,1,2); |
|
146 |
SeekToCluster(f1,5,5); |
|
147 |
||
148 |
f1.Close(); |
|
149 |
f2.Close(); |
|
150 |
r=TheFs.Delete(_L("BIGFile1.tst")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
151 |
test_KErrNone(r); |
0 | 152 |
r=TheFs.Delete(_L("BIGFile2.tst")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
153 |
test_KErrNone(r); |
0 | 154 |
CheckDisk(); |
155 |
} |
|
156 |
||
157 |
LOCAL_C void Test2() |
|
158 |
// |
|
159 |
// Reproduce old bugs |
|
160 |
// |
|
161 |
{ |
|
162 |
||
163 |
test.Next(_L("Regression Protection")); |
|
164 |
RFile f1,f2; |
|
165 |
// |
|
166 |
TInt r=f1.Replace(TheFs,_L("BIGFILE1.TST"),EFileWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
167 |
test_KErrNone(r); |
0 | 168 |
r=f2.Replace(TheFs,_L("BIGFILE2.TST"),EFileWrite); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
169 |
test_KErrNone(r); |
0 | 170 |
// |
171 |
WriteCluster(f1,0); |
|
172 |
WriteCluster(f1,1); |
|
173 |
WriteCluster(f1,2); |
|
174 |
WriteCluster(f1,3); |
|
175 |
WriteCluster(f1,4); |
|
176 |
WriteCluster(f1,5); |
|
177 |
WriteCluster(f2,0); |
|
178 |
WriteCluster(f1,6); |
|
179 |
// |
|
180 |
SeekToCluster(f1,6); |
|
181 |
SeekToCluster(f1,4); |
|
182 |
// |
|
183 |
f1.Close(); |
|
184 |
f2.Close(); |
|
185 |
r=TheFs.Delete(_L("BIGFile1.tst")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
186 |
test_KErrNone(r); |
0 | 187 |
r=TheFs.Delete(_L("BIGFile2.tst")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
188 |
test_KErrNone(r); |
0 | 189 |
CheckDisk(); |
190 |
} |
|
191 |
||
192 |
LOCAL_C void Test3() |
|
193 |
// |
|
194 |
// Change file size while seeking |
|
195 |
// |
|
196 |
{ |
|
197 |
||
198 |
test.Next(_L("Alter filesize")); |
|
199 |
RFile f1; |
|
200 |
TheSeed=917824; |
|
201 |
TInt i=0,j=0; |
|
202 |
// |
|
203 |
TInt r=f1.Replace(TheFs,_L("BIGFILE1.TST"),EFileWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
204 |
test_KErrNone(r); |
0 | 205 |
|
206 |
r=f1.SetSize(65534); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
207 |
test_KErrNone(r); |
0 | 208 |
|
209 |
for(i=0;i<=15;i++) |
|
210 |
WriteCluster(f1,i); |
|
211 |
||
212 |
for (j=0;j<100;j++) |
|
213 |
{ |
|
214 |
TInt cluster1=Math::Rand(TheSeed)%15; |
|
215 |
TInt cluster2=Math::Rand(TheSeed)%15; |
|
216 |
SeekToCluster(f1,cluster2,cluster1); |
|
217 |
} |
|
218 |
||
219 |
test.Next(_L("Increase Size")); |
|
220 |
r=f1.SetSize(1048577); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
221 |
test_Value(r, r == KErrNone || r==KErrDiskFull); |
0 | 222 |
if (r==KErrDiskFull) |
223 |
{ |
|
224 |
test.Printf(_L("File too big\n")); |
|
225 |
f1.Close(); |
|
226 |
return; |
|
227 |
} |
|
228 |
||
229 |
test.Next(_L("Test data still present")); |
|
230 |
for (j=0;j<200;j++) |
|
231 |
{ |
|
232 |
TInt cluster1=Math::Rand(TheSeed)%15; |
|
233 |
TInt cluster2=Math::Rand(TheSeed)%15; |
|
234 |
SeekToCluster(f1,cluster2,cluster1); |
|
235 |
} |
|
236 |
||
237 |
TInt newPos=8192; |
|
238 |
r=f1.Seek(ESeekStart,newPos); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
239 |
test_KErrNone(r); |
0 | 240 |
|
241 |
test.Next(_L("Write more data")); |
|
242 |
for(i=16;i<83;i++) |
|
243 |
WriteCluster(f1,i); |
|
244 |
||
245 |
test.Next(_L("Seek to new data")); |
|
246 |
for (j=0;j<200;j++) |
|
247 |
{ |
|
248 |
TInt cluster1=Math::Rand(TheSeed)%83; |
|
249 |
TInt cluster2=Math::Rand(TheSeed)%83; |
|
250 |
SeekToCluster(f1,cluster2,cluster1); |
|
251 |
} |
|
252 |
||
253 |
test.Next(_L("Reduce file size")); |
|
254 |
r=f1.SetSize(135000); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
255 |
test_KErrNone(r); |
0 | 256 |
|
257 |
test.Next(_L("Test data still present")); |
|
258 |
for (j=0;j<200;j++) |
|
259 |
{ |
|
260 |
TInt cluster1=Math::Rand(TheSeed)%31; |
|
261 |
TInt cluster2=Math::Rand(TheSeed)%31; |
|
262 |
SeekToCluster(f1,cluster2,cluster1); |
|
263 |
} |
|
264 |
||
265 |
f1.Close(); |
|
266 |
} |
|
267 |
||
268 |
class TFileReader |
|
269 |
{ |
|
270 |
public: |
|
271 |
TFileReader(RFile* aFile); |
|
272 |
void Next(TUint8& aVal,TInt& aLength); |
|
273 |
TBool Compare(TUint8 aVal,TInt aLength); |
|
274 |
private: |
|
275 |
RFile iFile; |
|
276 |
TBuf8<512> iData; |
|
277 |
TInt iPos; |
|
278 |
}; |
|
279 |
||
280 |
TFileReader::TFileReader(RFile* aFile) |
|
281 |
// |
|
282 |
// Constructor |
|
283 |
// |
|
284 |
: iFile(*aFile), iPos(0) |
|
285 |
{ |
|
286 |
||
287 |
TInt r=iFile.Read(0,iData); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
288 |
test_KErrNone(r); |
0 | 289 |
} |
290 |
||
291 |
void TFileReader::Next(TUint8& aVal,TInt& aLength) |
|
292 |
// |
|
293 |
// Read aLength contiguous bytes with aVal |
|
294 |
// |
|
295 |
{ |
|
296 |
||
297 |
if (iPos==iData.Length()) |
|
298 |
{ |
|
299 |
TInt r=iFile.Read(iData); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
300 |
test_KErrNone(r); |
0 | 301 |
iPos=0; |
302 |
if (iData.Length()==0) |
|
303 |
{ |
|
304 |
aLength=0; |
|
305 |
return; |
|
306 |
} |
|
307 |
} |
|
308 |
||
309 |
aVal=iData[iPos]; |
|
310 |
aLength=0; |
|
311 |
while(iPos<iData.Length()) |
|
312 |
{ |
|
313 |
if (iData[iPos]!=aVal) |
|
314 |
break; |
|
315 |
iPos++; |
|
316 |
aLength++; |
|
317 |
} |
|
318 |
} |
|
319 |
||
320 |
TBool TFileReader::Compare(TUint8 aVal, TInt aLength) |
|
321 |
// |
|
322 |
// Compare file contents == aVal for aLength bytes |
|
323 |
// |
|
324 |
{ |
|
325 |
||
326 |
FOREVER |
|
327 |
{ |
|
328 |
if(iPos==iData.Length()) |
|
329 |
{ |
|
330 |
TInt r=iFile.Read(iData); |
|
331 |
if (r!=KErrNone) |
|
332 |
{ |
|
333 |
test.Printf(_L("READ error %d\n"),r); |
|
334 |
//test.Getch(); |
|
335 |
RFs fs; |
|
336 |
r=fs.Connect(); |
|
337 |
test.Printf(_L("connect returned %d\n"),r); |
|
338 |
//test.Getch(); |
|
339 |
fs.Close(); |
|
340 |
test(0); |
|
341 |
return(EFalse); |
|
342 |
} |
|
343 |
iPos=0; |
|
344 |
if (iData.Length()==0) |
|
345 |
{ |
|
346 |
test.Printf(_L("\nFound Error\n")); |
|
347 |
test(0); |
|
348 |
//test.Getch(); |
|
349 |
return(EFalse); |
|
350 |
} |
|
351 |
} |
|
352 |
while(iPos<iData.Length()) |
|
353 |
{ |
|
354 |
if (iData[iPos]!=aVal) |
|
355 |
{ |
|
356 |
test.Printf(_L("\nFound Error\n")); |
|
357 |
test(0); |
|
358 |
//test.Getch(); |
|
359 |
return(EFalse); |
|
360 |
} |
|
361 |
iPos++; |
|
362 |
aLength--; |
|
363 |
if (aLength==0) |
|
364 |
return(ETrue); |
|
365 |
} |
|
366 |
} |
|
367 |
} |
|
368 |
||
369 |
LOCAL_C void CheckFileContents(RFile* aFile) |
|
370 |
// |
|
371 |
// Check all files have consistent contents |
|
372 |
// |
|
373 |
{ |
|
374 |
||
375 |
TFileReader f0(aFile); |
|
376 |
TFileReader f1(aFile+1); |
|
377 |
TFileReader f2(aFile+2); |
|
378 |
TFileReader f3(aFile+3); |
|
379 |
||
380 |
FOREVER |
|
381 |
{ |
|
382 |
TUint8 val; |
|
383 |
TInt length; |
|
384 |
f0.Next(val,length); |
|
385 |
if (length==0) |
|
386 |
break; |
|
387 |
test(f1.Compare(val,length*mult[1])); |
|
388 |
test(f2.Compare(val,length*mult[2])); |
|
389 |
test(f3.Compare(val,length*mult[3])); |
|
390 |
} |
|
391 |
||
392 |
TUint8 val; |
|
393 |
TInt length; |
|
394 |
f1.Next(val,length); |
|
395 |
if (length!=0) |
|
396 |
{ |
|
397 |
test.Printf(_L("\nFound Error\n")); |
|
398 |
test(0); |
|
399 |
//test.Getch(); |
|
400 |
} |
|
401 |
test(length==0); |
|
402 |
f2.Next(val,length); |
|
403 |
if (length!=0) |
|
404 |
{ |
|
405 |
test.Printf(_L("\nFound Error\n")); |
|
406 |
test(0); |
|
407 |
//test.Getch(); |
|
408 |
} |
|
409 |
test(length==0); |
|
410 |
f3.Next(val,length); |
|
411 |
if (length!=0) |
|
412 |
{ |
|
413 |
test.Printf(_L("\nFound Error\n")); |
|
414 |
test(0); |
|
415 |
//test.Getch(); |
|
416 |
} |
|
417 |
test(length==0); |
|
418 |
} |
|
419 |
||
420 |
LOCAL_C void Test4() |
|
421 |
// |
|
422 |
// Read, write and resize 4 interleaved files |
|
423 |
// |
|
424 |
{ |
|
425 |
||
426 |
RFile f[KMaxFiles]; |
|
427 |
HBufC8* dataBuf=HBufC8::NewL(KMaxBufferLength); |
|
428 |
||
429 |
TInt r=f[0].Replace(TheFs,_L("TEST1.DAT"),EFileWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
430 |
test_KErrNone(r); |
0 | 431 |
r=f[1].Replace(TheFs,_L("TEST2.DAT"),EFileWrite); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
432 |
test_KErrNone(r); |
0 | 433 |
r=f[2].Replace(TheFs,_L("TEST3.DAT"),EFileWrite); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
434 |
test_KErrNone(r); |
0 | 435 |
r=f[3].Replace(TheFs,_L("TEST4.DAT"),EFileWrite); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
436 |
test_KErrNone(r); |
0 | 437 |
|
438 |
TInt size=0; |
|
439 |
TInt iteration=0; |
|
440 |
||
441 |
FOREVER |
|
442 |
{ |
|
443 |
iteration++; |
|
444 |
TInt pos=(size) ? Math::Rand(TheSeed)%size : 0; |
|
445 |
TInt len=Math::Rand(TheSeed)%KMaxLengthIncrement; |
|
446 |
TInt order=Math::Rand(TheSeed)%KMaxFiles; |
|
447 |
TInt value=Math::Rand(TheSeed)%KMaxTUint8; |
|
448 |
||
449 |
TUint8* data=(TUint8*)dataBuf->Ptr(); |
|
450 |
Mem::Fill(data,KMaxBufferLength,value); |
|
451 |
||
452 |
if (pos+len>size) |
|
453 |
size=pos+len; |
|
454 |
||
455 |
for (TInt i=0;i<KMaxFiles;i++) |
|
456 |
{ |
|
457 |
TInt fileNum=(order+i)%KMaxFiles; |
|
458 |
TInt s=len*mult[fileNum]; |
|
459 |
TInt filePos=pos*mult[fileNum]; |
|
460 |
r=f[fileNum].Seek(ESeekStart,filePos); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
461 |
test_KErrNone(r); |
0 | 462 |
|
463 |
while(s>0) |
|
464 |
{ |
|
465 |
TInt l=(s>KMaxBufferLength) ? KMaxBufferLength : s; |
|
466 |
dataBuf->Des().SetLength(l); |
|
467 |
r=f[fileNum].Write(*dataBuf); |
|
468 |
||
469 |
// Flush if write caching enabled to ensure we get disk space notifications |
|
470 |
if ((gDriveCacheFlags & EFileCacheWriteOn) && (r == KErrNone)) |
|
471 |
r = f[fileNum].Flush(); |
|
472 |
||
473 |
if (r==KErrDiskFull) |
|
474 |
goto End; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
475 |
test_KErrNone(r); |
0 | 476 |
s-=l; |
477 |
} |
|
478 |
||
479 |
} |
|
480 |
||
481 |
if ((iteration%KCheckFileFrequency)==0) |
|
482 |
CheckFileContents(&f[0]); |
|
483 |
||
484 |
test.Printf(_L("Iteration %d, size %d \r"),iteration,size); |
|
485 |
if (iteration==KMaxIteration) |
|
486 |
break; |
|
487 |
||
488 |
if ((iteration%KReduceSizeFrequency)==0) |
|
489 |
{ |
|
490 |
size=(size) ? Math::Rand(TheSeed)%size : 0; |
|
491 |
test.Printf(_L("\nReduceSize newsize=%d\n"),size); |
|
492 |
for (TInt i=0;i<KMaxFiles;i++) |
|
493 |
{ |
|
494 |
TInt fileNum=(order+i)%KMaxFiles; |
|
495 |
r=f[fileNum].SetSize(size*mult[fileNum]); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
496 |
test_KErrNone(r); |
0 | 497 |
} |
498 |
CheckFileContents(&f[0]); |
|
499 |
} |
|
500 |
} |
|
501 |
End: |
|
502 |
delete dataBuf; |
|
503 |
for (TInt i=0;i<KMaxFiles;i++) |
|
504 |
f[i].Close(); |
|
505 |
test.Printf(_L("\n")); |
|
506 |
} |
|
507 |
||
508 |
GLDEF_C void CallTestsL() |
|
509 |
// |
|
510 |
// Call all tests |
|
511 |
// |
|
512 |
{ |
|
513 |
||
514 |
#if defined(__WINS__) |
|
515 |
if (gSessionPath[0]=='C') |
|
516 |
return; |
|
517 |
#endif |
|
518 |
if (gSessionPath[0]=='C' || gSessionPath[0]=='Y') |
|
519 |
KMaxIteration=100; |
|
520 |
else |
|
521 |
KMaxIteration=100; |
|
522 |
CreateTestDirectory(_L("\\TRAND\\")); |
|
523 |
Test1(); |
|
524 |
Test2(); |
|
525 |
Test3(); |
|
526 |
Test4(); |
|
527 |
DeleteTestDirectory(); |
|
528 |
} |