os/kernelhwsrv/kerneltest/f32test/bench/t_fat_perf_main.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/bench/t_fat_perf_main.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,154 @@
     1.4 +// Copyright (c) 1996-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 +// File Name:		f32test\bench\t_fat_perf_main.cpp
    1.18 +// This file is intentionally created although t_main.cpp exists 
    1.19 +// to start our tests.This file contains only necessary code to 
    1.20 +// start our tests, whereas t_main.cpp creates test directory 
    1.21 +// \\F32-TST\\, which will affect 'LeafDirCache' test cases
    1.22 +// (PREQ 1885).
    1.23 +// 
    1.24 +//
    1.25 +
    1.26 +#define __E32TEST_EXTENSION__
    1.27 +
    1.28 +#include <f32file.h>
    1.29 +#include <e32test.h>
    1.30 +#include <e32hal.h>
    1.31 +#include <e32math.h>
    1.32 +#include <f32dbg.h>
    1.33 +#include "t_server.h"
    1.34 +
    1.35 +RFs TheFs;
    1.36 +TFileName gSessionPath;
    1.37 +TChar gDriveToTest;
    1.38 +
    1.39 +
    1.40 +void SetSessionPath(const TDesC& aPathName)
    1.41 +//
    1.42 +// Set the session path and update gSessionPath
    1.43 +//
    1.44 +	{
    1.45 +
    1.46 +	TInt r=TheFs.SetSessionPath(aPathName);
    1.47 +	test(r==KErrNone);
    1.48 +	r=TheFs.SessionPath(gSessionPath);
    1.49 +	test(r==KErrNone);
    1.50 +	}
    1.51 +
    1.52 +TInt CurrentDrive()
    1.53 +//
    1.54 +// Return the current drive number
    1.55 +//
    1.56 +	{
    1.57 +
    1.58 +	TInt driveNum;
    1.59 +	TInt r=TheFs.CharToDrive(gSessionPath[0],driveNum);
    1.60 +	test(r==KErrNone);
    1.61 +	return(driveNum);
    1.62 +	}
    1.63 +
    1.64 +LOCAL_C void PushLotsL()
    1.65 +//
    1.66 +// Expand the cleanup stack
    1.67 +//
    1.68 +	{
    1.69 +	TInt i;
    1.70 +	for(i=0;i<1000;i++)
    1.71 +		CleanupStack::PushL((CBase*)NULL);
    1.72 +	CleanupStack::Pop(1000);
    1.73 +	}
    1.74 +
    1.75 +LOCAL_C void DoTests(TInt aDrive)
    1.76 +//
    1.77 +// Do testing on aDrive
    1.78 +//
    1.79 +	{
    1.80 +
    1.81 +	gSessionPath=_L("?:\\");
    1.82 +	TChar driveLetter;
    1.83 +	TInt r=TheFs.DriveToChar(aDrive,driveLetter);
    1.84 +	test(r==KErrNone);
    1.85 +	gSessionPath[0]=(TText)driveLetter;
    1.86 +	r=TheFs.SetSessionPath(gSessionPath);
    1.87 +	test(r==KErrNone);
    1.88 +
    1.89 +	TheFs.ResourceCountMarkStart();
    1.90 +	TRAP(r,CallTestsL());
    1.91 +	if (r==KErrNone)
    1.92 +		TheFs.ResourceCountMarkEnd();
    1.93 +	else
    1.94 +		{
    1.95 +		test.Printf(_L("Error: Leave %d\n"),r);
    1.96 +		test(EFalse);
    1.97 +		}
    1.98 +
    1.99 +	}
   1.100 +
   1.101 +
   1.102 +void ParseCommandArguments()
   1.103 +	{
   1.104 +	TBuf<0x100> cmd;
   1.105 +	User::CommandLine(cmd);
   1.106 +	TLex lex(cmd);
   1.107 +	TPtrC token=lex.NextToken();
   1.108 +	TFileName thisfile=RProcess().FileName();
   1.109 +	if (token.MatchF(thisfile)==0)
   1.110 +		{
   1.111 +		token.Set(lex.NextToken());
   1.112 +		}
   1.113 +	test.Printf(_L("CLP=%S"),&token);
   1.114 +
   1.115 +	if (token.Length()!=0)		
   1.116 +		{
   1.117 +		gDriveToTest=token[0];
   1.118 +		gDriveToTest.UpperCase();
   1.119 +		}
   1.120 +	else						
   1.121 +		{
   1.122 +		gDriveToTest='C';		
   1.123 +		}
   1.124 +	}
   1.125 +
   1.126 +
   1.127 +TInt E32Main()
   1.128 +    {
   1.129 +
   1.130 +	CTrapCleanup* cleanup;
   1.131 +	cleanup=CTrapCleanup::New();
   1.132 +	TRAPD(r,PushLotsL());
   1.133 +	__UHEAP_MARK;
   1.134 +
   1.135 +	test.Title();
   1.136 +	test.Start(_L("Starting tests..."));
   1.137 +
   1.138 +	ParseCommandArguments(); //need this for drive letter to test
   1.139 +
   1.140 +	r=TheFs.Connect();
   1.141 +	test(r==KErrNone);
   1.142 +
   1.143 +	TInt theDrive;
   1.144 +	r=TheFs.CharToDrive(gDriveToTest,theDrive);
   1.145 +    test(r==KErrNone);
   1.146 +	
   1.147 +	DoTests(theDrive);
   1.148 +
   1.149 +	TheFs.Close();
   1.150 +	test.End();
   1.151 +	test.Close();
   1.152 +	__UHEAP_MARKEND;
   1.153 +	delete cleanup;
   1.154 +	return(KErrNone);
   1.155 +    }
   1.156 +
   1.157 +//EOF