94 // |
94 // |
95 { |
95 { |
96 |
96 |
97 RFs fs; |
97 RFs fs; |
98 TInt ret=fs.Connect(); |
98 TInt ret=fs.Connect(); |
99 test(ret==KErrNone); |
99 test_KErrNone(ret); |
100 ret=fs.SetSessionPath(gSessionPath); |
100 ret=fs.SetSessionPath(gSessionPath); |
101 test(ret==KErrNone); |
101 test_KErrNone(ret); |
102 TTestCode testCode=*(TTestCode*)&aTestCode; |
102 TTestCode testCode=*(TTestCode*)&aTestCode; |
103 TInt count; |
103 TInt count; |
104 RFormat format; |
104 RFormat format; |
105 switch (testCode) |
105 switch (testCode) |
106 { |
106 { |
107 case ETest3: |
107 case ETest3: |
108 { |
108 { |
109 ret=format.Open(fs,gSessionPath,EQuickFormat,count); |
109 ret=format.Open(fs,gSessionPath,EQuickFormat,count); |
110 test(ret==KErrNone); |
110 test_KErrNone(ret); |
111 |
111 |
112 ret = DoFormatSteps(format, count); |
112 ret = DoFormatSteps(format, count); |
113 test(ret==KErrNone); |
113 test_KErrNone(ret); |
114 |
114 |
115 format.Close(); |
115 format.Close(); |
116 break; |
116 break; |
117 } |
117 } |
118 case ETest5: |
118 case ETest5: |
119 { |
119 { |
120 ret=format.Open(fs,gSessionPath,EFullFormat,count); |
120 ret=format.Open(fs,gSessionPath,EFullFormat,count); |
121 test(ret==KErrNone); |
121 test_KErrNone(ret); |
122 gSleepThread.Signal(); |
122 gSleepThread.Signal(); |
123 User::After(100000000); |
123 User::After(100000000); |
124 break; |
124 break; |
125 } |
125 } |
126 default: |
126 default: |
137 { |
137 { |
138 test.Printf(_L("CorruptCurrentDrive() %c:"), 'A'+CurrentDrive()); |
138 test.Printf(_L("CorruptCurrentDrive() %c:"), 'A'+CurrentDrive()); |
139 |
139 |
140 RRawDisk raw; |
140 RRawDisk raw; |
141 TInt r=raw.Open(TheFs,CurrentDrive()); |
141 TInt r=raw.Open(TheFs,CurrentDrive()); |
142 test(r==KErrNone); |
142 test_KErrNone(r); |
143 if (!Is_Lffs(TheFs, gDrive)) |
143 if (!Is_Lffs(TheFs, gDrive)) |
144 { |
144 { |
145 TBuf8<KSectorSize> zeroBuf(KSectorSize); |
145 TBuf8<KSectorSize> zeroBuf(KSectorSize); |
146 Mem::FillZ((TAny*)zeroBuf.Ptr(),zeroBuf.MaxSize()); |
146 Mem::FillZ((TAny*)zeroBuf.Ptr(),zeroBuf.MaxSize()); |
147 |
147 |
149 //-- otherwise it can be used and some tests will fail.. |
149 //-- otherwise it can be used and some tests will fail.. |
150 const TInt KMaxSectors = 25; //-- how many sectors to corrupt |
150 const TInt KMaxSectors = 25; //-- how many sectors to corrupt |
151 for(TInt i=0; i<KMaxSectors; ++i) |
151 for(TInt i=0; i<KMaxSectors; ++i) |
152 { |
152 { |
153 r=raw.Write(i*KSectorSize, zeroBuf); |
153 r=raw.Write(i*KSectorSize, zeroBuf); |
154 test(r==KErrNone); |
154 test_KErrNone(r); |
155 } |
155 } |
156 } |
156 } |
157 else |
157 else |
158 { |
158 { |
159 TBuf8<32> zeroBuf(32); |
159 TBuf8<32> zeroBuf(32); |
172 // The device driver most likely fails when writing a random |
172 // The device driver most likely fails when writing a random |
173 // buffer due to read back checks. Since we're writing |
173 // buffer due to read back checks. Since we're writing |
174 // aligned 32-byte blocks, we don't need to bother that much. |
174 // aligned 32-byte blocks, we don't need to bother that much. |
175 // The device driver writes the block but fails when reading |
175 // The device driver writes the block but fails when reading |
176 // it back. |
176 // it back. |
177 // test(r==KErrNone); |
177 // test_KErrNone(r); |
178 } |
178 } |
179 } |
179 } |
180 else if(cntlModeSize>0) |
180 else if(cntlModeSize>0) |
181 { |
181 { |
182 //test.Printf(_L("CorruptCurrentDrive() - Control mode = 0x%x\n"),r); |
182 //test.Printf(_L("CorruptCurrentDrive() - Control mode = 0x%x\n"),r); |
236 test.Next(_L("Test EFullFormat")); |
236 test.Next(_L("Test EFullFormat")); |
237 TInt count; |
237 TInt count; |
238 RFormat format; |
238 RFormat format; |
239 |
239 |
240 TInt r=format.Open(TheFs,gSessionPath,EFullFormat,count); |
240 TInt r=format.Open(TheFs,gSessionPath,EFullFormat,count); |
241 test(r==KErrNone); |
241 test_KErrNone(r); |
242 |
242 |
243 r = DoFormatSteps(format, count); |
243 r = DoFormatSteps(format, count); |
244 test(r==KErrNone); |
244 test_KErrNone(r); |
245 |
245 |
246 format.Close(); |
246 format.Close(); |
247 |
247 |
248 TVolumeInfo volInfo; |
248 TVolumeInfo volInfo; |
249 r=TheFs.Volume(volInfo); |
249 r=TheFs.Volume(volInfo); |
250 test(r==KErrNone); |
250 test_KErrNone(r); |
251 |
251 |
252 if (volInfo.iSize-volInfo.iFree!=0) |
252 if (volInfo.iSize-volInfo.iFree!=0) |
253 { |
253 { |
254 test.Printf(_L("Memory 'in use' after a full format = %ld\n"),(volInfo.iSize-volInfo.iFree)); |
254 test.Printf(_L("Memory 'in use' after a full format = %ld\n"),(volInfo.iSize-volInfo.iFree)); |
255 test.Printf(_L("volInfo.iSize = %ld\n"),volInfo.iSize); |
255 test.Printf(_L("volInfo.iSize = %ld\n"),volInfo.iSize); |
256 test.Printf(_L("volInfo.iFree = %ld\n"),volInfo.iFree); |
256 test.Printf(_L("volInfo.iFree = %ld\n"),volInfo.iFree); |
257 } |
257 } |
258 |
258 |
259 test.Next(_L("Test EQuickFormat")); |
259 test.Next(_L("Test EQuickFormat")); |
260 r=format.Open(TheFs,gSessionPath,EQuickFormat,count); |
260 r=format.Open(TheFs,gSessionPath,EQuickFormat,count); |
261 test(r==KErrNone); |
261 test_KErrNone(r); |
262 |
262 |
263 r = DoFormatSteps(format, count); |
263 r = DoFormatSteps(format, count); |
264 test(r==KErrNone); |
264 test_KErrNone(r); |
265 |
265 |
266 format.Close(); |
266 format.Close(); |
267 |
267 |
268 r=TheFs.Volume(volInfo); |
268 r=TheFs.Volume(volInfo); |
269 test(r==KErrNone); |
269 test_KErrNone(r); |
270 |
270 |
271 if (volInfo.iSize-volInfo.iFree!=0) |
271 if (volInfo.iSize-volInfo.iFree!=0) |
272 { |
272 { |
273 test.Printf(_L("Memory 'in use' after a quick format = %ld\n"),(volInfo.iSize-volInfo.iFree)); |
273 test.Printf(_L("Memory 'in use' after a quick format = %ld\n"),(volInfo.iSize-volInfo.iFree)); |
274 test.Printf(_L("volInfo.iSize = %ld\n"),volInfo.iSize); |
274 test.Printf(_L("volInfo.iSize = %ld\n"),volInfo.iSize); |
286 { |
286 { |
287 |
287 |
288 test.Next(_L("Test disk cannot be formatted while a file is open")); |
288 test.Next(_L("Test disk cannot be formatted while a file is open")); |
289 RFile f; |
289 RFile f; |
290 TInt r=f.Replace(TheFs,_L("BLARGME.BLARG"),EFileStream); |
290 TInt r=f.Replace(TheFs,_L("BLARGME.BLARG"),EFileStream); |
291 test(r==KErrNone); |
291 test_KErrNone(r); |
292 |
292 |
293 TInt count; |
293 TInt count; |
294 RFormat format; |
294 RFormat format; |
295 r=format.Open(TheFs,gSessionPath,EFullFormat,count); |
295 r=format.Open(TheFs,gSessionPath,EFullFormat,count); |
296 test(r==KErrInUse); |
296 test_Value(r, r == KErrInUse); |
297 |
297 |
298 f.Close(); |
298 f.Close(); |
299 r=format.Open(TheFs,gSessionPath,EFullFormat,count); |
299 r=format.Open(TheFs,gSessionPath,EFullFormat,count); |
300 test(r==KErrNone); |
300 test_KErrNone(r); |
301 format.Close(); |
301 format.Close(); |
302 |
302 |
303 CheckFileExists(_L("BLARGME.BLARG"),KErrNone); |
303 CheckFileExists(_L("BLARGME.BLARG"),KErrNone); |
304 } |
304 } |
305 |
305 |
316 TheFs.NotifyChange(ENotifyEntry,reqStat); |
316 TheFs.NotifyChange(ENotifyEntry,reqStat); |
317 |
317 |
318 RThread clientThread; |
318 RThread clientThread; |
319 TInt r=clientThread.Create(_L("ClientThread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest3); |
319 TInt r=clientThread.Create(_L("ClientThread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest3); |
320 test.Printf(_L("Created helper thread #1, res=%d\n"),r); |
320 test.Printf(_L("Created helper thread #1, res=%d\n"),r); |
321 test(r==KErrNone); |
321 test_KErrNone(r); |
322 |
322 |
323 clientThread.Logon(gThreadLogon); |
323 clientThread.Logon(gThreadLogon); |
324 clientThread.Resume(); |
324 clientThread.Resume(); |
325 clientThread.Close(); |
325 clientThread.Close(); |
326 |
326 |
334 MakeFile(_L("\\BLARG_BLARG_BLARG.BLG")); |
334 MakeFile(_L("\\BLARG_BLARG_BLARG.BLG")); |
335 |
335 |
336 TheFs.NotifyChange(ENotifyAll,reqStat); |
336 TheFs.NotifyChange(ENotifyAll,reqStat); |
337 r=clientThread.Create(_L("ClientThread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest3); |
337 r=clientThread.Create(_L("ClientThread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest3); |
338 test.Printf(_L("Created helper thread #2, res=%d\n"),r); |
338 test.Printf(_L("Created helper thread #2, res=%d\n"),r); |
339 test(r==KErrNone); |
339 test_KErrNone(r); |
340 |
340 |
341 |
341 |
342 clientThread.Logon(gThreadLogon); |
342 clientThread.Logon(gThreadLogon); |
343 clientThread.Resume(); |
343 clientThread.Resume(); |
344 clientThread.Close(); |
344 clientThread.Close(); |
373 |
373 |
374 test.Printf(_L("Formatting the drive...\n")); |
374 test.Printf(_L("Formatting the drive...\n")); |
375 |
375 |
376 RFormat format; |
376 RFormat format; |
377 TInt r=format.Open(TheFs,gSessionPath,EFullFormat,count); |
377 TInt r=format.Open(TheFs,gSessionPath,EFullFormat,count); |
378 test(r==KErrNone); |
378 test_KErrNone(r); |
379 |
379 |
380 while(count) |
380 while(count) |
381 { |
381 { |
382 RDir dir; |
382 RDir dir; |
383 r=dir.Open(TheFs,_L("\\*.*"),KEntryAttNormal); |
383 r=dir.Open(TheFs,_L("\\*.*"),KEntryAttNormal); |
384 test(r==KErrInUse); |
384 test_Value(r, r == KErrInUse); |
385 r=format.Next(count); |
385 r=format.Next(count); |
386 test(r==KErrNone); |
386 test_KErrNone(r); |
387 } |
387 } |
388 format.Close(); |
388 format.Close(); |
389 |
389 |
390 CheckFileExists(_L("\\FORMAT\\DIR1\\BLARG_BLARG_BLARG.BLG"),KErrPathNotFound); |
390 CheckFileExists(_L("\\FORMAT\\DIR1\\BLARG_BLARG_BLARG.BLG"),KErrPathNotFound); |
391 } |
391 } |
416 |
416 |
417 gSleepThread.CreateLocal(0); |
417 gSleepThread.CreateLocal(0); |
418 RThread clientThread; |
418 RThread clientThread; |
419 TInt r=clientThread.Create(_L("ClientThread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5); |
419 TInt r=clientThread.Create(_L("ClientThread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5); |
420 test.Printf(_L("Created helper thread #1, res=%d\n"),r); |
420 test.Printf(_L("Created helper thread #1, res=%d\n"),r); |
421 test(r==KErrNone); |
421 test_KErrNone(r); |
422 |
422 |
423 test.Printf(_L("Panicing formatting thread #1\n")); |
423 test.Printf(_L("Panicing formatting thread #1\n")); |
424 clientThread.Resume(); |
424 clientThread.Resume(); |
425 gSleepThread.Wait(); |
425 gSleepThread.Wait(); |
426 test.Printf(_L("Panicing formatting thread #2\n")); |
426 test.Printf(_L("Panicing formatting thread #2\n")); |
436 // { |
436 // { |
437 // dir.Close(); |
437 // dir.Close(); |
438 // } |
438 // } |
439 // else |
439 // else |
440 // { |
440 // { |
441 test(r==KErrCorrupt); |
441 test_Value(r, r == KErrCorrupt); |
442 // } |
442 // } |
443 |
443 |
444 test.Printf(_L("Formatting the drive...\n")); |
444 test.Printf(_L("Formatting the drive...\n")); |
445 |
445 |
446 TInt count; |
446 TInt count; |
447 RFormat format; |
447 RFormat format; |
448 r=format.Open(TheFs,gSessionPath,EQuickFormat,count); |
448 r=format.Open(TheFs,gSessionPath,EQuickFormat,count); |
449 test(r==KErrNone); |
449 test_KErrNone(r); |
450 |
450 |
451 r = DoFormatSteps(format, count); |
451 r = DoFormatSteps(format, count); |
452 test(r==KErrNone); |
452 test_KErrNone(r); |
453 |
453 |
454 format.Close(); |
454 format.Close(); |
455 |
455 |
456 MakeFile(_L("BLARGOID.BLARG")); |
456 MakeFile(_L("BLARGOID.BLARG")); |
457 CheckFileExists(_L("BLARGOID.BLARG"),KErrNone); |
457 CheckFileExists(_L("BLARGOID.BLARG"),KErrNone); |
467 { |
467 { |
468 |
468 |
469 test.Next(_L("Test ramdrive shrinks after formatting")); |
469 test.Next(_L("Test ramdrive shrinks after formatting")); |
470 TVolumeInfo volInfo; |
470 TVolumeInfo volInfo; |
471 TInt r=TheFs.Volume(volInfo); |
471 TInt r=TheFs.Volume(volInfo); |
472 test(r==KErrNone); |
472 test_KErrNone(r); |
473 if ((volInfo.iDrive.iMediaAtt&KMediaAttVariableSize)==0) |
473 if ((volInfo.iDrive.iMediaAtt&KMediaAttVariableSize)==0) |
474 return; |
474 return; |
475 |
475 |
476 TInt64 used=volInfo.iSize-volInfo.iFree; |
476 TInt64 used=volInfo.iSize-volInfo.iFree; |
477 RFile f; |
477 RFile f; |
478 r=f.Replace(TheFs,_L("BIGFILE.SIZE"),EFileRead|EFileWrite); |
478 r=f.Replace(TheFs,_L("BIGFILE.SIZE"),EFileRead|EFileWrite); |
479 test(r==KErrNone); |
479 test_KErrNone(r); |
480 f.SetSize(0x100000); // 1MB |
480 f.SetSize(0x100000); // 1MB |
481 f.Close(); |
481 f.Close(); |
482 |
482 |
483 r=TheFs.Volume(volInfo); |
483 r=TheFs.Volume(volInfo); |
484 test(r==KErrNone); |
484 test_KErrNone(r); |
485 TInt64 used2=volInfo.iSize-volInfo.iFree; |
485 TInt64 used2=volInfo.iSize-volInfo.iFree; |
486 test(used<used2); |
486 test(used<used2); |
487 |
487 |
488 r=TheFs.Delete(_L("BIGFILE.SIZE")); |
488 r=TheFs.Delete(_L("BIGFILE.SIZE")); |
489 test(r==KErrNone); |
489 test_KErrNone(r); |
490 r=TheFs.Volume(volInfo); |
490 r=TheFs.Volume(volInfo); |
491 test(r==KErrNone); |
491 test_KErrNone(r); |
492 used2=volInfo.iSize-volInfo.iFree; |
492 used2=volInfo.iSize-volInfo.iFree; |
493 test(used==used2); |
493 test(used==used2); |
494 |
494 |
495 r=f.Replace(TheFs,_L("BIGFILE.SIZE"),EFileRead|EFileWrite); |
495 r=f.Replace(TheFs,_L("BIGFILE.SIZE"),EFileRead|EFileWrite); |
496 test(r==KErrNone); |
496 test_KErrNone(r); |
497 f.SetSize(0x100000); // 1MB |
497 f.SetSize(0x100000); // 1MB |
498 f.Close(); |
498 f.Close(); |
499 |
499 |
500 r=TheFs.Volume(volInfo); |
500 r=TheFs.Volume(volInfo); |
501 test(r==KErrNone); |
501 test_KErrNone(r); |
502 used2=volInfo.iSize-volInfo.iFree; |
502 used2=volInfo.iSize-volInfo.iFree; |
503 test(used<used2); |
503 test(used<used2); |
504 |
504 |
505 TInt count; |
505 TInt count; |
506 RFormat format; |
506 RFormat format; |
507 r=format.Open(TheFs,gSessionPath,EQuickFormat,count); |
507 r=format.Open(TheFs,gSessionPath,EQuickFormat,count); |
508 test(r==KErrNone); |
508 test_KErrNone(r); |
509 |
509 |
510 r = DoFormatSteps(format, count); |
510 r = DoFormatSteps(format, count); |
511 test(r==KErrNone); |
511 test_KErrNone(r); |
512 |
512 |
513 format.Close(); |
513 format.Close(); |
514 |
514 |
515 r=TheFs.Volume(volInfo); |
515 r=TheFs.Volume(volInfo); |
516 test(r==KErrNone); |
516 test_KErrNone(r); |
517 used2=volInfo.iSize-volInfo.iFree; |
517 used2=volInfo.iSize-volInfo.iFree; |
518 test(used>=used2); |
518 test(used>=used2); |
519 } |
519 } |
520 |
520 |
521 static void Test7() |
521 static void Test7() |
548 GenerateMediaChange(); |
548 GenerateMediaChange(); |
549 WaitForMedia(); |
549 WaitForMedia(); |
550 TInt count; |
550 TInt count; |
551 RFormat format; |
551 RFormat format; |
552 r=format.Open(TheFs,gSessionPath,EQuickFormat,count); |
552 r=format.Open(TheFs,gSessionPath,EQuickFormat,count); |
553 test(r==KErrNone); |
553 test_KErrNone(r); |
554 |
554 |
555 r = DoFormatSteps(format, count); |
555 r = DoFormatSteps(format, count); |
556 test(r==KErrNone); |
556 test_KErrNone(r); |
557 |
557 |
558 format.Close(); |
558 format.Close(); |
559 } |
559 } |
560 |
560 |
561 //------------------------------------------------------------------- |
561 //------------------------------------------------------------------- |
583 WaitForMedia(); |
583 WaitForMedia(); |
584 } |
584 } |
585 |
585 |
586 TVolumeInfo volInfo; |
586 TVolumeInfo volInfo; |
587 TInt r=TheFs.Volume(volInfo); |
587 TInt r=TheFs.Volume(volInfo); |
588 // test(r==KErrCorrupt); |
588 // test_Value(r, r == KErrCorrupt); |
589 TInt count; |
589 TInt count; |
590 RFormat format; |
590 RFormat format; |
591 r=format.Open(TheFs,gSessionPath,EQuickFormat,count); |
591 r=format.Open(TheFs,gSessionPath,EQuickFormat,count); |
592 r=TheFs.Volume(volInfo); |
592 r=TheFs.Volume(volInfo); |
593 test(r==KErrInUse); |
593 test_Value(r, r == KErrInUse); |
594 r=format.Next(count); |
594 r=format.Next(count); |
595 test(r==KErrNone); |
595 test_KErrNone(r); |
596 TDriveList driveList; |
596 TDriveList driveList; |
597 r=TheFs.DriveList(driveList); |
597 r=TheFs.DriveList(driveList); |
598 test(r==KErrNone); |
598 test_KErrNone(r); |
599 |
599 |
600 if(gDrive == EDriveC) |
600 if(gDrive == EDriveC) |
601 { |
601 { |
602 r=TheFs.Volume(volInfo, gDrive); |
602 r=TheFs.Volume(volInfo, gDrive); |
603 test(r==KErrInUse); |
603 test_Value(r, r == KErrInUse); |
604 } |
604 } |
605 else |
605 else |
606 { |
606 { |
607 r=TheFs.Volume(volInfo,EDriveC); |
607 r=TheFs.Volume(volInfo,EDriveC); |
608 test(r==KErrNone); |
608 test_KErrNone(r); |
609 |
609 |
610 r=TheFs.Volume(volInfo,gDrive); |
610 r=TheFs.Volume(volInfo,gDrive); |
611 test(r==KErrInUse); |
611 test_Value(r, r == KErrInUse); |
612 |
612 |
613 r=TheFs.Volume(volInfo,gDrive); |
613 r=TheFs.Volume(volInfo,gDrive); |
614 test(r==KErrInUse); |
614 test_Value(r, r == KErrInUse); |
615 } |
615 } |
616 |
616 |
617 |
617 |
618 format.Close(); |
618 format.Close(); |
619 Format(CurrentDrive()); |
619 Format(CurrentDrive()); |
662 test_KErrNone(nRes); |
662 test_KErrNone(nRes); |
663 |
663 |
664 fmtMode = EQuickFormat; |
664 fmtMode = EQuickFormat; |
665 |
665 |
666 nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt); |
666 nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt); |
667 test(nRes == KErrInUse); |
667 test_Value(nRes, nRes == KErrInUse); |
668 format.Close(); |
668 format.Close(); |
669 |
669 |
670 buf8.SetLength(22); |
670 buf8.SetLength(22); |
671 nRes = file1.Write(buf8); |
671 nRes = file1.Write(buf8); |
672 test_KErrNone(nRes); |
672 test_KErrNone(nRes); |
677 nRes = dir.Open(TheFs,_L("\\*.*"),KEntryAttNormal); |
677 nRes = dir.Open(TheFs,_L("\\*.*"),KEntryAttNormal); |
678 test_KErrNone(nRes); |
678 test_KErrNone(nRes); |
679 |
679 |
680 fmtMode = EQuickFormat; |
680 fmtMode = EQuickFormat; |
681 nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt); |
681 nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt); |
682 test(nRes == KErrInUse); |
682 test_Value(nRes, nRes == KErrInUse); |
683 format.Close(); |
683 format.Close(); |
684 |
684 |
685 dir.Close(); |
685 dir.Close(); |
686 |
686 |
687 |
687 |
705 |
705 |
706 format.Close(); |
706 format.Close(); |
707 |
707 |
708 |
708 |
709 nRes=TheFs.CheckDisk(gSessionPath); |
709 nRes=TheFs.CheckDisk(gSessionPath); |
710 test(nRes==KErrNone||nRes==KErrNotSupported); |
710 test_Value(nRes, nRes == KErrNone||nRes==KErrNotSupported); |
711 |
711 |
712 buf8.SetLength(22); |
712 buf8.SetLength(22); |
713 nRes = file1.Write(buf8); |
713 nRes = file1.Write(buf8); |
714 test(nRes == KErrDisMounted); |
714 test_Value(nRes, nRes == KErrDisMounted); |
715 file1.Close(); //-- this will make the previously "Dismounted" mount die. |
715 file1.Close(); //-- this will make the previously "Dismounted" mount die. |
716 dir.Close(); |
716 dir.Close(); |
717 |
717 |
718 |
718 |
719 //--------------------------------------------------------------------------------- |
719 //--------------------------------------------------------------------------------- |
732 test_KErrNone(nRes); |
732 test_KErrNone(nRes); |
733 |
733 |
734 format.Close(); |
734 format.Close(); |
735 |
735 |
736 nRes=TheFs.CheckDisk(gSessionPath); |
736 nRes=TheFs.CheckDisk(gSessionPath); |
737 test(nRes==KErrNone||nRes==KErrNotSupported); |
737 test_Value(nRes, nRes == KErrNone||nRes==KErrNotSupported); |
738 |
738 |
739 buf8.SetLength(22); |
739 buf8.SetLength(22); |
740 nRes = file1.Write(buf8); |
740 nRes = file1.Write(buf8); |
741 test(nRes == KErrDisMounted); |
741 test_Value(nRes, nRes == KErrDisMounted); |
742 file1.Close(); //-- this will make the previously "Dismounted" mount die. |
742 file1.Close(); //-- this will make the previously "Dismounted" mount die. |
743 |
743 |
744 //--------------------------------------------------------------------------------- |
744 //--------------------------------------------------------------------------------- |
745 //-- 3. check that forced formatting will complete NotifyDismount |
745 //-- 3. check that forced formatting will complete NotifyDismount |
746 test.Printf(_L("Test forced formatting completes NotifyDismount\n")); |
746 test.Printf(_L("Test forced formatting completes NotifyDismount\n")); |
752 TheFs.NotifyDismount(gDrive, stat1, EFsDismountRegisterClient); |
752 TheFs.NotifyDismount(gDrive, stat1, EFsDismountRegisterClient); |
753 test(stat1.Int() == KRequestPending); |
753 test(stat1.Int() == KRequestPending); |
754 |
754 |
755 fmtMode = EQuickFormat; |
755 fmtMode = EQuickFormat; |
756 nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt); |
756 nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt); |
757 test(nRes == KErrInUse); |
757 test_Value(nRes, nRes == KErrInUse); |
758 format.Close(); |
758 format.Close(); |
759 |
759 |
760 test(stat1.Int() == KRequestPending); |
760 test(stat1.Int() == KRequestPending); |
761 |
761 |
762 fmtMode = EQuickFormat | EForceFormat; |
762 fmtMode = EQuickFormat | EForceFormat; |
767 User::WaitForRequest(stat1); |
767 User::WaitForRequest(stat1); |
768 test(stat1.Int() == KErrNone); |
768 test(stat1.Int() == KErrNone); |
769 |
769 |
770 buf8.SetLength(22); |
770 buf8.SetLength(22); |
771 nRes = file1.Write(buf8); |
771 nRes = file1.Write(buf8); |
772 test(nRes == KErrDisMounted); |
772 test_Value(nRes, nRes == KErrDisMounted); |
773 file1.Close(); |
773 file1.Close(); |
774 |
774 |
775 //--------------------------------------------------------------------------------- |
775 //--------------------------------------------------------------------------------- |
776 //-- 4.1 check that forced formatting will succeed with dirty file cache |
776 //-- 4.1 check that forced formatting will succeed with dirty file cache |
777 test.Printf(_L("Test forced formatting will succeed with dirty file cache\n")); |
777 test.Printf(_L("Test forced formatting will succeed with dirty file cache\n")); |
787 nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt); |
787 nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt); |
788 test_KErrNone(nRes); |
788 test_KErrNone(nRes); |
789 format.Close(); |
789 format.Close(); |
790 |
790 |
791 nRes = file1.Write(buf8); |
791 nRes = file1.Write(buf8); |
792 test(nRes == KErrDisMounted); |
792 test_Value(nRes, nRes == KErrDisMounted); |
793 file1.Close(); |
793 file1.Close(); |
794 |
794 |
795 |
795 |
796 //--------------------------------------------------------------------------------- |
796 //--------------------------------------------------------------------------------- |
797 |
797 |
799 |
799 |
800 //-- 5.1 check that forced formatting will fail when there are "disk access" objects opened RFormat |
800 //-- 5.1 check that forced formatting will fail when there are "disk access" objects opened RFormat |
801 RFormat format1; |
801 RFormat format1; |
802 |
802 |
803 nRes = format1.Open(TheFs, drivePath, fmtMode, fmtCnt); |
803 nRes = format1.Open(TheFs, drivePath, fmtMode, fmtCnt); |
804 test(nRes == KErrNone); |
804 test_KErrNone(nRes); |
805 |
805 |
806 fmtMode = EQuickFormat | EForceFormat; |
806 fmtMode = EQuickFormat | EForceFormat; |
807 nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt); |
807 nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt); |
808 test(nRes == KErrInUse); |
808 test_Value(nRes, nRes == KErrInUse); |
809 format.Close(); |
809 format.Close(); |
810 |
810 |
811 format1.Close(); |
811 format1.Close(); |
812 |
812 |
813 //-- 5.1 check that forced formatting will fail when there are "disk access" objects opened RRawDisk |
813 //-- 5.1 check that forced formatting will fail when there are "disk access" objects opened RRawDisk |
814 RRawDisk rawDisk; |
814 RRawDisk rawDisk; |
815 nRes = rawDisk.Open(TheFs, gDrive); |
815 nRes = rawDisk.Open(TheFs, gDrive); |
816 test(nRes == KErrNone); |
816 test_KErrNone(nRes); |
817 |
817 |
818 fmtMode = EQuickFormat | EForceFormat; |
818 fmtMode = EQuickFormat | EForceFormat; |
819 nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt); |
819 nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt); |
820 test(nRes == KErrInUse); |
820 test_Value(nRes, nRes == KErrInUse); |
821 format.Close(); |
821 format.Close(); |
822 |
822 |
823 rawDisk.Close(); |
823 rawDisk.Close(); |
824 |
824 |
825 |
825 |
865 // |
865 // |
866 { |
866 { |
867 |
867 |
868 TInt r; |
868 TInt r; |
869 r = TheFs.CharToDrive(gDriveToTest, gDrive); |
869 r = TheFs.CharToDrive(gDriveToTest, gDrive); |
870 test(r == KErrNone); |
870 test_KErrNone(r); |
871 |
871 |
872 //-- set up console output |
872 //-- set up console output |
873 F32_Test_Utils::SetConsole(test.Console()); |
873 F32_Test_Utils::SetConsole(test.Console()); |
874 |
874 |
875 TInt nRes=TheFs.CharToDrive(gDriveToTest, gDrive); |
875 TInt nRes=TheFs.CharToDrive(gDriveToTest, gDrive); |
876 test(nRes==KErrNone); |
876 test_KErrNone(nRes); |
877 |
877 |
878 PrintDrvInfo(TheFs, gDrive); |
878 PrintDrvInfo(TheFs, gDrive); |
879 |
879 |
880 if(Is_Win32(TheFs, gDrive)) |
880 if(Is_Win32(TheFs, gDrive)) |
881 return; //-- emulator drive c: |
881 return; //-- emulator drive c: |