kerneltest/f32test/filesystem/automounter/t_automounter.cpp
changeset 11 329ab0095843
parent 9 96e5fb8b040d
equal deleted inserted replaced
10:36bfc973b146 11:329ab0095843
    27 #include <e32math.h>
    27 #include <e32math.h>
    28 #include <e32property.h>
    28 #include <e32property.h>
    29 #include <f32dbg.h>
    29 #include <f32dbg.h>
    30 
    30 
    31 #include "filesystem_fat.h"
    31 #include "filesystem_fat.h"
    32 #include "filesystem_exfat.h" 
       
    33 #include "filesystem_automounter.h" 
    32 #include "filesystem_automounter.h" 
    34 
    33 
    35 
    34 
    36 #include "t_server.h"
    35 #include "t_server.h"
    37 #include "fat_utils.h"
    36 #include "fat_utils.h"
    68 _LIT(KFsy1, "efat32.fsy");
    67 _LIT(KFsy1, "efat32.fsy");
    69 #else
    68 #else
    70 _LIT(KFsy1, "elocal.fsy");
    69 _LIT(KFsy1, "elocal.fsy");
    71 #endif    
    70 #endif    
    72     
    71     
    73 //-- exFAT is used as a child filesystem #1
    72 
    74 //_LIT(KFSName2, "exfat");  ///< filesystem #2 name
    73 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    74 //-- exFAT is used as a child filesystem #1. The problem here: some poor guys might not have the exFAT at all including the header file
       
    75 //-- "filesystem_exfat.h" that defines exFAT volume formatting structure. Fortunately for them the exFAT formatting parameters like "sectors per cluster" and
       
    76 //-- "number of FATs" have the same layout in the data container as FAT ones. So FAT formatting structure can be used for formatting exFAT.
       
    77 //-- The macro defines if exFAT might not be available.
       
    78 #define EXFAT_MIGHT_NOT_BE_PRESENT
    75 
    79 
    76 /** filesystem #2 name */
    80 /** filesystem #2 name */
    77 #define KFSName2 KFileSystemName_exFAT
    81 #ifdef EXFAT_MIGHT_NOT_BE_PRESENT
       
    82     _LIT(KFSName2, "exFAT");
       
    83 #else
       
    84     #define KFSName2 KFileSystemName_exFAT
       
    85     #include "filesystem_exfat.h" 
       
    86     using namespace FileSystem_EXFAT;
       
    87 #endif
       
    88 
       
    89 
       
    90 
       
    91 
    78 _LIT(KFsy2, "exfat.fsy"); ///< filesystem #2 *.fsy module name
    92 _LIT(KFsy2, "exfat.fsy"); ///< filesystem #2 *.fsy module name
    79 
    93 
    80 TBool automounter_Loaded  = EFalse; ///< ETrue if automounter.fsy is loaded; used for correct cleanup
    94 TBool automounter_Loaded  = EFalse; ///< ETrue if automounter.fsy is loaded; used for correct cleanup
    81 TBool childFs1_Loaded     = EFalse; ///< ETrue if child #0 *.fsy is loaded; used for correct cleanup
    95 TBool childFs1_Loaded     = EFalse; ///< ETrue if child #0 *.fsy is loaded; used for correct cleanup
    82 TBool childFs2_Loaded     = EFalse; ///< ETrue if child #1 *.fsy is loaded; used for correct cleanup
    96 TBool childFs2_Loaded     = EFalse; ///< ETrue if child #1 *.fsy is loaded; used for correct cleanup
  1506     Note that some media types (like SD cards) do not support such type of formatting. 
  1520     Note that some media types (like SD cards) do not support such type of formatting. 
  1507 */
  1521 */
  1508 
  1522 
  1509 void TestFormatting_FsName_Parameters_exFAT()
  1523 void TestFormatting_FsName_Parameters_exFAT()
  1510 {
  1524 {
  1511     using namespace FileSystem_EXFAT;
  1525 
  1512 
  1526 
  1513     test.Next(_L("Testing TVolFormatParam_exFAT formatting API\n"));
  1527     test.Next(_L("Testing TVolFormatParam_exFAT formatting API\n"));
  1514 
  1528 
  1515     TInt nRes;
  1529     TInt nRes;
  1516     TBuf<40>    fsName(0);
  1530     TBuf<40>    fsName(0);
  1529     FormatVolume(); //-- old API, formatting with all parameters by default
  1543     FormatVolume(); //-- old API, formatting with all parameters by default
  1530 
  1544 
  1531     //================================================================================
  1545     //================================================================================
  1532     //-- 1.0  simple unit test for TVolFormatParam_FAT
  1546     //-- 1.0  simple unit test for TVolFormatParam_FAT
  1533 
  1547 
  1534     TVolFormatParam_exFATBuf    fmtParamBuf_exFAT;
  1548 #ifndef EXFAT_MIGHT_NOT_BE_PRESENT    
  1535     TVolFormatParam_exFAT&      fmtParam = fmtParamBuf_exFAT();
  1549     TVolFormatParam_exFATBuf    fmtParamBuf;
       
  1550     TVolFormatParam_exFAT&      fmtParam = fmtParamBuf();
       
  1551 #else
       
  1552     //-- see the comments to "EXFAT_MIGHT_NOT_BE_PRESENT" macro definition
       
  1553     TVolFormatParam_FATBuf  fmtParamBuf;
       
  1554     TVolFormatParam_FAT&    fmtParam= fmtParamBuf();
       
  1555 #endif
       
  1556 
  1536 
  1557 
  1537     fmtParam.SetSectPerCluster(64);
  1558     fmtParam.SetSectPerCluster(64);
  1538     test(fmtParam.SectPerCluster()==64);
  1559     test(fmtParam.SectPerCluster()==64);
  1539 
  1560 
  1540     fmtParam.SetSectPerCluster(14);
  1561     fmtParam.SetSectPerCluster(14);
  1553 
  1574 
  1554     //--- formatting exFAT without specifying any parameters. This shall always succeed
  1575     //--- formatting exFAT without specifying any parameters. This shall always succeed
  1555     test.Printf(_L("fmt: using TVolFormatParam_exFAT, no parameters.\n"));
  1576     test.Printf(_L("fmt: using TVolFormatParam_exFAT, no parameters.\n"));
  1556     fmtParam.Init();
  1577     fmtParam.Init();
  1557     
  1578     
  1558     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf_exFAT);
  1579 #ifdef EXFAT_MIGHT_NOT_BE_PRESENT
       
  1580     //-- need to forcedly set exFAT FS name, because fmtParam.Init(); set it to "FAT"
       
  1581     ((TVolFormatParam&)fmtParam).SetFileSystemName(KFSName2);
       
  1582 #endif        
       
  1583 
       
  1584     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
  1559     test(nRes==KErrNone);
  1585     test(nRes==KErrNone);
  1560     
  1586     
  1561     nRes = DoFormatSteps(format, fmtCnt);
  1587     nRes = DoFormatSteps(format, fmtCnt);
  1562     test(nRes==KErrNone);
  1588     test(nRes==KErrNone);
  1563 
  1589 
  1569     test.Printf(_L("fmt: using TVolFormatParam_exFAT, some exFAT specific parameters.\n"));
  1595     test.Printf(_L("fmt: using TVolFormatParam_exFAT, some exFAT specific parameters.\n"));
  1570 
  1596 
  1571     fmtParam.SetSectPerCluster(1);
  1597     fmtParam.SetSectPerCluster(1);
  1572     fmtParam.SetNumFATs(2);
  1598     fmtParam.SetNumFATs(2);
  1573 
  1599 
  1574     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf_exFAT);
  1600     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
  1575     test(nRes==KErrNone);
  1601     test(nRes==KErrNone);
  1576     
  1602     
  1577     nRes = DoFormatSteps(format, fmtCnt);
  1603     nRes = DoFormatSteps(format, fmtCnt);
  1578     if(nRes != KErrNone)
  1604     if(nRes != KErrNone)
  1579     {
  1605     {