112 HBufC8* gBuf = NULL; |
117 HBufC8* gBuf = NULL; |
113 TPtr8 gBufReadPtr(NULL, 0); |
118 TPtr8 gBufReadPtr(NULL, 0); |
114 HBufC8* gBufSec = NULL; |
119 HBufC8* gBufSec = NULL; |
115 TPtr8 gBufWritePtr(NULL, 0); |
120 TPtr8 gBufWritePtr(NULL, 0); |
116 |
121 |
117 const TInt KuStomS = 1000; |
|
118 const TInt KOneK = 1024; |
122 const TInt KOneK = 1024; |
119 const TInt KOneMeg = KOneK * 1024; |
123 const TInt KOneMeg = KOneK * 1024; |
120 const TInt KBigBlockSize = KOneMeg ; |
124 const TInt KBigBlockSize = KOneMeg ; |
121 const TInt KBlockSize = KOneK * 129 ; |
125 const TInt KBlockSize = KOneK * 129 ; |
122 const TInt KWaitRequestsTableSize = 70; |
126 const TInt KWaitRequestsTableSize = 70; |
608 r = aFs.Delete(fileName2); |
615 r = aFs.Delete(fileName2); |
609 TEST(r == KErrNone); |
616 TEST(r == KErrNone); |
610 } |
617 } |
611 |
618 |
612 |
619 |
613 |
|
614 /** Measure the time taken for a big block to be written synchronously |
620 /** Measure the time taken for a big block to be written synchronously |
615 */ |
621 */ |
616 void TimeTakenToWriteBigBlock() |
622 void TimeTakenToWriteBigBlock() |
617 { |
623 { |
618 TTime startTime; |
|
619 TTime endTime; |
|
620 RFile fileWrite; |
624 RFile fileWrite; |
621 |
625 |
622 TInt r = fileWrite.Replace(TheFs,gBigFile,EFileShareAny|EFileWrite|EFileWriteDirectIO); |
626 TInt r = fileWrite.Replace(TheFs,gBigFile,EFileShareAny|EFileWrite|EFileWriteDirectIO); |
623 TESTERROR(r); |
627 TESTERROR(r); |
624 |
628 |
625 // Calculate how long it takes to write a big block to be able to issue at the right time the concurrent writes |
629 // Calculate how long it takes to write a big block to be able to issue at the right time the concurrent writes |
626 startTime.HomeTime(); |
630 TF32TestTimer timer; |
|
631 timer.Start(); |
627 |
632 |
628 r = fileWrite.Write(gBufWritePtr, KBigBlockSize); |
633 r = fileWrite.Write(gBufWritePtr, KBigBlockSize); |
629 |
634 |
630 endTime.HomeTime(); |
635 timer.Stop(); |
631 |
636 |
632 fileWrite.Close(); |
637 fileWrite.Close(); |
633 |
638 |
634 TESTERROR(r); |
639 TESTERROR(r); |
635 |
640 |
636 gTimeTakenBigBlock = I64LOW(endTime.MicroSecondsFrom(startTime).Int64()/3); |
641 gTimeTakenBigBlock = timer.TimeInMicroSeconds()/3; |
637 |
642 |
638 test.Printf(_L("\nTime spent to write the big block in isolation: %d ms\n"), gTimeTakenBigBlock.Int() / KuStomS); |
643 test.Printf(_L("\nTime spent to write the big block in isolation: %d ms\n"), TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigBlock)); |
639 } |
644 } |
640 |
645 |
641 |
646 |
642 /** Measure the time taken for this file to be written synchronously |
647 /** Measure the time taken for this file to be written synchronously |
643 */ |
648 */ |
644 void TimeTakenToWriteBigFile(TInt aPos) |
649 void TimeTakenToWriteBigFile(TInt aPos) |
645 { |
650 { |
646 TTime startTime; |
|
647 TTime endTime; |
|
648 |
|
649 test((aPos >= 0) && (aPos <= 1)); |
651 test((aPos >= 0) && (aPos <= 1)); |
650 startTime.HomeTime(); |
652 TF32TestTimer timer; |
651 |
653 timer.Start(); |
|
654 |
652 WriteFile(TheFs,gBigFile, gBigFileSize, KBigBlockSize, ENoThreads); |
655 WriteFile(TheFs,gBigFile, gBigFileSize, KBigBlockSize, ENoThreads); |
653 |
656 |
654 endTime.HomeTime(); |
657 timer.Stop(); |
655 |
658 |
656 gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64()); |
659 gTimeTakenBigFile = timer.Time32(); |
657 |
660 |
658 |
661 test.Printf(_L("\nTime spent to write the big file in isolation: %d ms\n"), TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile)); |
659 test.Printf(_L("\nTime spent to write the big file in isolation: %d ms\n"), gTimeTakenBigFile.Int() / KuStomS); |
662 |
660 |
663 gTotalTimeSync[aPos] = Max(TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile), gTotalTimeSync[aPos]) ; |
661 gTotalTimeSync[aPos] = Max((gTimeTakenBigFile.Int()/KuStomS), gTotalTimeSync[aPos]) ; |
|
662 } |
664 } |
663 |
665 |
664 /** Measure the time taken for this file to be written asynchronously |
666 /** Measure the time taken for this file to be written asynchronously |
665 */ |
667 */ |
666 void TimeTakenToWriteBigFileAsync(TInt aPos) |
668 void TimeTakenToWriteBigFileAsync(TInt aPos) |
667 { |
669 { |
668 TTime startTime; |
|
669 TTime endTime; |
|
670 TTime endTime2; |
|
671 TRequestStatus status[KWaitRequestsTableSize]; |
670 TRequestStatus status[KWaitRequestsTableSize]; |
672 RFile bigFile; |
671 RFile bigFile; |
673 |
672 |
674 test((aPos >= 0) && (aPos <= 1)); |
673 test((aPos >= 0) && (aPos <= 1)); |
675 |
674 |
676 startTime.HomeTime(); |
675 TF32TestTimer2 timer; |
|
676 timer.Start(); |
677 WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize,KBigBlockSize,status); |
677 WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize,KBigBlockSize,status); |
678 endTime.HomeTime(); |
678 timer.Stop(); |
679 |
|
680 |
679 |
681 WaitForAll(status, gBigFileSize, KBigBlockSize); |
680 WaitForAll(status, gBigFileSize, KBigBlockSize); |
682 |
681 timer.Stop2(); |
683 endTime2.HomeTime(); |
682 |
684 |
683 gTimeTakenBigFile = timer.Time32(); |
685 gTimeTakenBigFile=I64LOW(endTime.MicroSecondsFrom(startTime).Int64()); |
|
686 bigFile.Close(); |
684 bigFile.Close(); |
687 test.Printf(_L("\nTime to queue the blocks in isolation asynchronously: %d ms, "), gTimeTakenBigFile.Int() / KuStomS); |
685 test.Printf(_L("\nTime to queue the blocks in isolation asynchronously: %d ms, "), timer.TimeInMilliSeconds()); |
688 gTimeTakenBigFile=I64LOW(endTime2.MicroSecondsFrom(startTime).Int64()); |
686 gTimeTakenBigFile = timer.Time2(); |
689 test.Printf(_L("to actually write it: %d ms\n"),gTimeTakenBigFile.Int() / KuStomS); |
687 test.Printf(_L("to actually write it: %d ms\n"), TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile)); |
690 gTotalTimeAsync[aPos] = Max((gTimeTakenBigFile.Int() / KuStomS), gTotalTimeAsync[aPos]) ; |
688 gTotalTimeAsync[aPos] = Max(TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile), gTotalTimeAsync[aPos]) ; |
691 } |
689 } |
692 |
690 |
693 /** Delete content of directory |
691 /** Delete content of directory |
694 |
692 |
695 @param aDir Target directory |
693 @param aDir Target directory |
895 |
893 |
896 /** Reads a small file while writing a big one |
894 /** Reads a small file while writing a big one |
897 |
895 |
898 */ |
896 */ |
899 void TestReadingWhileWriting() |
897 void TestReadingWhileWriting() |
900 { |
898 { |
901 TInt r = 0; |
|
902 TTime time1; |
|
903 TTime time2; |
|
904 |
|
905 time1.HomeTime(); |
|
906 |
|
907 // Write the small file and take the appropriate measures |
899 // Write the small file and take the appropriate measures |
908 WriteFile(TheFs,gSmallFile,KBlockSize, KBlockSize, ENoThreads); |
900 WriteFile(TheFs,gSmallFile,KBlockSize, KBlockSize, ENoThreads); |
909 |
901 |
910 // Sync test |
902 // Sync test |
911 TBuf<20> buf=_L("Big Write"); |
903 TBuf<20> buf=_L("Big Write"); |
912 r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
904 TInt r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
913 TEST(r == KErrNone); |
905 TEST(r == KErrNone); |
914 |
906 |
915 buf = _L("Small Read"); |
907 buf = _L("Small Read"); |
916 r = gSmall.Create(buf, ReadSmallFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
908 r = gSmall.Create(buf, ReadSmallFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
917 TEST(r == KErrNone); |
909 TEST(r == KErrNone); |
923 CLIENTWAIT(); |
915 CLIENTWAIT(); |
924 |
916 |
925 gBig.Close(); |
917 gBig.Close(); |
926 gSmall.Close(); |
918 gSmall.Close(); |
927 |
919 |
928 |
920 TTimeIntervalMicroSeconds timeTaken = gTestTimer.Time(); |
929 TTimeIntervalMicroSeconds timeTaken = gTime1.MicroSecondsFrom(gTime2); |
921 test.Printf(_L("\nSync read done %d ms before the write ended\n"), TF32TestTimer::TimeInMilliSeconds(timeTaken)); |
930 test.Printf(_L("\nSync read done %d ms before the write ended\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
|
931 TReal time=I64LOW(timeTaken.Int64() / KuStomS); |
|
932 #if !defined(__WINS__) |
922 #if !defined(__WINS__) |
933 // If this condition fails, means that writing the sync file while fairscheduling a small sync read takes too long |
923 // If this condition fails, it means that writing the sync file while |
934 test.Printf(_L("time: %f\n"), time); |
924 // fairscheduling a small sync read takes too long. Reading small file |
935 // test((time > 0) && (((gTotalTimeSync[0]-time)>0) || ((gTotalTimeSync[1]-time)>0)) ); |
925 // should complete first. |
936 test(time > 0); |
926 test(timeTaken > 0); |
937 #endif |
927 #endif |
938 |
928 |
939 // Async test |
929 // Async test |
940 TRequestStatus status[KWaitRequestsTableSize]; |
930 TRequestStatus status[KWaitRequestsTableSize]; |
941 TRequestStatus status2[2]; |
931 TRequestStatus status2[2]; |
943 |
933 |
944 WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize ,status); |
934 WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize ,status); |
945 ReadFileAsync(TheFs, smallFile, gSmallFile, KBlockSize, status2 ); |
935 ReadFileAsync(TheFs, smallFile, gSmallFile, KBlockSize, status2 ); |
946 |
936 |
947 WaitForAll(status2,KBlockSize , KBlockSize ); |
937 WaitForAll(status2,KBlockSize , KBlockSize ); |
948 time1.HomeTime(); |
938 |
|
939 TF32TestTimer timer; |
|
940 timer.Start(); |
949 |
941 |
950 WaitForAll(status,gBigFileSize, KBigBlockSize); |
942 WaitForAll(status,gBigFileSize, KBigBlockSize); |
951 |
943 |
952 time2.HomeTime(); |
944 timer.Stop(); |
953 bigFile.Close(); |
945 bigFile.Close(); |
954 smallFile.Close(); |
946 smallFile.Close(); |
955 |
947 |
956 timeTaken = time2.MicroSecondsFrom(time1); |
948 timeTaken = timer.Time(); |
957 |
949 |
958 test.Printf(_L("\nAsync read done %d ms before the write ended\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
950 test.Printf(_L("\nAsync read done %d ms before the write ended\n"), timer.TimeInMilliSeconds()); |
959 time = I64LOW(timeTaken.Int64() / KuStomS); |
|
960 |
951 |
961 #if !defined(__WINS__) |
952 #if !defined(__WINS__) |
962 // If this condition fails, means that writing the async file while fairscheduling a small async read takes too long |
953 if (!Is_HVFS(TheFs, gDrive)) |
963 test.Printf(_L("time: %f\n"), time); |
954 { |
|
955 // If this condition fails, it means that writing the async file while fairscheduling a small async read takes too long |
964 test.Printf(_L("gTotalTimeAsync[0] = %d , gTotalTimeAsync[1] = %d\n"),gTotalTimeAsync[0],gTotalTimeAsync[1] ); |
956 test.Printf(_L("gTotalTimeAsync[0] = %d , gTotalTimeAsync[1] = %d\n"),gTotalTimeAsync[0],gTotalTimeAsync[1] ); |
965 // test((time > 0) && (((gTotalTimeAsync[0]-time)>0) || ((gTotalTimeAsync[1]-time)>0)) ); |
957 test(timeTaken > 0); |
966 test(time > 0); |
958 } |
967 #endif |
959 #endif |
968 } |
960 } |
969 |
961 |
970 /** Writes a small file while writing a big one |
962 /** Writes a small file while writing a big one |
971 |
963 |
972 */ |
964 */ |
973 void TestWritingWhileWriting() |
965 void TestWritingWhileWriting() |
974 { |
966 { |
975 TInt r = 0; |
967 TInt r = 0; |
976 TTime time1; |
|
977 TTime time2; |
|
978 |
968 |
979 // Sync test |
969 // Sync test |
980 TBuf<20> buf = _L("Big Write II"); |
970 TBuf<20> buf = _L("Big Write II"); |
981 r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
971 r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
982 TEST(r == KErrNone); |
972 TEST(r == KErrNone); |
992 CLIENTWAIT(); |
982 CLIENTWAIT(); |
993 |
983 |
994 gBig.Close(); |
984 gBig.Close(); |
995 gSmall.Close(); |
985 gSmall.Close(); |
996 |
986 |
997 TTimeIntervalMicroSeconds timeTaken = gTime1.MicroSecondsFrom(gTime2); |
987 TTimeIntervalMicroSeconds timeTaken = gTestTimer.Time(); |
998 test.Printf(_L("\nSync write done %d ms before the big write ended\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
988 test.Printf(_L("\nSync write done %d ms before the big write ended\n"), gTestTimer.TimeInMilliSeconds()); |
999 TReal time=I64LOW(timeTaken.Int64() / KuStomS); |
|
1000 #if !defined(__WINS__) |
989 #if !defined(__WINS__) |
1001 // If this condition fails, means that writing the sync file while fairscheduling a small sync write takes too long |
990 // If this condition fails, it means that writing the sync file while |
1002 test.Printf(_L("time: %f\n"), time); |
991 // fairscheduling a small sync write takes too long |
1003 // test((time > 0) && (((gTotalTimeSync[0]-time)>0) || ((gTotalTimeSync[1]-time)>0)) ); |
992 test(timeTaken > 0); |
1004 test(time > 0); |
|
1005 #endif |
993 #endif |
1006 |
994 |
1007 // Async test |
995 // Async test |
1008 TRequestStatus status[KWaitRequestsTableSize]; |
996 TRequestStatus status[KWaitRequestsTableSize]; |
1009 TRequestStatus status2[1]; |
997 TRequestStatus status2[1]; |
1010 RFile bigFile, smallFile; |
998 RFile bigFile, smallFile; |
1011 |
999 |
1012 WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); |
1000 WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); |
1013 WriteFileAsync(TheFs,smallFile, gSmallFile,gSmallFileSize,KBlockSize,status2); |
1001 WriteFileAsync(TheFs,smallFile, gSmallFile,gSmallFileSize,KBlockSize,status2); |
1014 WaitForAll(status2,gSmallFileSize, KBlockSize); |
1002 WaitForAll(status2,gSmallFileSize, KBlockSize); |
1015 time1.HomeTime(); |
1003 TF32TestTimer timer; |
|
1004 timer.Start(); |
1016 WaitForAll(status, gBigFileSize, KBigBlockSize); |
1005 WaitForAll(status, gBigFileSize, KBigBlockSize); |
1017 time2.HomeTime(); |
1006 timer.Stop(); |
1018 |
1007 |
1019 timeTaken = time2.MicroSecondsFrom(time1); |
1008 timeTaken = timer.Time(); |
1020 test.Printf(_L("\nAsync write done %d ms before the big write ended\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
1009 test.Printf(_L("\nAsync write done %d ms before the big write ended\n"),timer.TimeInMilliSeconds()); |
1021 time=I64LOW(timeTaken.Int64() / KuStomS); |
|
1022 #if !defined(__WINS__) |
1010 #if !defined(__WINS__) |
1023 // If this condition fails, means that writing the async file while fairscheduling a small async write takes too long |
1011 if (!Is_HVFS(TheFs, gDrive)) |
1024 test.Printf(_L("time: %f\n"), time); |
1012 { |
|
1013 // If this condition fails, it means that writing the async file while fairscheduling a small async write takes too long |
1025 test.Printf(_L("gTotalTimeAsync[0] = %d , gTotalTimeAsync[1] = %d\n"),gTotalTimeAsync[0],gTotalTimeAsync[1] ); |
1014 test.Printf(_L("gTotalTimeAsync[0] = %d , gTotalTimeAsync[1] = %d\n"),gTotalTimeAsync[0],gTotalTimeAsync[1] ); |
1026 // test((time > 0) && (((gTotalTimeAsync[0]-time)>0) || ((gTotalTimeAsync[1]-time)>0)) ); |
1015 test(timeTaken > 0); |
1027 test(time > 0); |
1016 } |
1028 #endif |
1017 #endif |
1029 bigFile.Close(); |
1018 bigFile.Close(); |
1030 smallFile.Close(); |
1019 smallFile.Close(); |
1031 } |
1020 } |
1032 |
1021 |
1055 CLIENTWAIT(); |
1042 CLIENTWAIT(); |
1056 |
1043 |
1057 gBig.Close(); |
1044 gBig.Close(); |
1058 gSmall.Close(); |
1045 gSmall.Close(); |
1059 |
1046 |
1060 TTimeIntervalMicroSeconds timeTaken = gTime2.MicroSecondsFrom(gTime1); |
1047 TTimeIntervalMicroSeconds timeTaken = gTestTimer.Time(); |
1061 test.Printf(_L("\nSync first write ended %d ms before the second write ended (same file size)\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
1048 test.Printf(_L("\nSync first write ended %d ms before the second write ended (same file size)\n"),TF32TestTimer::TimeInMilliSeconds(timeTaken)); |
1062 |
1049 |
1063 // Async test |
1050 // Async test |
1064 TRequestStatus status[KWaitRequestsTableSize]; |
1051 TRequestStatus status[KWaitRequestsTableSize]; |
1065 TRequestStatus status2[KWaitRequestsTableSize]; |
1052 TRequestStatus status2[KWaitRequestsTableSize]; |
1066 RFile bigFile, bigFile2; |
1053 RFile bigFile, bigFile2; |
1067 |
1054 |
1068 WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); |
1055 WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); |
1069 WriteFileAsync(TheFs, bigFile2, gSmallFile, gBigFileSize, KBigBlockSize, status2); |
1056 WriteFileAsync(TheFs, bigFile2, gSmallFile, gBigFileSize, KBigBlockSize, status2); |
1070 WaitForAll(status, gBigFileSize, KBigBlockSize); |
1057 WaitForAll(status, gBigFileSize, KBigBlockSize); |
1071 time1.HomeTime(); |
1058 TF32TestTimer timer; |
|
1059 timer.Start(); |
1072 WaitForAll(status2, gBigFileSize, KBigBlockSize); |
1060 WaitForAll(status2, gBigFileSize, KBigBlockSize); |
1073 time2.HomeTime(); |
1061 timer.Stop(); |
1074 |
1062 |
1075 timeTaken = time2.MicroSecondsFrom(time1); |
1063 timeTaken = timer.Time(); |
1076 test.Printf(_L("\nAsync first write ended %d ms before the second write ended (same file size)\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
1064 test.Printf(_L("\nAsync first write ended %d ms before the second write ended (same file size)\n"),TF32TestTimer::TimeInMilliSeconds(timeTaken)); |
1077 bigFile.Close(); |
1065 bigFile.Close(); |
1078 bigFile2.Close(); |
1066 bigFile2.Close(); |
1079 } |
1067 } |
1080 |
1068 |
1081 /** Reads the file that is being written |
1069 /** Reads the file that is being written |
1082 |
1070 |
1083 */ |
1071 */ |
1084 void TestReadingWhileWritingSameFile() |
1072 void TestReadingWhileWritingSameFile() |
1085 { |
1073 { |
1086 TInt r = 0; |
1074 TInt r = 0; |
1087 TTime time1; |
1075 TF32TestTimer timer; |
1088 |
1076 |
1089 time1.HomeTime(); |
1077 timer.Start(); |
1090 |
1078 |
1091 // Sync test |
1079 // Sync test |
1092 TBuf<20> buf = _L("Big Write IV"); |
1080 TBuf<20> buf = _L("Big Write IV"); |
1093 r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
1081 r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
1094 TEST(r == KErrNone); |
1082 TEST(r == KErrNone); |
1275 test.Printf(_L("Disabling Lock Fail simulation ...\n")); |
1263 test.Printf(_L("Disabling Lock Fail simulation ...\n")); |
1276 // turn OFF lock failure mode (if cache is enabled) |
1264 // turn OFF lock failure mode (if cache is enabled) |
1277 |
1265 |
1278 TBool simulatelockFailureMode = EFalse; |
1266 TBool simulatelockFailureMode = EFalse; |
1279 r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode); |
1267 r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode); |
1280 test (r == KErrNone || r == KErrNotSupported); |
1268 test_Value(r, r == KErrNone || r == KErrNotSupported); |
1281 #endif |
1269 #endif |
1282 |
1270 |
1283 // FileNames/File generation |
1271 // FileNames/File generation |
1284 test.Start(_L("Preparing the environment\n")); |
1272 test.Start(_L("Preparing the environment\n")); |
1285 |
1273 |