kerneltest/f32test/server/t_fsys.cpp
changeset 266 0008ccd16016
parent 109 b3a1d9898418
child 269 d57b86b1867a
equal deleted inserted replaced
259:57b9594f5772 266:0008ccd16016
    18 #define __E32TEST_EXTENSION__
    18 #define __E32TEST_EXTENSION__
    19 
    19 
    20 #include <f32file.h>
    20 #include <f32file.h>
    21 #include <f32file_private.h>
    21 #include <f32file_private.h>
    22 #include <e32test.h>
    22 #include <e32test.h>
       
    23 #include <e32math.h>
    23 #include "t_server.h"
    24 #include "t_server.h"
    24 #include "fat_utils.h"
    25 #include "fat_utils.h"
    25 #include "filesystem_fat.h"
    26 #include "filesystem_fat.h"
    26 
    27 
    27 using namespace Fat_Test_Utils;
    28 using namespace Fat_Test_Utils;
    28 
    29 
    29 RTest test(_L("T_FSYS"));
    30 RTest test(_L("T_FSYS"));
       
    31 static TInt64   gRndSeed;
       
    32 
       
    33 //---------------------------------------------------
       
    34 
       
    35 
       
    36 void InitGlobals()
       
    37 {
       
    38     //-- initialise random generator 
       
    39     gRndSeed = 0xf73c1ab;
       
    40     Math::Rand(gRndSeed);
       
    41 }
       
    42 
       
    43 //---------------------------------------------------
       
    44 void DestroyGlobals()
       
    45 {
       
    46 }
       
    47 
       
    48 //---------------------------------------------------
       
    49 
       
    50 /**
       
    51     The maximum length for the file system and extension names is KMaxFSNameLength
       
    52     test how the file server supports this
       
    53 */
       
    54 void TestFileSystemNameLength()
       
    55 {
       
    56     test.Next(_L("Test file system name lenght limits"));
       
    57     if(Is_SimulatedSystemDrive(TheFs, CurrentDrive()))
       
    58     {
       
    59         test.Printf(_L("Can't test on a simulated drive, skipping!"));
       
    60         return;
       
    61     }
       
    62 
       
    63     TInt nRes;
       
    64     TBuf<1024> name;
       
    65     TInt i;
       
    66 
       
    67     _LIT(KEmptyName, "");                //-- invalid length == 0
       
    68     _LIT(KDoesNotExist,  "RubbishName"); //-- valid length == 11
       
    69     _LIT(KDoesNotExist1, "RubbishName123456789012345678901"); //-- valid length == 32 (KMaxFSNameLength)
       
    70 
       
    71     _LIT(KNameTooLong1,  "RubbishName123456789012345678901_"); //-- invalid length == 33 (KMaxFSNameLength+1)
       
    72 
       
    73 
       
    74     test(KDoesNotExist1().Length() == KMaxFSNameLength);
       
    75 
       
    76     //-- generate a very long name
       
    77     name.Zero();
       
    78     for(i=0; i<(name.MaxLength()/KDoesNotExist1().Length()); ++i)
       
    79     {
       
    80         name.Append(KDoesNotExist1);
       
    81     }
       
    82 
       
    83     //-- 1. try to dismount the existing FS/extension specifying invalid name
       
    84 
       
    85     //-- 1.1 try empty names
       
    86     nRes = TheFs.DismountFileSystem(KEmptyName, CurrentDrive());
       
    87     test_Value(nRes, nRes == KErrArgument);
       
    88 
       
    89     nRes = TheFs.DismountExtension(KEmptyName, CurrentDrive());
       
    90     test_Value(nRes, nRes == KErrArgument);
       
    91 
       
    92     //-- 1.2 valid length, but non-existing name
       
    93     nRes = TheFs.DismountFileSystem(KDoesNotExist, CurrentDrive());
       
    94     test_Value(nRes, nRes == KErrNotFound);
       
    95 
       
    96     nRes = TheFs.DismountExtension(KDoesNotExist, CurrentDrive());
       
    97     test_Value(nRes, nRes == KErrNotFound);
       
    98 
       
    99     //-- 1.2 valid length == KMaxFSNameLength, but non-existing name
       
   100     nRes = TheFs.DismountFileSystem(KDoesNotExist1, CurrentDrive());
       
   101     test_Value(nRes, nRes == KErrNotFound);
       
   102 
       
   103     nRes = TheFs.DismountExtension(KDoesNotExist1, CurrentDrive());
       
   104     test_Value(nRes, nRes == KErrNotFound);
       
   105 
       
   106     //-- 1.3 too long name == KMaxFSNameLength+1, 
       
   107     nRes = TheFs.DismountFileSystem(KNameTooLong1, CurrentDrive());
       
   108     test_Value(nRes, nRes == KErrArgument);
       
   109 
       
   110     nRes = TheFs.DismountExtension(KNameTooLong1, CurrentDrive());
       
   111     test_Value(nRes, nRes == KErrArgument);
       
   112 
       
   113     //-- 1.4 a very long name ~ 1024 characters, 
       
   114     nRes = TheFs.DismountFileSystem(name, CurrentDrive());
       
   115     test_Value(nRes, nRes == KErrArgument);
       
   116 
       
   117     nRes = TheFs.DismountExtension(name, CurrentDrive());
       
   118     test_Value(nRes, nRes == KErrArgument);
       
   119 
       
   120     
       
   121     //-- try mounting extensions with valid, bu non-existing names
       
   122     nRes = TheFs.MountExtension(KDoesNotExist, CurrentDrive());
       
   123     test_Value(nRes, nRes == KErrNotFound);
       
   124 
       
   125     nRes = TheFs.MountExtension(KDoesNotExist1, CurrentDrive());
       
   126     test_Value(nRes, nRes == KErrNotFound);
       
   127     
       
   128     
       
   129     //====================================================
       
   130     //-- dismount original file system from the drive
       
   131     TFSDescriptor orgFSDesc;
       
   132     nRes = GetFileSystemDescriptor(TheFs, CurrentDrive(), orgFSDesc);
       
   133     test_KErrNone(nRes);
       
   134 
       
   135     nRes = TheFs.DismountFileSystem(orgFSDesc.iFsName, CurrentDrive());
       
   136     test_KErrNone(nRes);
       
   137 
       
   138     //-- 2. try to mount a FS/extension with the invalid name
       
   139     
       
   140     //-- 2.1 try empty names
       
   141     nRes = TheFs.MountFileSystem(KEmptyName, CurrentDrive());
       
   142     test_Value(nRes, nRes == KErrArgument);
       
   143 
       
   144     nRes = TheFs.MountExtension(KEmptyName, CurrentDrive());
       
   145     test_Value(nRes, nRes == KErrArgument);
       
   146 
       
   147     //-- 1.2 valid length, but non-existing name
       
   148     nRes = TheFs.MountFileSystem(KDoesNotExist, CurrentDrive());
       
   149     test_Value(nRes, nRes == KErrNotFound);
       
   150 
       
   151 
       
   152     //-- 1.2 valid length == KMaxFSNameLength, but non-existing name
       
   153     nRes = TheFs.MountFileSystem(KDoesNotExist1, CurrentDrive());
       
   154     test_Value(nRes, nRes == KErrNotFound);
       
   155 
       
   156 
       
   157     //-- 1.3 too long name == KMaxFSNameLength+1, 
       
   158     nRes = TheFs.MountFileSystem(KNameTooLong1, CurrentDrive());
       
   159     test_Value(nRes, nRes == KErrArgument);
       
   160 
       
   161     nRes = TheFs.MountExtension(KNameTooLong1, CurrentDrive());
       
   162     test_Value(nRes, nRes == KErrArgument);
       
   163 
       
   164     //-- 1.4 a very long name ~ 1024 characters, 
       
   165     nRes = TheFs.MountFileSystem(name, CurrentDrive());
       
   166     test_Value(nRes, nRes == KErrArgument);
       
   167 
       
   168     nRes = TheFs.MountExtension(name, CurrentDrive());
       
   169     test_Value(nRes, nRes == KErrArgument);
       
   170     
       
   171     
       
   172     
       
   173     
       
   174     //-- mount original file system back to the drive
       
   175     nRes = MountFileSystem(TheFs, CurrentDrive(), orgFSDesc);
       
   176     test_KErrNone(nRes);
       
   177 }
       
   178 
    30 
   179 
    31 static void TestFileSystemNames()
   180 static void TestFileSystemNames()
    32     {
   181     {
    33     test.Next(_L("Read file system names for all drives"));
   182     test.Next(_L("Read file system names for all drives"));
    34     TFullName name;
   183     TFullName name;
  1062             }
  1211             }
  1063     #endif
  1212     #endif
  1064 
  1213 
  1065     //---------------------------------------
  1214     //---------------------------------------
  1066 
  1215 
       
  1216     InitGlobals();
       
  1217     
       
  1218     //---------------------------------------
  1067     TestFileSystemNames();
  1219     TestFileSystemNames();
       
  1220     TestFileSystemNameLength();
  1068     TestDismountFileSystem(CurrentDrive());
  1221     TestDismountFileSystem(CurrentDrive());
  1069 #if defined(__EPOC32__)
  1222 #if defined(__EPOC32__)
  1070     TestFileSystem(CurrentDrive());
  1223     TestFileSystem(CurrentDrive());
  1071 #endif
  1224 #endif
  1072 
  1225 
  1083     TestQueryVolumeInfoExtOnTestFS(CurrentDrive());
  1236     TestQueryVolumeInfoExtOnTestFS(CurrentDrive());
  1084 
  1237 
  1085     TestFileSystem_MaxSupportedFileSizeQuery();
  1238     TestFileSystem_MaxSupportedFileSizeQuery();
  1086 
  1239 
  1087     TestRemountFSWithOpenedObjects();
  1240     TestRemountFSWithOpenedObjects();
  1088     
  1241 
  1089     
  1242     //---------------------------------------
  1090     }
  1243     DestroyGlobals();    
       
  1244     }