sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // f32test\scndrv\t_scn32dr3.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "t_server.h" sl@0: sl@0: #include "fat_utils.h" sl@0: using namespace Fat_Test_Utils; sl@0: sl@0: sl@0: /* Tests rugged fat filing system for epoc platforms. Copies \t_scn32dr3.exe to sl@0: \sys\bin\eshell.exe to enable the test to carry on after a reset. sl@0: See t_tscan for a fuller description of the tests carried out. Good idea to sl@0: disable crash debugger via \e32\inc\m32std.h. Drive to be tested is selected at sl@0: the command line. Also useful to disable beep in \e32\kpepoc\kp_ini.cpp to sl@0: avoid excessive noise.*/ sl@0: sl@0: GLDEF_D RTest test(_L("T_SCN32DR3")); sl@0: sl@0: GLREF_D TInt TheFunctionNumber; sl@0: GLREF_D TInt TheOpNumber; sl@0: GLREF_D TInt TheFailCount; sl@0: GLREF_D TBool IsReset; sl@0: GLREF_D RFs TheFs; sl@0: GLREF_D TFileName TestExeName; sl@0: GLREF_D TFileName StartupExeName; sl@0: GLREF_D TFileName LogFileName; sl@0: sl@0: #if defined( _DEBUG) && !defined(__WINS__) sl@0: const TInt KControlIoRuggedOn=2; sl@0: const TInt KControlIoRuggedOff=3; sl@0: const TInt KControlIoIsRugged=4; sl@0: #endif sl@0: GLREF_D TInt WriteFailValue; sl@0: GLREF_C void ReadLogFile(); sl@0: GLREF_C void DoTests(); sl@0: sl@0: #if defined(_DEBUG) sl@0: LOCAL_C void OverrideEShell(void) sl@0: // sl@0: // Copies the executable file as the eshell so that it is automatically run sl@0: // sl@0: { sl@0: test.Next(_L("OverideEShell")); sl@0: RProcess myProc; sl@0: if (myProc.FileName().CompareF(StartupExeName) == 0) sl@0: test.Printf(_L("OverrideEShell: running as eshell\n")); sl@0: else sl@0: { sl@0: RFile logFile; sl@0: TInt r; sl@0: TFileName tempDirName=_L(""); sl@0: // Copy over this executable and create a progress file. sl@0: test.Printf(_L("Copying %S to %S\n"), &TestExeName, &StartupExeName); sl@0: if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)) sl@0: tempDirName = _L("?:\\SYS\\BIN\\"); sl@0: else sl@0: tempDirName = _L("?:\\SYSTEM\\BIN\\"); sl@0: tempDirName[0] = gSessionPath[0]; sl@0: r=TheFs.MkDirAll(tempDirName); sl@0: test(r==KErrNone||r==KErrAlreadyExists); sl@0: CFileMan* fileMan=NULL; sl@0: TRAP(r,fileMan = CFileMan::NewL(TheFs)); sl@0: test(r==KErrNone); sl@0: //Copy the test from Z drive. sl@0: TFileName temp=_L("Z:\\SYS\\BIN\\T_SCN32DR3.EXE"); sl@0: r = fileMan->Copy(temp, TestExeName, CFileMan::EOverWrite); sl@0: test(r==KErrNone); sl@0: r = fileMan->Copy(TestExeName, StartupExeName, CFileMan::EOverWrite); sl@0: test(r == KErrNone); sl@0: //Mask read attribute. Fix for DEF081323 sl@0: r = fileMan->Attribs(StartupExeName, 0, KEntryAttReadOnly, 0); sl@0: test(r == KErrNone); sl@0: r = fileMan->Attribs(TestExeName, 0, KEntryAttReadOnly, 0); sl@0: test(r == KErrNone); sl@0: r = logFile.Replace(TheFs,LogFileName,EFileShareExclusive|EFileWrite); sl@0: test(r == KErrNone); sl@0: logFile.Close(); sl@0: delete fileMan; sl@0: } sl@0: } sl@0: #endif sl@0: sl@0: GLDEF_C void CallTestsL() sl@0: // sl@0: // sl@0: // sl@0: { sl@0: if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)) sl@0: StartupExeName=_L("?:\\SYS\\BIN\\ESHELL.EXE"); sl@0: else sl@0: StartupExeName=_L("?:\\SYSTEM\\BIN\\ESHELL.EXE"); sl@0: //RFs::ControlIo only supported in debug build sl@0: #ifndef _DEBUG sl@0: test.Printf(_L("Error: Supported only debug testing\n")); sl@0: return; sl@0: #else sl@0: #if defined(__WINS__) sl@0: test.Printf(_L("WINS not tested\n")); sl@0: return; sl@0: #else sl@0: const TInt KWriteFailReset=-99; // soft reset after write fail sl@0: sl@0: TInt r; sl@0: TestExeName[0]=StartupExeName[0]=LogFileName[0]=gSessionPath[0]; sl@0: // ensure file system is rugged sl@0: TUint8 oldFsys; sl@0: TPtr8 pRugged(&oldFsys,1,1); sl@0: r=TheFs.ControlIo(gSessionPath[0]-'A',KControlIoIsRugged,pRugged); sl@0: test(r==KErrNone); sl@0: if(oldFsys==0) sl@0: { sl@0: r=TheFs.ControlIo(gSessionPath[0]-'A',KControlIoRuggedOn); sl@0: test(r==KErrNone); sl@0: } sl@0: TheFunctionNumber=0; sl@0: TheOpNumber=0; sl@0: TheFailCount=0; sl@0: IsReset=ETrue; sl@0: WriteFailValue=KWriteFailReset; sl@0: test.Printf(_L("IsReset=%d\n"),IsReset); sl@0: OverrideEShell(); sl@0: ReadLogFile(); sl@0: r=TheFs.ScanDrive(gSessionPath); sl@0: test(r==KErrNone); sl@0: r=TheFs.CheckDisk(gSessionPath); sl@0: test(r==KErrNone); sl@0: DoTests(); sl@0: r=TheFs.Delete(LogFileName); sl@0: test(r==KErrNone); sl@0: r=TheFs.Delete(StartupExeName); sl@0: test(r==KErrNone); sl@0: // return file system to original state sl@0: if(oldFsys==0) sl@0: r=TheFs.ControlIo(gSessionPath[0]-'A',KControlIoRuggedOff); sl@0: UserSvr::ResetMachine(EStartupWarmReset); sl@0: return; sl@0: #endif sl@0: #endif sl@0: } sl@0: sl@0: