26 #include <e32test.h> |
26 #include <e32test.h> |
27 #include <e32svr.h> |
27 #include <e32svr.h> |
28 #include <f32dbg.h> |
28 #include <f32dbg.h> |
29 #include "t_server.h" |
29 #include "t_server.h" |
30 #include <e32twin.h> |
30 #include <e32twin.h> |
31 #include <hal.h> |
|
32 #include "tf32testtimer.h" |
|
33 |
31 |
34 const TInt KTotalCacheSize = 32 * 1024 * 1024; |
32 const TInt KTotalCacheSize = 32 * 1024 * 1024; |
35 const TInt KDefaultCacheSize = (128 + 12) * 1024; // This size is the default configuration size |
33 const TInt KDefaultCacheSize = (128 + 12) * 1024; // This size is the default configuration size |
36 const TInt KFilesNeededToFillCache = (KTotalCacheSize / KDefaultCacheSize) + 2; |
34 const TInt KFilesNeededToFillCache = (KTotalCacheSize / KDefaultCacheSize) + 2; |
37 const TInt KMinSize = 254; // Boundary minim limit |
35 const TInt KMinSize = 254; // Boundary minim limit |
89 |
87 |
90 const TInt KOneK = 1024; |
88 const TInt KOneK = 1024; |
91 const TInt KOneMeg = KOneK * 1024; |
89 const TInt KOneMeg = KOneK * 1024; |
92 const TInt KBlockSize = KOneK; |
90 const TInt KBlockSize = KOneK; |
93 const TInt KWaitRequestsTableSize = 256; |
91 const TInt KWaitRequestsTableSize = 256; |
|
92 const TInt KMs = 1000; |
94 |
93 |
95 TInt gSecondFileSize = 0; |
94 TInt gSecondFileSize = 0; |
96 TInt gFirstFileSize = 0; |
95 TInt gFirstFileSize = 0; |
97 |
96 |
98 TInt64 gMediaSize = 0; |
97 TInt64 gMediaSize = 0; |
509 @param aBlockSize Size of the block |
511 @param aBlockSize Size of the block |
510 @param aMode Mode in which the file is going to be opened |
512 @param aMode Mode in which the file is going to be opened |
511 |
513 |
512 @return time taken to perform the operation in uS |
514 @return time taken to perform the operation in uS |
513 */ |
515 */ |
514 TTimeIntervalMicroSeconds WriteTestFile(RFile& aFile, TDes16& aFileName, TInt aSize, TInt aBlockSize, TInt aMode) |
516 TInt WriteTestFile(RFile& aFile, TDes16& aFileName, TInt aSize, TInt aBlockSize, TInt aMode) |
515 { |
517 { |
516 RTest test(_L("T_WCACHE")); |
518 RTest test(_L("T_WCACHE")); |
517 |
519 |
|
520 TTime startTime; |
|
521 TTime endTime; |
518 TInt r = 0; |
522 TInt r = 0; |
519 |
523 |
520 TF32TestTimer timer; |
524 startTime.HomeTime(); |
521 timer.Start(); |
|
522 |
525 |
523 r = WriteFile(gTheFs,aFile, aFileName , aSize * KOneK, aBlockSize, gBufWritePtr, aMode); |
526 r = WriteFile(gTheFs,aFile, aFileName , aSize * KOneK, aBlockSize, gBufWritePtr, aMode); |
524 test_KErrNone(r); |
527 test_KErrNone(r); |
525 |
528 |
526 timer.Stop(); |
529 endTime.HomeTime(); |
527 gTimeTakenBigFile = timer.Time(); |
530 |
|
531 gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64()); |
|
532 |
528 test.Close(); |
533 test.Close(); |
529 return timer.Time(); |
534 return I64LOW(gTimeTakenBigFile.Int64()); |
530 } |
535 } |
531 |
536 |
532 /** Measure the time taken for this file to be read synchronously |
537 /** Measure the time taken for this file to be read synchronously |
533 |
538 |
534 @param aFile File object |
539 @param aFile File object |
538 @param aMode Mode in which the file is going to be opened |
543 @param aMode Mode in which the file is going to be opened |
539 |
544 |
540 @return time taken to perform the operation in uS |
545 @return time taken to perform the operation in uS |
541 |
546 |
542 */ |
547 */ |
543 TTimeIntervalMicroSeconds ReadTestFile(RFile& aFile, TDes16& aFileName, TInt aSize, TInt aBlockSize, TInt aMode) |
548 TInt ReadTestFile(RFile& aFile, TDes16& aFileName, TInt aSize, TInt aBlockSize, TInt aMode) |
544 { |
549 { |
545 TF32TestTimer timer; |
550 TTime startTime; |
546 timer.Start(); |
551 TTime endTime; |
|
552 |
|
553 startTime.HomeTime(); |
547 ReadFile(gTheFs,aFile, aFileName, aSize * KOneK, aBlockSize, aMode); |
554 ReadFile(gTheFs,aFile, aFileName, aSize * KOneK, aBlockSize, aMode); |
548 timer.Stop(); |
555 endTime.HomeTime(); |
549 |
556 |
550 gTimeTakenBigFile = timer.Time(); |
557 gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64()); |
551 |
558 |
552 return timer.Time(); |
559 return I64LOW(gTimeTakenBigFile.Int64()) ; |
553 } |
560 } |
554 |
561 |
555 /** Read asynchronously the test file from the disc |
562 /** Read asynchronously the test file from the disc |
556 |
563 |
557 @param aFile File object |
564 @param aFile File object |
560 @param aBlockSize Size of the block |
567 @param aBlockSize Size of the block |
561 @param aMode Mode in which the file is going to be opened |
568 @param aMode Mode in which the file is going to be opened |
562 |
569 |
563 @return time taken to perform the operation in uS |
570 @return time taken to perform the operation in uS |
564 */ |
571 */ |
565 TTimeIntervalMicroSeconds ReadAsyncTestFile(RFile& file, TDes16& aFile, TInt aSize, TInt aBlockSize, TInt aMode) |
572 TInt ReadAsyncTestFile(RFile& file, TDes16& aFile, TInt aSize, TInt aBlockSize, TInt aMode) |
566 { |
573 { |
|
574 TTime startTime; |
|
575 TTime endTime; |
567 TRequestStatus status[KWaitRequestsTableSize]; |
576 TRequestStatus status[KWaitRequestsTableSize]; |
568 TF32TestTimer timer; |
577 |
569 timer.Start(); |
578 startTime.HomeTime(); |
570 |
579 |
571 ReadFileAsync(gTheFs, file, aFile, aSize * KOneK, aBlockSize, status, aMode); |
580 ReadFileAsync(gTheFs, file, aFile, aSize * KOneK, aBlockSize, status, aMode); |
572 WaitForAll(status, (aSize * KOneK)/KBlockSize); |
581 WaitForAll(status, (aSize * KOneK)/KBlockSize); |
573 timer.Stop(); |
582 |
574 |
583 endTime.HomeTime(); |
575 gTimeTakenBigFile = timer.Time(); |
584 |
576 |
585 gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64()); |
577 return timer.Time(); |
586 |
|
587 return I64LOW(gTimeTakenBigFile.Int64()); |
578 } |
588 } |
579 |
589 |
580 /** Read asynchronously the test file from the disc |
590 /** Read asynchronously the test file from the disc |
581 |
591 |
582 @param aFile File object |
592 @param aFile File object |
584 @param aSize Size in kilobytes |
594 @param aSize Size in kilobytes |
585 @param aMode Mode in which the file is going to be opened |
595 @param aMode Mode in which the file is going to be opened |
586 |
596 |
587 @return time taken to perform the operation in uS |
597 @return time taken to perform the operation in uS |
588 */ |
598 */ |
589 TTimeIntervalMicroSeconds WriteAsyncTestFile(RFile& aFile, TDes16& aFileName, TInt aSize, TInt aMode) |
599 TInt WriteAsyncTestFile(RFile& aFile, TDes16& aFileName, TInt aSize, TInt aMode) |
590 { |
600 { |
|
601 TTime startTime; |
|
602 TTime endTime; |
591 TRequestStatus status[KWaitRequestsTableSize]; |
603 TRequestStatus status[KWaitRequestsTableSize]; |
592 TF32TestTimer timer; |
604 |
593 timer.Start(); |
605 startTime.HomeTime(); |
594 |
606 |
595 WriteFileAsync(gTheFs, aFile, aFileName, aSize * KOneK, aMode, status ); |
607 WriteFileAsync(gTheFs, aFile, aFileName, aSize * KOneK, aMode, status ); |
596 WaitForAll(status, (aSize * KOneK)/KBlockSize); |
608 WaitForAll(status, (aSize * KOneK)/KBlockSize); |
597 timer.Stop(); |
609 |
598 |
610 endTime.HomeTime(); |
599 gTimeTakenBigFile = timer.Time(); |
611 |
600 |
612 gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64()); |
601 return timer.Time(); |
613 |
|
614 return I64LOW(gTimeTakenBigFile.Int64()); |
602 } |
615 } |
603 |
616 |
604 /** Test Boundaries |
617 /** Test Boundaries |
605 |
618 |
606 This function is testing the behaviour on the boundaries of the write cache size |
619 This function is testing the behaviour on the boundaries of the write cache size |
607 */ |
620 */ |
608 void TestBoundaries() |
621 void TestBoundaries() |
609 { |
622 { |
610 TInt r = 0; |
623 TInt r = 0; |
611 TTimeIntervalMicroSeconds time = 0; |
624 TInt time = 0; |
612 TTimeIntervalMicroSeconds rtime = 0; |
625 TInt rtime = 0; |
613 TTimeIntervalMicroSeconds tcreate = 0; |
626 TInt tcreate = 0; |
614 RFile fileWriter; |
627 RFile fileWriter; |
615 RFile fileWriter2; |
628 RFile fileWriter2; |
616 RFile fileReader; |
629 RFile fileReader; |
617 |
630 |
618 test.Start(_L("Test Boundaries")); |
631 test.Start(_L("Test Boundaries")); |
626 while(i < KMaxSize) |
639 while(i < KMaxSize) |
627 { |
640 { |
628 test.Printf(_L("\nSync: Write from 1 K to %d K \n"), i); |
641 test.Printf(_L("\nSync: Write from 1 K to %d K \n"), i); |
629 |
642 |
630 tcreate = WriteTestFile(fileWriter, gSecondFile, i, KBlockSize, EFileShareAny|EFileWrite|EFileWriteDirectIO); |
643 tcreate = WriteTestFile(fileWriter, gSecondFile, i, KBlockSize, EFileShareAny|EFileWrite|EFileWriteDirectIO); |
631 test.Printf(_L("Time to write %d K without caching: %d mS\n"), i, TF32TestTimer::TimeInMilliSeconds(tcreate)); |
644 test.Printf(_L("Time to write %d K without caching: %d mS\n"), i, tcreate/KMs); |
632 fileWriter.Close(); |
645 fileWriter.Close(); |
633 |
646 |
634 time = WriteTestFile(fileWriter2, gFirstFile, i, KBlockSize, EFileShareAny|EFileWrite|EFileWriteBuffered); |
647 time = WriteTestFile(fileWriter2, gFirstFile, i, KBlockSize, EFileShareAny|EFileWrite|EFileWriteBuffered); |
635 test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), i, TF32TestTimer::TimeInMilliSeconds(time)); |
648 test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), i, time/KMs); |
636 |
649 |
637 rtime = ReadTestFile(fileReader, gFirstFile, i, KBlockSize, EFileShareAny|EFileRead|EFileReadBuffered); |
650 rtime = ReadTestFile(fileReader, gFirstFile, i, KBlockSize, EFileShareAny|EFileRead|EFileReadBuffered); |
638 test.Printf(_L("Time to read %d K from the cache: %d mS\n"), i, TF32TestTimer::TimeInMilliSeconds(rtime)); |
651 test.Printf(_L("Time to read %d K from the cache: %d mS\n"), i, rtime/KMs); |
|
652 |
639 |
653 |
640 fileReader.Close(); |
654 fileReader.Close(); |
641 fileWriter2.Close(); |
655 fileWriter2.Close(); |
642 |
656 |
643 #if !defined(__WINS__) |
657 #if !defined(__WINS__) |
644 test(tcreate > TTimeIntervalMicroSeconds(0)); // test measured time is correct |
658 test((tcreate > time) || (tcreate > rtime)); |
645 test(tcreate > time); |
|
646 test(tcreate > rtime); |
|
647 #endif |
659 #endif |
648 |
660 |
649 r = gTheFs.Delete(gFirstFile); |
661 r = gTheFs.Delete(gFirstFile); |
650 test_KErrNone(r); |
662 test_KErrNone(r); |
651 r = gTheFs.Delete(gSecondFile); |
663 r = gTheFs.Delete(gSecondFile); |
662 while(i < KMaxSize) |
674 while(i < KMaxSize) |
663 { |
675 { |
664 test.Printf(_L("\nAsync: Write from 1 K to %d K \n"), i); |
676 test.Printf(_L("\nAsync: Write from 1 K to %d K \n"), i); |
665 |
677 |
666 tcreate = WriteAsyncTestFile(fileWriter, gSecondFile, i, EFileShareAny|EFileWrite|EFileWriteDirectIO); |
678 tcreate = WriteAsyncTestFile(fileWriter, gSecondFile, i, EFileShareAny|EFileWrite|EFileWriteDirectIO); |
667 test.Printf(_L("Time to write %d K without caching: %d mS\n"), i, TF32TestTimer::TimeInMilliSeconds(tcreate)); |
679 test.Printf(_L("Time to write %d K without caching: %d mS\n"), i, tcreate/KMs); |
668 fileWriter.Close(); |
680 fileWriter.Close(); |
669 |
681 |
670 time = WriteAsyncTestFile(fileWriter2, gFirstFile, i,EFileShareAny|EFileWrite|EFileWriteBuffered); |
682 time = WriteAsyncTestFile(fileWriter2, gFirstFile, i,EFileShareAny|EFileWrite|EFileWriteBuffered); |
671 test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), i, TF32TestTimer::TimeInMilliSeconds(time)); |
683 test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), i, time/KMs); |
672 |
684 |
673 |
685 |
674 rtime = ReadAsyncTestFile(fileReader, gFirstFile, i, KBlockSize, EFileShareAny|EFileRead|EFileReadBuffered); |
686 rtime = ReadAsyncTestFile(fileReader, gFirstFile, i, KBlockSize, EFileShareAny|EFileRead|EFileReadBuffered); |
675 test.Printf(_L("Time to read %d K from the cache: %d mS\n"), i, TF32TestTimer::TimeInMilliSeconds(rtime)); |
687 test.Printf(_L("Time to read %d K from the cache: %d mS\n"), i, rtime/KMs); |
676 |
688 |
677 fileReader.Close(); |
689 fileReader.Close(); |
678 fileWriter2.Close(); |
690 fileWriter2.Close(); |
679 |
691 |
680 #if !defined(__WINS__) |
692 #if !defined(__WINS__) |
681 test(tcreate > TTimeIntervalMicroSeconds(0)); // test measured time is correct |
693 test((tcreate > time) || (tcreate > rtime)); |
682 test(tcreate > time); |
|
683 test(tcreate > rtime); |
|
684 #endif |
694 #endif |
685 |
695 |
686 r = gTheFs.Delete(gFirstFile); |
696 r = gTheFs.Delete(gFirstFile); |
687 test_KErrNone(r); |
697 test_KErrNone(r); |
688 r = gTheFs.Delete(gSecondFile); |
698 r = gTheFs.Delete(gSecondFile); |
737 |
747 |
738 @param aFile file name to verify |
748 @param aFile file name to verify |
739 |
749 |
740 @return returns the time that took to do the verification in mS, fails if the file is not corrupted/modified |
750 @return returns the time that took to do the verification in mS, fails if the file is not corrupted/modified |
741 */ |
751 */ |
742 TTimeIntervalMicroSeconds ReadTestFileVerif(TDes16& aFile) |
752 TInt ReadTestFileVerif(TDes16& aFile) |
743 { |
753 { |
|
754 TTime startTime; |
|
755 TTime endTime; |
744 TInt r = 0; |
756 TInt r = 0; |
745 TInt size = 0; |
757 TInt size = 0; |
746 RFile fileRead; |
758 RFile fileRead; |
747 TInt corrupt = 0; |
759 TInt corrupt = 0; |
748 TBool isFat=IsFSFAT(gTheFs,gDrive); |
760 TBool isFat=IsFSFAT(gTheFs,gDrive); |
749 |
761 |
750 TF32TestTimer timer; |
762 startTime.HomeTime(); |
751 timer.Start(); |
|
752 |
763 |
753 r = fileRead.Open(gTheFs,aFile,EFileShareAny|EFileRead|EFileReadBuffered|EFileReadAheadOff); |
764 r = fileRead.Open(gTheFs,aFile,EFileShareAny|EFileRead|EFileReadBuffered|EFileReadAheadOff); |
754 test_KErrNone(r); |
765 test_KErrNone(r); |
755 |
766 |
756 r = fileRead.Size(size); |
767 r = fileRead.Size(size); |
796 RFile fileWrite; |
808 RFile fileWrite; |
797 HBufC8* dummy = NULL; |
809 HBufC8* dummy = NULL; |
798 TPtr8 dummyPtr(NULL, 0); |
810 TPtr8 dummyPtr(NULL, 0); |
799 |
811 |
800 TRAPD(res,dummy = HBufC8::NewL(4)); |
812 TRAPD(res,dummy = HBufC8::NewL(4)); |
801 test_Value(res, res == KErrNone && dummy != NULL); |
813 test(res == KErrNone && dummy != NULL); |
802 |
814 |
803 dummyPtr.Set(dummy->Des()); |
815 dummyPtr.Set(dummy->Des()); |
804 FillBuffer(dummyPtr, 4, '1'); |
816 FillBuffer(dummyPtr, 4, '1'); |
805 |
817 |
806 r = fileWrite.Open(gTheFs,gSecondFile,EFileShareAny|EFileWrite|EFileWriteBuffered); |
818 r = fileWrite.Open(gTheFs,gSecondFile,EFileShareAny|EFileWrite|EFileWriteBuffered); |
826 |
838 |
827 */ |
839 */ |
828 LOCAL_C void TestIntegrity() |
840 LOCAL_C void TestIntegrity() |
829 { |
841 { |
830 TInt r = 0; |
842 TInt r = 0; |
831 TTimeIntervalMicroSeconds time; |
843 TInt time; |
832 TTimeIntervalMicroSeconds tcreate = 0; |
844 TInt tcreate = 0; |
833 RFile file; |
845 RFile file; |
834 |
846 |
835 // Modify file in some position |
847 // Modify file in some position |
836 test.Printf(_L("Overwrite partially a file\n")); |
848 test.Printf(_L("Overwrite partially a file\n")); |
837 |
849 |
838 test.Printf(_L("\nSync: Write from 1 K to %d K \n"), 255); |
850 test.Printf(_L("\nSync: Write from 1 K to %d K \n"), 255); |
839 |
851 |
840 tcreate = WriteTestFile(file, gSecondFile, 255, KBlockSize, EFileShareAny|EFileWrite|EFileWriteBuffered); |
852 tcreate = WriteTestFile(file, gSecondFile, 255, KBlockSize, EFileShareAny|EFileWrite|EFileWriteBuffered); |
841 test.Printf(_L("Time to write %d K with caching: %d mS\n"), 255, TF32TestTimer::TimeInMilliSeconds(tcreate)); |
853 test.Printf(_L("Time to write %d K with caching: %d mS\n"), 255, tcreate/KMs); |
842 file.Close(); |
854 file.Close(); |
843 |
855 |
844 test.Printf(_L("Mess the content that is still in the cache\n")); |
856 test.Printf(_L("Mess the content that is still in the cache\n")); |
845 CorruptSecondFile(); |
857 CorruptSecondFile(); |
846 |
858 |
847 time = ReadTestFileVerif(gSecondFile); |
859 time = ReadTestFileVerif(gSecondFile); |
848 test.Printf(_L("Time taken to verify: %ld\n"),time.Int64()); |
860 test.Printf(_L("Time taken to verify: %d\n"),time); |
849 |
861 |
850 test.Printf(_L("Integrity verified\n")); |
862 test.Printf(_L("Integrity verified\n")); |
851 |
863 |
852 r = DeleteAllL(gSessionPath); |
864 r = DeleteAllL(gSessionPath); |
853 test_KErrNone(r); |
865 test_KErrNone(r); |
879 // create a big buffer to speed things up |
891 // create a big buffer to speed things up |
880 HBufC8* bigBuf = NULL; |
892 HBufC8* bigBuf = NULL; |
881 TInt KBigBifferSize = 32 * KOneK; |
893 TInt KBigBifferSize = 32 * KOneK; |
882 |
894 |
883 TRAPD(res,bigBuf = HBufC8::NewL(KBigBifferSize)); |
895 TRAPD(res,bigBuf = HBufC8::NewL(KBigBifferSize)); |
884 test_Value(res, res == KErrNone && bigBuf != NULL); |
896 test(res == KErrNone && bigBuf != NULL); |
885 |
897 |
886 TPtr8 bigBufWritePtr(NULL, 0); |
898 TPtr8 bigBufWritePtr(NULL, 0); |
887 bigBufWritePtr.Set(bigBuf->Des()); |
899 bigBufWritePtr.Set(bigBuf->Des()); |
888 FillBuffer(bigBufWritePtr, KBigBifferSize, 'A'); |
900 FillBuffer(bigBufWritePtr, KBigBifferSize, 'A'); |
889 |
901 |
945 |
957 |
946 // create a big buffer to speed things up |
958 // create a big buffer to speed things up |
947 HBufC8* bigBuf = NULL; |
959 HBufC8* bigBuf = NULL; |
948 const TInt KBigBifferSize = 32 * 1024; |
960 const TInt KBigBifferSize = 32 * 1024; |
949 TRAPD(res,bigBuf = HBufC8::NewL(KBigBifferSize)); |
961 TRAPD(res,bigBuf = HBufC8::NewL(KBigBifferSize)); |
950 test_Value(res, res == KErrNone && bigBuf != NULL); |
962 test(res == KErrNone && bigBuf != NULL); |
951 |
963 |
952 TPtr8 bigBufWritePtr(NULL, 0); |
964 TPtr8 bigBufWritePtr(NULL, 0); |
953 bigBufWritePtr.Set(bigBuf->Des()); |
965 bigBufWritePtr.Set(bigBuf->Des()); |
954 FillBuffer(bigBufWritePtr, KBigBifferSize, 'A'); |
966 FillBuffer(bigBufWritePtr, KBigBifferSize, 'A'); |
955 |
967 |
1002 TBuf16<50> buffer(50); |
1014 TBuf16<50> buffer(50); |
1003 HBufC8* buf = NULL; |
1015 HBufC8* buf = NULL; |
1004 TPtr8 bufPtr(NULL, 0); |
1016 TPtr8 bufPtr(NULL, 0); |
1005 |
1017 |
1006 TRAPD(res,buf = HBufC8::NewL(2)); |
1018 TRAPD(res,buf = HBufC8::NewL(2)); |
1007 test_Value(res, res == KErrNone && buf != NULL); |
1019 test(res == KErrNone && buf != NULL); |
1008 bufPtr.Set(buf->Des()); |
1020 bufPtr.Set(buf->Des()); |
1009 |
1021 |
1010 directory = gSessionPath; |
1022 directory = gSessionPath; |
1011 |
1023 |
1012 i = 0; |
1024 i = 0; |
1200 dir.Append(gSecondFile); |
1212 dir.Append(gSecondFile); |
1201 gSecondFile = dir; |
1213 gSecondFile = dir; |
1202 |
1214 |
1203 |
1215 |
1204 TRAPD(res,gBuf = HBufC8::NewL(KBlockSize+1)); |
1216 TRAPD(res,gBuf = HBufC8::NewL(KBlockSize+1)); |
1205 test_Value(res, res == KErrNone && gBuf != NULL); |
1217 test(res == KErrNone && gBuf != NULL); |
1206 |
1218 |
1207 gBufWritePtr.Set(gBuf->Des()); |
1219 gBufWritePtr.Set(gBuf->Des()); |
1208 FillBuffer(gBufWritePtr, KBlockSize, 'A'); |
1220 FillBuffer(gBufWritePtr, KBlockSize, 'A'); |
1209 |
1221 |
1210 TRAPD(res2,gBufSec = HBufC8::NewL(KBlockSize+1)); |
1222 TRAPD(res2,gBufSec = HBufC8::NewL(KBlockSize+1)); |
1213 |
1225 |
1214 |
1226 |
1215 test.Printf(_L("\nSync: Write from 1 K to 254 K \n")); |
1227 test.Printf(_L("\nSync: Write from 1 K to 254 K \n")); |
1216 |
1228 |
1217 time = WriteTestFile(file1, gSecondFile, KMinSize, KBlockSize, EFileShareAny|EFileWrite|EFileWriteBuffered); |
1229 time = WriteTestFile(file1, gSecondFile, KMinSize, KBlockSize, EFileShareAny|EFileWrite|EFileWriteBuffered); |
1218 test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), KMinSize, TF32TestTimer::TimeInMilliSeconds(time)); |
1230 test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), KMinSize, time/KMs); |
1219 test.Printf(_L("Remove MMC card,! and then press a key\n")); |
1231 test.Printf(_L("Remove MMC card,! and then press a key\n")); |
1220 test.Getch(); |
1232 test.Getch(); |
1221 |
1233 |
1222 test.Printf(_L("Wait 3 seconds and insert MMC card! and then press a key\n")); |
1234 test.Printf(_L("Wait 3 seconds and insert MMC card! and then press a key\n")); |
1223 test.Getch(); |
1235 test.Getch(); |
1224 |
1236 |
1225 rtime = ReadTestFile(file2, gSecondFile, KMinSize, KBlockSize, EFileShareAny|EFileRead|EFileReadBuffered); |
1237 rtime = ReadTestFile(file2, gSecondFile, KMinSize, KBlockSize, EFileShareAny|EFileRead|EFileReadBuffered); |
1226 test.Printf(_L("Time to read %d K from the cache: %d mS\n"), KMinSize, TF32TestTimer::TimeInMilliSeconds(rtime)); |
1238 test.Printf(_L("Time to read %d K from the cache: %d mS\n"), KMinSize, rtime/KMs); |
1227 |
1239 |
1228 test.Printf(_L("Remove MMC card! and then press a key\n")); |
1240 test.Printf(_L("Remove MMC card! and then press a key\n")); |
1229 test.Getch(); |
1241 test.Getch(); |
1230 |
1242 |
1231 test.Printf(_L("Wait 3 seconds and insert MMC card! and then press a key\n")); |
1243 test.Printf(_L("Wait 3 seconds and insert MMC card! and then press a key\n")); |
1233 |
1245 |
1234 |
1246 |
1235 test.Printf(_L("\nSync: Write from 1 K to 255 K \n")); |
1247 test.Printf(_L("\nSync: Write from 1 K to 255 K \n")); |
1236 |
1248 |
1237 time = WriteTestFile(file1, gFirstFile, KMinSize + 1 , KBlockSize, EFileShareAny|EFileWrite|EFileWriteBuffered); |
1249 time = WriteTestFile(file1, gFirstFile, KMinSize + 1 , KBlockSize, EFileShareAny|EFileWrite|EFileWriteBuffered); |
1238 test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), KMinSize + 1, TF32TestTimer::TimeInMilliSeconds(time)); |
1250 test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), KMinSize + 1, time/KMs); |
1239 test.Printf(_L("Remove MMC card and delete the file //F32-TST//FFFFFFF0.TXT and then press a key\n")); |
1251 test.Printf(_L("Remove MMC card and delete the file //F32-TST//FFFFFFF0.TXT and then press a key\n")); |
1240 test.Getch(); |
1252 test.Getch(); |
1241 |
1253 |
1242 test.Printf(_L("Wait 3 seconds and insert MMC card! and then press a key\n")); |
1254 test.Printf(_L("Wait 3 seconds and insert MMC card! and then press a key\n")); |
1243 test.Getch(); |
1255 test.Getch(); |
1244 |
1256 |
1245 rtime = ReadTestFile(file2, gFirstFile, KMinSize + 1, KBlockSize, EFileShareAny|EFileRead|EFileReadBuffered); |
1257 rtime = ReadTestFile(file2, gFirstFile, KMinSize + 1, KBlockSize, EFileShareAny|EFileRead|EFileReadBuffered); |
1246 test.Printf(_L("Time to read %d K from the cache: %d mS\n"), KMinSize + 1, TF32TestTimer::TimeInMilliSeconds(rtime)); |
1258 test.Printf(_L("Time to read %d K from the cache: %d mS\n"), KMinSize + 1, rtime/KMs); |
1247 |
1259 |
1248 test.Printf(_L("Remove MMC card! and then press a key\n")); |
1260 test.Printf(_L("Remove MMC card! and then press a key\n")); |
1249 test.Getch(); |
1261 test.Getch(); |
1250 |
1262 |
1251 test.Printf(_L("Wait 3 seconds and insert MMC card! and then press a key\n")); |
1263 test.Printf(_L("Wait 3 seconds and insert MMC card! and then press a key\n")); |
1285 dir.Append(gSecondFile); |
1297 dir.Append(gSecondFile); |
1286 gSecondFile = dir; |
1298 gSecondFile = dir; |
1287 |
1299 |
1288 |
1300 |
1289 TRAPD(res,gBuf = HBufC8::NewL(KBlockSize+1)); |
1301 TRAPD(res,gBuf = HBufC8::NewL(KBlockSize+1)); |
1290 test_Value(res, res == KErrNone && gBuf != NULL); |
1302 test(res == KErrNone && gBuf != NULL); |
1291 |
1303 |
1292 gBufWritePtr.Set(gBuf->Des()); |
1304 gBufWritePtr.Set(gBuf->Des()); |
1293 FillBuffer(gBufWritePtr, KBlockSize, 'A'); |
1305 FillBuffer(gBufWritePtr, KBlockSize, 'A'); |
1294 |
1306 |
1295 TRAPD(res2,gBufSec = HBufC8::NewL(KBlockSize+1)); |
1307 TRAPD(res2,gBufSec = HBufC8::NewL(KBlockSize+1)); |
1353 TBool CheckForDiskSize() |
1365 TBool CheckForDiskSize() |
1354 { |
1366 { |
1355 TVolumeInfo volInfo; |
1367 TVolumeInfo volInfo; |
1356 TInt r = gTheFs.Volume(volInfo, gDrive); |
1368 TInt r = gTheFs.Volume(volInfo, gDrive); |
1357 test_KErrNone(r); |
1369 test_KErrNone(r); |
1358 gMediaSize = volInfo.iFree; |
1370 gMediaSize = volInfo.iSize; |
1359 test.Printf(_L("\nMedia free space: %d MB\n"), gMediaSize/KOneMeg); |
1371 |
|
1372 test.Printf(_L("\nMedia size: %d MB\n"), gMediaSize/KOneMeg ); |
|
1373 |
1360 return ETrue; |
1374 return ETrue; |
1361 } |
1375 } |
1362 |
1376 |
1363 /** Main function |
1377 /** Main function |
1364 |
1378 |