sl@0
|
1 |
// Copyright (c) 2008-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 |
// f32test\cfileman\t_cfileman.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#define __E32TEST_EXTENSION__
|
sl@0
|
19 |
#include <f32file.h>
|
sl@0
|
20 |
#include <e32test.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
#include "t_cfileman_cases.h"
|
sl@0
|
23 |
|
sl@0
|
24 |
static RArray<TUint> gFailedTestCases;
|
sl@0
|
25 |
|
sl@0
|
26 |
RTest test(_L("T_CFILEMAN"));
|
sl@0
|
27 |
|
sl@0
|
28 |
/*
|
sl@0
|
29 |
* Prints failure notification for failed test cases during test running period
|
sl@0
|
30 |
*/
|
sl@0
|
31 |
void DoLogTestCaseFailure(const TTestParamAll& aParam)
|
sl@0
|
32 |
{
|
sl@0
|
33 |
const TUint testCaseId = aParam.iTestCaseID;
|
sl@0
|
34 |
test.Printf(_L("Test Failure: Case %d !\n"), testCaseId);
|
sl@0
|
35 |
gFailedTestCases.Append(testCaseId);
|
sl@0
|
36 |
test.Printf(_L("Print out directory contents:\n"));
|
sl@0
|
37 |
PrintDir(aParam.iSrcPrsPath, *aParam.iSrcDrvChar);
|
sl@0
|
38 |
PrintDir(aParam.iSrcCmpPath, *aParam.iSrcDrvChar);
|
sl@0
|
39 |
if (aParam.iAPI == ECFMMove || aParam.iAPI == ECFMRename || aParam.iAPI == ECFMCopy || aParam.iAPI == ECFMCopyHandle)
|
sl@0
|
40 |
{
|
sl@0
|
41 |
PrintDir(aParam.iTrgPrsPath, *aParam.iTrgDrvChar);
|
sl@0
|
42 |
PrintDir(aParam.iTrgCmpPath, *aParam.iTrgDrvChar);
|
sl@0
|
43 |
}
|
sl@0
|
44 |
}
|
sl@0
|
45 |
|
sl@0
|
46 |
/*
|
sl@0
|
47 |
* Overall test results logging module, prints out the failing test cases with their ID
|
sl@0
|
48 |
*/
|
sl@0
|
49 |
void DoPrintTestResults()
|
sl@0
|
50 |
{
|
sl@0
|
51 |
// if no failure found
|
sl@0
|
52 |
if (gFailedTestCases.Count() == 0)
|
sl@0
|
53 |
{
|
sl@0
|
54 |
test.Printf(_L("All test cases have passed!\n"));
|
sl@0
|
55 |
return;
|
sl@0
|
56 |
}
|
sl@0
|
57 |
|
sl@0
|
58 |
test.Printf(_L("Test failure(s) found in following case(s):\n"));
|
sl@0
|
59 |
for (TInt i = 0; i < gFailedTestCases.Count(); i++)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
test.Printf(_L("Test Case: %u"), gFailedTestCases[i]);
|
sl@0
|
62 |
}
|
sl@0
|
63 |
test(EFalse);
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
/*
|
sl@0
|
67 |
* Presetting module, presets initial source, target and comparing direcotries.
|
sl@0
|
68 |
* @param aParam test param that contains all information about a test case
|
sl@0
|
69 |
*/
|
sl@0
|
70 |
void DoPresettings(const TTestParamAll& aParam)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
|
sl@0
|
73 |
// Setup source files
|
sl@0
|
74 |
TFileName path = aParam.iSrcPrsPath;
|
sl@0
|
75 |
path[0] = (TUint16)*aParam.iSrcDrvChar;
|
sl@0
|
76 |
|
sl@0
|
77 |
if(path[0] == (TUint8)gDriveToTest || path[0] == (TUint8)gFixedDriveValid)
|
sl@0
|
78 |
{
|
sl@0
|
79 |
SetupDirFiles(path, aParam.iSrcPrsFiles);
|
sl@0
|
80 |
|
sl@0
|
81 |
// setup source cmp files
|
sl@0
|
82 |
path = aParam.iSrcCmpPath;
|
sl@0
|
83 |
path[0] = (TUint16)*aParam.iSrcDrvChar;
|
sl@0
|
84 |
SetupDirFiles(path, aParam.iSrcCmpFiles);
|
sl@0
|
85 |
}
|
sl@0
|
86 |
|
sl@0
|
87 |
if (aParam.iAPI == ECFMMove || aParam.iAPI == ECFMRename || aParam.iAPI == ECFMCopy || aParam.iAPI == ECFMCopyHandle)
|
sl@0
|
88 |
{
|
sl@0
|
89 |
// setup trg files
|
sl@0
|
90 |
path = aParam.iTrgPrsPath;
|
sl@0
|
91 |
path[0] = (TUint16)*aParam.iTrgDrvChar;
|
sl@0
|
92 |
|
sl@0
|
93 |
if(path[0]== (TUint8)gDriveToTest)
|
sl@0
|
94 |
{
|
sl@0
|
95 |
SetupDirFiles(path, aParam.iTrgPrsFiles);
|
sl@0
|
96 |
|
sl@0
|
97 |
// setup trg cmp files
|
sl@0
|
98 |
path = aParam.iTrgCmpPath;
|
sl@0
|
99 |
path[0] = (TUint16)*aParam.iTrgDrvChar;
|
sl@0
|
100 |
SetupDirFiles(path, aParam.iTrgCmpFiles);
|
sl@0
|
101 |
}
|
sl@0
|
102 |
}
|
sl@0
|
103 |
}
|
sl@0
|
104 |
|
sl@0
|
105 |
/*
|
sl@0
|
106 |
* Test execution module
|
sl@0
|
107 |
* @param aParam test param that contains all information about a test case
|
sl@0
|
108 |
* @panic USER:84 if return codes do not match the expected values.
|
sl@0
|
109 |
*/
|
sl@0
|
110 |
|
sl@0
|
111 |
typedef TBuf<350> TTestFileName;
|
sl@0
|
112 |
void DoCmdExecution(const TTestParamAll& aParam)
|
sl@0
|
113 |
{
|
sl@0
|
114 |
TTestFileName srcCmd = aParam.iSrcCmdPath;
|
sl@0
|
115 |
if (srcCmd.Length() > 0)
|
sl@0
|
116 |
{
|
sl@0
|
117 |
srcCmd[0] = (TUint16)*aParam.iSrcDrvChar;
|
sl@0
|
118 |
}
|
sl@0
|
119 |
else
|
sl@0
|
120 |
{
|
sl@0
|
121 |
srcCmd= gSessionPath;
|
sl@0
|
122 |
srcCmd[0] = (TUint16)*aParam.iSrcDrvChar;
|
sl@0
|
123 |
}
|
sl@0
|
124 |
TInt r = KErrNone;
|
sl@0
|
125 |
switch(aParam.iAPI)
|
sl@0
|
126 |
{
|
sl@0
|
127 |
case ECFMDelete:
|
sl@0
|
128 |
if (!gAsynch)
|
sl@0
|
129 |
{
|
sl@0
|
130 |
r = gFileMan->Delete(srcCmd, aParam.iSwitch);
|
sl@0
|
131 |
test_Equal(r, aParam.iSyncReturn);
|
sl@0
|
132 |
}
|
sl@0
|
133 |
else
|
sl@0
|
134 |
{
|
sl@0
|
135 |
r = gFileMan->Delete(srcCmd, aParam.iSwitch, gStat);
|
sl@0
|
136 |
User::WaitForRequest(gStat);
|
sl@0
|
137 |
test_Equal(r , aParam.iAsyncReturn);
|
sl@0
|
138 |
test(gStat == aParam.iAsyncStatus);
|
sl@0
|
139 |
}
|
sl@0
|
140 |
break;
|
sl@0
|
141 |
|
sl@0
|
142 |
case ECFMRmDir:
|
sl@0
|
143 |
if (!gAsynch)
|
sl@0
|
144 |
{
|
sl@0
|
145 |
r = gFileMan->RmDir(srcCmd);
|
sl@0
|
146 |
test_Equal(r , aParam.iSyncReturn);
|
sl@0
|
147 |
}
|
sl@0
|
148 |
else
|
sl@0
|
149 |
{
|
sl@0
|
150 |
r = gFileMan->RmDir(srcCmd, gStat);
|
sl@0
|
151 |
User::WaitForRequest(gStat);
|
sl@0
|
152 |
test_Equal(r , aParam.iAsyncReturn);
|
sl@0
|
153 |
test(gStat == aParam.iAsyncStatus);
|
sl@0
|
154 |
}
|
sl@0
|
155 |
break;
|
sl@0
|
156 |
case ECFMAttribs:
|
sl@0
|
157 |
if (!gAsynch)
|
sl@0
|
158 |
{
|
sl@0
|
159 |
r = gFileMan->Attribs(srcCmd, aParam.iSetAttribs, aParam.iClearAttribs, aParam.iSetModified, aParam.iSwitch);
|
sl@0
|
160 |
test_Equal(r , aParam.iSyncReturn);
|
sl@0
|
161 |
}
|
sl@0
|
162 |
else
|
sl@0
|
163 |
{
|
sl@0
|
164 |
r = gFileMan->Attribs(srcCmd, aParam.iSetAttribs, aParam.iClearAttribs, aParam.iSetModified, aParam.iSwitch, gStat);
|
sl@0
|
165 |
User::WaitForRequest(gStat);
|
sl@0
|
166 |
test_Equal(r , aParam.iAsyncReturn);
|
sl@0
|
167 |
test(gStat == aParam.iAsyncStatus);
|
sl@0
|
168 |
}
|
sl@0
|
169 |
break;
|
sl@0
|
170 |
case ECFMMove:
|
sl@0
|
171 |
{
|
sl@0
|
172 |
TTestFileName trgCmd = aParam.iTrgCmdPath;
|
sl@0
|
173 |
if (trgCmd.Length() > 0)
|
sl@0
|
174 |
{
|
sl@0
|
175 |
trgCmd[0] = (TUint16)*aParam.iTrgDrvChar;
|
sl@0
|
176 |
}
|
sl@0
|
177 |
else
|
sl@0
|
178 |
{
|
sl@0
|
179 |
trgCmd= gSessionPath;
|
sl@0
|
180 |
}
|
sl@0
|
181 |
if (!gAsynch)
|
sl@0
|
182 |
{
|
sl@0
|
183 |
r = gFileMan->Move(srcCmd, trgCmd, aParam.iSwitch);
|
sl@0
|
184 |
test_Equal(r , aParam.iSyncReturn);
|
sl@0
|
185 |
}
|
sl@0
|
186 |
else
|
sl@0
|
187 |
{
|
sl@0
|
188 |
r = gFileMan->Move(srcCmd, trgCmd, aParam.iSwitch, gStat);
|
sl@0
|
189 |
User::WaitForRequest(gStat);
|
sl@0
|
190 |
test_Equal(r , aParam.iAsyncReturn);
|
sl@0
|
191 |
test(gStat == aParam.iAsyncStatus);
|
sl@0
|
192 |
}
|
sl@0
|
193 |
break;
|
sl@0
|
194 |
}
|
sl@0
|
195 |
case ECFMCopy:
|
sl@0
|
196 |
{
|
sl@0
|
197 |
TTestFileName trgCmd = aParam.iTrgCmdPath;
|
sl@0
|
198 |
if (trgCmd.Length() > 0)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
trgCmd[0] = (TUint16)*aParam.iTrgDrvChar;
|
sl@0
|
201 |
}
|
sl@0
|
202 |
else
|
sl@0
|
203 |
{
|
sl@0
|
204 |
trgCmd= gSessionPath;
|
sl@0
|
205 |
}
|
sl@0
|
206 |
if (!gAsynch)
|
sl@0
|
207 |
{
|
sl@0
|
208 |
r = gFileMan->Copy(srcCmd, trgCmd, aParam.iSwitch);
|
sl@0
|
209 |
test_Equal(r , aParam.iSyncReturn);
|
sl@0
|
210 |
}
|
sl@0
|
211 |
else
|
sl@0
|
212 |
{
|
sl@0
|
213 |
r = gFileMan->Copy(srcCmd, trgCmd,aParam.iSwitch, gStat);
|
sl@0
|
214 |
User::WaitForRequest(gStat);
|
sl@0
|
215 |
test_Equal(r , aParam.iAsyncReturn);
|
sl@0
|
216 |
test(gStat == aParam.iAsyncStatus);
|
sl@0
|
217 |
}
|
sl@0
|
218 |
break;
|
sl@0
|
219 |
}
|
sl@0
|
220 |
case ECFMRename:
|
sl@0
|
221 |
{
|
sl@0
|
222 |
TTestFileName trgCmd = aParam.iTrgCmdPath;
|
sl@0
|
223 |
if (trgCmd.Length() > 0)
|
sl@0
|
224 |
{
|
sl@0
|
225 |
trgCmd[0] = (TUint16)*aParam.iTrgDrvChar;
|
sl@0
|
226 |
}
|
sl@0
|
227 |
else
|
sl@0
|
228 |
{
|
sl@0
|
229 |
trgCmd= gSessionPath;
|
sl@0
|
230 |
}
|
sl@0
|
231 |
if (!gAsynch)
|
sl@0
|
232 |
{
|
sl@0
|
233 |
r = gFileMan->Rename(srcCmd, trgCmd, aParam.iSwitch);
|
sl@0
|
234 |
test_Equal(r , aParam.iSyncReturn);
|
sl@0
|
235 |
}
|
sl@0
|
236 |
else
|
sl@0
|
237 |
{
|
sl@0
|
238 |
r = gFileMan->Rename(srcCmd, trgCmd, aParam.iSwitch, gStat);
|
sl@0
|
239 |
User::WaitForRequest(gStat);
|
sl@0
|
240 |
test_Equal(r , aParam.iAsyncReturn);
|
sl@0
|
241 |
test(gStat == aParam.iAsyncStatus);
|
sl@0
|
242 |
}
|
sl@0
|
243 |
break;
|
sl@0
|
244 |
}
|
sl@0
|
245 |
case ECFMCopyHandle:
|
sl@0
|
246 |
{
|
sl@0
|
247 |
TTestFileName trgCmd = aParam.iTrgCmdPath;
|
sl@0
|
248 |
if (trgCmd.Length() > 0)
|
sl@0
|
249 |
{
|
sl@0
|
250 |
trgCmd[0] = (TUint16)*aParam.iTrgDrvChar;
|
sl@0
|
251 |
}
|
sl@0
|
252 |
else
|
sl@0
|
253 |
{
|
sl@0
|
254 |
trgCmd= gSessionPath;
|
sl@0
|
255 |
}
|
sl@0
|
256 |
|
sl@0
|
257 |
if (!gAsynch)
|
sl@0
|
258 |
{
|
sl@0
|
259 |
RFile tryfile;
|
sl@0
|
260 |
TInt ret = 0;
|
sl@0
|
261 |
ret = tryfile.Open(TheFs, srcCmd, EFileRead|EFileWrite);
|
sl@0
|
262 |
test_Equal(ret , KErrNone);
|
sl@0
|
263 |
r = gFileMan->Copy(tryfile, trgCmd, aParam.iSwitch);
|
sl@0
|
264 |
test_Equal(r , aParam.iSyncReturn);
|
sl@0
|
265 |
tryfile.Close();
|
sl@0
|
266 |
}
|
sl@0
|
267 |
else
|
sl@0
|
268 |
{
|
sl@0
|
269 |
RFile tryfile;
|
sl@0
|
270 |
TInt ret = 0;
|
sl@0
|
271 |
ret = tryfile.Open(TheFs, srcCmd, EFileRead|EFileWrite);
|
sl@0
|
272 |
test(ret == KErrNone);
|
sl@0
|
273 |
r = gFileMan->Copy(tryfile, trgCmd, aParam.iSwitch, gStat);
|
sl@0
|
274 |
User::WaitForRequest(gStat);
|
sl@0
|
275 |
test_Equal(r , aParam.iAsyncReturn);
|
sl@0
|
276 |
test(gStat == aParam.iAsyncStatus);
|
sl@0
|
277 |
tryfile.Close();
|
sl@0
|
278 |
}
|
sl@0
|
279 |
}
|
sl@0
|
280 |
default:
|
sl@0
|
281 |
break;
|
sl@0
|
282 |
|
sl@0
|
283 |
}
|
sl@0
|
284 |
|
sl@0
|
285 |
}
|
sl@0
|
286 |
|
sl@0
|
287 |
/*
|
sl@0
|
288 |
* Result verification module.
|
sl@0
|
289 |
* @param aParam test param that contains all information about a test case
|
sl@0
|
290 |
* @return ETrue if test results in expected behaviour, i.e. test passes
|
sl@0
|
291 |
* EFalse if test results in unexpected behaviour, i.e. test fails
|
sl@0
|
292 |
*/
|
sl@0
|
293 |
TBool DoResultsVerification(const TTestParamAll& aParam)
|
sl@0
|
294 |
{
|
sl@0
|
295 |
TFileName srcPath = aParam.iSrcPrsPath;
|
sl@0
|
296 |
srcPath[0] = (TUint16)*aParam.iSrcDrvChar;
|
sl@0
|
297 |
TFileName srcCmpPath = aParam.iSrcCmpPath;
|
sl@0
|
298 |
srcCmpPath[0] = (TUint16)*aParam.iSrcDrvChar;
|
sl@0
|
299 |
|
sl@0
|
300 |
if ((*aParam.iSrcDrvChar == gDriveToTest))
|
sl@0
|
301 |
{
|
sl@0
|
302 |
TBool rel = CompareL(srcPath, srcCmpPath);
|
sl@0
|
303 |
if(!rel)
|
sl@0
|
304 |
return EFalse;
|
sl@0
|
305 |
}
|
sl@0
|
306 |
|
sl@0
|
307 |
if (aParam.iAPI == ECFMMove || aParam.iAPI == ECFMRename || aParam.iAPI == ECFMCopy || aParam.iAPI == ECFMCopyHandle)
|
sl@0
|
308 |
{
|
sl@0
|
309 |
TFileName trgPath = aParam.iTrgPrsPath;
|
sl@0
|
310 |
trgPath[0] = (TUint16)*aParam.iTrgDrvChar;
|
sl@0
|
311 |
TFileName trgCmpPath = aParam.iTrgCmpPath;
|
sl@0
|
312 |
trgCmpPath[0] = (TUint16)*aParam.iTrgDrvChar;
|
sl@0
|
313 |
if ((*aParam.iTrgDrvChar == gDriveToTest))
|
sl@0
|
314 |
{
|
sl@0
|
315 |
TBool rel = CompareL(trgPath, trgCmpPath);
|
sl@0
|
316 |
if(!rel)
|
sl@0
|
317 |
return rel;
|
sl@0
|
318 |
}
|
sl@0
|
319 |
|
sl@0
|
320 |
}
|
sl@0
|
321 |
return ETrue;
|
sl@0
|
322 |
}
|
sl@0
|
323 |
|
sl@0
|
324 |
/*
|
sl@0
|
325 |
* Search test cases by the index of the array of test case group, overloaded version for basic unitary cases.
|
sl@0
|
326 |
* @param aIdx the test case index in search
|
sl@0
|
327 |
* @param aBasicUnitaryTestCaseGroup the input test group, should always be gBasicUnitaryTestCases[]
|
sl@0
|
328 |
* @param aTestCaseFound contains params of the test case found by the test case Id.
|
sl@0
|
329 |
* @return KErrNone if only one test case on the id is found
|
sl@0
|
330 |
* KErrNotFound if no test case is found
|
sl@0
|
331 |
*/
|
sl@0
|
332 |
TInt SearchTestCaseByArrayIdx(TUint aIdx, const TTestCaseUnitaryBasic aBasicUnitaryTestCaseGroup[], TTestParamAll& aTestCaseFound)
|
sl@0
|
333 |
{
|
sl@0
|
334 |
if (aBasicUnitaryTestCaseGroup[aIdx].iBasic.iTestCaseID != 0)
|
sl@0
|
335 |
{
|
sl@0
|
336 |
aTestCaseFound.iTestCaseID = aBasicUnitaryTestCaseGroup[aIdx].iBasic.iTestCaseID;
|
sl@0
|
337 |
aTestCaseFound.iAPI = aBasicUnitaryTestCaseGroup[aIdx].iBasic.iAPI;
|
sl@0
|
338 |
aTestCaseFound.iSwitch = aBasicUnitaryTestCaseGroup[aIdx].iBasic.iSwitch;
|
sl@0
|
339 |
aTestCaseFound.iSyncReturn = aBasicUnitaryTestCaseGroup[aIdx].iBasic.iSyncReturn;
|
sl@0
|
340 |
aTestCaseFound.iAsyncReturn = aBasicUnitaryTestCaseGroup[aIdx].iBasic.iAsyncReturn;
|
sl@0
|
341 |
aTestCaseFound.iAsyncStatus = aBasicUnitaryTestCaseGroup[aIdx].iBasic.iAsyncStatus;
|
sl@0
|
342 |
|
sl@0
|
343 |
aTestCaseFound.iSrcDrvChar = aBasicUnitaryTestCaseGroup[aIdx].iSrcPrsBasic.iDrvChar;
|
sl@0
|
344 |
aTestCaseFound.iSrcCmdPath.Set(aBasicUnitaryTestCaseGroup[aIdx].iSrcPrsBasic.iCmdPath);
|
sl@0
|
345 |
aTestCaseFound.iSrcPrsPath.Set(aBasicUnitaryTestCaseGroup[aIdx].iSrcPrsBasic.iPrsPath);
|
sl@0
|
346 |
aTestCaseFound.iSrcPrsFiles = aBasicUnitaryTestCaseGroup[aIdx].iSrcPrsBasic.iPrsFiles;
|
sl@0
|
347 |
aTestCaseFound.iSrcCmpPath.Set(aBasicUnitaryTestCaseGroup[aIdx].iSrcPrsBasic.iCmpPath);
|
sl@0
|
348 |
aTestCaseFound.iSrcCmpFiles = aBasicUnitaryTestCaseGroup[aIdx].iSrcPrsBasic.iCmpFiles;
|
sl@0
|
349 |
}
|
sl@0
|
350 |
else
|
sl@0
|
351 |
return KErrNotFound;
|
sl@0
|
352 |
return KErrNone;
|
sl@0
|
353 |
|
sl@0
|
354 |
}
|
sl@0
|
355 |
|
sl@0
|
356 |
/*
|
sl@0
|
357 |
* Search test cases by the index of the array of test case group, overloaded version for basic binary cases.
|
sl@0
|
358 |
* @param aIdx the test case index in search
|
sl@0
|
359 |
* @param aBasicUnitaryTestCaseGroup the input test group, should always be gBasicBinaryTestCases[]
|
sl@0
|
360 |
* @param aTestCaseFound contains params of the test case found by the test case Id.
|
sl@0
|
361 |
* @return KErrNone if only one test case on the id is found
|
sl@0
|
362 |
* KErrNotFound if no test case is found
|
sl@0
|
363 |
*/
|
sl@0
|
364 |
TInt SearchTestCaseByArrayIdx(TUint aIdx, const TTestCaseBinaryBasic aBasicBinaryTestCaseGroup[], TTestParamAll& aTestCaseFound)
|
sl@0
|
365 |
{
|
sl@0
|
366 |
if (aBasicBinaryTestCaseGroup[aIdx].iBasic.iTestCaseID != 0)
|
sl@0
|
367 |
{
|
sl@0
|
368 |
aTestCaseFound.iTestCaseID = aBasicBinaryTestCaseGroup[aIdx].iBasic.iTestCaseID;
|
sl@0
|
369 |
aTestCaseFound.iAPI = aBasicBinaryTestCaseGroup[aIdx].iBasic.iAPI;
|
sl@0
|
370 |
aTestCaseFound.iSwitch = aBasicBinaryTestCaseGroup[aIdx].iBasic.iSwitch;
|
sl@0
|
371 |
aTestCaseFound.iSyncReturn = aBasicBinaryTestCaseGroup[aIdx].iBasic.iSyncReturn;
|
sl@0
|
372 |
aTestCaseFound.iAsyncReturn = aBasicBinaryTestCaseGroup[aIdx].iBasic.iAsyncReturn;
|
sl@0
|
373 |
aTestCaseFound.iAsyncStatus = aBasicBinaryTestCaseGroup[aIdx].iBasic.iAsyncStatus;
|
sl@0
|
374 |
|
sl@0
|
375 |
aTestCaseFound.iSrcDrvChar = aBasicBinaryTestCaseGroup[aIdx].iSrcPrsBasic.iDrvChar;
|
sl@0
|
376 |
aTestCaseFound.iSrcCmdPath.Set(aBasicBinaryTestCaseGroup[aIdx].iSrcPrsBasic.iCmdPath);
|
sl@0
|
377 |
aTestCaseFound.iSrcPrsPath.Set(aBasicBinaryTestCaseGroup[aIdx].iSrcPrsBasic.iPrsPath);
|
sl@0
|
378 |
aTestCaseFound.iSrcPrsFiles = aBasicBinaryTestCaseGroup[aIdx].iSrcPrsBasic.iPrsFiles;
|
sl@0
|
379 |
aTestCaseFound.iSrcCmpPath.Set(aBasicBinaryTestCaseGroup[aIdx].iSrcPrsBasic.iCmpPath);
|
sl@0
|
380 |
aTestCaseFound.iSrcCmpFiles = aBasicBinaryTestCaseGroup[aIdx].iSrcPrsBasic.iCmpFiles;
|
sl@0
|
381 |
|
sl@0
|
382 |
aTestCaseFound.iTrgDrvChar = aBasicBinaryTestCaseGroup[aIdx].iTrgPrsBasic.iDrvChar;
|
sl@0
|
383 |
aTestCaseFound.iTrgCmdPath.Set(aBasicBinaryTestCaseGroup[aIdx].iTrgPrsBasic.iCmdPath);
|
sl@0
|
384 |
aTestCaseFound.iTrgPrsPath.Set(aBasicBinaryTestCaseGroup[aIdx].iTrgPrsBasic.iPrsPath);
|
sl@0
|
385 |
aTestCaseFound.iTrgPrsFiles = aBasicBinaryTestCaseGroup[aIdx].iTrgPrsBasic.iPrsFiles;
|
sl@0
|
386 |
aTestCaseFound.iTrgCmpPath.Set(aBasicBinaryTestCaseGroup[aIdx].iTrgPrsBasic.iCmpPath);
|
sl@0
|
387 |
aTestCaseFound.iTrgCmpFiles = aBasicBinaryTestCaseGroup[aIdx].iTrgPrsBasic.iCmpFiles;
|
sl@0
|
388 |
}
|
sl@0
|
389 |
else
|
sl@0
|
390 |
{
|
sl@0
|
391 |
return KErrNotFound;
|
sl@0
|
392 |
}
|
sl@0
|
393 |
return KErrNone;
|
sl@0
|
394 |
}
|
sl@0
|
395 |
|
sl@0
|
396 |
/*
|
sl@0
|
397 |
* Search test cases by test case Id, overloaded version for Basic unitary cases.
|
sl@0
|
398 |
* @param aCaseId the test case Id in search
|
sl@0
|
399 |
* @param aBasicUnitaryTestCaseGroup the input test group, should always be gBasicUnitaryTestCases[]
|
sl@0
|
400 |
* @param aTestCaseFound contains params of the test case found by the test case Id.
|
sl@0
|
401 |
* @return KErrNone if only one test case on the id is found
|
sl@0
|
402 |
* KErrAlreadyExists if more than one test cases found by the test case Id
|
sl@0
|
403 |
* KErrNotFound if no test case is found
|
sl@0
|
404 |
*/
|
sl@0
|
405 |
TInt SearchTestCaseByTestCaseId(TUint aCaseId, const TTestCaseUnitaryBasic aBasicUnitaryTestCaseGroup[], TTestParamAll& aTestCaseFound)
|
sl@0
|
406 |
{
|
sl@0
|
407 |
TBool found = EFalse;
|
sl@0
|
408 |
TInt rel = KErrNone;
|
sl@0
|
409 |
|
sl@0
|
410 |
// Scan through the test group by array index
|
sl@0
|
411 |
for(TInt i = 0; rel == KErrNone; i++)
|
sl@0
|
412 |
{
|
sl@0
|
413 |
rel = SearchTestCaseByArrayIdx(i, aBasicUnitaryTestCaseGroup, aTestCaseFound);
|
sl@0
|
414 |
if(aTestCaseFound.iTestCaseID == aCaseId)
|
sl@0
|
415 |
{
|
sl@0
|
416 |
// If more than one test cases found, return error
|
sl@0
|
417 |
if(found)
|
sl@0
|
418 |
{
|
sl@0
|
419 |
return KErrAlreadyExists;
|
sl@0
|
420 |
}
|
sl@0
|
421 |
found = ETrue;
|
sl@0
|
422 |
}
|
sl@0
|
423 |
}
|
sl@0
|
424 |
|
sl@0
|
425 |
if (!found)
|
sl@0
|
426 |
{
|
sl@0
|
427 |
return KErrNotFound;
|
sl@0
|
428 |
}
|
sl@0
|
429 |
return KErrNone;
|
sl@0
|
430 |
}
|
sl@0
|
431 |
|
sl@0
|
432 |
/*
|
sl@0
|
433 |
* Do all basic binary test cases defined in gBasicUnitaryTestCases[]
|
sl@0
|
434 |
*/
|
sl@0
|
435 |
void DoAllBasicUnitaryTests(const TTestCaseUnitaryBasic aBasicUnitaryTestCaseGroup[])
|
sl@0
|
436 |
{
|
sl@0
|
437 |
TTestParamAll nextTestCase;
|
sl@0
|
438 |
TInt i = 0;
|
sl@0
|
439 |
|
sl@0
|
440 |
while (SearchTestCaseByArrayIdx(i, aBasicUnitaryTestCaseGroup, nextTestCase) == KErrNone)
|
sl@0
|
441 |
{
|
sl@0
|
442 |
TTime startTime;
|
sl@0
|
443 |
TTime endTime;
|
sl@0
|
444 |
startTime.HomeTime();
|
sl@0
|
445 |
DoPresettings(nextTestCase);
|
sl@0
|
446 |
DoCmdExecution(nextTestCase);
|
sl@0
|
447 |
if (!DoResultsVerification(nextTestCase))
|
sl@0
|
448 |
{
|
sl@0
|
449 |
DoLogTestCaseFailure(nextTestCase);
|
sl@0
|
450 |
}
|
sl@0
|
451 |
else
|
sl@0
|
452 |
{
|
sl@0
|
453 |
test.Printf(_L("Test ID %d passed \n"),nextTestCase.iTestCaseID);
|
sl@0
|
454 |
}
|
sl@0
|
455 |
endTime.HomeTime();
|
sl@0
|
456 |
TTimeIntervalMicroSeconds timeTaken(0);
|
sl@0
|
457 |
timeTaken = endTime.MicroSecondsFrom(startTime);
|
sl@0
|
458 |
TInt time2=0;
|
sl@0
|
459 |
time2=I64LOW(timeTaken.Int64()/1000);
|
sl@0
|
460 |
test.Printf(_L("Time Taken by testid %d = %d mS \n"),nextTestCase.iTestCaseID,time2);
|
sl@0
|
461 |
++i;
|
sl@0
|
462 |
|
sl@0
|
463 |
}
|
sl@0
|
464 |
}
|
sl@0
|
465 |
|
sl@0
|
466 |
/*
|
sl@0
|
467 |
* Do all basic binary test cases defined in gBasicBinaryTestCases[]
|
sl@0
|
468 |
*/
|
sl@0
|
469 |
void DoAllBasicBinaryTests(const TTestCaseBinaryBasic aBasicBinaryTestCaseGroup[])
|
sl@0
|
470 |
{
|
sl@0
|
471 |
TTestParamAll nextTestCase;
|
sl@0
|
472 |
TInt i = 0;
|
sl@0
|
473 |
while (SearchTestCaseByArrayIdx(i, aBasicBinaryTestCaseGroup, nextTestCase) == KErrNone)
|
sl@0
|
474 |
{
|
sl@0
|
475 |
TTime startTime;
|
sl@0
|
476 |
TTime endTime;
|
sl@0
|
477 |
startTime.HomeTime();
|
sl@0
|
478 |
DoPresettings(nextTestCase);
|
sl@0
|
479 |
DoCmdExecution(nextTestCase);
|
sl@0
|
480 |
if (!DoResultsVerification(nextTestCase))
|
sl@0
|
481 |
{
|
sl@0
|
482 |
DoLogTestCaseFailure(nextTestCase);
|
sl@0
|
483 |
}
|
sl@0
|
484 |
else
|
sl@0
|
485 |
{
|
sl@0
|
486 |
test.Printf(_L("Test ID %d passed \n"),nextTestCase.iTestCaseID);
|
sl@0
|
487 |
}
|
sl@0
|
488 |
endTime.HomeTime();
|
sl@0
|
489 |
TTimeIntervalMicroSeconds timeTaken(0);
|
sl@0
|
490 |
timeTaken = endTime.MicroSecondsFrom(startTime);
|
sl@0
|
491 |
|
sl@0
|
492 |
TInt time2=0;
|
sl@0
|
493 |
time2=I64LOW(timeTaken.Int64()/1000);
|
sl@0
|
494 |
test.Printf(_L("Time Taken by test id %d = %d mS \n"),nextTestCase.iTestCaseID,time2);
|
sl@0
|
495 |
++i;
|
sl@0
|
496 |
}
|
sl@0
|
497 |
}
|
sl@0
|
498 |
|
sl@0
|
499 |
// Future work: provide command arguement parsing faclity so that users
|
sl@0
|
500 |
// can choose specific test case(s) in ranges
|
sl@0
|
501 |
// can choose specific API(s), switches, configurations, etc. for testing
|
sl@0
|
502 |
/*
|
sl@0
|
503 |
* Main testing control unit
|
sl@0
|
504 |
*/
|
sl@0
|
505 |
void TestMain()
|
sl@0
|
506 |
{
|
sl@0
|
507 |
//The __PERFTEST__ macro is for future use when a tests are setup to run on a performance machine
|
sl@0
|
508 |
//which will be enabled to run for both WINSCW and ARMV5
|
sl@0
|
509 |
#ifndef __PERFTEST__
|
sl@0
|
510 |
//Tests are enabled to run for WINSCW only on the below specified drives due to the time constraint.
|
sl@0
|
511 |
if((gDriveToTest == 'C') || (gDriveToTest == 'X') || (gDriveToTest == 'Y'))
|
sl@0
|
512 |
{
|
sl@0
|
513 |
DoAllBasicUnitaryTests(gBasicUnitaryTestCases);
|
sl@0
|
514 |
DoAllBasicBinaryTests(gBasicBinaryTestCases);
|
sl@0
|
515 |
}
|
sl@0
|
516 |
else
|
sl@0
|
517 |
{
|
sl@0
|
518 |
test.Printf(_L("Drive %C: is not supported for this configuration, see test logs for supported configuration details"),gDriveToTest);
|
sl@0
|
519 |
}
|
sl@0
|
520 |
#endif
|
sl@0
|
521 |
|
sl@0
|
522 |
#ifdef __PERFTEST__
|
sl@0
|
523 |
DoAllBasicUnitaryTests(gBasicUnitaryTestCases);
|
sl@0
|
524 |
DoAllBasicBinaryTests(gBasicBinaryTestCases);
|
sl@0
|
525 |
#endif
|
sl@0
|
526 |
}
|
sl@0
|
527 |
|
sl@0
|
528 |
|
sl@0
|
529 |
/*
|
sl@0
|
530 |
* Initialise test, do all tests in both sync and async mode.
|
sl@0
|
531 |
*/
|
sl@0
|
532 |
void CallTestsL()
|
sl@0
|
533 |
{
|
sl@0
|
534 |
InitialiseL();
|
sl@0
|
535 |
|
sl@0
|
536 |
CreateTestDirectory(_L("\\F32-TST\\T_CFILEMAN\\"));
|
sl@0
|
537 |
|
sl@0
|
538 |
gAsynch=EFalse;
|
sl@0
|
539 |
test.Next(_L("Synchronous tests ..."));
|
sl@0
|
540 |
TestMain();
|
sl@0
|
541 |
|
sl@0
|
542 |
DeleteTestDirectory();
|
sl@0
|
543 |
|
sl@0
|
544 |
CreateTestDirectory(_L("\\F32-TST\\T_CFILEMAN\\"));
|
sl@0
|
545 |
gAsynch=ETrue;
|
sl@0
|
546 |
test.Next(_L("Asynchronous tests ..."));
|
sl@0
|
547 |
TestMain();
|
sl@0
|
548 |
|
sl@0
|
549 |
DoPrintTestResults();
|
sl@0
|
550 |
Cleanup();
|
sl@0
|
551 |
DeleteTestDirectory();
|
sl@0
|
552 |
}
|