sl@0
|
1 |
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// f32test\server\t_format.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#define __E32TEST_EXTENSION__
|
sl@0
|
19 |
|
sl@0
|
20 |
#include <f32file.h>
|
sl@0
|
21 |
#include <e32test.h>
|
sl@0
|
22 |
#include <e32svr.h>
|
sl@0
|
23 |
#include "t_server.h"
|
sl@0
|
24 |
#include "t_chlffs.h"
|
sl@0
|
25 |
|
sl@0
|
26 |
#include "f32_test_utils.h"
|
sl@0
|
27 |
|
sl@0
|
28 |
using namespace F32_Test_Utils;
|
sl@0
|
29 |
|
sl@0
|
30 |
|
sl@0
|
31 |
GLREF_D TFileName gSessionPath;
|
sl@0
|
32 |
|
sl@0
|
33 |
|
sl@0
|
34 |
void GenerateMediaChange()
|
sl@0
|
35 |
{
|
sl@0
|
36 |
TBuf<2> b;
|
sl@0
|
37 |
b.SetLength(2);
|
sl@0
|
38 |
b[0]=gSessionPath[0];
|
sl@0
|
39 |
b[1]=':';
|
sl@0
|
40 |
RFormat format;
|
sl@0
|
41 |
TInt count;
|
sl@0
|
42 |
TInt r=format.Open(TheFs,b,EHighDensity,count);
|
sl@0
|
43 |
test(r==KErrNone);
|
sl@0
|
44 |
format.Close();
|
sl@0
|
45 |
}
|
sl@0
|
46 |
|
sl@0
|
47 |
RTest test(_L("T_FORMAT"));
|
sl@0
|
48 |
RSemaphore gSleepThread;
|
sl@0
|
49 |
TRequestStatus gThreadLogon;
|
sl@0
|
50 |
|
sl@0
|
51 |
static TInt gDrive=-1;
|
sl@0
|
52 |
static const TInt KSectorSize=512;
|
sl@0
|
53 |
static const TInt KHeapSize=0x200;
|
sl@0
|
54 |
|
sl@0
|
55 |
enum TTestCode{ETest3,ETest5};
|
sl@0
|
56 |
|
sl@0
|
57 |
|
sl@0
|
58 |
//-------------------------------------------------------------------
|
sl@0
|
59 |
TInt DoFormatSteps(RFormat& aFormat, TInt& aFmtCnt)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
TInt nRes = KErrNone;
|
sl@0
|
62 |
|
sl@0
|
63 |
while(aFmtCnt)
|
sl@0
|
64 |
{
|
sl@0
|
65 |
nRes = aFormat.Next(aFmtCnt);
|
sl@0
|
66 |
if(nRes != KErrNone)
|
sl@0
|
67 |
{
|
sl@0
|
68 |
test.Printf(_L("RFormat::Next() failed! code:%d\n"), nRes);
|
sl@0
|
69 |
break;
|
sl@0
|
70 |
}
|
sl@0
|
71 |
}
|
sl@0
|
72 |
|
sl@0
|
73 |
return nRes;
|
sl@0
|
74 |
}
|
sl@0
|
75 |
|
sl@0
|
76 |
static void WaitForMedia()
|
sl@0
|
77 |
//
|
sl@0
|
78 |
// Wait until the media change is serviced
|
sl@0
|
79 |
//
|
sl@0
|
80 |
{
|
sl@0
|
81 |
|
sl@0
|
82 |
FOREVER
|
sl@0
|
83 |
{
|
sl@0
|
84 |
TInt r=TheFs.MkDir(_L("\\"));
|
sl@0
|
85 |
if (r!=KErrNotReady)
|
sl@0
|
86 |
break;
|
sl@0
|
87 |
User::After(100000);
|
sl@0
|
88 |
}
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
static TInt ThreadEntryPoint(TAny* aTestCode)
|
sl@0
|
92 |
//
|
sl@0
|
93 |
// Thread entry point
|
sl@0
|
94 |
//
|
sl@0
|
95 |
{
|
sl@0
|
96 |
|
sl@0
|
97 |
RFs fs;
|
sl@0
|
98 |
TInt ret=fs.Connect();
|
sl@0
|
99 |
test(ret==KErrNone);
|
sl@0
|
100 |
ret=fs.SetSessionPath(gSessionPath);
|
sl@0
|
101 |
test(ret==KErrNone);
|
sl@0
|
102 |
TTestCode testCode=*(TTestCode*)&aTestCode;
|
sl@0
|
103 |
TInt count;
|
sl@0
|
104 |
RFormat format;
|
sl@0
|
105 |
switch (testCode)
|
sl@0
|
106 |
{
|
sl@0
|
107 |
case ETest3:
|
sl@0
|
108 |
{
|
sl@0
|
109 |
ret=format.Open(fs,gSessionPath,EQuickFormat,count);
|
sl@0
|
110 |
test(ret==KErrNone);
|
sl@0
|
111 |
|
sl@0
|
112 |
ret = DoFormatSteps(format, count);
|
sl@0
|
113 |
test(ret==KErrNone);
|
sl@0
|
114 |
|
sl@0
|
115 |
format.Close();
|
sl@0
|
116 |
break;
|
sl@0
|
117 |
}
|
sl@0
|
118 |
case ETest5:
|
sl@0
|
119 |
{
|
sl@0
|
120 |
ret=format.Open(fs,gSessionPath,EFullFormat,count);
|
sl@0
|
121 |
test(ret==KErrNone);
|
sl@0
|
122 |
gSleepThread.Signal();
|
sl@0
|
123 |
User::After(100000000);
|
sl@0
|
124 |
break;
|
sl@0
|
125 |
}
|
sl@0
|
126 |
default:
|
sl@0
|
127 |
break;
|
sl@0
|
128 |
}
|
sl@0
|
129 |
return(KErrNone);
|
sl@0
|
130 |
}
|
sl@0
|
131 |
|
sl@0
|
132 |
//-------------------------------------------------------------------
|
sl@0
|
133 |
static void CorruptCurrentDrive()
|
sl@0
|
134 |
//
|
sl@0
|
135 |
// Corrupt the current drive
|
sl@0
|
136 |
//
|
sl@0
|
137 |
{
|
sl@0
|
138 |
test.Printf(_L("CorruptCurrentDrive() %c:"), 'A'+CurrentDrive());
|
sl@0
|
139 |
|
sl@0
|
140 |
RRawDisk raw;
|
sl@0
|
141 |
TInt r=raw.Open(TheFs,CurrentDrive());
|
sl@0
|
142 |
test(r==KErrNone);
|
sl@0
|
143 |
if (!Is_Lffs(TheFs, gDrive))
|
sl@0
|
144 |
{
|
sl@0
|
145 |
TBuf8<KSectorSize> zeroBuf(KSectorSize);
|
sl@0
|
146 |
Mem::FillZ((TAny*)zeroBuf.Ptr(),zeroBuf.MaxSize());
|
sl@0
|
147 |
|
sl@0
|
148 |
//-- for FAT32 we need to corrupt a backup BOOT sector as well,
|
sl@0
|
149 |
//-- otherwise it can be used and some tests will fail..
|
sl@0
|
150 |
const TInt KMaxSectors = 25; //-- how many sectors to corrupt
|
sl@0
|
151 |
for(TInt i=0; i<KMaxSectors; ++i)
|
sl@0
|
152 |
{
|
sl@0
|
153 |
r=raw.Write(i*KSectorSize, zeroBuf);
|
sl@0
|
154 |
test(r==KErrNone);
|
sl@0
|
155 |
}
|
sl@0
|
156 |
}
|
sl@0
|
157 |
else
|
sl@0
|
158 |
{
|
sl@0
|
159 |
TBuf8<32> zeroBuf(32);
|
sl@0
|
160 |
for (TInt j=0;j<32;++j)
|
sl@0
|
161 |
zeroBuf[j]=(TUint8)j; //Not actuall zero buf for lffs
|
sl@0
|
162 |
// For LFFS, the media may not exhibit a contiguous region of sufficient length
|
sl@0
|
163 |
// to support a continuous sequence of writes. This is the case if the
|
sl@0
|
164 |
// Control Mode Size is non-zero
|
sl@0
|
165 |
TInt cntlModeSize=GetLFFSControlModeSize();
|
sl@0
|
166 |
if(cntlModeSize==0)
|
sl@0
|
167 |
{
|
sl@0
|
168 |
//test.Printf(_L("CorruptCurrentDrive() - Control mode size is zero\n"),r);
|
sl@0
|
169 |
for (TInt writePos=0;writePos<0x20200;writePos+=32)
|
sl@0
|
170 |
{
|
sl@0
|
171 |
r=raw.Write(writePos,zeroBuf);
|
sl@0
|
172 |
// The device driver most likely fails when writing a random
|
sl@0
|
173 |
// buffer due to read back checks. Since we're writing
|
sl@0
|
174 |
// aligned 32-byte blocks, we don't need to bother that much.
|
sl@0
|
175 |
// The device driver writes the block but fails when reading
|
sl@0
|
176 |
// it back.
|
sl@0
|
177 |
// test(r==KErrNone);
|
sl@0
|
178 |
}
|
sl@0
|
179 |
}
|
sl@0
|
180 |
else if(cntlModeSize>0)
|
sl@0
|
181 |
{
|
sl@0
|
182 |
//test.Printf(_L("CorruptCurrentDrive() - Control mode = 0x%x\n"),r);
|
sl@0
|
183 |
// For devices which have a non-zero control mode size, the writes may
|
sl@0
|
184 |
// require segmentation.
|
sl@0
|
185 |
TInt cmBase=0;
|
sl@0
|
186 |
TInt cmOffset=0;
|
sl@0
|
187 |
TInt bufOffset=0;
|
sl@0
|
188 |
TInt bytesWritten=0;
|
sl@0
|
189 |
TPtrC8 writeBuf;
|
sl@0
|
190 |
while(bytesWritten < 0x20200)
|
sl@0
|
191 |
{
|
sl@0
|
192 |
TInt bufLeft = 32 - bufOffset; // 32 from size of zeroBuf
|
sl@0
|
193 |
TInt spaceLeft = cntlModeSize - cmOffset;
|
sl@0
|
194 |
TInt writeLen=(bufLeft>spaceLeft)? spaceLeft : bufLeft;
|
sl@0
|
195 |
writeBuf.Set(&(zeroBuf[bufOffset]),writeLen);
|
sl@0
|
196 |
TInt writePos = cmBase + cmOffset;
|
sl@0
|
197 |
r=raw.Write(writePos,writeBuf);
|
sl@0
|
198 |
bytesWritten += writeLen;
|
sl@0
|
199 |
if(bufLeft < spaceLeft)
|
sl@0
|
200 |
{
|
sl@0
|
201 |
bufOffset = 0;
|
sl@0
|
202 |
cmOffset += bufLeft;
|
sl@0
|
203 |
}
|
sl@0
|
204 |
else if(bufLeft == spaceLeft)
|
sl@0
|
205 |
{
|
sl@0
|
206 |
bufOffset = 0;
|
sl@0
|
207 |
cmOffset = 0;
|
sl@0
|
208 |
cmBase += (2*cntlModeSize);
|
sl@0
|
209 |
}
|
sl@0
|
210 |
else
|
sl@0
|
211 |
{ // bufRemaining>spaceRemaining
|
sl@0
|
212 |
bufOffset += spaceLeft;
|
sl@0
|
213 |
cmOffset = 0;
|
sl@0
|
214 |
cmBase += (2*cntlModeSize);
|
sl@0
|
215 |
}
|
sl@0
|
216 |
}
|
sl@0
|
217 |
}
|
sl@0
|
218 |
else
|
sl@0
|
219 |
{
|
sl@0
|
220 |
// Negative value (error code) returned from GetLFFSControlModeSize()
|
sl@0
|
221 |
test.Printf(_L("CorruptCurrentDrive() - Control mode = %d (ERROR!) \n"),cntlModeSize);
|
sl@0
|
222 |
test(0);
|
sl@0
|
223 |
}
|
sl@0
|
224 |
}
|
sl@0
|
225 |
raw.Close();
|
sl@0
|
226 |
}
|
sl@0
|
227 |
|
sl@0
|
228 |
|
sl@0
|
229 |
//-------------------------------------------------------------------
|
sl@0
|
230 |
static void Test1()
|
sl@0
|
231 |
//
|
sl@0
|
232 |
// Format disk
|
sl@0
|
233 |
//
|
sl@0
|
234 |
{
|
sl@0
|
235 |
|
sl@0
|
236 |
test.Next(_L("Test EFullFormat"));
|
sl@0
|
237 |
TInt count;
|
sl@0
|
238 |
RFormat format;
|
sl@0
|
239 |
|
sl@0
|
240 |
TInt r=format.Open(TheFs,gSessionPath,EFullFormat,count);
|
sl@0
|
241 |
test(r==KErrNone);
|
sl@0
|
242 |
|
sl@0
|
243 |
r = DoFormatSteps(format, count);
|
sl@0
|
244 |
test(r==KErrNone);
|
sl@0
|
245 |
|
sl@0
|
246 |
format.Close();
|
sl@0
|
247 |
|
sl@0
|
248 |
TVolumeInfo volInfo;
|
sl@0
|
249 |
r=TheFs.Volume(volInfo);
|
sl@0
|
250 |
test(r==KErrNone);
|
sl@0
|
251 |
|
sl@0
|
252 |
if (volInfo.iSize-volInfo.iFree!=0)
|
sl@0
|
253 |
{
|
sl@0
|
254 |
test.Printf(_L("Memory 'in use' after a full format = %ld\n"),(volInfo.iSize-volInfo.iFree));
|
sl@0
|
255 |
test.Printf(_L("volInfo.iSize = %ld\n"),volInfo.iSize);
|
sl@0
|
256 |
test.Printf(_L("volInfo.iFree = %ld\n"),volInfo.iFree);
|
sl@0
|
257 |
}
|
sl@0
|
258 |
|
sl@0
|
259 |
test.Next(_L("Test EQuickFormat"));
|
sl@0
|
260 |
r=format.Open(TheFs,gSessionPath,EQuickFormat,count);
|
sl@0
|
261 |
test(r==KErrNone);
|
sl@0
|
262 |
|
sl@0
|
263 |
r = DoFormatSteps(format, count);
|
sl@0
|
264 |
test(r==KErrNone);
|
sl@0
|
265 |
|
sl@0
|
266 |
format.Close();
|
sl@0
|
267 |
|
sl@0
|
268 |
r=TheFs.Volume(volInfo);
|
sl@0
|
269 |
test(r==KErrNone);
|
sl@0
|
270 |
|
sl@0
|
271 |
if (volInfo.iSize-volInfo.iFree!=0)
|
sl@0
|
272 |
{
|
sl@0
|
273 |
test.Printf(_L("Memory 'in use' after a quick format = %ld\n"),(volInfo.iSize-volInfo.iFree));
|
sl@0
|
274 |
test.Printf(_L("volInfo.iSize = %ld\n"),volInfo.iSize);
|
sl@0
|
275 |
test.Printf(_L("volInfo.iFree = %ld\n"),volInfo.iFree);
|
sl@0
|
276 |
return;
|
sl@0
|
277 |
}
|
sl@0
|
278 |
|
sl@0
|
279 |
}
|
sl@0
|
280 |
|
sl@0
|
281 |
//-------------------------------------------------------------------
|
sl@0
|
282 |
static void Test2()
|
sl@0
|
283 |
//
|
sl@0
|
284 |
// Test access controls
|
sl@0
|
285 |
//
|
sl@0
|
286 |
{
|
sl@0
|
287 |
|
sl@0
|
288 |
test.Next(_L("Test disk cannot be formatted while a file is open"));
|
sl@0
|
289 |
RFile f;
|
sl@0
|
290 |
TInt r=f.Replace(TheFs,_L("BLARGME.BLARG"),EFileStream);
|
sl@0
|
291 |
test(r==KErrNone);
|
sl@0
|
292 |
|
sl@0
|
293 |
TInt count;
|
sl@0
|
294 |
RFormat format;
|
sl@0
|
295 |
r=format.Open(TheFs,gSessionPath,EFullFormat,count);
|
sl@0
|
296 |
test(r==KErrInUse);
|
sl@0
|
297 |
|
sl@0
|
298 |
f.Close();
|
sl@0
|
299 |
r=format.Open(TheFs,gSessionPath,EFullFormat,count);
|
sl@0
|
300 |
test(r==KErrNone);
|
sl@0
|
301 |
format.Close();
|
sl@0
|
302 |
|
sl@0
|
303 |
CheckFileExists(_L("BLARGME.BLARG"),KErrNone);
|
sl@0
|
304 |
}
|
sl@0
|
305 |
|
sl@0
|
306 |
//-------------------------------------------------------------------
|
sl@0
|
307 |
static void Test3()
|
sl@0
|
308 |
//
|
sl@0
|
309 |
// Test notification
|
sl@0
|
310 |
//
|
sl@0
|
311 |
{
|
sl@0
|
312 |
|
sl@0
|
313 |
test.Next(_L("Test successful format triggers notifier"));
|
sl@0
|
314 |
MakeFile(_L("\\BLARG_BLARG_BLARG.BLG"));
|
sl@0
|
315 |
TRequestStatus reqStat;
|
sl@0
|
316 |
TheFs.NotifyChange(ENotifyEntry,reqStat);
|
sl@0
|
317 |
|
sl@0
|
318 |
RThread clientThread;
|
sl@0
|
319 |
TInt r=clientThread.Create(_L("ClientThread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest3);
|
sl@0
|
320 |
test.Printf(_L("Created helper thread #1, res=%d\n"),r);
|
sl@0
|
321 |
test(r==KErrNone);
|
sl@0
|
322 |
|
sl@0
|
323 |
clientThread.Logon(gThreadLogon);
|
sl@0
|
324 |
clientThread.Resume();
|
sl@0
|
325 |
clientThread.Close();
|
sl@0
|
326 |
|
sl@0
|
327 |
User::WaitForRequest(reqStat);
|
sl@0
|
328 |
test.Printf(_L("Notifier triggered #1, res=%d\n"),reqStat.Int());
|
sl@0
|
329 |
|
sl@0
|
330 |
User::WaitForRequest(gThreadLogon);
|
sl@0
|
331 |
test.Printf(_L("Helper thread exited #1, res=%d\n"),gThreadLogon.Int());
|
sl@0
|
332 |
|
sl@0
|
333 |
CheckFileExists(_L("BLARG_BLARG_BLARG.BLG"),KErrNotFound);
|
sl@0
|
334 |
MakeFile(_L("\\BLARG_BLARG_BLARG.BLG"));
|
sl@0
|
335 |
|
sl@0
|
336 |
TheFs.NotifyChange(ENotifyAll,reqStat);
|
sl@0
|
337 |
r=clientThread.Create(_L("ClientThread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest3);
|
sl@0
|
338 |
test.Printf(_L("Created helper thread #2, res=%d\n"),r);
|
sl@0
|
339 |
test(r==KErrNone);
|
sl@0
|
340 |
|
sl@0
|
341 |
|
sl@0
|
342 |
clientThread.Logon(gThreadLogon);
|
sl@0
|
343 |
clientThread.Resume();
|
sl@0
|
344 |
clientThread.Close();
|
sl@0
|
345 |
|
sl@0
|
346 |
User::WaitForRequest(reqStat);
|
sl@0
|
347 |
test.Printf(_L("Notifier triggered #2, res=%d\n"),reqStat.Int());
|
sl@0
|
348 |
|
sl@0
|
349 |
User::WaitForRequest(gThreadLogon);
|
sl@0
|
350 |
test.Printf(_L("Helper thread exited #2, res=%d\n"),gThreadLogon.Int());
|
sl@0
|
351 |
|
sl@0
|
352 |
CheckFileExists(_L("BLARG_BLARG_BLARG.BLG"),KErrNotFound);
|
sl@0
|
353 |
}
|
sl@0
|
354 |
|
sl@0
|
355 |
//-------------------------------------------------------------------
|
sl@0
|
356 |
static void Test4()
|
sl@0
|
357 |
//
|
sl@0
|
358 |
// Test partially completed formats
|
sl@0
|
359 |
//
|
sl@0
|
360 |
{
|
sl@0
|
361 |
test.Next(_L("Test partially completed formats"));
|
sl@0
|
362 |
|
sl@0
|
363 |
if(Is_Automounter(TheFs, gDrive))
|
sl@0
|
364 |
{//-- if we have automounter FS installed, formatting of the corrupted media is not straightforward
|
sl@0
|
365 |
//-- The automounter might not be able to decide which of the child file systems shall be used; This issue is covered in a specific test.
|
sl@0
|
366 |
test.Printf(_L("This step is skipped for Automounter File System\n"));
|
sl@0
|
367 |
return;
|
sl@0
|
368 |
}
|
sl@0
|
369 |
|
sl@0
|
370 |
MakeFile(_L("\\FORMAT\\DIR1\\BLARG_BLARG_BLARG.BLG"));
|
sl@0
|
371 |
TInt count;
|
sl@0
|
372 |
CorruptCurrentDrive();
|
sl@0
|
373 |
|
sl@0
|
374 |
test.Printf(_L("Formatting the drive...\n"));
|
sl@0
|
375 |
|
sl@0
|
376 |
RFormat format;
|
sl@0
|
377 |
TInt r=format.Open(TheFs,gSessionPath,EFullFormat,count);
|
sl@0
|
378 |
test(r==KErrNone);
|
sl@0
|
379 |
|
sl@0
|
380 |
while(count)
|
sl@0
|
381 |
{
|
sl@0
|
382 |
RDir dir;
|
sl@0
|
383 |
r=dir.Open(TheFs,_L("\\*.*"),KEntryAttNormal);
|
sl@0
|
384 |
test(r==KErrInUse);
|
sl@0
|
385 |
r=format.Next(count);
|
sl@0
|
386 |
test(r==KErrNone);
|
sl@0
|
387 |
}
|
sl@0
|
388 |
format.Close();
|
sl@0
|
389 |
|
sl@0
|
390 |
CheckFileExists(_L("\\FORMAT\\DIR1\\BLARG_BLARG_BLARG.BLG"),KErrPathNotFound);
|
sl@0
|
391 |
}
|
sl@0
|
392 |
|
sl@0
|
393 |
//-------------------------------------------------------------------
|
sl@0
|
394 |
static void Test5()
|
sl@0
|
395 |
//
|
sl@0
|
396 |
// Test panic formatting thread
|
sl@0
|
397 |
//
|
sl@0
|
398 |
{
|
sl@0
|
399 |
|
sl@0
|
400 |
test.Next(_L("Test panic formatting thread"));
|
sl@0
|
401 |
|
sl@0
|
402 |
if(Is_Automounter(TheFs, gDrive))
|
sl@0
|
403 |
{//-- if we have automounter FS installed, formatting of the corrupted media is not straightforward
|
sl@0
|
404 |
//-- The automounter might not be able to decide which of the child file systems shall be used; This issue is covered in a specific test.
|
sl@0
|
405 |
test.Printf(_L("This step is skipped for Automounter File System\n"));
|
sl@0
|
406 |
return;
|
sl@0
|
407 |
}
|
sl@0
|
408 |
|
sl@0
|
409 |
CorruptCurrentDrive();
|
sl@0
|
410 |
if (!(IsTestingLFFS() && GetDriveLFFS()==EDriveC)) // ??? Remove after ER5U
|
sl@0
|
411 |
{
|
sl@0
|
412 |
// UserSvr::ForceRemountMedia(ERemovableMedia0); // Generate media change
|
sl@0
|
413 |
GenerateMediaChange();
|
sl@0
|
414 |
WaitForMedia();
|
sl@0
|
415 |
}
|
sl@0
|
416 |
|
sl@0
|
417 |
gSleepThread.CreateLocal(0);
|
sl@0
|
418 |
RThread clientThread;
|
sl@0
|
419 |
TInt r=clientThread.Create(_L("ClientThread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
|
sl@0
|
420 |
test.Printf(_L("Created helper thread #1, res=%d\n"),r);
|
sl@0
|
421 |
test(r==KErrNone);
|
sl@0
|
422 |
|
sl@0
|
423 |
test.Printf(_L("Panicing formatting thread #1\n"));
|
sl@0
|
424 |
clientThread.Resume();
|
sl@0
|
425 |
gSleepThread.Wait();
|
sl@0
|
426 |
test.Printf(_L("Panicing formatting thread #2\n"));
|
sl@0
|
427 |
User::SetJustInTime(EFalse);
|
sl@0
|
428 |
clientThread.Panic(_L("Panic formatting thread"),KErrGeneral);
|
sl@0
|
429 |
User::SetJustInTime(ETrue);
|
sl@0
|
430 |
User::After(200000); // to let panic take effect
|
sl@0
|
431 |
test.Printf(_L("Panicing formatting thread #3\n"));
|
sl@0
|
432 |
|
sl@0
|
433 |
RDir dir;
|
sl@0
|
434 |
r=dir.Open(TheFs,_L("\\*.*"),KEntryAttNormal);
|
sl@0
|
435 |
// if(IsTestingLFFS() && (r==KErrNone))
|
sl@0
|
436 |
// {
|
sl@0
|
437 |
// dir.Close();
|
sl@0
|
438 |
// }
|
sl@0
|
439 |
// else
|
sl@0
|
440 |
// {
|
sl@0
|
441 |
test(r==KErrCorrupt);
|
sl@0
|
442 |
// }
|
sl@0
|
443 |
|
sl@0
|
444 |
test.Printf(_L("Formatting the drive...\n"));
|
sl@0
|
445 |
|
sl@0
|
446 |
TInt count;
|
sl@0
|
447 |
RFormat format;
|
sl@0
|
448 |
r=format.Open(TheFs,gSessionPath,EQuickFormat,count);
|
sl@0
|
449 |
test(r==KErrNone);
|
sl@0
|
450 |
|
sl@0
|
451 |
r = DoFormatSteps(format, count);
|
sl@0
|
452 |
test(r==KErrNone);
|
sl@0
|
453 |
|
sl@0
|
454 |
format.Close();
|
sl@0
|
455 |
|
sl@0
|
456 |
MakeFile(_L("BLARGOID.BLARG"));
|
sl@0
|
457 |
CheckFileExists(_L("BLARGOID.BLARG"),KErrNone);
|
sl@0
|
458 |
clientThread.Close();
|
sl@0
|
459 |
gSleepThread.Close();
|
sl@0
|
460 |
}
|
sl@0
|
461 |
|
sl@0
|
462 |
//-------------------------------------------------------------------
|
sl@0
|
463 |
static void Test6()
|
sl@0
|
464 |
//
|
sl@0
|
465 |
// Test ramdrive is shrunk after formatting
|
sl@0
|
466 |
//
|
sl@0
|
467 |
{
|
sl@0
|
468 |
|
sl@0
|
469 |
test.Next(_L("Test ramdrive shrinks after formatting"));
|
sl@0
|
470 |
TVolumeInfo volInfo;
|
sl@0
|
471 |
TInt r=TheFs.Volume(volInfo);
|
sl@0
|
472 |
test(r==KErrNone);
|
sl@0
|
473 |
if ((volInfo.iDrive.iMediaAtt&KMediaAttVariableSize)==0)
|
sl@0
|
474 |
return;
|
sl@0
|
475 |
|
sl@0
|
476 |
TInt64 used=volInfo.iSize-volInfo.iFree;
|
sl@0
|
477 |
RFile f;
|
sl@0
|
478 |
r=f.Replace(TheFs,_L("BIGFILE.SIZE"),EFileRead|EFileWrite);
|
sl@0
|
479 |
test(r==KErrNone);
|
sl@0
|
480 |
f.SetSize(0x100000); // 1MB
|
sl@0
|
481 |
f.Close();
|
sl@0
|
482 |
|
sl@0
|
483 |
r=TheFs.Volume(volInfo);
|
sl@0
|
484 |
test(r==KErrNone);
|
sl@0
|
485 |
TInt64 used2=volInfo.iSize-volInfo.iFree;
|
sl@0
|
486 |
test(used<used2);
|
sl@0
|
487 |
|
sl@0
|
488 |
r=TheFs.Delete(_L("BIGFILE.SIZE"));
|
sl@0
|
489 |
test(r==KErrNone);
|
sl@0
|
490 |
r=TheFs.Volume(volInfo);
|
sl@0
|
491 |
test(r==KErrNone);
|
sl@0
|
492 |
used2=volInfo.iSize-volInfo.iFree;
|
sl@0
|
493 |
test(used==used2);
|
sl@0
|
494 |
|
sl@0
|
495 |
r=f.Replace(TheFs,_L("BIGFILE.SIZE"),EFileRead|EFileWrite);
|
sl@0
|
496 |
test(r==KErrNone);
|
sl@0
|
497 |
f.SetSize(0x100000); // 1MB
|
sl@0
|
498 |
f.Close();
|
sl@0
|
499 |
|
sl@0
|
500 |
r=TheFs.Volume(volInfo);
|
sl@0
|
501 |
test(r==KErrNone);
|
sl@0
|
502 |
used2=volInfo.iSize-volInfo.iFree;
|
sl@0
|
503 |
test(used<used2);
|
sl@0
|
504 |
|
sl@0
|
505 |
TInt count;
|
sl@0
|
506 |
RFormat format;
|
sl@0
|
507 |
r=format.Open(TheFs,gSessionPath,EQuickFormat,count);
|
sl@0
|
508 |
test(r==KErrNone);
|
sl@0
|
509 |
|
sl@0
|
510 |
r = DoFormatSteps(format, count);
|
sl@0
|
511 |
test(r==KErrNone);
|
sl@0
|
512 |
|
sl@0
|
513 |
format.Close();
|
sl@0
|
514 |
|
sl@0
|
515 |
r=TheFs.Volume(volInfo);
|
sl@0
|
516 |
test(r==KErrNone);
|
sl@0
|
517 |
used2=volInfo.iSize-volInfo.iFree;
|
sl@0
|
518 |
test(used>=used2);
|
sl@0
|
519 |
}
|
sl@0
|
520 |
|
sl@0
|
521 |
static void Test7()
|
sl@0
|
522 |
//
|
sl@0
|
523 |
// Generate media change before formatting.
|
sl@0
|
524 |
//
|
sl@0
|
525 |
{
|
sl@0
|
526 |
|
sl@0
|
527 |
test.Next(_L("Generate Media change before formatting"));
|
sl@0
|
528 |
|
sl@0
|
529 |
if(Is_Automounter(TheFs, gDrive))
|
sl@0
|
530 |
{//-- if we have automounter FS installed, formatting of the corrupted media is not straightforward
|
sl@0
|
531 |
//-- The automounter might not be able to decide which of the child file systems shall be used; This issue is covered in a specific test.
|
sl@0
|
532 |
test.Printf(_L("This step is skipped for Automounter File System\n"));
|
sl@0
|
533 |
return;
|
sl@0
|
534 |
}
|
sl@0
|
535 |
|
sl@0
|
536 |
TVolumeInfo volInfo;
|
sl@0
|
537 |
TInt r=TheFs.Volume(volInfo);
|
sl@0
|
538 |
test(r==KErrNone);
|
sl@0
|
539 |
|
sl@0
|
540 |
if (volInfo.iDrive.iMediaAtt&KMediaAttVariableSize)
|
sl@0
|
541 |
return; // Don't bother on internal disk
|
sl@0
|
542 |
|
sl@0
|
543 |
if (Is_Lffs(TheFs, gDrive))
|
sl@0
|
544 |
return; // Don't bother on LFFS
|
sl@0
|
545 |
|
sl@0
|
546 |
CorruptCurrentDrive();
|
sl@0
|
547 |
// UserSvr::ForceRemountMedia(ERemovableMedia0); // Generate media change
|
sl@0
|
548 |
GenerateMediaChange();
|
sl@0
|
549 |
WaitForMedia();
|
sl@0
|
550 |
TInt count;
|
sl@0
|
551 |
RFormat format;
|
sl@0
|
552 |
r=format.Open(TheFs,gSessionPath,EQuickFormat,count);
|
sl@0
|
553 |
test(r==KErrNone);
|
sl@0
|
554 |
|
sl@0
|
555 |
r = DoFormatSteps(format, count);
|
sl@0
|
556 |
test(r==KErrNone);
|
sl@0
|
557 |
|
sl@0
|
558 |
format.Close();
|
sl@0
|
559 |
}
|
sl@0
|
560 |
|
sl@0
|
561 |
//-------------------------------------------------------------------
|
sl@0
|
562 |
static void Test8()
|
sl@0
|
563 |
//
|
sl@0
|
564 |
// Test incomplete format
|
sl@0
|
565 |
//
|
sl@0
|
566 |
{
|
sl@0
|
567 |
|
sl@0
|
568 |
test.Next(_L("Test incomplete format"));
|
sl@0
|
569 |
|
sl@0
|
570 |
if(Is_Automounter(TheFs, gDrive))
|
sl@0
|
571 |
{//-- if we have automounter FS installed, formatting of the corrupted media is not straightforward
|
sl@0
|
572 |
//-- The automounter might not be able to decide which of the child file systems shall be used; This issue is covered in a specific test.
|
sl@0
|
573 |
test.Printf(_L("This step is skipped for Automounter File System\n"));
|
sl@0
|
574 |
return;
|
sl@0
|
575 |
}
|
sl@0
|
576 |
|
sl@0
|
577 |
CorruptCurrentDrive();
|
sl@0
|
578 |
|
sl@0
|
579 |
if (!(IsTestingLFFS() && GetDriveLFFS()==EDriveC)) // ??? Remove after ER5U
|
sl@0
|
580 |
{
|
sl@0
|
581 |
// UserSvr::ForceRemountMedia(ERemovableMedia0); // Generate media change
|
sl@0
|
582 |
GenerateMediaChange();
|
sl@0
|
583 |
WaitForMedia();
|
sl@0
|
584 |
}
|
sl@0
|
585 |
|
sl@0
|
586 |
TVolumeInfo volInfo;
|
sl@0
|
587 |
TInt r=TheFs.Volume(volInfo);
|
sl@0
|
588 |
// test(r==KErrCorrupt);
|
sl@0
|
589 |
TInt count;
|
sl@0
|
590 |
RFormat format;
|
sl@0
|
591 |
r=format.Open(TheFs,gSessionPath,EQuickFormat,count);
|
sl@0
|
592 |
r=TheFs.Volume(volInfo);
|
sl@0
|
593 |
test(r==KErrInUse);
|
sl@0
|
594 |
r=format.Next(count);
|
sl@0
|
595 |
test(r==KErrNone);
|
sl@0
|
596 |
TDriveList driveList;
|
sl@0
|
597 |
r=TheFs.DriveList(driveList);
|
sl@0
|
598 |
test(r==KErrNone);
|
sl@0
|
599 |
|
sl@0
|
600 |
if(gDrive == EDriveC)
|
sl@0
|
601 |
{
|
sl@0
|
602 |
r=TheFs.Volume(volInfo, gDrive);
|
sl@0
|
603 |
test(r==KErrInUse);
|
sl@0
|
604 |
}
|
sl@0
|
605 |
else
|
sl@0
|
606 |
{
|
sl@0
|
607 |
r=TheFs.Volume(volInfo,EDriveC);
|
sl@0
|
608 |
test(r==KErrNone);
|
sl@0
|
609 |
|
sl@0
|
610 |
r=TheFs.Volume(volInfo,gDrive);
|
sl@0
|
611 |
test(r==KErrInUse);
|
sl@0
|
612 |
|
sl@0
|
613 |
r=TheFs.Volume(volInfo,gDrive);
|
sl@0
|
614 |
test(r==KErrInUse);
|
sl@0
|
615 |
}
|
sl@0
|
616 |
|
sl@0
|
617 |
|
sl@0
|
618 |
format.Close();
|
sl@0
|
619 |
Format(CurrentDrive());
|
sl@0
|
620 |
}
|
sl@0
|
621 |
|
sl@0
|
622 |
|
sl@0
|
623 |
//-------------------------------------------------------------------
|
sl@0
|
624 |
/**
|
sl@0
|
625 |
Test an API that allows force media formatting with the files or other objects opened on the volume
|
sl@0
|
626 |
*/
|
sl@0
|
627 |
void TestFormat_ForceDismount()
|
sl@0
|
628 |
{
|
sl@0
|
629 |
test.Next(_L("Test format with forced media dismounting"));
|
sl@0
|
630 |
|
sl@0
|
631 |
if(Is_Lffs(TheFs, gDrive))
|
sl@0
|
632 |
{//-- forced FS dismounting with files/directories opened damages LFFS structure for unknown reason.
|
sl@0
|
633 |
//-- this is a problem of LFFS, anyway, it is not supported.
|
sl@0
|
634 |
test.Next(_L("This test can't be performed on LFFS, Skipping."));
|
sl@0
|
635 |
return;
|
sl@0
|
636 |
}
|
sl@0
|
637 |
|
sl@0
|
638 |
TInt nRes;
|
sl@0
|
639 |
RFormat format;
|
sl@0
|
640 |
TUint fmtMode = EQuickFormat;
|
sl@0
|
641 |
TInt fmtCnt;
|
sl@0
|
642 |
TBuf<10> drivePath;
|
sl@0
|
643 |
drivePath.Format(_L("%C:\\"), gDrive+'A');
|
sl@0
|
644 |
|
sl@0
|
645 |
|
sl@0
|
646 |
RBuf8 buf8;
|
sl@0
|
647 |
RFile file1;
|
sl@0
|
648 |
RDir dir;
|
sl@0
|
649 |
|
sl@0
|
650 |
const TInt KBufLen = 128*K1KiloByte;
|
sl@0
|
651 |
nRes = buf8.CreateMax(KBufLen);
|
sl@0
|
652 |
test_KErrNone(nRes);
|
sl@0
|
653 |
|
sl@0
|
654 |
_LIT(KFname, "\\file1");
|
sl@0
|
655 |
|
sl@0
|
656 |
|
sl@0
|
657 |
|
sl@0
|
658 |
//---------------------------------------------------------------------------------
|
sl@0
|
659 |
//-- 1.1 open a file, try to format in normal mode; this shall fail with KErrInUse
|
sl@0
|
660 |
test.Printf(_L("Test normal format with normal opened objects\n"));
|
sl@0
|
661 |
nRes = file1.Replace(TheFs, KFname, EFileWrite);
|
sl@0
|
662 |
test_KErrNone(nRes);
|
sl@0
|
663 |
|
sl@0
|
664 |
fmtMode = EQuickFormat;
|
sl@0
|
665 |
|
sl@0
|
666 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
|
sl@0
|
667 |
test(nRes == KErrInUse);
|
sl@0
|
668 |
format.Close();
|
sl@0
|
669 |
|
sl@0
|
670 |
buf8.SetLength(22);
|
sl@0
|
671 |
nRes = file1.Write(buf8);
|
sl@0
|
672 |
test_KErrNone(nRes);
|
sl@0
|
673 |
|
sl@0
|
674 |
file1.Close();
|
sl@0
|
675 |
|
sl@0
|
676 |
//-- 1.2 open a directory, try to format in normal mode; this shall fail with KErrInUse
|
sl@0
|
677 |
nRes = dir.Open(TheFs,_L("\\*.*"),KEntryAttNormal);
|
sl@0
|
678 |
test_KErrNone(nRes);
|
sl@0
|
679 |
|
sl@0
|
680 |
fmtMode = EQuickFormat;
|
sl@0
|
681 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
|
sl@0
|
682 |
test(nRes == KErrInUse);
|
sl@0
|
683 |
format.Close();
|
sl@0
|
684 |
|
sl@0
|
685 |
dir.Close();
|
sl@0
|
686 |
|
sl@0
|
687 |
|
sl@0
|
688 |
//---------------------------------------------------------------------------------
|
sl@0
|
689 |
//-- 2.1 forced quick formatting
|
sl@0
|
690 |
test.Printf(_L("Test forced quick formatting\n"));
|
sl@0
|
691 |
nRes = file1.Replace(TheFs, KFname, EFileWrite); //-- open a file
|
sl@0
|
692 |
test_KErrNone(nRes);
|
sl@0
|
693 |
|
sl@0
|
694 |
nRes = dir.Open(TheFs,_L("\\*.*"),KEntryAttNormal); //-- open a directory
|
sl@0
|
695 |
test_KErrNone(nRes);
|
sl@0
|
696 |
|
sl@0
|
697 |
//-- this will mark the current Mount as "Dismounted" and will instantiate another CMountCB for formatting
|
sl@0
|
698 |
fmtMode = EQuickFormat | EForceFormat;
|
sl@0
|
699 |
|
sl@0
|
700 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
|
sl@0
|
701 |
test_KErrNone(nRes);
|
sl@0
|
702 |
|
sl@0
|
703 |
nRes = DoFormatSteps(format, fmtCnt);
|
sl@0
|
704 |
test_KErrNone(nRes);
|
sl@0
|
705 |
|
sl@0
|
706 |
format.Close();
|
sl@0
|
707 |
|
sl@0
|
708 |
|
sl@0
|
709 |
nRes=TheFs.CheckDisk(gSessionPath);
|
sl@0
|
710 |
test(nRes==KErrNone||nRes==KErrNotSupported);
|
sl@0
|
711 |
|
sl@0
|
712 |
buf8.SetLength(22);
|
sl@0
|
713 |
nRes = file1.Write(buf8);
|
sl@0
|
714 |
test(nRes == KErrDisMounted);
|
sl@0
|
715 |
file1.Close(); //-- this will make the previously "Dismounted" mount die.
|
sl@0
|
716 |
dir.Close();
|
sl@0
|
717 |
|
sl@0
|
718 |
|
sl@0
|
719 |
//---------------------------------------------------------------------------------
|
sl@0
|
720 |
//-- 2.2 forced full formatting
|
sl@0
|
721 |
test.Printf(_L("Test forced full formatting\n"));
|
sl@0
|
722 |
nRes = file1.Replace(TheFs, KFname, EFileWrite);
|
sl@0
|
723 |
test_KErrNone(nRes);
|
sl@0
|
724 |
|
sl@0
|
725 |
//-- this will mark the current Mount as "Dismounted" and will instantiate another CMountCB for formatting
|
sl@0
|
726 |
fmtMode = EFullFormat | EForceFormat;
|
sl@0
|
727 |
|
sl@0
|
728 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
|
sl@0
|
729 |
test_KErrNone(nRes);
|
sl@0
|
730 |
|
sl@0
|
731 |
nRes = DoFormatSteps(format, fmtCnt);
|
sl@0
|
732 |
test_KErrNone(nRes);
|
sl@0
|
733 |
|
sl@0
|
734 |
format.Close();
|
sl@0
|
735 |
|
sl@0
|
736 |
nRes=TheFs.CheckDisk(gSessionPath);
|
sl@0
|
737 |
test(nRes==KErrNone||nRes==KErrNotSupported);
|
sl@0
|
738 |
|
sl@0
|
739 |
buf8.SetLength(22);
|
sl@0
|
740 |
nRes = file1.Write(buf8);
|
sl@0
|
741 |
test(nRes == KErrDisMounted);
|
sl@0
|
742 |
file1.Close(); //-- this will make the previously "Dismounted" mount die.
|
sl@0
|
743 |
|
sl@0
|
744 |
//---------------------------------------------------------------------------------
|
sl@0
|
745 |
//-- 3. check that forced formatting will complete NotifyDismount
|
sl@0
|
746 |
test.Printf(_L("Test forced formatting completes NotifyDismount\n"));
|
sl@0
|
747 |
TRequestStatus stat1;
|
sl@0
|
748 |
|
sl@0
|
749 |
nRes = file1.Replace(TheFs, KFname, EFileWrite);
|
sl@0
|
750 |
test_KErrNone(nRes);
|
sl@0
|
751 |
|
sl@0
|
752 |
TheFs.NotifyDismount(gDrive, stat1, EFsDismountRegisterClient);
|
sl@0
|
753 |
test(stat1.Int() == KRequestPending);
|
sl@0
|
754 |
|
sl@0
|
755 |
fmtMode = EQuickFormat;
|
sl@0
|
756 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
|
sl@0
|
757 |
test(nRes == KErrInUse);
|
sl@0
|
758 |
format.Close();
|
sl@0
|
759 |
|
sl@0
|
760 |
test(stat1.Int() == KRequestPending);
|
sl@0
|
761 |
|
sl@0
|
762 |
fmtMode = EQuickFormat | EForceFormat;
|
sl@0
|
763 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
|
sl@0
|
764 |
test_KErrNone(nRes);
|
sl@0
|
765 |
format.Close();
|
sl@0
|
766 |
|
sl@0
|
767 |
User::WaitForRequest(stat1);
|
sl@0
|
768 |
test(stat1.Int() == KErrNone);
|
sl@0
|
769 |
|
sl@0
|
770 |
buf8.SetLength(22);
|
sl@0
|
771 |
nRes = file1.Write(buf8);
|
sl@0
|
772 |
test(nRes == KErrDisMounted);
|
sl@0
|
773 |
file1.Close();
|
sl@0
|
774 |
|
sl@0
|
775 |
//---------------------------------------------------------------------------------
|
sl@0
|
776 |
//-- 4.1 check that forced formatting will succeed with dirty file cache
|
sl@0
|
777 |
test.Printf(_L("Test forced formatting will succeed with dirty file cache\n"));
|
sl@0
|
778 |
|
sl@0
|
779 |
nRes = file1.Replace(TheFs, KFname, EFileWrite | EFileWriteBuffered); //-- enable write caching
|
sl@0
|
780 |
test_KErrNone(nRes);
|
sl@0
|
781 |
|
sl@0
|
782 |
buf8.SetLength(KBufLen);
|
sl@0
|
783 |
nRes = file1.Write(buf8); //-- this will hopefully get via file write cache
|
sl@0
|
784 |
test_KErrNone(nRes);
|
sl@0
|
785 |
|
sl@0
|
786 |
fmtMode = EQuickFormat | EForceFormat;
|
sl@0
|
787 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
|
sl@0
|
788 |
test_KErrNone(nRes);
|
sl@0
|
789 |
format.Close();
|
sl@0
|
790 |
|
sl@0
|
791 |
nRes = file1.Write(buf8);
|
sl@0
|
792 |
test(nRes == KErrDisMounted);
|
sl@0
|
793 |
file1.Close();
|
sl@0
|
794 |
|
sl@0
|
795 |
|
sl@0
|
796 |
//---------------------------------------------------------------------------------
|
sl@0
|
797 |
|
sl@0
|
798 |
test.Printf(_L("Test forced formatting with disk access objects opened\n"));
|
sl@0
|
799 |
|
sl@0
|
800 |
//-- 5.1 check that forced formatting will fail when there are "disk access" objects opened RFormat
|
sl@0
|
801 |
RFormat format1;
|
sl@0
|
802 |
|
sl@0
|
803 |
nRes = format1.Open(TheFs, drivePath, fmtMode, fmtCnt);
|
sl@0
|
804 |
test(nRes == KErrNone);
|
sl@0
|
805 |
|
sl@0
|
806 |
fmtMode = EQuickFormat | EForceFormat;
|
sl@0
|
807 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
|
sl@0
|
808 |
test(nRes == KErrInUse);
|
sl@0
|
809 |
format.Close();
|
sl@0
|
810 |
|
sl@0
|
811 |
format1.Close();
|
sl@0
|
812 |
|
sl@0
|
813 |
//-- 5.1 check that forced formatting will fail when there are "disk access" objects opened RRawDisk
|
sl@0
|
814 |
RRawDisk rawDisk;
|
sl@0
|
815 |
nRes = rawDisk.Open(TheFs, gDrive);
|
sl@0
|
816 |
test(nRes == KErrNone);
|
sl@0
|
817 |
|
sl@0
|
818 |
fmtMode = EQuickFormat | EForceFormat;
|
sl@0
|
819 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
|
sl@0
|
820 |
test(nRes == KErrInUse);
|
sl@0
|
821 |
format.Close();
|
sl@0
|
822 |
|
sl@0
|
823 |
rawDisk.Close();
|
sl@0
|
824 |
|
sl@0
|
825 |
|
sl@0
|
826 |
//---------------------------------------------------------------------------------
|
sl@0
|
827 |
//-- 6. Try forced formatting with clamped files, this shall fail with KErrInuse
|
sl@0
|
828 |
test.Printf(_L("Test forced formatting and clamps on the volume\n"));
|
sl@0
|
829 |
|
sl@0
|
830 |
nRes = file1.Replace(TheFs, KFname, EFileWrite);
|
sl@0
|
831 |
test_KErrNone(nRes);
|
sl@0
|
832 |
|
sl@0
|
833 |
buf8.SetLength(KBufLen);
|
sl@0
|
834 |
nRes = file1.Write(buf8); //-- this will hopefully get via file write cache
|
sl@0
|
835 |
test_KErrNone(nRes);
|
sl@0
|
836 |
file1.Flush();
|
sl@0
|
837 |
|
sl@0
|
838 |
//-- Clamp file
|
sl@0
|
839 |
RFileClamp handle;
|
sl@0
|
840 |
|
sl@0
|
841 |
nRes=handle.Clamp(file1);
|
sl@0
|
842 |
if(nRes != KErrNone)
|
sl@0
|
843 |
{
|
sl@0
|
844 |
test.Printf(_L("file clamps on this drive are not supported\n"));
|
sl@0
|
845 |
}
|
sl@0
|
846 |
else
|
sl@0
|
847 |
{
|
sl@0
|
848 |
fmtMode = EQuickFormat | EForceFormat;
|
sl@0
|
849 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
|
sl@0
|
850 |
test(nRes == KErrInUse);
|
sl@0
|
851 |
format.Close();
|
sl@0
|
852 |
}
|
sl@0
|
853 |
|
sl@0
|
854 |
handle.Close(TheFs);
|
sl@0
|
855 |
|
sl@0
|
856 |
file1.Close();
|
sl@0
|
857 |
|
sl@0
|
858 |
buf8.Close();
|
sl@0
|
859 |
}
|
sl@0
|
860 |
|
sl@0
|
861 |
|
sl@0
|
862 |
void CallTestsL()
|
sl@0
|
863 |
//
|
sl@0
|
864 |
// Call tests that may leave
|
sl@0
|
865 |
//
|
sl@0
|
866 |
{
|
sl@0
|
867 |
|
sl@0
|
868 |
TInt r;
|
sl@0
|
869 |
r = TheFs.CharToDrive(gDriveToTest, gDrive);
|
sl@0
|
870 |
test(r == KErrNone);
|
sl@0
|
871 |
|
sl@0
|
872 |
//-- set up console output
|
sl@0
|
873 |
F32_Test_Utils::SetConsole(test.Console());
|
sl@0
|
874 |
|
sl@0
|
875 |
TInt nRes=TheFs.CharToDrive(gDriveToTest, gDrive);
|
sl@0
|
876 |
test(nRes==KErrNone);
|
sl@0
|
877 |
|
sl@0
|
878 |
PrintDrvInfo(TheFs, gDrive);
|
sl@0
|
879 |
|
sl@0
|
880 |
if(Is_Win32(TheFs, gDrive))
|
sl@0
|
881 |
return; //-- emulator drive c:
|
sl@0
|
882 |
|
sl@0
|
883 |
|
sl@0
|
884 |
SetSessionPath(_L("\\"));
|
sl@0
|
885 |
|
sl@0
|
886 |
Test1();
|
sl@0
|
887 |
Test2();
|
sl@0
|
888 |
Test3();
|
sl@0
|
889 |
Test4();
|
sl@0
|
890 |
Test5();
|
sl@0
|
891 |
Test6();
|
sl@0
|
892 |
Test7();
|
sl@0
|
893 |
Test8();
|
sl@0
|
894 |
TestFormat_ForceDismount();
|
sl@0
|
895 |
|
sl@0
|
896 |
r=TheFs.CheckDisk(gSessionPath);
|
sl@0
|
897 |
test(r==KErrNone||r==KErrNotSupported);
|
sl@0
|
898 |
}
|
sl@0
|
899 |
|
sl@0
|
900 |
|