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