kerneltest/f32test/filesystem/fat/t_scn32dr1.cpp
branchGCC_SURGE
changeset 210 b592f7984442
parent 109 b3a1d9898418
equal deleted inserted replaced
209:6035754ebf88 210:b592f7984442
   517 //
   517 //
   518 // Return a pointer to a local buffer containing the attribute letters.
   518 // Return a pointer to a local buffer containing the attribute letters.
   519 //
   519 //
   520     {
   520     {
   521     LOCAL_D TBuf<6> str;
   521     LOCAL_D TBuf<6> str;
   522     LOCAL_D char*   atr = "RHSVDA";
   522     LOCAL_D char const *   atr = "RHSVDA";
   523     str.Fill(TText('-'), 6);
   523     str.Fill(TText('-'), 6);
   524     for (TInt i = 0; i < 6; i++)
   524     for (TInt i = 0; i < 6; i++)
   525         if ((aAttrib >> i) & 1)
   525         if ((aAttrib >> i) & 1)
   526             str[i] = atr[i];
   526             str[i] = atr[i];
   527     return &str;
   527     return &str;
  1985         UnFillUpRootDir(2);
  1985         UnFillUpRootDir(2);
  1986         ReadDirDisk(dirBuf);
  1986         ReadDirDisk(dirBuf);
  1987         ReadFatDisk(fatBuf);
  1987         ReadFatDisk(fatBuf);
  1988         }
  1988         }
  1989 
  1989 
  1990     // use first entry \scndrv\dir2\almostfull\ 
  1990     // use first entry \scndrv\dir2\almostfull
  1991     test.Next(_L("Partial entry in middle of subdir"));
  1991     test.Next(_L("Partial entry in middle of subdir"));
  1992     last = GetStartCluster(gClusterDir2_AFull,7);
  1992     last = GetStartCluster(gClusterDir2_AFull,7);
  1993     TEntryInfo partial2(ClusterEntryToBytes(gClusterDir2_AFull,2),6);
  1993     TEntryInfo partial2(ClusterEntryToBytes(gClusterDir2_AFull,2),6);
  1994     CreatePartialEntry(partial2,3,EFalse);
  1994     CreatePartialEntry(partial2,3,EFalse);
  1995     // entry has been allocated a cluster which scandrive should delete along with partial entry
  1995     // entry has been allocated a cluster which scandrive should delete along with partial entry
  1996     if (last > 0)
  1996     if (last > 0)
  1997         WriteToFatBuf(last,0,fatBuf.Ptr());
  1997         WriteToFatBuf(last,0,fatBuf.Ptr());
  1998     res=TestPartialEntry(partial2);
  1998     res=TestPartialEntry(partial2);
  1999     test(res);
  1999     test(res);
  2000 
  2000 
  2001     // reduce size of \scndrv\dir2\full\ 
  2001     // reduce size of \scndrv\dir2\full 
  2002     test.Next(_L("Test directory reclaim"));
  2002     test.Next(_L("Test directory reclaim"));
  2003     last = GetStartCluster(gClusterDir2_Full,gEntriesPerCluster-2);
  2003     last = GetStartCluster(gClusterDir2_Full,gEntriesPerCluster-2);
  2004     WriteEndOfDir(ClusterEntryToBytes(gClusterDir2_Full,gEntriesPerCluster-2));
  2004     WriteEndOfDir(ClusterEntryToBytes(gClusterDir2_Full,gEntriesPerCluster-2));
  2005     WriteDirEntryToDisk(dirBuf);
  2005     WriteDirEntryToDisk(dirBuf);
  2006     TInt entry = GetFatEntry(gClusterDir2_Full, fatBuf.Ptr());
  2006     TInt entry = GetFatEntry(gClusterDir2_Full, fatBuf.Ptr());
  2016     r=TheFs.ScanDrive(gSessionPath);
  2016     r=TheFs.ScanDrive(gSessionPath);
  2017     test_KErrNone(r);
  2017     test_KErrNone(r);
  2018     res=IsSameAsDrive(fatBuf,dirBuf);
  2018     res=IsSameAsDrive(fatBuf,dirBuf);
  2019     test(res);
  2019     test(res);
  2020 
  2020 
  2021     // use last entry of first cluster in \scndrv\dir2\full\ 
  2021     // use last entry of first cluster in \scndrv\dir2\full
  2022     test.Next(_L("Partial entry at end of subdir"));
  2022     test.Next(_L("Partial entry at end of subdir"));
  2023     r=temp.Create(TheFs,_L("\\scndrv\\dir2\\full\\temp"),EFileShareAny);
  2023     r=temp.Create(TheFs,_L("\\scndrv\\dir2\\full\\temp"),EFileShareAny);
  2024     test_KErrNone(r);
  2024     test_KErrNone(r);
  2025     temp.Close();
  2025     temp.Close();
  2026     ReadDirDisk(dirBuf);
  2026     ReadDirDisk(dirBuf);
  2028     TEntryInfo partial3(ClusterEntryToBytes(gClusterDir2_Full,gEntriesPerCluster-2),2);
  2028     TEntryInfo partial3(ClusterEntryToBytes(gClusterDir2_Full,gEntriesPerCluster-2),2);
  2029     CreatePartialEntry(partial3,1,EFalse);
  2029     CreatePartialEntry(partial3,1,EFalse);
  2030     res=TestPartialEntry(partial3);
  2030     res=TestPartialEntry(partial3);
  2031     test(res);
  2031     test(res);
  2032 
  2032 
  2033     // use entry in \scndrv\dir2\almostfull\ 
  2033     // use entry in \scndrv\dir2\almostfull 
  2034     test.Next(_L("Partial entry preceeding end-of-dir marker"));
  2034     test.Next(_L("Partial entry preceeding end-of-dir marker"));
  2035     last = GetStartCluster(gClusterDir2_AFull,14);
  2035     last = GetStartCluster(gClusterDir2_AFull,14);
  2036     if (last > 0)
  2036     if (last > 0)
  2037         WriteToFatBuf(last,0,fatBuf.Ptr());
  2037         WriteToFatBuf(last,0,fatBuf.Ptr());
  2038     last = GetStartCluster(gClusterDir2_AFull,8);
  2038     last = GetStartCluster(gClusterDir2_AFull,8);
  2050 	//	PDEF128576: Unicode name file deleted after Scandrive
  2050 	//	PDEF128576: Unicode name file deleted after Scandrive
  2051 	// In the fixes, we decided to discard file name checking in ScanDrive,
  2051 	// In the fixes, we decided to discard file name checking in ScanDrive,
  2052 	//	as it is impossible for ScanDrive to judge if the illegal byte is part of a legal
  2052 	//	as it is impossible for ScanDrive to judge if the illegal byte is part of a legal
  2053 	//	DBCS charater.
  2053 	//	DBCS charater.
  2054 
  2054 
  2055 	// create entry in \scndrv\dir2\almostfull\ 
  2055 	// create entry in \scndrv\dir2\almostfull 
  2056 //	test.Next(_L("Partial entry with invalid dos name"));
  2056 //	test.Next(_L("Partial entry with invalid dos name"));
  2057 //	r=temp.Create(TheFs,_L("\\scndrv\\dir2\\almostfull\\Dodgy file name"),EFileShareAny);
  2057 //	r=temp.Create(TheFs,_L("\\scndrv\\dir2\\almostfull\\Dodgy file name"),EFileShareAny);
  2058 //	test_KErrNone(r);
  2058 //	test_KErrNone(r);
  2059 //	temp.Close();
  2059 //	temp.Close();
  2060 //	ReadDirDisk(dirBuf);
  2060 //	ReadDirDisk(dirBuf);
  2067 //	res=IsSameAsDrive(fatBuf,dirBuf);
  2067 //	res=IsSameAsDrive(fatBuf,dirBuf);
  2068 //	test(res);
  2068 //	test(res);
  2069 
  2069 
  2070     if (BootSector.SectorsPerCluster() == 1)
  2070     if (BootSector.SectorsPerCluster() == 1)
  2071         {
  2071         {
  2072         // use entry created in \scndrv\dir2\ 
  2072         // use entry created in \scndrv\dir2 
  2073         test.Next(_L("Partial entry spanning more than two clusters"));
  2073         test.Next(_L("Partial entry spanning more than two clusters"));
  2074         last = GetStartCluster(gClusterDir2_Full,gEntriesPerCluster-1);
  2074         last = GetStartCluster(gClusterDir2_Full,gEntriesPerCluster-1);
  2075         WriteEndOfDir(ClusterEntryToBytes(gClusterDir2_Full,gEntriesPerCluster-2));
  2075         WriteEndOfDir(ClusterEntryToBytes(gClusterDir2_Full,gEntriesPerCluster-2));
  2076         WriteEndOfDir(ClusterEntryToBytes(gClusterDir2_Full,gEntriesPerCluster-1));
  2076         WriteEndOfDir(ClusterEntryToBytes(gClusterDir2_Full,gEntriesPerCluster-1));
  2077         WriteDirEntryToDisk(dirBuf);
  2077         WriteDirEntryToDisk(dirBuf);
  2119     CreateMatchingEntry(to1,from1,EFalse);
  2119     CreateMatchingEntry(to1,from1,EFalse);
  2120     TBool res=TestMatchingEntry(to1);
  2120     TBool res=TestMatchingEntry(to1);
  2121     test(res);
  2121     test(res);
  2122 
  2122 
  2123     // matching entries between 2 subdirs, one which has a full cluster
  2123     // matching entries between 2 subdirs, one which has a full cluster
  2124     // first entry in \scndrv\dir2\full\ + end of \scndrv\dir2\almostfull\ 
  2124     // first entry in \scndrv\dir2\full\ + end of \scndrv\dir2\almostfull
  2125     test.Next(_L("matching entries between 2 subdirs"));
  2125     test.Next(_L("matching entries between 2 subdirs"));
  2126     TEntryInfo from2(ClusterEntryToBytes(gClusterDir2_Full,2),2);
  2126     TEntryInfo from2(ClusterEntryToBytes(gClusterDir2_Full,2),2);
  2127     TEntryInfo to2(ClusterEntryToBytes(gClusterDir2_AFull,14),2);
  2127     TEntryInfo to2(ClusterEntryToBytes(gClusterDir2_AFull,14),2);
  2128     CreateMatchingEntry(to2,from2,EFalse);
  2128     CreateMatchingEntry(to2,from2,EFalse);
  2129     res=TestMatchingEntry(to2);
  2129     res=TestMatchingEntry(to2);
  2130     test(res);
  2130     test(res);
  2131 
  2131 
  2132     // matching entries between two subdirs - one with end of dir marker next
  2132     // matching entries between two subdirs - one with end of dir marker next
  2133     // \scndrv\dir2\somedirwith3entries to \scndrv\ 
  2133     // \scndrv\dir2\somedirwith3entries to \scndrv 
  2134     test.Next(_L("matching entries between two subdirs"));
  2134     test.Next(_L("matching entries between two subdirs"));
  2135     TEntryInfo from3(ClusterEntryToBytes(gClusterDir2,4),3);
  2135     TEntryInfo from3(ClusterEntryToBytes(gClusterDir2,4),3);
  2136     TEntryInfo to3(ClusterEntryToBytes(gClusterScnDrv,6),3);
  2136     TEntryInfo to3(ClusterEntryToBytes(gClusterScnDrv,6),3);
  2137     CreateMatchingEntry(to3,from3,ETrue);
  2137     CreateMatchingEntry(to3,from3,ETrue);
  2138     res=TestMatchingEntry(to3);
  2138     res=TestMatchingEntry(to3);
  2139     test(res);
  2139     test(res);
  2140 
  2140 
  2141     // matching entries in same subdir, one in new cluster - irrelevant if matching names
  2141     // matching entries in same subdir, one in new cluster - irrelevant if matching names
  2142     // 1st and last entries in \scndrv\dir2\full\ 
  2142     // 1st and last entries in \scndrv\dir2\full 
  2143     test.Next(_L("matching entries in same subdir"));
  2143     test.Next(_L("matching entries in same subdir"));
  2144     // delete entries to allow contiguous clusters in \scndrv\dir2\full directory
  2144     // delete entries to allow contiguous clusters in \scndrv\dir2\full directory
  2145     TInt r=TheFs.RmDir(_L("\\scndrv\\dir2\\somedirwith3entries\\"));
  2145     TInt r=TheFs.RmDir(_L("\\scndrv\\dir2\\somedirwith3entries\\"));
  2146     test_KErrNone(r);
  2146     test_KErrNone(r);
  2147     r=TheFs.RmDir(_L("\\scndrv\\dir2\\somedir2with3entries\\"));
  2147     r=TheFs.RmDir(_L("\\scndrv\\dir2\\somedir2with3entries\\"));
  2159     TEntryInfo to4(ClusterEntryToBytes(gClusterDir2_Full+1,0),2);
  2159     TEntryInfo to4(ClusterEntryToBytes(gClusterDir2_Full+1,0),2);
  2160     CreateMatchingEntry(to4,from4,ETrue);
  2160     CreateMatchingEntry(to4,from4,ETrue);
  2161     res=TestMatchingEntry(to4);
  2161     res=TestMatchingEntry(to4);
  2162     test(res);
  2162     test(res);
  2163 
  2163 
  2164     // \scndrv\dir1\very long name to \\scndrv\dir2\full\ 
  2164     // \scndrv\dir1\very long name to \\scndrv\dir2\full 
  2165     test.Next(_L("matching entries in diff dirs + new cluster"));
  2165     test.Next(_L("matching entries in diff dirs + new cluster"));
  2166     // delete last entry in directory
  2166     // delete last entry in directory
  2167     r=TheFs.Delete(LastInFull);
  2167     r=TheFs.Delete(LastInFull);
  2168     test_KErrNone(r);
  2168     test_KErrNone(r);
  2169     TFileName veryLongName=_L("\\scndrv\\dir2\\full\\");
  2169     TFileName veryLongName=_L("\\scndrv\\dir2\\full\\");