kerneltest/f32test/filesystem/fat/t_scn32dr2.cpp
changeset 0 a41df078684a
child 109 b3a1d9898418
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // f32test\scndrv\t_scn32dr2.cpp
       
    15 //
       
    16 //
       
    17 
       
    18 #include <f32file.h>
       
    19 #include <e32test.h>
       
    20 #include "t_server.h"
       
    21 
       
    22 #include "fat_utils.h"
       
    23 using namespace Fat_Test_Utils;
       
    24 
       
    25 
       
    26 
       
    27 /* Tests rugged fat file system. Power failure is simulated by failure of write
       
    28 operation in TDriver class. See t_tscan.cpp for fuller description.
       
    29 Tests drive set in the default path for epoc platforms and x: for WINS.*/
       
    30 
       
    31 GLDEF_D RTest test(_L("T_SCN32DR2"));
       
    32 GLDEF_D TFileName TheDrive=_L("?:\\");
       
    33 
       
    34 GLREF_D TInt TheFunctionNumber;
       
    35 GLREF_D TInt TheOpNumber;
       
    36 GLREF_D TInt TheFailCount;
       
    37 GLREF_D TBool IsReset;
       
    38 GLREF_D RFs TheFs;
       
    39 GLREF_D TFileName TestExeName;
       
    40 GLREF_D TFileName StartupExeName;
       
    41 GLREF_D TFileName LogFileName;
       
    42 
       
    43 #ifdef _DEBUG
       
    44 const TInt KControlIoRuggedOn=2;
       
    45 const TInt KControlIoRuggedOff=3;
       
    46 const TInt KControlIoIsRugged=4;
       
    47 #endif
       
    48 GLREF_D TInt WriteFailValue;
       
    49 
       
    50 GLREF_C void ReadLogFile();
       
    51 GLREF_C void DoTests();
       
    52 
       
    53 GLDEF_C void CallTestsL()
       
    54 //
       
    55 // Do all tests
       
    56 //
       
    57     {
       
    58     if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
       
    59         StartupExeName=_L("?:\\SYS\\BIN\\ESHELL.EXE");
       
    60     else
       
    61         StartupExeName=_L("?:\\SYSTEM\\BIN\\ESHELL.EXE");
       
    62 
       
    63 
       
    64 #ifndef _DEBUG
       
    65     test.Printf(_L("Error: Only debug builds supported\n"));
       
    66     return;
       
    67 #else
       
    68 
       
    69     const TInt KWriteFailStd=-100; // error -100 returned from write fail
       
    70 
       
    71     TInt gDriveNumber;
       
    72 
       
    73     TInt r = TheFs.CharToDrive( gSessionPath[0], gDriveNumber );
       
    74     test( KErrNone == r );
       
    75 
       
    76     //-- set up console output
       
    77     Fat_Test_Utils::SetConsole(test.Console());
       
    78 
       
    79     //-- print drive information
       
    80     PrintDrvInfo(TheFs, gDriveNumber);
       
    81 
       
    82     if (!Is_Fat(TheFs, gDriveNumber))
       
    83         {
       
    84         test.Printf(_L("CallTestsL: Skipped: test requires FAT filesystem\n"));
       
    85         return;
       
    86         }
       
    87 
       
    88     TheFunctionNumber=0;
       
    89     TheOpNumber=0;
       
    90     TheFailCount=0;
       
    91     IsReset=EFalse;
       
    92     WriteFailValue=KWriteFailStd;
       
    93 
       
    94     // ensure that fat filing system is rugged
       
    95     TUint8 oldFsys;
       
    96     TPtr8 pRugged(&oldFsys,1,1);
       
    97     r=TheFs.ControlIo(gDriveNumber,KControlIoIsRugged,pRugged);
       
    98     test(r==KErrNone);
       
    99     if(oldFsys==0)
       
   100         {
       
   101         r=TheFs.ControlIo(gDriveNumber,KControlIoRuggedOn);
       
   102         test(r==KErrNone);
       
   103         }
       
   104     DoTests();
       
   105     // if nec, set filing system back to !rugged
       
   106     if(oldFsys==0)
       
   107         {
       
   108         r=TheFs.ControlIo(gDriveNumber,KControlIoRuggedOff);
       
   109         test(r==KErrNone);
       
   110         }
       
   111 
       
   112     return;
       
   113 #endif
       
   114     }
       
   115 
       
   116 
       
   117