author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 02 Sep 2010 21:54:16 +0300 | |
changeset 259 | 57b9594f5772 |
parent 109 | b3a1d9898418 |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1998-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 |
// f32test\server\t_hungfs.cpp |
|
15 |
// this test will either run with a secure mmc or will simulate a |
|
16 |
// mmc card. |
|
17 |
// |
|
18 |
// |
|
19 |
||
20 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
21 |
#define __E32TEST_EXTENSION__ |
0 | 22 |
#include <f32file.h> |
23 |
#include <e32test.h> |
|
24 |
#include "t_server.h" |
|
25 |
||
26 |
GLDEF_D RTest test(_L("T_HUNGFS")); |
|
27 |
GLREF_D RFs TheFs; |
|
28 |
||
29 |
LOCAL_D RFile SubFile1; |
|
30 |
LOCAL_D TInt HungReturnCodeC; |
|
31 |
||
32 |
LOCAL_D RSemaphore HungSemaphoreC; |
|
33 |
LOCAL_D TInt HungReturnCodeNC; |
|
34 |
LOCAL_D RSemaphore HungSemaphoreNC; |
|
35 |
||
36 |
GLREF_C void Format(TInt aDrive); |
|
37 |
||
38 |
LOCAL_D const TInt KControlIoLockMount=5; |
|
39 |
LOCAL_D const TInt KControlIoClearLockMount=6; |
|
40 |
LOCAL_D const TInt KControlIoCNotifier=7; |
|
41 |
LOCAL_D const TInt KControlIoClearCNotifier=8; |
|
42 |
||
43 |
LOCAL_D const TInt KControlIoCancelNCNotifier=KMaxTInt-1; |
|
44 |
||
45 |
LOCAL_D TBool isSecureMmc; |
|
46 |
LOCAL_D TFileName gLockedPath; |
|
47 |
LOCAL_D TFileName gLockedBase; |
|
48 |
LOCAL_D TInt gLockedDrive; |
|
49 |
GLREF_D TFileName gSessionPath; |
|
50 |
LOCAL_D TInt gSessionDrive; |
|
51 |
||
52 |
TBuf8<16> KPassword8=_L8("abc"); |
|
53 |
TBuf16<8> KPassword=_L("abc"); |
|
54 |
_LIT(File1,"file1"); |
|
55 |
_LIT(File2,"file2"); |
|
56 |
_LIT(Dir1,"\\dir1\\"); |
|
57 |
_LIT(NotifyDir,"\\not\\"); |
|
58 |
_LIT(NotifyDir2,"\\abc\\"); |
|
59 |
_LIT(HungDirNC,"\\hungnc\\"); |
|
60 |
_LIT(HungDirC,"\\hungc\\"); |
|
61 |
||
62 |
LOCAL_D const TInt KHeapSize=0x2000; |
|
63 |
||
64 |
struct SNonCriticalInfo |
|
65 |
{ |
|
66 |
TBool iSameSession; |
|
67 |
TBool iUseRFile; |
|
68 |
}; |
|
69 |
||
70 |
LOCAL_C TInt ThreadFunctionNC(TAny* aInfo) |
|
71 |
// |
|
72 |
// Thread entry point to put up non-critical notifier |
|
73 |
// |
|
74 |
{ |
|
75 |
RFs fs; |
|
76 |
TInt r; |
|
77 |
||
78 |
TBuf8<8> mmcBuf; |
|
79 |
// pad out password if using lockable mmc |
|
80 |
if(isSecureMmc) |
|
81 |
{ |
|
82 |
TUint8 pBuf[]={0x61,0x00,0x62,0x00,0x63,00}; |
|
83 |
mmcBuf.SetLength(6); |
|
84 |
for(TInt i=0;i<6;++i) |
|
85 |
mmcBuf[i]=pBuf[i]; |
|
86 |
} |
|
87 |
||
88 |
SNonCriticalInfo* info=NULL; |
|
89 |
if(aInfo!=NULL) |
|
90 |
info=(SNonCriticalInfo*)aInfo; |
|
91 |
||
92 |
r=fs.Connect(); |
|
93 |
||
94 |
if(isSecureMmc) |
|
95 |
{ |
|
96 |
if(info && info->iSameSession) |
|
97 |
r=TheFs.LockDrive(gLockedDrive,NULL,mmcBuf,EFalse); |
|
98 |
else |
|
99 |
{ |
|
100 |
r=fs.LockDrive(gLockedDrive,NULL,mmcBuf,EFalse); |
|
101 |
RDebug::Print(_L("l=%d"),r); |
|
102 |
} |
|
103 |
} |
|
104 |
else |
|
105 |
{ |
|
106 |
if(info && info->iSameSession) |
|
107 |
r=TheFs.ControlIo(gLockedDrive,KControlIoLockMount,KPassword8); |
|
108 |
else |
|
109 |
r=fs.ControlIo(gLockedDrive,KControlIoLockMount,KPassword8); |
|
110 |
} |
|
111 |
// UserSvr::ForceRemountMedia(ERemovableMedia0); |
|
112 |
User::After(300000); |
|
113 |
HungSemaphoreNC.Signal(); |
|
114 |
||
115 |
TFileName hungDir=gLockedBase; |
|
116 |
hungDir+=HungDirNC; |
|
117 |
if(info && info->iSameSession) |
|
118 |
r=TheFs.RmDir(hungDir); |
|
119 |
else if(info && info->iSameSession && info->iUseRFile) |
|
120 |
{ |
|
121 |
TBuf8<16> buf=_L8("abc"); |
|
122 |
r=SubFile1.Write(buf); |
|
123 |
} |
|
124 |
else |
|
125 |
{ |
|
126 |
r=fs.RmDir(hungDir); |
|
127 |
RDebug::Print(_L("rd=%d"),r); |
|
128 |
} |
|
129 |
HungReturnCodeNC=r; |
|
130 |
||
131 |
if(isSecureMmc) |
|
132 |
{ |
|
133 |
r=fs.UnlockDrive(gLockedDrive,mmcBuf,EFalse); |
|
134 |
r=fs.ClearPassword(gLockedDrive,mmcBuf); |
|
135 |
} |
|
136 |
else |
|
137 |
r=fs.ControlIo(gLockedDrive,KControlIoClearLockMount,KPassword8); |
|
138 |
||
139 |
HungSemaphoreNC.Signal(); |
|
140 |
||
141 |
fs.Close(); |
|
142 |
||
143 |
return(KErrNone); |
|
144 |
} |
|
145 |
||
146 |
LOCAL_C TInt ThreadFunctionC(TAny* aDrive) |
|
147 |
// |
|
148 |
// Thread entry point to put up a critical notifier |
|
149 |
// |
|
150 |
{ |
|
151 |
RFs fs; |
|
152 |
TInt r=fs.Connect(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
153 |
test_KErrNone(r); |
0 | 154 |
|
155 |
TInt drive; |
|
156 |
#if defined(__WINS__) |
|
157 |
drive=EDriveY; |
|
158 |
#else |
|
159 |
drive=EDriveC; |
|
160 |
#endif |
|
161 |
// can only get critcal notifer up using ControIo |
|
162 |
// assumes fat file system running on one of the drives named below |
|
163 |
r=fs.ControlIo(drive,KControlIoCNotifier); |
|
164 |
||
165 |
TBool isRemovable=*(TBool*)aDrive; |
|
166 |
TFileName hungDir=(_L("?:")); |
|
167 |
#if defined(__WINS__) |
|
168 |
if(isRemovable) |
|
169 |
hungDir[0]=(TText)('A'+EDriveX); |
|
170 |
else |
|
171 |
hungDir[0]=(TText)('A'+EDriveY); |
|
172 |
#else |
|
173 |
if(isRemovable) |
|
174 |
hungDir[0]=(TText)('A'+EDriveD); |
|
175 |
else |
|
176 |
hungDir[0]=(TText)('A'+EDriveC); |
|
177 |
#endif |
|
178 |
hungDir+=HungDirC; |
|
179 |
r=fs.RmDir(hungDir); |
|
180 |
r=fs.MkDir(hungDir); |
|
181 |
HungReturnCodeC=r; |
|
182 |
||
183 |
r=fs.ControlIo(drive,KControlIoClearCNotifier); |
|
184 |
||
185 |
HungSemaphoreC.Signal(); |
|
186 |
r=fs.RmDir(hungDir); |
|
187 |
fs.Close(); |
|
188 |
return(KErrNone); |
|
189 |
} |
|
190 |
||
191 |
LOCAL_C void PutNonCriticalNotifier(TAny* aInfo,RThread& aThread) |
|
192 |
// |
|
193 |
// put up a non-critical notifier on a removable media |
|
194 |
// |
|
195 |
{ |
|
196 |
TInt r=aThread.Create(_L("ThreadNC"),ThreadFunctionNC,KDefaultStackSize,KMinHeapSize,KMinHeapSize,aInfo); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
197 |
test_KErrNone(r); |
0 | 198 |
aThread.SetPriority(EPriorityMore); |
199 |
aThread.Resume(); |
|
200 |
HungSemaphoreNC.Wait(); |
|
201 |
User::After(1000000); |
|
202 |
||
203 |
} |
|
204 |
||
205 |
LOCAL_C void PutCriticalNotifier(TBool aBool,RThread& aThread) |
|
206 |
// |
|
207 |
// put up a critical notifier on the specified drive |
|
208 |
// |
|
209 |
{ |
|
210 |
TInt r=aThread.Create(_L("ThreadC"),ThreadFunctionC,KDefaultStackSize,KMinHeapSize,KMinHeapSize,&aBool); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
211 |
test_KErrNone(r); |
0 | 212 |
aThread.SetPriority(EPriorityMore); |
213 |
aThread.Resume(); |
|
214 |
User::After(1000000); |
|
215 |
} |
|
216 |
||
217 |
void TestNotifiers() |
|
218 |
// |
|
219 |
// Test non-critical notifier is cancelled when the critical notifier is put up |
|
220 |
// Needs to be carried out on platform with password notifier which handles requests |
|
221 |
// asynchronously and uses CAtaDisk in fat file system on c: drive ie. not internal ram |
|
222 |
// drive |
|
223 |
// |
|
224 |
{ |
|
225 |
test.Next(_L("TestNotifiers")); |
|
226 |
if(isSecureMmc) |
|
227 |
return; |
|
228 |
RThread threadNC,threadC; |
|
229 |
PutNonCriticalNotifier(NULL,threadNC); |
|
230 |
PutCriticalNotifier(EFalse,threadC); |
|
231 |
// get rid of critical notifier |
|
232 |
test.Printf(_L("Press cancel on for critcal notifier\n")); |
|
233 |
test.Printf(_L("Press any character\n")); |
|
234 |
test.Getch(); |
|
235 |
TRequestStatus deathStat; |
|
236 |
threadNC.Logon( deathStat ); |
|
237 |
HungSemaphoreC.Wait(); |
|
238 |
// test(HungReturnCodeNC==KErrAbort); |
|
239 |
TRequestStatus deathStat2; |
|
240 |
threadC.Logon(deathStat2); |
|
241 |
HungSemaphoreNC.Wait(); |
|
242 |
//test(HungReturnCodeNC==KErrLocked); |
|
243 |
User::WaitForRequest(deathStat2); |
|
244 |
threadNC.Close(); |
|
245 |
threadC.Close(); |
|
246 |
} |
|
247 |
||
248 |
void TestCriticalFunctions() |
|
249 |
// |
|
250 |
// test that only a subset of functions are supported when the critical notifier is up |
|
251 |
// |
|
252 |
{ |
|
253 |
test.Next(_L("test functions supported with critical notifier")); |
|
254 |
// used for EFsSubClose |
|
255 |
RFile file; |
|
256 |
TInt r=file.Create(TheFs,File1,EFileShareAny|EFileWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
257 |
test_Value(r, r == KErrNone || r == KErrAlreadyExists); |
0 | 258 |
if(r==KErrAlreadyExists) |
259 |
{ |
|
260 |
r=file.Open(TheFs,File1,EFileShareAny|EFileWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
261 |
test_KErrNone(r); |
0 | 262 |
} |
263 |
TBuf8<16> buf=_L8("abcdefghijklmnop"); |
|
264 |
r=file.Write(buf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
265 |
test_KErrNone(r); |
0 | 266 |
|
267 |
r=TheFs.MkDir(NotifyDir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
268 |
test_KErrNone(r); |
0 | 269 |
|
270 |
RThread thread; |
|
271 |
PutCriticalNotifier(ETrue,thread); |
|
272 |
||
273 |
// test functions that are supported with critical notifier |
|
274 |
// EFsNotifyChange |
|
275 |
test.Next(_L("test functions that are supported with critical notifier")); |
|
276 |
TRequestStatus status; |
|
277 |
TheFs.NotifyChange(ENotifyAll,status); |
|
278 |
test(status==KRequestPending); |
|
279 |
// EFsNotifyChangeCancel |
|
280 |
TheFs.NotifyChangeCancel(); |
|
281 |
test(status==KErrCancel); |
|
282 |
// EFsNotifyChangeEx |
|
283 |
TheFs.NotifyChange(ENotifyAll,status,gSessionPath); |
|
284 |
test(status==KRequestPending); |
|
285 |
// EFsNotifyChangeCancelEx |
|
286 |
TheFs.NotifyChangeCancel(status); |
|
287 |
test(status==KErrCancel); |
|
288 |
// EFsSubClose |
|
289 |
// difficult to test properly because this does not return an error value |
|
290 |
file.Close(); |
|
291 |
||
292 |
// test that notifications are not completed when a critical notifier completes |
|
293 |
test.Next(_L("test notifications not completed")); |
|
294 |
TheFs.NotifyChange(ENotifyDisk,status); |
|
295 |
test(status==KRequestPending); |
|
296 |
TRequestStatus status2; |
|
297 |
TheFs.NotifyChange(ENotifyDir,status2,NotifyDir); |
|
298 |
test(status2==KRequestPending); |
|
299 |
||
300 |
// test some functions that are not supported when critcical notifier up |
|
301 |
// EFsFileOpen |
|
302 |
test.Next(_L("test functions that are not supported with critical notifier")); |
|
303 |
r=file.Open(TheFs,File2,EFileShareAny); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
304 |
test_Value(r, r == KErrInUse); |
0 | 305 |
// EFsFileCreate |
306 |
r=file.Create(TheFs,File2,EFileShareAny); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
307 |
test_Value(r, r == KErrInUse); |
0 | 308 |
// EFsMkDir |
309 |
r=TheFs.MkDir(Dir1); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
310 |
test_Value(r, r == KErrInUse); |
0 | 311 |
// EFsVolume |
312 |
TVolumeInfo info; |
|
313 |
r=TheFs.Volume(info,gSessionDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
314 |
test_Value(r, r == KErrInUse); |
0 | 315 |
|
316 |
// get rid of critical notifier |
|
317 |
test.Printf(_L("Press escape on the critical notifier\n")); |
|
318 |
TRequestStatus deathStat; |
|
319 |
thread.Logon(deathStat); |
|
320 |
HungSemaphoreC.Wait(); |
|
321 |
test(HungReturnCodeC==KErrAbort); |
|
322 |
User::WaitForRequest(deathStat); |
|
323 |
thread.Close(); |
|
324 |
||
325 |
// test notifiers have not gone off |
|
326 |
test(status==KRequestPending&&status2==KRequestPending); |
|
327 |
||
328 |
// test that notification setup on default drive has had the drive changed |
|
329 |
// to * since the critical notifier was up |
|
330 |
TFileName notDir=gLockedBase; |
|
331 |
notDir+=NotifyDir; |
|
332 |
r=TheFs.MkDir(notDir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
333 |
test_KErrNone(r); |
0 | 334 |
test(status==KRequestPending&&status2==KErrNone); |
335 |
TheFs.NotifyChangeCancel(); |
|
336 |
test(status==KErrCancel); |
|
337 |
r=TheFs.Delete(File1); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
338 |
test_KErrNone(r); |
0 | 339 |
r=TheFs.RmDir(notDir); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
340 |
test_KErrNone(r); |
0 | 341 |
r=TheFs.RmDir(NotifyDir); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
342 |
test_KErrNone(r); |
0 | 343 |
} |
344 |
||
345 |
void TestParsingFunctions() |
|
346 |
// |
|
347 |
// Test functions that use Parse* and Validate* functions with |
|
348 |
// non-critical notifier up |
|
349 |
// |
|
350 |
{ |
|
351 |
test.Next(_L("TestParsingFunctions")); |
|
352 |
RThread thread; |
|
353 |
PutNonCriticalNotifier(NULL,thread); |
|
354 |
||
355 |
// test on same drive as notifier |
|
356 |
test.Next(_L("test parsing functions on same drive")); |
|
357 |
// Using ParseSubst |
|
358 |
TFileName dir=gLockedBase; |
|
359 |
dir+=Dir1; |
|
360 |
TInt r=TheFs.MkDir(dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
361 |
test_Value(r, r == KErrInUse); |
0 | 362 |
TFileName file=gLockedPath; |
363 |
file+=File1; |
|
364 |
RFile f; |
|
365 |
r=f.Create(TheFs,file,EFileShareAny); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
366 |
test_Value(r, r == KErrInUse); |
0 | 367 |
// Using ParsePathPtr0 |
368 |
r=TheFs.SetSubst(gLockedPath,EDriveO); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
369 |
test_Value(r, r == KErrInUse); |
0 | 370 |
// ValidateDrive |
371 |
TVolumeInfo info; |
|
372 |
r=TheFs.Volume(info,gLockedDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
373 |
test_Value(r, r == KErrInUse); |
0 | 374 |
|
375 |
TFileName origSessPath; |
|
376 |
r=TheFs.SessionPath(origSessPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
377 |
test_KErrNone(r); |
0 | 378 |
|
379 |
// test these work ok |
|
380 |
r=TheFs.SetSessionPath(gLockedPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
381 |
test_KErrNone(r); |
0 | 382 |
r=TheFs.SetSessionPath(origSessPath); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
383 |
test_KErrNone(r); |
0 | 384 |
|
385 |
// test on different drive from notifier - the session path |
|
386 |
test.Next(_L("test parsing functions on a different drive")); |
|
387 |
// Using ParseSubst |
|
388 |
r=TheFs.MkDir(Dir1); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
389 |
test_KErrNone(r); |
0 | 390 |
r=TheFs.RmDir(Dir1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
391 |
test_KErrNone(r); |
0 | 392 |
r=f.Create(TheFs,File1,EFileShareAny); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
393 |
test_KErrNone(r); |
0 | 394 |
f.Close(); |
395 |
r=TheFs.Delete(File1); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
396 |
test_KErrNone(r); |
0 | 397 |
// Using ParsePathPtr0 |
398 |
r=TheFs.SetSubst(gSessionPath,EDriveO); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
399 |
test_KErrNone(r); |
0 | 400 |
r=TheFs.SetSubst(_L(""),EDriveO); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
401 |
test_KErrNone(r); |
0 | 402 |
// ValidateDrive |
403 |
r=TheFs.Volume(info,gSessionDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
404 |
test_KErrNone(r); |
0 | 405 |
|
406 |
// get rid of non-critical notifier |
|
407 |
test.Printf(_L("Enter %S on the notifier\n"),&KPassword); |
|
408 |
||
409 |
TRequestStatus deathStat; |
|
410 |
thread.Logon( deathStat ); |
|
411 |
HungSemaphoreNC.Wait(); |
|
412 |
test(HungReturnCodeNC==KErrNotFound); |
|
413 |
User::WaitForRequest( deathStat ); |
|
414 |
thread.Close(); |
|
415 |
||
416 |
// test.End(); |
|
417 |
} |
|
418 |
||
419 |
void TestTFsFunctions() |
|
420 |
// |
|
421 |
// test functions that do not use the Parse* and Validate* functions |
|
422 |
// |
|
423 |
{ |
|
424 |
test.Next(_L("TestTFsFunctions")); |
|
425 |
TFileName sessName,lockedName; |
|
426 |
TInt r=TheFs.FileSystemName(sessName,gSessionDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
427 |
test_KErrNone(r); |
0 | 428 |
r=TheFs.FileSystemName(lockedName,gLockedDrive); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
429 |
test_KErrNone(r); |
0 | 430 |
|
431 |
RThread thread; |
|
432 |
PutNonCriticalNotifier(NULL,thread); |
|
433 |
||
434 |
// test functions on hung drive - should return KErrInUse |
|
435 |
test.Next(_L("test TFs functions on hung drive")); |
|
436 |
// TFsDismountFileSystem |
|
437 |
r=TheFs.DismountFileSystem(lockedName,gLockedDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
438 |
test_Value(r, r == KErrInUse); |
0 | 439 |
// TFsMountFileSystem |
440 |
r=TheFs.MountFileSystem(lockedName,gLockedDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
441 |
test_Value(r, r == KErrInUse); |
0 | 442 |
// TFsFileSystemName |
443 |
r=TheFs.FileSystemName(lockedName,gLockedDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
444 |
test_Value(r, r == KErrInUse); |
0 | 445 |
|
446 |
// test functions on drive other than hung drive |
|
447 |
test.Next(_L("test TFs functions on drive that is not hung")); |
|
448 |
// TFsDismountFileSystem |
|
449 |
#if defined(__WINS__) |
|
450 |
// bug in TFsMountFileSystem which needs to be fixed before running on EDriveC on WINS |
|
451 |
if(gSessionDrive!=EDriveC) |
|
452 |
{ |
|
453 |
#endif |
|
454 |
r=TheFs.DismountFileSystem(sessName,gSessionDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
455 |
test_KErrNone(r); |
0 | 456 |
// TFsMountFileSystem |
457 |
r=TheFs.MountFileSystem(sessName,gSessionDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
458 |
test_KErrNone(r); |
0 | 459 |
#if defined(__WINS__) |
460 |
} |
|
461 |
#endif |
|
462 |
// TFsFileSystemName |
|
463 |
TFileName fsName; |
|
464 |
r=TheFs.FileSystemName(fsName,gSessionDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
465 |
test_KErrNone(r); |
0 | 466 |
test(fsName==sessName); |
467 |
||
468 |
// test functions that fail on all drives |
|
469 |
test.Next(_L("test TFs functions that fail on all drives")); |
|
470 |
// TFsListOpenFiles |
|
471 |
CFileList* list=NULL; |
|
472 |
TOpenFileScan fileScan(TheFs); |
|
473 |
TRAP(r,fileScan.NextL(list)); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
474 |
test_Value(r, r == KErrInUse); |
0 | 475 |
|
476 |
// test functions that should pass on any drive |
|
477 |
test.Next(_L("test TFs functions that pass on all drives")); |
|
478 |
// TFsSetDefaultPath |
|
479 |
// TFsSetSessionPath |
|
480 |
r=TheFs.SetSessionPath(gLockedPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
481 |
test_KErrNone(r); |
0 | 482 |
r=TheFs.SetSessionPath(gSessionPath); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
483 |
test_KErrNone(r); |
0 | 484 |
|
485 |
// get rid of non-critical notifier |
|
486 |
test.Printf(_L("Enter %S on the notifier\n"),&KPassword); |
|
487 |
TRequestStatus deathStat; |
|
488 |
thread.Logon( deathStat ); |
|
489 |
HungSemaphoreNC.Wait(); |
|
490 |
test(HungReturnCodeNC==KErrNotFound); |
|
491 |
User::WaitForRequest( deathStat ); |
|
492 |
thread.Close(); |
|
493 |
// test.End(); |
|
494 |
} |
|
495 |
||
496 |
||
497 |
void TestSubsessions() |
|
498 |
// |
|
499 |
// test subsession functions |
|
500 |
// |
|
501 |
{ |
|
502 |
test.Next(_L("TestSubsessions")); |
|
503 |
RThread thread; |
|
504 |
PutNonCriticalNotifier(NULL,thread); |
|
505 |
||
506 |
// test that subsessions cannot be opened on a hung drive |
|
507 |
test.Next(_L("test subsessions cannot be opened on a hung drive")); |
|
508 |
// EFsFileCreate |
|
509 |
RFile file; |
|
510 |
TFileName fileName=gLockedPath; |
|
511 |
fileName+=File1; |
|
512 |
TInt r=file.Create(TheFs,fileName,EFileShareAny); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
513 |
test_Value(r, r == KErrInUse); |
0 | 514 |
// EFsFormatOpen |
515 |
RFormat format; |
|
516 |
TInt count; |
|
517 |
r=format.Open(TheFs,gLockedPath,EHighDensity,count); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
518 |
test_Value(r, r == KErrInUse); |
0 | 519 |
// EFsDirOpen |
520 |
RDir dir; |
|
521 |
r=dir.Open(TheFs,gLockedPath,KEntryAttMaskSupported); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
522 |
test_Value(r, r == KErrInUse); |
0 | 523 |
// EFsRawDiskOpen |
524 |
RRawDisk raw; |
|
525 |
r=raw.Open(TheFs,gLockedDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
526 |
test_Value(r, r == KErrInUse); |
0 | 527 |
|
528 |
// get rid of non-critical notifier |
|
529 |
test.Printf(_L("Enter %S on the notifier\n"),&KPassword); |
|
530 |
TRequestStatus deathStat; |
|
531 |
thread.Logon( deathStat ); |
|
532 |
HungSemaphoreNC.Wait(); |
|
533 |
test(HungReturnCodeNC==KErrNotFound); |
|
534 |
User::WaitForRequest( deathStat ); |
|
535 |
thread.Close(); |
|
536 |
||
537 |
// now open the subsessions |
|
538 |
r=file.Create(TheFs,fileName,EFileShareAny); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
539 |
test_Value(r, r == KErrNone || r == KErrAlreadyExists); |
0 | 540 |
if(r==KErrAlreadyExists) |
541 |
{ |
|
542 |
r=file.Open(TheFs,fileName,EFileShareAny); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
543 |
test_KErrNone(r); |
0 | 544 |
} |
545 |
r=dir.Open(TheFs,gLockedPath,KEntryAttMaskSupported); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
546 |
test_KErrNone(r); |
0 | 547 |
|
548 |
// put notifier back up |
|
549 |
PutNonCriticalNotifier(NULL,thread); |
|
550 |
||
551 |
// test subsession operations fail on a hung drive |
|
552 |
test.Next(_L("test subsession operations fail on a hung drive")); |
|
553 |
// EFsFileRead |
|
554 |
TBuf8<16> readBuf; |
|
555 |
r=file.Read(readBuf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
556 |
test_Value(r, r == KErrInUse); |
0 | 557 |
// subsession should be able to be closed ok |
558 |
file.Close(); |
|
559 |
// EFsDelete |
|
560 |
r=TheFs.Delete(fileName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
561 |
test_Value(r, r == KErrInUse); |
0 | 562 |
// EFsDirRead |
563 |
TEntry entry; |
|
564 |
r=dir.Read(entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
565 |
test_Value(r, r == KErrInUse); |
0 | 566 |
// subsession should be able to be closed ok |
567 |
dir.Close(); |
|
568 |
||
569 |
// not going to test operations on a drive the is not hung |
|
570 |
// since this will be tested on other tests |
|
571 |
||
572 |
// get rid of non-critical notifier |
|
573 |
test.Printf(_L("Enter %S on the notifier\n"),&KPassword); |
|
574 |
thread.Logon( deathStat ); |
|
575 |
HungSemaphoreNC.Wait(); |
|
576 |
test(HungReturnCodeNC==KErrNotFound); |
|
577 |
User::WaitForRequest( deathStat ); |
|
578 |
thread.Close(); |
|
579 |
||
580 |
r=TheFs.Delete(fileName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
581 |
test_KErrNone(r); |
0 | 582 |
// test.End(); |
583 |
} |
|
584 |
||
585 |
void TestSameSession() |
|
586 |
// |
|
587 |
// Test functions that can and cannot be handled from same session when notifier is up |
|
588 |
// |
|
589 |
{ |
|
590 |
test.Next(_L("TestSameSession")); |
|
591 |
||
592 |
RFile file; |
|
593 |
TInt r=file.Create(TheFs,File1,EFileWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
594 |
test_KErrNone(r); |
0 | 595 |
|
596 |
// put notifier up using TheFs session |
|
597 |
SNonCriticalInfo info={ETrue,0}; |
|
598 |
RThread thread; |
|
599 |
PutNonCriticalNotifier(&info,thread); |
|
600 |
||
601 |
// test critical functions can be handled |
|
602 |
test.Next(_L("test critical functions can be handled")); |
|
603 |
// EFsNotifyChange |
|
604 |
TRequestStatus status; |
|
605 |
TheFs.NotifyChange(ENotifyAll,status); |
|
606 |
test(status==KRequestPending); |
|
607 |
// EFsNotifyChangeCancel |
|
608 |
TheFs.NotifyChangeCancel(); |
|
609 |
test(status==KErrCancel); |
|
610 |
// EFsNotifyChange again |
|
611 |
TheFs.NotifyChange(ENotifyAll,status); |
|
612 |
test(status==KRequestPending); |
|
613 |
// EFsNotifyChangeCancelEx |
|
614 |
TheFs.NotifyChangeCancel(status); |
|
615 |
test(status==KErrCancel); |
|
616 |
// not going to test EFsSubClose |
|
617 |
||
618 |
// test other functions are not handled |
|
619 |
test.Next(_L("test other functions cannot be handled")); |
|
620 |
// EFsNotifyChangeEx |
|
621 |
TheFs.NotifyChange(ENotifyAll,status,gSessionPath); |
|
622 |
test(status==KErrInUse); |
|
623 |
TFileName defPath; |
|
624 |
// EFsCheckDisk |
|
625 |
r=TheFs.CheckDisk(gSessionPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
626 |
test_Value(r, r == KErrInUse); |
0 | 627 |
// EFsFileWrite |
628 |
_LIT8(buffer,"abc"); |
|
629 |
TBuf8<8> buf(buffer); |
|
630 |
r=file.Write(buf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
631 |
test_Value(r, r == KErrInUse); |
0 | 632 |
|
633 |
// this file should be able to be closed |
|
634 |
file.Close(); |
|
635 |
||
636 |
// get rid of non-critical notifier |
|
637 |
test.Printf(_L("Enter %S on the notifier\n"),&KPassword); |
|
638 |
||
639 |
TRequestStatus deathStat; |
|
640 |
thread.Logon( deathStat ); |
|
641 |
HungSemaphoreNC.Wait(); |
|
642 |
test(HungReturnCodeNC==KErrNotFound); |
|
643 |
User::WaitForRequest( deathStat ); |
|
644 |
thread.Close(); |
|
645 |
||
646 |
r=TheFs.Delete(File1); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
647 |
test_KErrNone(r); |
0 | 648 |
// test.End(); |
649 |
} |
|
650 |
||
651 |
void TestSameSubSession() |
|
652 |
// |
|
653 |
// test hung file server with same subsession |
|
654 |
// |
|
655 |
{ |
|
656 |
_LIT(file1Name,"\\SubFile1"); |
|
657 |
_LIT(file2Name,"\\SubFile2"); |
|
658 |
_LIT(file3Name,"\\SubFile3"); |
|
659 |
_LIT(file4Name,"\\SubFile4"); |
|
660 |
TFileName origSession; |
|
661 |
TInt r=TheFs.SessionPath(origSession); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
662 |
test_KErrNone(r); |
0 | 663 |
TFileName file1Path(gLockedBase); |
664 |
file1Path+=file1Name; |
|
665 |
TFileName file2Path(file2Name); |
|
666 |
TFileName file3Path(gLockedBase); |
|
667 |
file3Path+=file3Name; |
|
668 |
TFileName file4Path(file4Name); |
|
669 |
// create file that will be used to hang file server |
|
670 |
r=SubFile1.Create(TheFs,file1Path,EFileWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
671 |
test_KErrNone(r); |
0 | 672 |
// create file with same session but on different drive |
673 |
RFile subfile2; |
|
674 |
r=subfile2.Create(TheFs,file2Path,EFileWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
675 |
test_KErrNone(r); |
0 | 676 |
// create file on unhung drive and with different session |
677 |
RFs fs2; |
|
678 |
r=fs2.Connect(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
679 |
test_KErrNone(r); |
0 | 680 |
r=fs2.SetSessionPath(origSession); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
681 |
test_KErrNone(r); |
0 | 682 |
RFile subfile3; |
683 |
r=subfile3.Create(fs2,file3Path,EFileWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
684 |
test_KErrNone(r); |
0 | 685 |
// create file on unhung drive and with different session |
686 |
RFile subfile4; |
|
687 |
r=subfile4.Create(fs2,file4Path,EFileWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
688 |
test_KErrNone(r); |
0 | 689 |
// in a different thread cause the server to hang using one of the File1 subsession |
690 |
// put notifier up using TheFs session |
|
691 |
SNonCriticalInfo info={ETrue,ETrue}; |
|
692 |
RThread thread; |
|
693 |
PutNonCriticalNotifier(&info,thread); |
|
694 |
test.Next(_L("test writing to files with hung file server")); |
|
695 |
// check only file4 can be written to |
|
696 |
_LIT8(buffer,"abc"); |
|
697 |
TBuf8<8> buf(buffer); |
|
698 |
// File1 caused hung file server |
|
699 |
r=SubFile1.Write(buf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
700 |
test_Value(r, r == KErrInUse); |
0 | 701 |
// file2 is same session as subsession that caused hung file server |
702 |
r=subfile2.Write(buf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
703 |
test_Value(r, r == KErrInUse); |
0 | 704 |
// file3 is opened on hung drive |
705 |
r=subfile3.Write(buf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
706 |
test_Value(r, r == KErrInUse); |
0 | 707 |
// file4 should be ok |
708 |
r=subfile4.Write(buf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
709 |
test_KErrNone(r); |
0 | 710 |
// hard to test EFsSubClose since does not return an error value |
711 |
test.Next(_L("test closing down the subsessions")); |
|
712 |
subfile4.Close(); |
|
713 |
// calling close on the same subsession as is hung will cause this subsession |
|
714 |
// to be closed once the original request is completed |
|
715 |
SubFile1.Close(); |
|
716 |
subfile2.Close(); |
|
717 |
||
718 |
// get rid of non-critical notifier |
|
719 |
test.Printf(_L("Enter %S on the notifier\n"),&KPassword); |
|
720 |
TRequestStatus deathStat; |
|
721 |
thread.Logon( deathStat ); |
|
722 |
HungSemaphoreNC.Wait(); |
|
723 |
test(HungReturnCodeNC==KErrNotFound); |
|
724 |
User::WaitForRequest( deathStat ); |
|
725 |
thread.Close(); |
|
726 |
// close remaining files |
|
727 |
subfile3.Close(); |
|
728 |
// clean up |
|
729 |
fs2.Close(); |
|
730 |
r=TheFs.Delete(file1Path); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
731 |
test_KErrNone(r); |
0 | 732 |
r=TheFs.Delete(file2Path); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
733 |
test_KErrNone(r); |
0 | 734 |
r=TheFs.Delete(file3Path); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
735 |
test_KErrNone(r); |
0 | 736 |
r=TheFs.Delete(file4Path); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
737 |
test_KErrNone(r); |
0 | 738 |
} |
739 |
||
740 |
void TestExtendedNotifier() |
|
741 |
// |
|
742 |
// |
|
743 |
// |
|
744 |
{ |
|
745 |
test.Next(_L("TestExtendedNotifier")); |
|
746 |
// setup a notification on a removable media |
|
747 |
test.Next(_L("test with drive specified")); |
|
748 |
TFileName notDir=gLockedBase; |
|
749 |
notDir+=NotifyDir; |
|
750 |
TRequestStatus status; |
|
751 |
TheFs.NotifyChange(ENotifyAll,status,notDir); |
|
752 |
test(status==KRequestPending); |
|
753 |
// now do an operation on c: and test no notification |
|
754 |
TInt r=TheFs.MkDir(NotifyDir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
755 |
test_KErrNone(r); |
0 | 756 |
r=TheFs.RmDir(NotifyDir); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
757 |
test_KErrNone(r); |
0 | 758 |
User::After(1000000); |
759 |
test(status==KRequestPending); |
|
760 |
TheFs.NotifyChangeCancel(status); |
|
761 |
test(status==KErrCancel); |
|
762 |
||
763 |
// now put up the notifier |
|
764 |
RThread thread; |
|
765 |
PutNonCriticalNotifier(NULL,thread); |
|
766 |
||
767 |
// repeat the above notification |
|
768 |
// setup a notification on a removable media - the drive should be changed |
|
769 |
// to * since notifier is up |
|
770 |
test.Next(_L("test with wildcard for drive")); |
|
771 |
TheFs.NotifyChange(ENotifyAll,status,notDir); |
|
772 |
test(status==KRequestPending); |
|
773 |
// test notification does not go off with wrong path |
|
774 |
r=TheFs.MkDir(NotifyDir2); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
775 |
test_KErrNone(r); |
0 | 776 |
r=TheFs.RmDir(NotifyDir2); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
777 |
test_KErrNone(r); |
0 | 778 |
test(status==KRequestPending); |
779 |
// now do an operation on c: and test there has been a notification |
|
780 |
r=TheFs.MkDir(NotifyDir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
781 |
test_KErrNone(r); |
0 | 782 |
r=TheFs.RmDir(NotifyDir); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
783 |
test_KErrNone(r); |
0 | 784 |
User::After(1000000); |
785 |
// request should be completed this time |
|
786 |
test(status==KErrNone); |
|
787 |
||
788 |
// set up a notification on drive that is not removable |
|
789 |
// the path should not be changed |
|
790 |
test.Next(_L("test with non-removable drive")); |
|
791 |
TheFs.NotifyChange(ENotifyAll,status,notDir); |
|
792 |
test(status==KRequestPending); |
|
793 |
TRequestStatus status2; |
|
794 |
TFileName origSession; |
|
795 |
r=TheFs.SessionPath(origSession); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
796 |
test_KErrNone(r); |
0 | 797 |
RFs fs2; |
798 |
r=fs2.Connect(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
799 |
test_KErrNone(r); |
0 | 800 |
r=fs2.SetSessionPath(origSession); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
801 |
test_KErrNone(r); |
0 | 802 |
_LIT(notifyDirZ,"z:\\test\\"); |
803 |
_LIT(notifyDirSess,"\\test\\"); |
|
804 |
// notifyDirZ already exists, create test dir in session path |
|
805 |
r=fs2.MkDir(notifyDirSess); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
806 |
test_KErrNone(r); |
0 | 807 |
fs2.NotifyChange(ENotifyDir,status2,notifyDirZ); |
808 |
test(status2==KRequestPending); |
|
809 |
TRequestStatus status3; |
|
810 |
fs2.NotifyChange(ENotifyDir,status3,notifyDirSess); |
|
811 |
test(status3==KRequestPending); |
|
812 |
// now delete session dir and test no notification |
|
813 |
r=TheFs.RmDir(notifyDirSess); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
814 |
test_KErrNone(r); |
0 | 815 |
test(status2==KRequestPending && status3==KErrNone); |
816 |
||
817 |
// get rid of non-critical notifier |
|
818 |
test.Printf(_L("Enter %S on the notifier\n"),&KPassword); |
|
819 |
TRequestStatus deathStat; |
|
820 |
thread.Logon( deathStat ); |
|
821 |
HungSemaphoreNC.Wait(); |
|
822 |
test(HungReturnCodeNC==KErrNotFound); |
|
823 |
User::WaitForRequest( deathStat ); |
|
824 |
thread.Close(); |
|
825 |
test(status==KErrNone&&status2==KErrNone); |
|
826 |
fs2.Close(); |
|
827 |
||
828 |
test.Next(_L("test extended notification with critical notifier")); |
|
829 |
RThread threadC; |
|
830 |
// put a a critical notifier |
|
831 |
PutCriticalNotifier(ETrue,threadC); |
|
832 |
// setup extended change notification on session path, drive should be changed to * |
|
833 |
TheFs.NotifyChange(ENotifyAll,status,NotifyDir); |
|
834 |
test(status==KRequestPending); |
|
835 |
// get rid of notifier |
|
836 |
test.Printf(_L("Press cancel on for critcal notifier\n")); |
|
837 |
threadC.Logon(deathStat); |
|
838 |
HungSemaphoreC.Wait(); |
|
839 |
User::WaitForRequest(deathStat); |
|
840 |
threadC.Close(); |
|
841 |
// test that notification has not gone off |
|
842 |
test(status==KRequestPending); |
|
843 |
// create directory on locked drive |
|
844 |
r=TheFs.MkDir(notDir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
845 |
test_KErrNone(r); |
0 | 846 |
// test notifier goes off |
847 |
test(status==KErrNone); |
|
848 |
r=TheFs.RmDir(notDir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
849 |
test_KErrNone(r); |
0 | 850 |
// get rid of critical notifier |
851 |
} |
|
852 |
||
853 |
LOCAL_C TBool TestSessionPath() |
|
854 |
// |
|
855 |
// |
|
856 |
// |
|
857 |
{ |
|
858 |
#if defined(__WINS__) |
|
859 |
TInt r=TheFs.CharToDrive(gSessionPath[0],gSessionDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
860 |
test_KErrNone(r); |
0 | 861 |
if(gSessionDrive==EDriveX) |
862 |
return(EFalse); |
|
863 |
#else |
|
864 |
TInt r=TheFs.CharToDrive(gSessionPath[0],gSessionDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
865 |
test_KErrNone(r); |
0 | 866 |
TDriveList list; |
867 |
r=TheFs.DriveList(list); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
868 |
test_KErrNone(r); |
0 | 869 |
if((list[gSessionDrive])&KDriveAttRemovable) |
870 |
return(EFalse); |
|
871 |
#endif |
|
872 |
return(ETrue); |
|
873 |
} |
|
874 |
||
875 |
||
876 |
GLDEF_C void CallTestsL() |
|
877 |
// |
|
878 |
// Test a hung file server |
|
879 |
// |
|
880 |
{ |
|
881 |
if(!IsTestTypeStandard()) |
|
882 |
return; |
|
883 |
||
884 |
if(!TestSessionPath()) |
|
885 |
{ |
|
886 |
test.Printf(_L("Not testing on %S\n"),&gSessionPath); |
|
887 |
return; |
|
888 |
} |
|
889 |
#if defined(__WINS__) |
|
890 |
gLockedDrive=EDriveX; |
|
891 |
gLockedPath=_L("?:\\"); |
|
892 |
gLockedBase=_L("?:"); |
|
893 |
gLockedPath[0]=gLockedBase[0]=(TText)('A'+gLockedDrive); |
|
894 |
#else |
|
895 |
gLockedDrive=EDriveD; |
|
896 |
gLockedPath=_L("?:\\"); |
|
897 |
gLockedBase=_L("?:"); |
|
898 |
gLockedPath[0]=gLockedBase[0]=(TText)('A'+gLockedDrive); |
|
899 |
#endif |
|
900 |
||
901 |
test.Printf(_L("Is a secure mmc present? Press y for yes\n")); |
|
902 |
TChar c=test.Getch(); |
|
903 |
if(c=='y'||c=='Y') |
|
904 |
isSecureMmc=ETrue; |
|
905 |
else |
|
906 |
isSecureMmc=EFalse; |
|
907 |
||
908 |
TInt r=HungSemaphoreC.CreateLocal(0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
909 |
test_KErrNone(r); |
0 | 910 |
r=HungSemaphoreNC.CreateLocal(0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
911 |
test_KErrNone(r); |
0 | 912 |
|
913 |
// create sharable session |
|
914 |
TheFs.ShareAuto(); |
|
915 |
||
916 |
TestParsingFunctions(); |
|
917 |
TestTFsFunctions(); |
|
918 |
TestExtendedNotifier(); |
|
919 |
TestSubsessions(); |
|
920 |
// TestNotifiers(); |
|
921 |
TestCriticalFunctions(); |
|
922 |
TestSameSession(); |
|
923 |
TestSameSubSession(); |
|
924 |
||
925 |
HungSemaphoreC.Close(); |
|
926 |
HungSemaphoreNC.Close(); |
|
927 |
} |