os/kernelhwsrv/kerneltest/f32test/bench/t_fat_perf_main.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1996-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 // File Name:		f32test\bench\t_fat_perf_main.cpp
    15 // This file is intentionally created although t_main.cpp exists 
    16 // to start our tests.This file contains only necessary code to 
    17 // start our tests, whereas t_main.cpp creates test directory 
    18 // \\F32-TST\\, which will affect 'LeafDirCache' test cases
    19 // (PREQ 1885).
    20 // 
    21 //
    22 
    23 #define __E32TEST_EXTENSION__
    24 
    25 #include <f32file.h>
    26 #include <e32test.h>
    27 #include <e32hal.h>
    28 #include <e32math.h>
    29 #include <f32dbg.h>
    30 #include "t_server.h"
    31 
    32 RFs TheFs;
    33 TFileName gSessionPath;
    34 TChar gDriveToTest;
    35 
    36 
    37 void SetSessionPath(const TDesC& aPathName)
    38 //
    39 // Set the session path and update gSessionPath
    40 //
    41 	{
    42 
    43 	TInt r=TheFs.SetSessionPath(aPathName);
    44 	test(r==KErrNone);
    45 	r=TheFs.SessionPath(gSessionPath);
    46 	test(r==KErrNone);
    47 	}
    48 
    49 TInt CurrentDrive()
    50 //
    51 // Return the current drive number
    52 //
    53 	{
    54 
    55 	TInt driveNum;
    56 	TInt r=TheFs.CharToDrive(gSessionPath[0],driveNum);
    57 	test(r==KErrNone);
    58 	return(driveNum);
    59 	}
    60 
    61 LOCAL_C void PushLotsL()
    62 //
    63 // Expand the cleanup stack
    64 //
    65 	{
    66 	TInt i;
    67 	for(i=0;i<1000;i++)
    68 		CleanupStack::PushL((CBase*)NULL);
    69 	CleanupStack::Pop(1000);
    70 	}
    71 
    72 LOCAL_C void DoTests(TInt aDrive)
    73 //
    74 // Do testing on aDrive
    75 //
    76 	{
    77 
    78 	gSessionPath=_L("?:\\");
    79 	TChar driveLetter;
    80 	TInt r=TheFs.DriveToChar(aDrive,driveLetter);
    81 	test(r==KErrNone);
    82 	gSessionPath[0]=(TText)driveLetter;
    83 	r=TheFs.SetSessionPath(gSessionPath);
    84 	test(r==KErrNone);
    85 
    86 	TheFs.ResourceCountMarkStart();
    87 	TRAP(r,CallTestsL());
    88 	if (r==KErrNone)
    89 		TheFs.ResourceCountMarkEnd();
    90 	else
    91 		{
    92 		test.Printf(_L("Error: Leave %d\n"),r);
    93 		test(EFalse);
    94 		}
    95 
    96 	}
    97 
    98 
    99 void ParseCommandArguments()
   100 	{
   101 	TBuf<0x100> cmd;
   102 	User::CommandLine(cmd);
   103 	TLex lex(cmd);
   104 	TPtrC token=lex.NextToken();
   105 	TFileName thisfile=RProcess().FileName();
   106 	if (token.MatchF(thisfile)==0)
   107 		{
   108 		token.Set(lex.NextToken());
   109 		}
   110 	test.Printf(_L("CLP=%S"),&token);
   111 
   112 	if (token.Length()!=0)		
   113 		{
   114 		gDriveToTest=token[0];
   115 		gDriveToTest.UpperCase();
   116 		}
   117 	else						
   118 		{
   119 		gDriveToTest='C';		
   120 		}
   121 	}
   122 
   123 
   124 TInt E32Main()
   125     {
   126 
   127 	CTrapCleanup* cleanup;
   128 	cleanup=CTrapCleanup::New();
   129 	TRAPD(r,PushLotsL());
   130 	__UHEAP_MARK;
   131 
   132 	test.Title();
   133 	test.Start(_L("Starting tests..."));
   134 
   135 	ParseCommandArguments(); //need this for drive letter to test
   136 
   137 	r=TheFs.Connect();
   138 	test(r==KErrNone);
   139 
   140 	TInt theDrive;
   141 	r=TheFs.CharToDrive(gDriveToTest,theDrive);
   142     test(r==KErrNone);
   143 	
   144 	DoTests(theDrive);
   145 
   146 	TheFs.Close();
   147 	test.End();
   148 	test.Close();
   149 	__UHEAP_MARKEND;
   150 	delete cleanup;
   151 	return(KErrNone);
   152     }
   153 
   154 //EOF