kerneltest/f32test/filesystem/fat/t_compat32.cpp
branchRCL_3
changeset 21 e7d2d738d3c2
parent 6 0173bcd7697c
child 43 c1f20ce4abcf
equal deleted inserted replaced
20:597aaf25e343 21:e7d2d738d3c2
   154 
   154 
   155 //
   155 //
   156 // Replace a 8.3 filename with upper and lower case letters which is, actually out of FAT specs.
   156 // Replace a 8.3 filename with upper and lower case letters which is, actually out of FAT specs.
   157 // I.e. VFAT entries are valid, but DOS entry has a lower case symbol, which is wrong.
   157 // I.e. VFAT entries are valid, but DOS entry has a lower case symbol, which is wrong.
   158 //
   158 //
   159 LOCAL_C void Test1(TNameCase aCase)
   159 static void Test1(TNameCase aCase)
   160 	{
   160 	{
   161 	test.Next(_L("Replace a file with a wrong DOS entry"));
   161 	test.Next(_L("Replace a file with a wrong DOS entry"));
   162 	QuickFormat();
   162 	QuickFormat();
   163 
   163 
   164     //-- N.B. This shall be the before any dir. entries creation in the root directory
   164     //-- N.B. This shall be the before any dir. entries creation in the root directory
   188 
   188 
   189 //
   189 //
   190 // Renaming a 8.3 filename with upper and lower case letters which is, actually out of FAT specs.
   190 // Renaming a 8.3 filename with upper and lower case letters which is, actually out of FAT specs.
   191 // I.e. VFAT entries are valid, but DOS entry has a lower case symbol, which is wrong.
   191 // I.e. VFAT entries are valid, but DOS entry has a lower case symbol, which is wrong.
   192 //
   192 //
   193 LOCAL_C void Test2(TNameCase aCase)
   193 static void Test2(TNameCase aCase)
   194 	{
   194 	{
   195 	test.Next(_L("Rename a file with a wrong DOS entry"));
   195 	test.Next(_L("Rename a file with a wrong DOS entry"));
   196 	QuickFormat();
   196 	QuickFormat();
   197 	RFile file;
   197 	RFile file;
   198     TInt r;
   198     TInt r;
   518     test(entry.iSize == KFile1Sz && entry.iName == KLongName2);
   518     test(entry.iSize == KFile1Sz && entry.iName == KLongName2);
   519 
   519 
   520 
   520 
   521 }
   521 }
   522 
   522 
   523 
   523 //---------------------------------------------
   524 GLDEF_C void CallTestsL()
   524 /**
   525 //
   525     Test that the created VFAT entryset corresponds to what Windows creates in the 
   526 // Call tests that may leave
   526     same situation
   527 //
   527 */
       
   528 void TestVFatEntryInterop()
       
   529 {
       
   530     test.Next(_L("Testind VFAT entries interoperability\n"));
       
   531     QuickFormat();
       
   532 
       
   533     TInt nRes;
       
   534     _LIT(KFName, "\\longfilename12345678");
       
   535     
       
   536     //-- 1. create a file with long FN that isn't multiple of 13 (max unicode characters in VFAT entry)
       
   537     const TUint KFileSize = 24;
       
   538     nRes = CreateEmptyFile(TheFs, KFName, KFileSize);
       
   539     test(nRes == KErrNone);
       
   540 
       
   541     //-- 2. verify that the dir. entries are the same what Windows creates.
       
   542 	nRes = TheDisk.Open(TheFs,CurrentDrive());
       
   543 	test(nRes == KErrNone);
       
   544 
       
   545     //-- read 1st dir. entry from the root dir and check it.
       
   546     //-- this is the rest of the LFN 
       
   547     TInt64 posEntry = gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
       
   548 
       
   549     TFatDirEntry fatEntry;
       
   550 	TPtr8 ptrEntry((TUint8*)&fatEntry, KSizeOfFatDirEntry);
       
   551 
       
   552     nRes = TheDisk.Read(posEntry, ptrEntry);
       
   553     test(nRes == KErrNone);
       
   554 
       
   555     //-- the expected entry #1 contents (what Windows places there). 
       
   556     const TUint8 KEntry1[KSizeOfFatDirEntry] = {0x42, 0x32, 0x00, 0x33, 0x00, 0x34, 0x00, 0x35, 0x00, 0x36, 0x00, 0x0F, 0x00, 0xF7, 0x37, 0x00,
       
   557                                                 0x38, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF };
       
   558 
       
   559     nRes = Mem::Compare(fatEntry.iData, KSizeOfFatDirEntry, KEntry1, KSizeOfFatDirEntry);
       
   560     test(nRes == KErrNone);
       
   561 
       
   562     //-- read 2nd dir. entry from the root dir and check it.
       
   563     //-- this is the beginning of the LFN 
       
   564 
       
   565     posEntry += KSizeOfFatDirEntry;
       
   566     nRes = TheDisk.Read(posEntry, ptrEntry);
       
   567     test(nRes == KErrNone);
       
   568 
       
   569     //-- the expected entry #2 contents (what Windows places there). 
       
   570     const TUint8 KEntry2[KSizeOfFatDirEntry] = { 0x01, 0x6C, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x67, 0x00, 0x66, 0x00, 0x0F, 0x00, 0xF7, 0x69, 0x00,
       
   571                                                  0x6C, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x00, 0x00, 0x65, 0x00, 0x31, 0x00 };
       
   572 
       
   573     nRes = Mem::Compare(fatEntry.iData, KSizeOfFatDirEntry, KEntry2, KSizeOfFatDirEntry);
       
   574     test(nRes == KErrNone);
       
   575 
       
   576     //-- read the last, 3rd entry from the root dir and check it.
       
   577     //-- this is the DOS entry
       
   578 
       
   579     posEntry += KSizeOfFatDirEntry;
       
   580     nRes = TheDisk.Read(posEntry, ptrEntry);
       
   581     test(nRes == KErrNone);
       
   582 
       
   583     //-- first 13 bytes of DOS entry SFN, attributes and DIR_NTRes field
       
   584     const TUint8 KEntry3[13] = {'L','O','N','G','F','I','~','1',' ',' ',' ', 0x20, 0x00 };
       
   585     nRes = Mem::Compare(fatEntry.iData, 13, KEntry3, 13);
       
   586     test(nRes == KErrNone);
       
   587 
       
   588     //-- skip file time stamps, they are not consistent
       
   589 
       
   590     //-- test file size and start cluster of the file
       
   591     test(fatEntry.StartCluster() != gBootSector.RootClusterNum() && fatEntry.StartCluster() != 0);
       
   592     test(fatEntry.Size() == KFileSize);
       
   593 
       
   594     //-- goto the next entry, this must be the end of directory
       
   595     posEntry += KSizeOfFatDirEntry;
       
   596     nRes = TheDisk.Read(posEntry, ptrEntry);
       
   597     test(nRes == KErrNone);
       
   598     test(fatEntry.IsEndOfDirectory());
       
   599 
       
   600     TheDisk.Close();
       
   601 
       
   602 }
       
   603 
       
   604 
       
   605 void CallTestsL()
   528 	{
   606 	{
   529 
   607 
   530 	TInt drvNum;
   608 	TInt drvNum;
   531 	TInt r=TheFs.CharToDrive(gDriveToTest,drvNum);
   609 	TInt r=TheFs.CharToDrive(gDriveToTest,drvNum);
   532 	test(r==KErrNone);
   610 	test(r==KErrNone);
   544     //-- print drive information
   622     //-- print drive information
   545     PrintDrvInfo(TheFs, drvNum);
   623     PrintDrvInfo(TheFs, drvNum);
   546 
   624 
   547 	GetBootInfo();
   625 	GetBootInfo();
   548 
   626 
       
   627     TestVFatEntryInterop();
       
   628 
   549 	Test1(EUpper); // Test directory entries with 8.3 uppercase (no VFAT entries expected)
   629 	Test1(EUpper); // Test directory entries with 8.3 uppercase (no VFAT entries expected)
   550 	Test1(ELower); // Test directory entries with 8.3 lowercase (   VFAT entries expected)
   630 	Test1(ELower); // Test directory entries with 8.3 lowercase (   VFAT entries expected)
   551 	Test1(EMixed); // Test directory entries with 8.3 mixed     (   VFAT entries expected)
   631 	Test1(EMixed); // Test directory entries with 8.3 mixed     (   VFAT entries expected)
   552 
   632 
   553 	Test2(EUpper); // Test directory entries with 8.3 uppercase (no VFAT entries expected)
   633 	Test2(EUpper); // Test directory entries with 8.3 uppercase (no VFAT entries expected)
   557 	TestDEF115314();
   637 	TestDEF115314();
   558 	TestDEF113633();
   638 	TestDEF113633();
   559 	TestPDEF116912();
   639 	TestPDEF116912();
   560 
   640 
   561     TestReplaceByShortName();
   641     TestReplaceByShortName();
   562 
   642 	}
   563 	}
   643 
   564 
   644 
   565 
   645 
   566