1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/filesystem/fat/t_scn32dr2.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,117 @@
1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// f32test\scndrv\t_scn32dr2.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include <f32file.h>
1.22 +#include <e32test.h>
1.23 +#include "t_server.h"
1.24 +
1.25 +#include "fat_utils.h"
1.26 +using namespace Fat_Test_Utils;
1.27 +
1.28 +
1.29 +
1.30 +/* Tests rugged fat file system. Power failure is simulated by failure of write
1.31 +operation in TDriver class. See t_tscan.cpp for fuller description.
1.32 +Tests drive set in the default path for epoc platforms and x: for WINS.*/
1.33 +
1.34 +GLDEF_D RTest test(_L("T_SCN32DR2"));
1.35 +GLDEF_D TFileName TheDrive=_L("?:\\");
1.36 +
1.37 +GLREF_D TInt TheFunctionNumber;
1.38 +GLREF_D TInt TheOpNumber;
1.39 +GLREF_D TInt TheFailCount;
1.40 +GLREF_D TBool IsReset;
1.41 +GLREF_D RFs TheFs;
1.42 +GLREF_D TFileName TestExeName;
1.43 +GLREF_D TFileName StartupExeName;
1.44 +GLREF_D TFileName LogFileName;
1.45 +
1.46 +#ifdef _DEBUG
1.47 +const TInt KControlIoRuggedOn=2;
1.48 +const TInt KControlIoRuggedOff=3;
1.49 +const TInt KControlIoIsRugged=4;
1.50 +#endif
1.51 +GLREF_D TInt WriteFailValue;
1.52 +
1.53 +GLREF_C void ReadLogFile();
1.54 +GLREF_C void DoTests();
1.55 +
1.56 +GLDEF_C void CallTestsL()
1.57 +//
1.58 +// Do all tests
1.59 +//
1.60 + {
1.61 + if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
1.62 + StartupExeName=_L("?:\\SYS\\BIN\\ESHELL.EXE");
1.63 + else
1.64 + StartupExeName=_L("?:\\SYSTEM\\BIN\\ESHELL.EXE");
1.65 +
1.66 +
1.67 +#ifndef _DEBUG
1.68 + test.Printf(_L("Error: Only debug builds supported\n"));
1.69 + return;
1.70 +#else
1.71 +
1.72 + const TInt KWriteFailStd=-100; // error -100 returned from write fail
1.73 +
1.74 + TInt gDriveNumber;
1.75 +
1.76 + TInt r = TheFs.CharToDrive( gSessionPath[0], gDriveNumber );
1.77 + test( KErrNone == r );
1.78 +
1.79 + //-- set up console output
1.80 + Fat_Test_Utils::SetConsole(test.Console());
1.81 +
1.82 + //-- print drive information
1.83 + PrintDrvInfo(TheFs, gDriveNumber);
1.84 +
1.85 + if (!Is_Fat(TheFs, gDriveNumber))
1.86 + {
1.87 + test.Printf(_L("CallTestsL: Skipped: test requires FAT filesystem\n"));
1.88 + return;
1.89 + }
1.90 +
1.91 + TheFunctionNumber=0;
1.92 + TheOpNumber=0;
1.93 + TheFailCount=0;
1.94 + IsReset=EFalse;
1.95 + WriteFailValue=KWriteFailStd;
1.96 +
1.97 + // ensure that fat filing system is rugged
1.98 + TUint8 oldFsys;
1.99 + TPtr8 pRugged(&oldFsys,1,1);
1.100 + r=TheFs.ControlIo(gDriveNumber,KControlIoIsRugged,pRugged);
1.101 + test(r==KErrNone);
1.102 + if(oldFsys==0)
1.103 + {
1.104 + r=TheFs.ControlIo(gDriveNumber,KControlIoRuggedOn);
1.105 + test(r==KErrNone);
1.106 + }
1.107 + DoTests();
1.108 + // if nec, set filing system back to !rugged
1.109 + if(oldFsys==0)
1.110 + {
1.111 + r=TheFs.ControlIo(gDriveNumber,KControlIoRuggedOff);
1.112 + test(r==KErrNone);
1.113 + }
1.114 +
1.115 + return;
1.116 +#endif
1.117 + }
1.118 +
1.119 +
1.120 +