sl@0: // Copyright (c) 1996-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: // File Name: f32test\bench\t_fat_perf_main.cpp sl@0: // This file is intentionally created although t_main.cpp exists sl@0: // to start our tests.This file contains only necessary code to sl@0: // start our tests, whereas t_main.cpp creates test directory sl@0: // \\F32-TST\\, which will affect 'LeafDirCache' test cases sl@0: // (PREQ 1885). sl@0: // sl@0: // sl@0: sl@0: #define __E32TEST_EXTENSION__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "t_server.h" sl@0: sl@0: RFs TheFs; sl@0: TFileName gSessionPath; sl@0: TChar gDriveToTest; sl@0: sl@0: sl@0: void SetSessionPath(const TDesC& aPathName) sl@0: // sl@0: // Set the session path and update gSessionPath sl@0: // sl@0: { sl@0: sl@0: TInt r=TheFs.SetSessionPath(aPathName); sl@0: test(r==KErrNone); sl@0: r=TheFs.SessionPath(gSessionPath); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: TInt CurrentDrive() sl@0: // sl@0: // Return the current drive number sl@0: // sl@0: { sl@0: sl@0: TInt driveNum; sl@0: TInt r=TheFs.CharToDrive(gSessionPath[0],driveNum); sl@0: test(r==KErrNone); sl@0: return(driveNum); sl@0: } sl@0: sl@0: LOCAL_C void PushLotsL() sl@0: // sl@0: // Expand the cleanup stack sl@0: // sl@0: { sl@0: TInt i; sl@0: for(i=0;i<1000;i++) sl@0: CleanupStack::PushL((CBase*)NULL); sl@0: CleanupStack::Pop(1000); sl@0: } sl@0: sl@0: LOCAL_C void DoTests(TInt aDrive) sl@0: // sl@0: // Do testing on aDrive sl@0: // sl@0: { sl@0: sl@0: gSessionPath=_L("?:\\"); sl@0: TChar driveLetter; sl@0: TInt r=TheFs.DriveToChar(aDrive,driveLetter); sl@0: test(r==KErrNone); sl@0: gSessionPath[0]=(TText)driveLetter; sl@0: r=TheFs.SetSessionPath(gSessionPath); sl@0: test(r==KErrNone); sl@0: sl@0: TheFs.ResourceCountMarkStart(); sl@0: TRAP(r,CallTestsL()); sl@0: if (r==KErrNone) sl@0: TheFs.ResourceCountMarkEnd(); sl@0: else sl@0: { sl@0: test.Printf(_L("Error: Leave %d\n"),r); sl@0: test(EFalse); sl@0: } sl@0: sl@0: } sl@0: sl@0: sl@0: void ParseCommandArguments() sl@0: { sl@0: TBuf<0x100> cmd; sl@0: User::CommandLine(cmd); sl@0: TLex lex(cmd); sl@0: TPtrC token=lex.NextToken(); sl@0: TFileName thisfile=RProcess().FileName(); sl@0: if (token.MatchF(thisfile)==0) sl@0: { sl@0: token.Set(lex.NextToken()); sl@0: } sl@0: test.Printf(_L("CLP=%S"),&token); sl@0: sl@0: if (token.Length()!=0) sl@0: { sl@0: gDriveToTest=token[0]; sl@0: gDriveToTest.UpperCase(); sl@0: } sl@0: else sl@0: { sl@0: gDriveToTest='C'; sl@0: } sl@0: } sl@0: sl@0: sl@0: TInt E32Main() sl@0: { sl@0: sl@0: CTrapCleanup* cleanup; sl@0: cleanup=CTrapCleanup::New(); sl@0: TRAPD(r,PushLotsL()); sl@0: __UHEAP_MARK; sl@0: sl@0: test.Title(); sl@0: test.Start(_L("Starting tests...")); sl@0: sl@0: ParseCommandArguments(); //need this for drive letter to test sl@0: sl@0: r=TheFs.Connect(); sl@0: test(r==KErrNone); sl@0: sl@0: TInt theDrive; sl@0: r=TheFs.CharToDrive(gDriveToTest,theDrive); sl@0: test(r==KErrNone); sl@0: sl@0: DoTests(theDrive); sl@0: sl@0: TheFs.Close(); sl@0: test.End(); sl@0: test.Close(); sl@0: __UHEAP_MARKEND; sl@0: delete cleanup; sl@0: return(KErrNone); sl@0: } sl@0: sl@0: //EOF