sl@0
|
1 |
// Copyright (c) 1998-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\fsstress\t_remses.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#if !defined(__T_REMFSY_H__)
|
sl@0
|
19 |
#include "t_remfsy.h"
|
sl@0
|
20 |
#endif
|
sl@0
|
21 |
|
sl@0
|
22 |
GLDEF_D TFileName tPath;
|
sl@0
|
23 |
|
sl@0
|
24 |
LOCAL_C void printDriveAtt(TInt aDrive,TUint anAtt,RTest& aTest);
|
sl@0
|
25 |
LOCAL_C void printDriveInfo(TInt aDrive,TDriveInfo& anInfo, RTest& aTest);
|
sl@0
|
26 |
LOCAL_C void DriveInformation(TInt aDrive,TDriveInfo& anInfo,RTest& aTest);
|
sl@0
|
27 |
|
sl@0
|
28 |
|
sl@0
|
29 |
void TMultipleSessionTest::Initialise(RFs& aFs)
|
sl@0
|
30 |
//
|
sl@0
|
31 |
// Initialise iFs
|
sl@0
|
32 |
//
|
sl@0
|
33 |
{
|
sl@0
|
34 |
iFs=aFs;
|
sl@0
|
35 |
}
|
sl@0
|
36 |
|
sl@0
|
37 |
|
sl@0
|
38 |
void TMultipleSessionTest::SetSessionPath(TInt aDrive)
|
sl@0
|
39 |
//
|
sl@0
|
40 |
// Set the session path for a RFs connection to aDrive
|
sl@0
|
41 |
//
|
sl@0
|
42 |
{
|
sl@0
|
43 |
iSessionPath=(_L("?:\\MULTIPLE_SESSION_TEST\\"));
|
sl@0
|
44 |
TChar driveLetter;
|
sl@0
|
45 |
TInt r=iFs.DriveToChar(aDrive,driveLetter);
|
sl@0
|
46 |
test(r==KErrNone);
|
sl@0
|
47 |
|
sl@0
|
48 |
iSessionPath[0]=(TText)driveLetter;
|
sl@0
|
49 |
r=iFs.SetSessionPath(iSessionPath);
|
sl@0
|
50 |
test(r==KErrNone);
|
sl@0
|
51 |
r=iFs.MkDirAll(iSessionPath);
|
sl@0
|
52 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
|
sl@0
|
56 |
void TMultipleSessionTest::RunTests(RTest& aTest)
|
sl@0
|
57 |
//
|
sl@0
|
58 |
// Run tests on iFs file server session
|
sl@0
|
59 |
//
|
sl@0
|
60 |
|
sl@0
|
61 |
{
|
sl@0
|
62 |
|
sl@0
|
63 |
testDriveList(aTest);
|
sl@0
|
64 |
testDriveInfo(aTest);
|
sl@0
|
65 |
testVolumeInfo(aTest);
|
sl@0
|
66 |
// testPowerDown(aTest);
|
sl@0
|
67 |
testSetVolume(aTest);
|
sl@0
|
68 |
testInitialisation(aTest);
|
sl@0
|
69 |
// testMediaChange(aTest);
|
sl@0
|
70 |
testSubst(aTest);
|
sl@0
|
71 |
MakeAndDeleteFiles(aTest);
|
sl@0
|
72 |
}
|
sl@0
|
73 |
|
sl@0
|
74 |
|
sl@0
|
75 |
|
sl@0
|
76 |
void TMultipleSessionTest::testDriveList(RTest& aTest)
|
sl@0
|
77 |
//
|
sl@0
|
78 |
// Test the drive list.
|
sl@0
|
79 |
//
|
sl@0
|
80 |
{
|
sl@0
|
81 |
|
sl@0
|
82 |
aTest.Next(_L("The drive list"));
|
sl@0
|
83 |
TInt r=iFs.SetSessionPath(iSessionPath);
|
sl@0
|
84 |
TDriveList list;
|
sl@0
|
85 |
r=iFs.DriveList(list);
|
sl@0
|
86 |
aTest(r==KErrNone);
|
sl@0
|
87 |
|
sl@0
|
88 |
for (TInt i=0;i<KMaxDrives;i++)
|
sl@0
|
89 |
{
|
sl@0
|
90 |
TInt att=list[i];
|
sl@0
|
91 |
if (att)
|
sl@0
|
92 |
printDriveAtt(i,att,aTest);
|
sl@0
|
93 |
}
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
void TMultipleSessionTest::testDriveInfo(RTest& aTest)
|
sl@0
|
97 |
//
|
sl@0
|
98 |
// Test the drive info.
|
sl@0
|
99 |
//
|
sl@0
|
100 |
{
|
sl@0
|
101 |
|
sl@0
|
102 |
aTest.Next(_L("The drive info"));
|
sl@0
|
103 |
TInt r=iFs.SetSessionPath(iSessionPath);
|
sl@0
|
104 |
TDriveList list;
|
sl@0
|
105 |
r=iFs.DriveList(list);
|
sl@0
|
106 |
aTest(r==KErrNone);
|
sl@0
|
107 |
for (TInt i=0;i<KMaxDrives;i++)
|
sl@0
|
108 |
{
|
sl@0
|
109 |
TInt att=list[i];
|
sl@0
|
110 |
if (att)
|
sl@0
|
111 |
{
|
sl@0
|
112 |
TDriveInfo d;
|
sl@0
|
113 |
r=iFs.Drive(d,i);
|
sl@0
|
114 |
//aTest(r==KErrNone);
|
sl@0
|
115 |
printDriveInfo(i,d,aTest);
|
sl@0
|
116 |
aTest.Printf(_L("\n"));
|
sl@0
|
117 |
if (r==KErrNone)
|
sl@0
|
118 |
DriveInformation(i,d, aTest);
|
sl@0
|
119 |
}
|
sl@0
|
120 |
}
|
sl@0
|
121 |
}
|
sl@0
|
122 |
/*
|
sl@0
|
123 |
void TMultipleSessionTest::testPowerDown(RTest& aTest)
|
sl@0
|
124 |
//
|
sl@0
|
125 |
// Test the effect of multiple power downs
|
sl@0
|
126 |
//
|
sl@0
|
127 |
{
|
sl@0
|
128 |
aTest.Next(_L("Power Down"));
|
sl@0
|
129 |
|
sl@0
|
130 |
RTimer timer;
|
sl@0
|
131 |
test(timer.CreateLocal()==KErrNone);
|
sl@0
|
132 |
TTime time;
|
sl@0
|
133 |
TRequestStatus status;
|
sl@0
|
134 |
|
sl@0
|
135 |
for (TInt index=0; index<5; index++)
|
sl@0
|
136 |
{
|
sl@0
|
137 |
aTest.Printf(_L("********** %d **********\n"),(5-index));
|
sl@0
|
138 |
time.HomeTime();
|
sl@0
|
139 |
time+=TTimeIntervalSeconds(8);
|
sl@0
|
140 |
timer.At(status,time);
|
sl@0
|
141 |
UserHal::SwitchOff(); // Switch off
|
sl@0
|
142 |
User::WaitForRequest(status); // Switch back on
|
sl@0
|
143 |
aTest(status==KErrNone);
|
sl@0
|
144 |
}
|
sl@0
|
145 |
}
|
sl@0
|
146 |
|
sl@0
|
147 |
*/
|
sl@0
|
148 |
/*
|
sl@0
|
149 |
void TMultipleSessionTest::testMediaChange(RTest& aTest)
|
sl@0
|
150 |
//
|
sl@0
|
151 |
// Test the effect of multiple media changes
|
sl@0
|
152 |
//
|
sl@0
|
153 |
{
|
sl@0
|
154 |
aTest.Next(_L("Media Change"));
|
sl@0
|
155 |
TInt drive=CurrentDrive(aTest);
|
sl@0
|
156 |
|
sl@0
|
157 |
if (drive>KMaxLocalDrives)
|
sl@0
|
158 |
return;
|
sl@0
|
159 |
|
sl@0
|
160 |
#if defined (__MARM__)
|
sl@0
|
161 |
if (drive==EDriveC)
|
sl@0
|
162 |
return;
|
sl@0
|
163 |
#endif
|
sl@0
|
164 |
|
sl@0
|
165 |
TLocalDrive theDrive;
|
sl@0
|
166 |
TLocalDriveCaps info;
|
sl@0
|
167 |
TBool changedFlag;
|
sl@0
|
168 |
for (TInt index=0; index<5; index++)
|
sl@0
|
169 |
{
|
sl@0
|
170 |
aTest.Printf(_L("********** %d **********\n"),(5-index));
|
sl@0
|
171 |
changedFlag=EFalse;
|
sl@0
|
172 |
TInt r=theDrive.Connect(drive,changedFlag);
|
sl@0
|
173 |
aTest(r==KErrNone);
|
sl@0
|
174 |
UserSvr::ForceRemountMedia(ERemovableMedia0); // Generate media change
|
sl@0
|
175 |
aTest(changedFlag);
|
sl@0
|
176 |
|
sl@0
|
177 |
do
|
sl@0
|
178 |
{
|
sl@0
|
179 |
r=theDrive.Caps(info);
|
sl@0
|
180 |
} while (r==KErrNotReady);
|
sl@0
|
181 |
// Wait a second...
|
sl@0
|
182 |
// User::After(1000000);
|
sl@0
|
183 |
}
|
sl@0
|
184 |
}
|
sl@0
|
185 |
*/
|
sl@0
|
186 |
|
sl@0
|
187 |
void TMultipleSessionTest::testVolumeInfo(RTest& aTest)
|
sl@0
|
188 |
//
|
sl@0
|
189 |
// Test volume info.
|
sl@0
|
190 |
//
|
sl@0
|
191 |
{
|
sl@0
|
192 |
|
sl@0
|
193 |
aTest.Next(_L("The volume info"));
|
sl@0
|
194 |
TInt r=iFs.SetSessionPath(iSessionPath);
|
sl@0
|
195 |
TDriveList list;
|
sl@0
|
196 |
r=iFs.DriveList(list);
|
sl@0
|
197 |
aTest(r==KErrNone);
|
sl@0
|
198 |
for (TInt i=0;i<KMaxDrives;i++)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
TVolumeInfo v;
|
sl@0
|
201 |
if ((r=iFs.Volume(v,i))==KErrNone)
|
sl@0
|
202 |
{
|
sl@0
|
203 |
printDriveInfo(i,v.iDrive,aTest);
|
sl@0
|
204 |
aTest.Printf(_L(" VOL=\"%S\" ID=%08x\n"),&v.iName,v.iUniqueID);
|
sl@0
|
205 |
aTest.Printf(_L(" SIZE=%ldK FREE=%ldK\n"),v.iSize/1024,v.iFree/1024);
|
sl@0
|
206 |
}
|
sl@0
|
207 |
else if (r==KErrNotReady)
|
sl@0
|
208 |
aTest.Printf(_L("%c: Not Ready\n"),i+'A');
|
sl@0
|
209 |
else if (r==KErrPathNotFound)
|
sl@0
|
210 |
aTest.Printf(_L("%c: Not Found\n"),i+'A');
|
sl@0
|
211 |
else
|
sl@0
|
212 |
{
|
sl@0
|
213 |
aTest.Printf(_L("%c: Error %d\n"),i+'A',r);
|
sl@0
|
214 |
aTest.Getch();
|
sl@0
|
215 |
}
|
sl@0
|
216 |
aTest.Printf(_L("\n"));
|
sl@0
|
217 |
}
|
sl@0
|
218 |
}
|
sl@0
|
219 |
|
sl@0
|
220 |
|
sl@0
|
221 |
void TMultipleSessionTest::testInitialisation(RTest& aTest)
|
sl@0
|
222 |
//
|
sl@0
|
223 |
// Modified from T_SESSION. Still tests that calls to CheckedClose() are
|
sl@0
|
224 |
// OK, ie, tests bug fix, but doesn't check returned error values since remote drive
|
sl@0
|
225 |
// doesn't necessarily return them.
|
sl@0
|
226 |
//
|
sl@0
|
227 |
{
|
sl@0
|
228 |
RFile file;
|
sl@0
|
229 |
RDir dir;
|
sl@0
|
230 |
|
sl@0
|
231 |
aTest.Next(_L("Test calls to CheckedClose are OK"));
|
sl@0
|
232 |
|
sl@0
|
233 |
TInt r=iFs.SetSessionPath(iSessionPath);
|
sl@0
|
234 |
TInt count;
|
sl@0
|
235 |
RFormat format;
|
sl@0
|
236 |
r=format.Open(iFs,_L("Z:\\"),EFullFormat,count);
|
sl@0
|
237 |
|
sl@0
|
238 |
aTest((r==KErrAccessDenied)||(r==KErrInUse));
|
sl@0
|
239 |
|
sl@0
|
240 |
r=dir.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\ERRORTEST\\"),KEntryAttMatchMask);
|
sl@0
|
241 |
// aTest(r==KErrPathNotFound);
|
sl@0
|
242 |
if (r==KErrNone)
|
sl@0
|
243 |
dir.Close();
|
sl@0
|
244 |
|
sl@0
|
245 |
r=file.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\SessionTest1.txt"),EFileRead);
|
sl@0
|
246 |
// aTest(r==KErrNotFound);
|
sl@0
|
247 |
if (r==KErrNone)
|
sl@0
|
248 |
file.Close();
|
sl@0
|
249 |
|
sl@0
|
250 |
r=dir.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\ERRORTEST2\\"),KEntryAttMatchMask);
|
sl@0
|
251 |
// aTest(r==KErrPathNotFound);
|
sl@0
|
252 |
if (r==KErrNone)
|
sl@0
|
253 |
dir.Close();
|
sl@0
|
254 |
|
sl@0
|
255 |
r=file.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\SessionTest2.txt"),EFileRead);
|
sl@0
|
256 |
// aTest(r==KErrNotFound);
|
sl@0
|
257 |
if (r==KErrNone)
|
sl@0
|
258 |
file.Close();
|
sl@0
|
259 |
|
sl@0
|
260 |
r=dir.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\ERRORTEST3\\"),KEntryAttMatchMask);
|
sl@0
|
261 |
// aTest(r==KErrPathNotFound);
|
sl@0
|
262 |
if (r==KErrNone)
|
sl@0
|
263 |
dir.Close();
|
sl@0
|
264 |
|
sl@0
|
265 |
r=file.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\SessionTest3.txt"),EFileRead);
|
sl@0
|
266 |
// aTest(r==KErrNotFound);
|
sl@0
|
267 |
if (r==KErrNone)
|
sl@0
|
268 |
file.Close();
|
sl@0
|
269 |
|
sl@0
|
270 |
r=file.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\SessionTest4.txt"),EFileRead);
|
sl@0
|
271 |
// aTest(r==KErrNotFound);
|
sl@0
|
272 |
if (r==KErrNone)
|
sl@0
|
273 |
file.Close();
|
sl@0
|
274 |
}
|
sl@0
|
275 |
|
sl@0
|
276 |
|
sl@0
|
277 |
void TMultipleSessionTest::testSubst(RTest& aTest)
|
sl@0
|
278 |
//
|
sl@0
|
279 |
// Test the substitute functions
|
sl@0
|
280 |
//
|
sl@0
|
281 |
{
|
sl@0
|
282 |
|
sl@0
|
283 |
aTest.Next(_L("Test subst"));
|
sl@0
|
284 |
TInt r=iFs.SetSessionPath(iSessionPath);
|
sl@0
|
285 |
TVolumeInfo v;
|
sl@0
|
286 |
r=iFs.Volume(v);
|
sl@0
|
287 |
aTest(r==KErrNone);
|
sl@0
|
288 |
|
sl@0
|
289 |
TDriveInfo driveInfo;
|
sl@0
|
290 |
r=iFs.Drive(driveInfo,EDriveO);
|
sl@0
|
291 |
aTest(r==KErrNone);
|
sl@0
|
292 |
|
sl@0
|
293 |
testSetVolume(aTest);
|
sl@0
|
294 |
|
sl@0
|
295 |
if (driveInfo.iDriveAtt==KDriveAttLocal)
|
sl@0
|
296 |
return; // Subst local drives fails
|
sl@0
|
297 |
|
sl@0
|
298 |
TFileName n;
|
sl@0
|
299 |
r=iFs.Subst(n,EDriveO);
|
sl@0
|
300 |
aTest(r==KErrNone);
|
sl@0
|
301 |
aTest(n.Length()==0);
|
sl@0
|
302 |
r=iFs.SetSubst(iSessionPath,EDriveO);
|
sl@0
|
303 |
aTest(r==KErrNone);
|
sl@0
|
304 |
r=iFs.Subst(n,EDriveO);
|
sl@0
|
305 |
aTest(r==KErrNone);
|
sl@0
|
306 |
aTest(n==iSessionPath);
|
sl@0
|
307 |
TVolumeInfo w;
|
sl@0
|
308 |
r=iFs.Volume(w,EDriveO);
|
sl@0
|
309 |
aTest(r==KErrNone);
|
sl@0
|
310 |
aTest(w.iDrive.iType==v.iDrive.iType);
|
sl@0
|
311 |
aTest(w.iDrive.iConnectionBusType==v.iDrive.iConnectionBusType);
|
sl@0
|
312 |
aTest(w.iDrive.iDriveAtt==v.iDrive.iDriveAtt);
|
sl@0
|
313 |
aTest(w.iDrive.iMediaAtt==v.iDrive.iMediaAtt);
|
sl@0
|
314 |
aTest(w.iUniqueID==v.iUniqueID);
|
sl@0
|
315 |
aTest(w.iSize==v.iSize);
|
sl@0
|
316 |
aTest(w.iFree==v.iFree);
|
sl@0
|
317 |
aTest(w.iName==v.iName);
|
sl@0
|
318 |
TDriveInfo d;
|
sl@0
|
319 |
r=iFs.Drive(d,EDriveO);
|
sl@0
|
320 |
aTest(r==KErrNone);
|
sl@0
|
321 |
aTest(d.iDriveAtt==KDriveAttSubsted);
|
sl@0
|
322 |
|
sl@0
|
323 |
aTest.Next(_L("Test real name"));
|
sl@0
|
324 |
r=iFs.RealName(_L("O:\\FILE.XXX"),n);
|
sl@0
|
325 |
aTest(r==KErrNone);
|
sl@0
|
326 |
TFileName substedPath=iSessionPath;
|
sl@0
|
327 |
substedPath.Append(_L("FILE.XXX"));
|
sl@0
|
328 |
aTest(n==substedPath);
|
sl@0
|
329 |
|
sl@0
|
330 |
aTest.Next(_L("Test MkDir, Rename and RmDir on Substed drive"));
|
sl@0
|
331 |
r=iFs.MkDir(_L("C:\\MULTIPLE_SESSION_TEST\\TFSRV\\turgid\\"));
|
sl@0
|
332 |
aTest(r==KErrNone);
|
sl@0
|
333 |
r=iFs.Rename(_L("O:\\turgid"), _L("O:\\facile"));
|
sl@0
|
334 |
aTest(r==KErrNone);
|
sl@0
|
335 |
r=iFs.MkDir(_L("O:\\insipid\\"));
|
sl@0
|
336 |
aTest(r==KErrNone);
|
sl@0
|
337 |
r=iFs.Rename(_L("O:\\insipid"), _L("O:\\glib"));
|
sl@0
|
338 |
aTest(r==KErrNone);
|
sl@0
|
339 |
r=iFs.RmDir(_L("O:\\facile\\"));
|
sl@0
|
340 |
aTest(r==KErrNone);
|
sl@0
|
341 |
r=iFs.RmDir(_L("C:\\MULTIPLE_SESSION_TEST\\TFSRV\\glib\\"));
|
sl@0
|
342 |
aTest(r==KErrNone);
|
sl@0
|
343 |
|
sl@0
|
344 |
r=iFs.SetSubst(_L(""),EDriveO);
|
sl@0
|
345 |
aTest(r==KErrNone);
|
sl@0
|
346 |
r=iFs.Subst(n,EDriveO);
|
sl@0
|
347 |
aTest(r==KErrNone);
|
sl@0
|
348 |
aTest(n==_L(""));
|
sl@0
|
349 |
r=iFs.Drive(d,EDriveO);
|
sl@0
|
350 |
aTest(r==KErrNone);
|
sl@0
|
351 |
aTest(d.iDriveAtt==0);
|
sl@0
|
352 |
|
sl@0
|
353 |
}
|
sl@0
|
354 |
|
sl@0
|
355 |
|
sl@0
|
356 |
LOCAL_C TInt CreateFileX(const TDesC& aBaseName,TInt aX, RFs iFs, RTest& aTest)
|
sl@0
|
357 |
//
|
sl@0
|
358 |
// Create a large file. Return KErrEof or KErrNone
|
sl@0
|
359 |
//
|
sl@0
|
360 |
{
|
sl@0
|
361 |
|
sl@0
|
362 |
TBuf<128> fileName=aBaseName;
|
sl@0
|
363 |
fileName.AppendNum(aX);
|
sl@0
|
364 |
|
sl@0
|
365 |
RFile file;
|
sl@0
|
366 |
TInt r=file.Replace(iFs,fileName,EFileWrite);
|
sl@0
|
367 |
if (r==KErrDiskFull)
|
sl@0
|
368 |
return(r);
|
sl@0
|
369 |
if (r!=KErrNone)
|
sl@0
|
370 |
{
|
sl@0
|
371 |
aTest.Printf(_L("ERROR:: Replace returned %d\n"),r);
|
sl@0
|
372 |
aTest.Getch();
|
sl@0
|
373 |
return(KErrDiskFull);
|
sl@0
|
374 |
}
|
sl@0
|
375 |
r=file.SetSize(65536);
|
sl@0
|
376 |
if (r==KErrDiskFull)
|
sl@0
|
377 |
{
|
sl@0
|
378 |
file.Close();
|
sl@0
|
379 |
return(r);
|
sl@0
|
380 |
}
|
sl@0
|
381 |
if (r!=KErrNone)
|
sl@0
|
382 |
{
|
sl@0
|
383 |
aTest.Printf(_L("ERROR:: SetSize returned %d\n"),r);
|
sl@0
|
384 |
aTest.Getch();
|
sl@0
|
385 |
file.Close();
|
sl@0
|
386 |
return(KErrDiskFull);
|
sl@0
|
387 |
}
|
sl@0
|
388 |
file.Close();
|
sl@0
|
389 |
aTest.Printf(_L("Created file %d size 64k\n"),aX);
|
sl@0
|
390 |
return(KErrNone);
|
sl@0
|
391 |
}
|
sl@0
|
392 |
|
sl@0
|
393 |
LOCAL_C TInt DeleteFileX(TBuf<128>& aBaseName,TInt aX, RFs iFs, TInt aDrive,RTest& aTest)
|
sl@0
|
394 |
//
|
sl@0
|
395 |
// Delete a file.
|
sl@0
|
396 |
//
|
sl@0
|
397 |
{
|
sl@0
|
398 |
|
sl@0
|
399 |
TBuf<128> fileName=aBaseName;
|
sl@0
|
400 |
fileName.AppendNum(aX);
|
sl@0
|
401 |
|
sl@0
|
402 |
TInt r=iFs.Delete(fileName);
|
sl@0
|
403 |
if (aDrive!=EDriveQ) // T_REMFSY may return incorrect value on WINS
|
sl@0
|
404 |
aTest(r==KErrNone);
|
sl@0
|
405 |
aTest.Printf(_L("Deleted File %d\n"),aX);
|
sl@0
|
406 |
return(KErrNone);
|
sl@0
|
407 |
}
|
sl@0
|
408 |
|
sl@0
|
409 |
void TMultipleSessionTest::MakeAndDeleteFiles(RTest& aTest)
|
sl@0
|
410 |
//
|
sl@0
|
411 |
// Create and delete large files in a randomish order
|
sl@0
|
412 |
//
|
sl@0
|
413 |
{
|
sl@0
|
414 |
|
sl@0
|
415 |
aTest.Next(_L("Create and delete large files"));
|
sl@0
|
416 |
TInt r=iFs.SetSessionPath(iSessionPath);
|
sl@0
|
417 |
r=iFs.MkDirAll(_L("\\MULTIPLE_SESSION_TEST\\SMALLDIRECTORY\\"));
|
sl@0
|
418 |
|
sl@0
|
419 |
if (CurrentDrive(aTest)!=EDriveQ) // T_REMFSY may return incorrect result on WINS
|
sl@0
|
420 |
aTest(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
421 |
|
sl@0
|
422 |
TBuf<128> fileName=_L("\\MULTIPLE_SESSION_TEST\\SMALLDIRECTORY\\FILE");
|
sl@0
|
423 |
r=CreateFileX(fileName,0,iFs,aTest);
|
sl@0
|
424 |
aTest(r==KErrNone);
|
sl@0
|
425 |
r=CreateFileX(fileName,1,iFs,aTest);
|
sl@0
|
426 |
aTest(r==KErrNone);
|
sl@0
|
427 |
r=DeleteFileX(fileName,0,iFs,CurrentDrive(aTest),aTest);
|
sl@0
|
428 |
aTest(r==KErrNone);
|
sl@0
|
429 |
r=CreateFileX(fileName,2,iFs,aTest);
|
sl@0
|
430 |
aTest(r==KErrNone);
|
sl@0
|
431 |
r=CreateFileX(fileName,1,iFs,aTest);
|
sl@0
|
432 |
aTest(r==KErrNone);
|
sl@0
|
433 |
r=CreateFileX(fileName,3,iFs,aTest);
|
sl@0
|
434 |
aTest(r==KErrNone);
|
sl@0
|
435 |
r=DeleteFileX(fileName,1,iFs,CurrentDrive(aTest),aTest);
|
sl@0
|
436 |
aTest(r==KErrNone);
|
sl@0
|
437 |
r=CreateFileX(fileName,4,iFs,aTest);
|
sl@0
|
438 |
aTest(r==KErrNone);
|
sl@0
|
439 |
r=DeleteFileX(fileName,2,iFs,CurrentDrive(aTest),aTest);
|
sl@0
|
440 |
aTest(r==KErrNone);
|
sl@0
|
441 |
r=DeleteFileX(fileName,3,iFs,CurrentDrive(aTest),aTest);
|
sl@0
|
442 |
aTest(r==KErrNone);
|
sl@0
|
443 |
r=DeleteFileX(fileName,4,iFs,CurrentDrive(aTest),aTest);
|
sl@0
|
444 |
aTest(r==KErrNone);
|
sl@0
|
445 |
r=CreateFileX(fileName,1,iFs,aTest);
|
sl@0
|
446 |
aTest(r==KErrNone);
|
sl@0
|
447 |
r=DeleteFileX(fileName,1,iFs,CurrentDrive(aTest),aTest);
|
sl@0
|
448 |
aTest(r==KErrNone);
|
sl@0
|
449 |
|
sl@0
|
450 |
r=iFs.CheckDisk(fileName);
|
sl@0
|
451 |
if (r!=KErrNone && r!=KErrNotSupported)
|
sl@0
|
452 |
aTest.Printf(_L("ERROR:: CheckDisk returned %d\n"),r);
|
sl@0
|
453 |
}
|
sl@0
|
454 |
|
sl@0
|
455 |
void TMultipleSessionTest::FillUpDisk(RTest& aTest)
|
sl@0
|
456 |
//
|
sl@0
|
457 |
// Test that a full disk is ok
|
sl@0
|
458 |
//
|
sl@0
|
459 |
{
|
sl@0
|
460 |
|
sl@0
|
461 |
aTest.Next(_L("Fill disk to capacity"));
|
sl@0
|
462 |
TInt r=iFs.SetSessionPath(iSessionPath);
|
sl@0
|
463 |
r=iFs.MkDirAll(_L("\\MULTIPLE_SESSION_TEST\\BIGDIRECTORY\\"));
|
sl@0
|
464 |
if (CurrentDrive(aTest)!=EDriveQ) // T_REMFSY may return incorrect result on WINS
|
sl@0
|
465 |
aTest(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
466 |
TInt count=0;
|
sl@0
|
467 |
TFileName sessionPath;
|
sl@0
|
468 |
r=iFs.SessionPath(sessionPath);
|
sl@0
|
469 |
test(sessionPath==iSessionPath);
|
sl@0
|
470 |
aTest(r==KErrNone);
|
sl@0
|
471 |
TBuf<128> fileName=_L("\\MULTIPLE_SESSION_TEST\\BIGDIRECTORY\\FILE");
|
sl@0
|
472 |
FOREVER
|
sl@0
|
473 |
{
|
sl@0
|
474 |
TInt r=CreateFileX(fileName,count,iFs, aTest);
|
sl@0
|
475 |
if (r==KErrDiskFull)
|
sl@0
|
476 |
break;
|
sl@0
|
477 |
aTest(r==KErrNone);
|
sl@0
|
478 |
count++;
|
sl@0
|
479 |
#if defined(__WINS__)
|
sl@0
|
480 |
if (count==32 && sessionPath[0]=='C') // Don't fill up disk on NT
|
sl@0
|
481 |
break;
|
sl@0
|
482 |
#endif
|
sl@0
|
483 |
}
|
sl@0
|
484 |
|
sl@0
|
485 |
r=iFs.CheckDisk(fileName);
|
sl@0
|
486 |
if (r!=KErrNone && r!=KErrNotSupported)
|
sl@0
|
487 |
{
|
sl@0
|
488 |
aTest.Printf(_L("ERROR:: CheckDisk returned %d\n"),r);
|
sl@0
|
489 |
aTest.Getch();
|
sl@0
|
490 |
}
|
sl@0
|
491 |
|
sl@0
|
492 |
while(count--)
|
sl@0
|
493 |
DeleteFileX(fileName,count,iFs,CurrentDrive(aTest),aTest);
|
sl@0
|
494 |
|
sl@0
|
495 |
r=iFs.CheckDisk(fileName);
|
sl@0
|
496 |
if (r!=KErrNone && r!=KErrNotSupported)
|
sl@0
|
497 |
{
|
sl@0
|
498 |
aTest.Printf(_L("ERROR:: CheckDisk returned %d\n"),r);
|
sl@0
|
499 |
aTest.Getch();
|
sl@0
|
500 |
}
|
sl@0
|
501 |
}
|
sl@0
|
502 |
|
sl@0
|
503 |
|
sl@0
|
504 |
void TMultipleSessionTest::testSetVolume(RTest& aTest)
|
sl@0
|
505 |
//
|
sl@0
|
506 |
// Test setting the volume info.
|
sl@0
|
507 |
//
|
sl@0
|
508 |
{
|
sl@0
|
509 |
|
sl@0
|
510 |
aTest.Next(_L("Test setting the volume label"));
|
sl@0
|
511 |
TInt r=iFs.SetSessionPath(iSessionPath);
|
sl@0
|
512 |
aTest(r==KErrNone);
|
sl@0
|
513 |
#if defined(_UNICODE)
|
sl@0
|
514 |
aTest.Printf(_L("Unicode volume label set not implemented ****\n"));
|
sl@0
|
515 |
return;
|
sl@0
|
516 |
#else
|
sl@0
|
517 |
TInt driveNum=CurrentDrive(aTest);
|
sl@0
|
518 |
TVolumeInfo v;
|
sl@0
|
519 |
r=iFs.Volume(v,driveNum);
|
sl@0
|
520 |
aTest(r==KErrNone);
|
sl@0
|
521 |
TFileName n=v.iName;
|
sl@0
|
522 |
aTest.Printf(_L("VOL=\"%S\"\n"),&n);
|
sl@0
|
523 |
|
sl@0
|
524 |
aTest.Next(_L("Set volume label to nothing"));
|
sl@0
|
525 |
r=iFs.SetVolumeLabel(_L(""),driveNum);
|
sl@0
|
526 |
if (r==KErrGeneral)
|
sl@0
|
527 |
return;
|
sl@0
|
528 |
aTest(r==KErrNone);
|
sl@0
|
529 |
r=iFs.Volume(v,driveNum);
|
sl@0
|
530 |
aTest(r==KErrNone);
|
sl@0
|
531 |
aTest(v.iName==_L(""));
|
sl@0
|
532 |
aTest.Printf(_L("VOL=\"%S\"\n"),&v.iName);
|
sl@0
|
533 |
|
sl@0
|
534 |
aTest.Next(_L("Set volume label to ABCDEFGHIJK"));
|
sl@0
|
535 |
r=iFs.SetVolumeLabel(_L("ABCDEFGHIJK"),driveNum);
|
sl@0
|
536 |
aTest(r==KErrNone);
|
sl@0
|
537 |
r=iFs.Volume(v,driveNum);
|
sl@0
|
538 |
aTest(r==KErrNone);
|
sl@0
|
539 |
aTest(v.iName==_L("ABCDEFGHIJK"));
|
sl@0
|
540 |
aTest.Printf(_L("VOL=\"%S\"\n"),&v.iName);
|
sl@0
|
541 |
|
sl@0
|
542 |
aTest.Next(_L("Set volume label back to nothing"));
|
sl@0
|
543 |
r=iFs.SetVolumeLabel(_L(""),driveNum);
|
sl@0
|
544 |
aTest(r==KErrNone);
|
sl@0
|
545 |
r=iFs.Volume(v,driveNum);
|
sl@0
|
546 |
aTest(r==KErrNone);
|
sl@0
|
547 |
aTest(v.iName==_L(""));
|
sl@0
|
548 |
aTest.Printf(_L("VOL=\"%S\"\n"),&v.iName);
|
sl@0
|
549 |
|
sl@0
|
550 |
aTest.Next(_L("Set volume label to original"));
|
sl@0
|
551 |
r=iFs.SetVolumeLabel(n,driveNum);
|
sl@0
|
552 |
aTest(r==KErrNone);
|
sl@0
|
553 |
r=iFs.Volume(v,driveNum);
|
sl@0
|
554 |
aTest(r==KErrNone);
|
sl@0
|
555 |
aTest(v.iName==n);
|
sl@0
|
556 |
aTest.Printf(_L("VOL=\"%S\"\n"),&v.iName);
|
sl@0
|
557 |
|
sl@0
|
558 |
#endif
|
sl@0
|
559 |
}
|
sl@0
|
560 |
|
sl@0
|
561 |
|
sl@0
|
562 |
LOCAL_C void printDriveAtt(TInt aDrive,TUint anAtt,RTest& aTest)
|
sl@0
|
563 |
//
|
sl@0
|
564 |
// Print a drive attribute.
|
sl@0
|
565 |
//
|
sl@0
|
566 |
{
|
sl@0
|
567 |
|
sl@0
|
568 |
aTest.Printf(_L("%c: "),aDrive+'A');
|
sl@0
|
569 |
if (anAtt&KDriveAttRemote)
|
sl@0
|
570 |
aTest.Printf(_L("REMOTE "));
|
sl@0
|
571 |
else if (anAtt&KDriveAttLocal)
|
sl@0
|
572 |
aTest.Printf(_L("LOCAL "));
|
sl@0
|
573 |
if (anAtt&KDriveAttRom)
|
sl@0
|
574 |
aTest.Printf(_L("ROM "));
|
sl@0
|
575 |
if (anAtt&KDriveAttRedirected)
|
sl@0
|
576 |
aTest.Printf(_L("REDIRECTED "));
|
sl@0
|
577 |
if (anAtt&KDriveAttSubsted)
|
sl@0
|
578 |
aTest.Printf(_L("SUBST "));
|
sl@0
|
579 |
if (anAtt&KDriveAttInternal)
|
sl@0
|
580 |
aTest.Printf(_L("INTERNAL "));
|
sl@0
|
581 |
if (anAtt&KDriveAttRemovable)
|
sl@0
|
582 |
aTest.Printf(_L("REMOVABLE "));
|
sl@0
|
583 |
aTest.Printf(_L("\n"));
|
sl@0
|
584 |
}
|
sl@0
|
585 |
|
sl@0
|
586 |
LOCAL_C void printDriveInfo(TInt aDrive,TDriveInfo& anInfo,RTest& aTest)
|
sl@0
|
587 |
//
|
sl@0
|
588 |
// Print a drive info.
|
sl@0
|
589 |
//
|
sl@0
|
590 |
{
|
sl@0
|
591 |
|
sl@0
|
592 |
printDriveAtt(aDrive,anInfo.iDriveAtt,aTest);
|
sl@0
|
593 |
aTest.Printf(_L(" MEDIA-ATT="));
|
sl@0
|
594 |
if (anInfo.iMediaAtt==0)
|
sl@0
|
595 |
aTest.Printf(_L("<none>"));
|
sl@0
|
596 |
if (anInfo.iMediaAtt&KMediaAttVariableSize)
|
sl@0
|
597 |
aTest.Printf(_L("VariableSize "));
|
sl@0
|
598 |
if (anInfo.iMediaAtt&KMediaAttDualDensity)
|
sl@0
|
599 |
aTest.Printf(_L("DualDensity "));
|
sl@0
|
600 |
if (anInfo.iMediaAtt&KMediaAttFormattable)
|
sl@0
|
601 |
aTest.Printf(_L("Formattable "));
|
sl@0
|
602 |
if (anInfo.iMediaAtt&KMediaAttWriteProtected)
|
sl@0
|
603 |
aTest.Printf(_L("WProtected "));
|
sl@0
|
604 |
aTest.Printf(_L("\n CONNECTION BUS TYPE="));
|
sl@0
|
605 |
switch(anInfo.iConnectionBusType)
|
sl@0
|
606 |
{
|
sl@0
|
607 |
case EConnectionBusInternal: aTest.Printf(_L("Internal\n")); break;
|
sl@0
|
608 |
case EConnectionBusUsb: aTest.Printf(_L("USB\n")); break;
|
sl@0
|
609 |
default:
|
sl@0
|
610 |
aTest.Printf(_L("Unknown value\n"));
|
sl@0
|
611 |
}
|
sl@0
|
612 |
aTest.Printf(_L(" MEDIA="));
|
sl@0
|
613 |
switch(anInfo.iType)
|
sl@0
|
614 |
{
|
sl@0
|
615 |
case EMediaNotPresent: aTest.Printf(_L("Not present\n")); break;
|
sl@0
|
616 |
case EMediaUnknown: aTest.Printf(_L("Unknown\n")); break;
|
sl@0
|
617 |
case EMediaFloppy: aTest.Printf(_L("Floppy\n")); break;
|
sl@0
|
618 |
case EMediaHardDisk: aTest.Printf(_L("Hard disk\n")); break;
|
sl@0
|
619 |
case EMediaCdRom: aTest.Printf(_L("CD Rom\n")); break;
|
sl@0
|
620 |
case EMediaRam: aTest.Printf(_L("Ram\n")); break;
|
sl@0
|
621 |
case EMediaFlash: aTest.Printf(_L("Flash\n")); break;
|
sl@0
|
622 |
case EMediaRom: aTest.Printf(_L("Rom\n")); break;
|
sl@0
|
623 |
case EMediaRemote: aTest.Printf(_L("Remote\n")); break;
|
sl@0
|
624 |
default:
|
sl@0
|
625 |
aTest.Printf(_L("Unknown value\n"));
|
sl@0
|
626 |
}
|
sl@0
|
627 |
}
|
sl@0
|
628 |
|
sl@0
|
629 |
LOCAL_C void DriveInformation(TInt aDrive,TDriveInfo& anInfo,RTest& aTest)
|
sl@0
|
630 |
//
|
sl@0
|
631 |
// Test the drive info is reasonable
|
sl@0
|
632 |
//
|
sl@0
|
633 |
{
|
sl@0
|
634 |
|
sl@0
|
635 |
aTest(anInfo.iConnectionBusType==EConnectionBusInternal || anInfo.iConnectionBusType==EConnectionBusUsb);
|
sl@0
|
636 |
|
sl@0
|
637 |
if (aDrive==EDriveZ)
|
sl@0
|
638 |
{
|
sl@0
|
639 |
if (anInfo.iType==EMediaNotPresent)
|
sl@0
|
640 |
return;
|
sl@0
|
641 |
|
sl@0
|
642 |
aTest(anInfo.iMediaAtt==KMediaAttWriteProtected);
|
sl@0
|
643 |
aTest(anInfo.iDriveAtt==(KDriveAttRom|KDriveAttInternal));
|
sl@0
|
644 |
aTest(anInfo.iType==EMediaRom);
|
sl@0
|
645 |
}
|
sl@0
|
646 |
|
sl@0
|
647 |
else if (aDrive==EDriveC || aDrive==EDriveY)
|
sl@0
|
648 |
{
|
sl@0
|
649 |
if (anInfo.iType==EMediaNotPresent)
|
sl@0
|
650 |
return;
|
sl@0
|
651 |
|
sl@0
|
652 |
aTest(anInfo.iDriveAtt==(KDriveAttLocal|KDriveAttInternal));
|
sl@0
|
653 |
aTest(anInfo.iType==EMediaHardDisk);
|
sl@0
|
654 |
aTest(anInfo.iMediaAtt==(KMediaAttVariableSize|KMediaAttFormattable));
|
sl@0
|
655 |
}
|
sl@0
|
656 |
else if (aDrive==EDriveD || aDrive==EDriveX)
|
sl@0
|
657 |
{
|
sl@0
|
658 |
if (anInfo.iType==EMediaNotPresent)
|
sl@0
|
659 |
return;
|
sl@0
|
660 |
|
sl@0
|
661 |
aTest(anInfo.iDriveAtt==(KDriveAttLocal|KDriveAttRemovable));
|
sl@0
|
662 |
aTest(anInfo.iType==EMediaHardDisk);
|
sl@0
|
663 |
aTest(anInfo.iMediaAtt==KMediaAttFormattable);
|
sl@0
|
664 |
}
|
sl@0
|
665 |
}
|
sl@0
|
666 |
|
sl@0
|
667 |
|
sl@0
|
668 |
|
sl@0
|
669 |
GLDEF_C void ReportCheckDiskFailure(TInt aRet,RTest& aTest)
|
sl@0
|
670 |
//
|
sl@0
|
671 |
// Report the failure of checkdisk
|
sl@0
|
672 |
//
|
sl@0
|
673 |
{
|
sl@0
|
674 |
|
sl@0
|
675 |
aTest.Printf(_L("CHECKDISK FAILED: "));
|
sl@0
|
676 |
switch(aRet)
|
sl@0
|
677 |
{
|
sl@0
|
678 |
case 1: aTest.Printf(_L("File cluster chain contains a bad value (<2 or >maxCluster)\n")); break;
|
sl@0
|
679 |
case 2: aTest.Printf(_L("Two files are linked to the same cluster\n")); break;
|
sl@0
|
680 |
case 3: aTest.Printf(_L("Unallocated cluster contains a value != 0\n")); break;
|
sl@0
|
681 |
case 4: aTest.Printf(_L("Size of file != number of clusters in chain\n")); break;
|
sl@0
|
682 |
default: aTest.Printf(_L("Undefined Error value %d\n"),aRet);
|
sl@0
|
683 |
}
|
sl@0
|
684 |
aTest.Printf(_L("Press any key to continue\n"));
|
sl@0
|
685 |
aTest.Getch();
|
sl@0
|
686 |
}
|
sl@0
|
687 |
|
sl@0
|
688 |
|
sl@0
|
689 |
|
sl@0
|
690 |
TInt TMultipleSessionTest::CurrentDrive(RTest& aTest)
|
sl@0
|
691 |
//
|
sl@0
|
692 |
// Return the current drive number
|
sl@0
|
693 |
//
|
sl@0
|
694 |
{
|
sl@0
|
695 |
TInt r=iFs.SetSessionPath(iSessionPath);
|
sl@0
|
696 |
aTest(r==KErrNone);
|
sl@0
|
697 |
TInt driveNum;
|
sl@0
|
698 |
r=iFs.CharToDrive(iSessionPath[0],driveNum);
|
sl@0
|
699 |
aTest(r==KErrNone);
|
sl@0
|
700 |
return(driveNum);
|
sl@0
|
701 |
}
|
sl@0
|
702 |
|
sl@0
|
703 |
|
sl@0
|
704 |
|
sl@0
|
705 |
|