author | Mike Kinghan <mikek@symbian.org> |
Mon, 19 Jul 2010 08:40:05 +0100 | |
branch | GCC_SURGE |
changeset 209 | 6035754ebf88 |
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\fsstress\t_remote.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#if !defined(__F32FILE_H__) |
|
19 |
#include <f32file.h> |
|
20 |
#endif |
|
21 |
#if !defined(__E32TEST_H__) |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
22 |
#define __E32TEST_EXTENSION__ |
0 | 23 |
#include <e32test.h> |
24 |
#endif |
|
25 |
#if !defined(__T_STD_H__) |
|
26 |
#include "t_std.h" |
|
27 |
#endif |
|
28 |
#if !defined(__T_REMFSY_H__) |
|
29 |
#include "t_remfsy.h" |
|
30 |
#endif |
|
31 |
||
32 |
GLDEF_D RTest test(_L("T_REMOTE - DEFAULT DRIVE")); |
|
33 |
GLDEF_D RTest testx(_L("X Drive (WINS) <-> D Drive (MARM)")); |
|
34 |
GLDEF_D RTest testy(_L("Y Drive (WINS) <-> C Drive (MARM)")); |
|
35 |
GLDEF_D RTest testq(_L("REMOTE Q Drive")); |
|
36 |
||
37 |
LOCAL_D TFileName gBatchFile; |
|
38 |
LOCAL_D TBool gRunByBatch=EFalse; |
|
39 |
||
40 |
GLDEF_D TFileName gExeFileName(RProcess().FileName()); |
|
41 |
||
42 |
/* |
|
43 |
INFORMATION - What this test is all about |
|
44 |
||
45 |
T_REMOTE tests the asynchronous remote file system implementation, introduced in |
|
46 |
F32 release 110 and refined in release 112. The test sets up and mounts four drives, |
|
47 |
the default drive (usually C on WINS and MARM), a remote drive (Q) and two others, on |
|
48 |
MARM these are C and D, on WINS these are X and Y. The remote filesystem is the only |
|
49 |
system treated asynchronously by F32. |
|
50 |
||
51 |
The test sets up a thread for each drive and runs a number of tests on each drive. |
|
52 |
In the remote filesystem case, a dummy filesystem has been implemented, this is built |
|
53 |
as T_REMFSY.fsy. The tests are designed to stress a number of fileserver API |
|
54 |
functions. The test MultipleSessions() is adapted from another F32 test T_SESSION. |
|
55 |
It sets up an array of fileserver connections and then uses each connection to run |
|
56 |
a number of tests - alternating between connections to stress F32 as it does so. The |
|
57 |
test should therefore be testing multiple fileserver connections on multiple drives - |
|
58 |
the remote filesystem running concurrently with the other drives. There should be |
|
59 |
no failure or confusion between fileserver sessions. Each drive has a separate test |
|
60 |
console which should complete successfully. |
|
61 |
||
62 |
NOTE: TO RUN THIS CARD SUCCESSFULLY ON MARM A CF CARD IS REQUIRED |
|
63 |
||
64 |
*/ |
|
65 |
||
66 |
LOCAL_C void Test0(RTest& aTest) |
|
67 |
// |
|
68 |
// Scan for open files - no sessions |
|
69 |
// |
|
70 |
{ |
|
71 |
aTest.Next(_L("Scan for open files with no sessions open")); |
|
72 |
CFileList* list; |
|
73 |
TOpenFileScan fileScan(TheFs); |
|
74 |
fileScan.NextL(list); |
|
75 |
if (list==NULL) |
|
76 |
return; |
|
77 |
TInt count=list->Count(); |
|
78 |
if (count==1) |
|
79 |
{ |
|
80 |
gRunByBatch=ETrue; |
|
81 |
gBatchFile=(*list)[0].iName; |
|
82 |
delete list; |
|
83 |
fileScan.NextL(list); |
|
84 |
if (list==NULL) |
|
85 |
return; |
|
86 |
count=list->Count(); |
|
87 |
} |
|
88 |
while (count--) |
|
89 |
{ |
|
90 |
TEntry entry=(*list)[count]; |
|
91 |
aTest.Printf(_L("%d) EntryName = %S\n"),count,&entry.iName); |
|
92 |
} |
|
93 |
//aTest.Printf(_L("Test will fail unless files are closed.\n")); |
|
94 |
//aTest.Printf(_L("Press any key ...\n")); |
|
95 |
//aTest.Getch(); |
|
96 |
} |
|
97 |
||
98 |
||
99 |
LOCAL_C void Test1() |
|
100 |
// |
|
101 |
// This test is only called by default drive |
|
102 |
// Test OpenFileScan |
|
103 |
// |
|
104 |
{ |
|
105 |
test.Next(_L("Scan for open files - one session only")); |
|
106 |
||
107 |
RFile file1,file2,file3; |
|
108 |
TFileName fn; |
|
109 |
fn = _L("Z:\\TEST\\T_FSRV.CPP"); |
|
110 |
fn[0] = gExeFileName[0]; |
|
111 |
TInt r=file1.Open(TheFs,fn,EFileRead|EFileShareReadersOnly); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
112 |
test_KErrNone(r); |
0 | 113 |
fn = _L("Z:\\TEST\\T_FILE.CPP"); |
114 |
fn[0] = gExeFileName[0]; |
|
115 |
r=file2.Open(TheFs,fn,EFileRead); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
116 |
test_KErrNone(r); |
0 | 117 |
fn = _L("Z:\\TEST\\T_FSRV.CPP"); |
118 |
fn[0] = gExeFileName[0]; |
|
119 |
r=file3.Open(TheFs,fn,EFileRead|EFileShareReadersOnly); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
120 |
test_KErrNone(r); |
0 | 121 |
|
122 |
CFileList* list; |
|
123 |
TOpenFileScan fileScan(TheFs); |
|
124 |
fileScan.NextL(list); |
|
125 |
||
126 |
if (gRunByBatch) |
|
127 |
{ |
|
128 |
test(list!=NULL); |
|
129 |
test(list->Count()==1); |
|
130 |
TEntry entry=(*list)[0]; |
|
131 |
test(entry.iName.FindF(_L(".BAT"))>=0); |
|
132 |
delete list; |
|
133 |
fileScan.NextL(list); |
|
134 |
} |
|
135 |
||
136 |
test(list!=NULL); |
|
137 |
TInt count=list->Count(); |
|
138 |
test(count==3); |
|
139 |
TEntry entry=(*list)[0]; |
|
140 |
test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); |
|
141 |
entry=(*list)[1]; |
|
142 |
test(entry.iName.FindF(_L("T_FILE.CPP"))>=0); |
|
143 |
entry=(*list)[2]; |
|
144 |
test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); |
|
145 |
TThreadId threadId=fileScan.ThreadId(); |
|
146 |
RThread current; |
|
147 |
TThreadId currentId=current.Id(); |
|
148 |
test(threadId==currentId); |
|
149 |
delete list; |
|
150 |
||
151 |
fileScan.NextL(list); |
|
152 |
test(list==NULL); |
|
153 |
||
154 |
file1.Close(); |
|
155 |
file2.Close(); |
|
156 |
file3.Close(); |
|
157 |
} |
|
158 |
||
159 |
LOCAL_C void Test2() |
|
160 |
// |
|
161 |
// Test openfilescan - empty, full, empty. |
|
162 |
// |
|
163 |
{ |
|
164 |
test.Next(_L("Scan for open files - empty sessions")); |
|
165 |
||
166 |
RFs fs1,fs2,fs3,fs4; |
|
167 |
TInt r=fs1.Connect(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
168 |
test_KErrNone(r); |
0 | 169 |
r=fs2.Connect(); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
170 |
test_KErrNone(r); |
0 | 171 |
r=fs3.Connect(); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
172 |
test_KErrNone(r); |
0 | 173 |
r=fs4.Connect(); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
174 |
test_KErrNone(r); |
0 | 175 |
|
176 |
RFile file1,file2,file3; |
|
177 |
TFileName fn; |
|
178 |
fn = _L("Z:\\TEST\\T_FSRV.CPP"); |
|
179 |
fn[0] = gExeFileName[0]; |
|
180 |
r=file1.Open(fs2,fn,EFileRead|EFileShareReadersOnly); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
181 |
test_KErrNone(r); |
0 | 182 |
fn = _L("Z:\\TEST\\T_FILE.CPP"); |
183 |
fn[0] = gExeFileName[0]; |
|
184 |
r=file2.Open(fs2,fn,EFileRead); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
185 |
test_KErrNone(r); |
0 | 186 |
fn = _L("Z:\\TEST\\T_FSRV.CPP"); |
187 |
fn[0] = gExeFileName[0]; |
|
188 |
r=file3.Open(fs2,fn,EFileRead|EFileShareReadersOnly); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
189 |
test_KErrNone(r); |
0 | 190 |
|
191 |
CFileList* list; |
|
192 |
TOpenFileScan fileScan(TheFs); |
|
193 |
fileScan.NextL(list); |
|
194 |
||
195 |
if (gRunByBatch) |
|
196 |
{ |
|
197 |
test(list!=NULL); |
|
198 |
test(list->Count()==1); |
|
199 |
TEntry entry=(*list)[0]; |
|
200 |
test(entry.iName.FindF(_L(".BAT"))>=0); |
|
201 |
delete list; |
|
202 |
fileScan.NextL(list); |
|
203 |
} |
|
204 |
||
205 |
test(list!=NULL); |
|
206 |
TInt count=list->Count(); |
|
207 |
test(count==3); |
|
208 |
TEntry entry=(*list)[0]; |
|
209 |
test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); |
|
210 |
entry=(*list)[1]; |
|
211 |
test(entry.iName.FindF(_L("T_FILE.CPP"))>=0); |
|
212 |
entry=(*list)[2]; |
|
213 |
test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); |
|
214 |
TThreadId threadId=fileScan.ThreadId(); |
|
215 |
RThread current; |
|
216 |
TThreadId currentId=current.Id(); |
|
217 |
test(threadId==currentId); |
|
218 |
delete list; |
|
219 |
||
220 |
fileScan.NextL(list); |
|
221 |
test(list==NULL); |
|
222 |
||
223 |
file1.Close(); |
|
224 |
file2.Close(); |
|
225 |
file3.Close(); |
|
226 |
fs1.Close(); |
|
227 |
fs2.Close(); |
|
228 |
fs3.Close(); |
|
229 |
fs4.Close(); |
|
230 |
} |
|
231 |
||
232 |
LOCAL_C void Test3() |
|
233 |
// |
|
234 |
// Test openfilescan - empty, full, empty full |
|
235 |
// |
|
236 |
{ |
|
237 |
test.Next(_L("Scan for open files - multiple sessions")); |
|
238 |
||
239 |
RFs fs1,fs2,fs3,fs4; |
|
240 |
TInt r=fs1.Connect(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
241 |
test_KErrNone(r); |
0 | 242 |
r=fs2.Connect(); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
243 |
test_KErrNone(r); |
0 | 244 |
r=fs3.Connect(); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
245 |
test_KErrNone(r); |
0 | 246 |
r=fs4.Connect(); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
247 |
test_KErrNone(r); |
0 | 248 |
|
249 |
RFile file1,file2,file3; |
|
250 |
TFileName fn; |
|
251 |
fn = _L("Z:\\TEST\\T_FSRV.CPP"); |
|
252 |
fn[0] = gExeFileName[0]; |
|
253 |
r=file1.Open(fs2,fn,EFileRead|EFileShareReadersOnly); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
254 |
test_KErrNone(r); |
0 | 255 |
fn = _L("Z:\\TEST\\T_FILE.CPP"); |
256 |
fn[0] = gExeFileName[0]; |
|
257 |
r=file2.Open(fs2,fn,EFileRead|EFileShareReadersOnly); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
258 |
test_KErrNone(r); |
0 | 259 |
fn = _L("Z:\\TEST\\T_FSRV.CPP"); |
260 |
fn[0] = gExeFileName[0]; |
|
261 |
r=file3.Open(fs2,fn,EFileRead|EFileShareReadersOnly); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
262 |
test_KErrNone(r); |
0 | 263 |
|
264 |
r=file1.Open(fs4,fn,EFileRead|EFileShareReadersOnly); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
265 |
test_KErrNone(r); |
0 | 266 |
fn = _L("Z:\\TEST\\T_FILE.CPP"); |
267 |
fn[0] = gExeFileName[0]; |
|
268 |
r=file2.Open(fs4,fn,EFileRead|EFileShareReadersOnly); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
269 |
test_KErrNone(r); |
0 | 270 |
fn = _L("Z:\\TEST\\T_FSRV.CPP"); |
271 |
fn[0] = gExeFileName[0]; |
|
272 |
r=file3.Open(fs4,fn,EFileRead|EFileShareReadersOnly); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
273 |
test_KErrNone(r); |
0 | 274 |
|
275 |
CFileList* list; |
|
276 |
TOpenFileScan fileScan(TheFs); |
|
277 |
fileScan.NextL(list); |
|
278 |
||
279 |
if (gRunByBatch) |
|
280 |
{ |
|
281 |
test(list!=NULL); |
|
282 |
test(list->Count()==1); |
|
283 |
TEntry entry=(*list)[0]; |
|
284 |
test(entry.iName.FindF(_L(".BAT"))>=0); |
|
285 |
delete list; |
|
286 |
fileScan.NextL(list); |
|
287 |
} |
|
288 |
||
289 |
test(list!=NULL); |
|
290 |
TInt count=list->Count(); |
|
291 |
test(count==3); |
|
292 |
TEntry entry=(*list)[0]; |
|
293 |
test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); |
|
294 |
entry=(*list)[1]; |
|
295 |
test(entry.iName.FindF(_L("T_FILE.CPP"))>=0); |
|
296 |
entry=(*list)[2]; |
|
297 |
test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); |
|
298 |
TThreadId threadId=fileScan.ThreadId(); |
|
299 |
RThread current; |
|
300 |
TThreadId currentId=current.Id(); |
|
301 |
test(threadId==currentId); |
|
302 |
delete list; |
|
303 |
||
304 |
fileScan.NextL(list); |
|
305 |
test(list!=NULL); |
|
306 |
count=list->Count(); |
|
307 |
test(count==3); |
|
308 |
entry=(*list)[0]; |
|
309 |
test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); |
|
310 |
entry=(*list)[1]; |
|
311 |
test(entry.iName.FindF(_L("T_FILE.CPP"))>=0); |
|
312 |
entry=(*list)[2]; |
|
313 |
test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); |
|
314 |
threadId=fileScan.ThreadId(); |
|
315 |
currentId=current.Id(); |
|
316 |
test(threadId==currentId); |
|
317 |
delete list; |
|
318 |
||
319 |
fileScan.NextL(list); |
|
320 |
test(list==NULL); |
|
321 |
||
322 |
file1.Close(); |
|
323 |
file2.Close(); |
|
324 |
file3.Close(); |
|
325 |
fs1.Close(); |
|
326 |
fs2.Close(); |
|
327 |
fs3.Close(); |
|
328 |
fs4.Close(); |
|
329 |
} |
|
330 |
||
331 |
LOCAL_C void Test4() |
|
332 |
// |
|
333 |
// Test openfilescan - rdirs, empty, full, empty rdirs. |
|
334 |
// |
|
335 |
{ |
|
336 |
test.Next(_L("Scan for open files - check RDir sessions are ignored")); |
|
337 |
||
338 |
RFs fs1,fs2,fs3,fs4; |
|
339 |
TFileName fn; |
|
340 |
TInt r=fs1.Connect(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
341 |
test_KErrNone(r); |
0 | 342 |
r=fs2.Connect(); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
343 |
test_KErrNone(r); |
0 | 344 |
r=fs3.Connect(); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
345 |
test_KErrNone(r); |
0 | 346 |
r=fs4.Connect(); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
347 |
test_KErrNone(r); |
0 | 348 |
|
349 |
RDir dir1,dir2,dir3,dir4; |
|
350 |
fn = _L("Z:\\TEST\\*.XDE"); |
|
351 |
fn[0] = gExeFileName[0]; |
|
352 |
r=dir1.Open(TheFs,fn,KEntryAttMaskSupported); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
353 |
test_KErrNone(r); |
0 | 354 |
r=dir2.Open(TheFs,fn,KEntryAttMaskSupported); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
355 |
test_KErrNone(r); |
0 | 356 |
r=dir3.Open(TheFs,fn,KEntryAttMaskSupported); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
357 |
test_KErrNone(r); |
0 | 358 |
r=dir4.Open(TheFs,fn,KEntryAttMaskSupported); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
359 |
test_KErrNone(r); |
0 | 360 |
|
361 |
RFile file1,file2,file3; |
|
362 |
fn = _L("Z:\\TEST\\T_FSRV.CPP"); |
|
363 |
fn[0] = gExeFileName[0]; |
|
364 |
r=file1.Open(fs2,fn,EFileRead|EFileShareReadersOnly); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
365 |
test_KErrNone(r); |
0 | 366 |
fn = _L("Z:\\TEST\\T_FILE.CPP"); |
367 |
fn[0] = gExeFileName[0]; |
|
368 |
r=file2.Open(fs2,fn,EFileRead); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
369 |
test_KErrNone(r); |
0 | 370 |
fn = _L("Z:\\TEST\\T_FSRV.CPP"); |
371 |
fn[0] = gExeFileName[0]; |
|
372 |
r=file3.Open(fs2,fn,EFileRead|EFileShareReadersOnly); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
373 |
test_KErrNone(r); |
0 | 374 |
|
375 |
RDir dir5,dir6,dir7,dir8; |
|
376 |
fn = _L("Z:\\TEST\\*.XDE"); |
|
377 |
fn[0] = gExeFileName[0]; |
|
378 |
r=dir5.Open(fs4,fn,KEntryAttMaskSupported); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
379 |
test_KErrNone(r); |
0 | 380 |
r=dir6.Open(fs4,fn,KEntryAttMaskSupported); |
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=dir7.Open(fs4,fn,KEntryAttMaskSupported); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
383 |
test_KErrNone(r); |
0 | 384 |
r=dir8.Open(fs4,fn,KEntryAttMaskSupported); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
385 |
test_KErrNone(r); |
0 | 386 |
|
387 |
CFileList* list; |
|
388 |
TOpenFileScan fileScan(TheFs); |
|
389 |
fileScan.NextL(list); |
|
390 |
||
391 |
if (gRunByBatch) |
|
392 |
{ |
|
393 |
test(list!=NULL); |
|
394 |
test(list->Count()==1); |
|
395 |
TEntry entry=(*list)[0]; |
|
396 |
test(entry.iName.FindF(_L(".BAT"))>=0); |
|
397 |
delete list; |
|
398 |
fileScan.NextL(list); |
|
399 |
} |
|
400 |
||
401 |
test(list!=NULL); |
|
402 |
TInt count=list->Count(); |
|
403 |
test(count==3); |
|
404 |
TEntry entry=(*list)[0]; |
|
405 |
test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); |
|
406 |
entry=(*list)[1]; |
|
407 |
test(entry.iName.FindF(_L("T_FILE.CPP"))>=0); |
|
408 |
entry=(*list)[2]; |
|
409 |
test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); |
|
410 |
TThreadId threadId=fileScan.ThreadId(); |
|
411 |
RThread current; |
|
412 |
TThreadId currentId=current.Id(); |
|
413 |
test(threadId==currentId); |
|
414 |
delete list; |
|
415 |
||
416 |
fileScan.NextL(list); |
|
417 |
test(list==NULL); |
|
418 |
||
419 |
file1.Close(); |
|
420 |
file2.Close(); |
|
421 |
file3.Close(); |
|
422 |
dir1.Close(); dir2.Close(); |
|
423 |
dir3.Close(); dir4.Close(); |
|
424 |
dir5.Close(); dir6.Close(); |
|
425 |
dir7.Close(); dir8.Close(); |
|
426 |
fs1.Close(); fs2.Close(); |
|
427 |
fs3.Close(); fs4.Close(); |
|
428 |
} |
|
429 |
||
430 |
LOCAL_C void Test5() |
|
431 |
// |
|
432 |
// Test OpenFileScan |
|
433 |
// |
|
434 |
{ |
|
435 |
||
436 |
test.Next(_L("Scan for open files - mixed RDirs and RFiles")); |
|
437 |
||
438 |
RFile file1,file2,file3; |
|
439 |
TFileName fn; |
|
440 |
fn = _L("Z:\\TEST\\T_FSRV.CPP"); |
|
441 |
fn[0] = gExeFileName[0]; |
|
442 |
TInt r=file1.Open(TheFs,fn,EFileRead|EFileShareReadersOnly); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
443 |
test_KErrNone(r); |
0 | 444 |
fn = _L("Z:\\TEST\\T_FILE.CPP"); |
445 |
fn[0] = gExeFileName[0]; |
|
446 |
r=file2.Open(TheFs,fn,EFileRead); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
447 |
test_KErrNone(r); |
0 | 448 |
fn = _L("Z:\\TEST\\T_FSRV.CPP"); |
449 |
fn[0] = gExeFileName[0]; |
|
450 |
r=file3.Open(TheFs,fn,EFileRead|EFileShareReadersOnly); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
451 |
test_KErrNone(r); |
0 | 452 |
|
453 |
RDir dir1,dir2,dir3,dir4; |
|
454 |
fn = _L("Z:\\TEST\\*.XDE"); |
|
455 |
fn[0] = gExeFileName[0]; |
|
456 |
r=dir1.Open(TheFs,fn,KEntryAttMaskSupported); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
457 |
test_KErrNone(r); |
0 | 458 |
r=dir2.Open(TheFs,fn,KEntryAttMaskSupported); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
459 |
test_KErrNone(r); |
0 | 460 |
r=dir3.Open(TheFs,fn,KEntryAttMaskSupported); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
461 |
test_KErrNone(r); |
0 | 462 |
r=dir4.Open(TheFs,fn,KEntryAttMaskSupported); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
463 |
test_KErrNone(r); |
0 | 464 |
|
465 |
CFileList* list; |
|
466 |
TOpenFileScan fileScan(TheFs); |
|
467 |
fileScan.NextL(list); |
|
468 |
||
469 |
if (gRunByBatch) |
|
470 |
{ |
|
471 |
test(list!=NULL); |
|
472 |
test(list->Count()==1); |
|
473 |
TEntry entry=(*list)[0]; |
|
474 |
test(entry.iName.FindF(_L(".BAT"))>=0); |
|
475 |
delete list; |
|
476 |
fileScan.NextL(list); |
|
477 |
} |
|
478 |
||
479 |
test(list!=NULL); |
|
480 |
TInt count=list->Count(); |
|
481 |
test(count==3); |
|
482 |
TEntry entry=(*list)[0]; |
|
483 |
test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); |
|
484 |
entry=(*list)[1]; |
|
485 |
test(entry.iName.FindF(_L("T_FILE.CPP"))>=0); |
|
486 |
entry=(*list)[2]; |
|
487 |
test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); |
|
488 |
TThreadId threadId=fileScan.ThreadId(); |
|
489 |
RThread current; |
|
490 |
TThreadId currentId=current.Id(); |
|
491 |
test(threadId==currentId); |
|
492 |
delete list; |
|
493 |
||
494 |
fileScan.NextL(list); |
|
495 |
test(list==NULL); |
|
496 |
||
497 |
file1.Close(); |
|
498 |
file2.Close(); |
|
499 |
file3.Close(); |
|
500 |
dir1.Close(); |
|
501 |
dir2.Close(); |
|
502 |
dir3.Close(); |
|
503 |
dir4.Close(); |
|
504 |
} |
|
505 |
||
506 |
||
507 |
||
508 |
LOCAL_C void MultipleSessions(TInt aDrive, RTest& aTest) |
|
509 |
// |
|
510 |
// Create an array of fileserver sessions |
|
511 |
// Create an array of TMultipleSessionTest objects |
|
512 |
// |
|
513 |
||
514 |
{ |
|
515 |
#if defined(UNICODE) |
|
516 |
const TInt maxNumberSessions=10; |
|
517 |
#else |
|
518 |
const TInt maxNumberSessions=20; |
|
519 |
#endif |
|
520 |
||
521 |
RFs session[maxNumberSessions]; |
|
522 |
TMultipleSessionTest testObject[maxNumberSessions]; |
|
523 |
TInt i=0; |
|
524 |
TInt r; |
|
525 |
||
526 |
for (; i<maxNumberSessions; i++) |
|
527 |
{ |
|
528 |
r=session[i].Connect(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
529 |
test_KErrNone(r); |
0 | 530 |
testObject[i].Initialise(session[i]); |
531 |
testObject[i].SetSessionPath(aDrive); |
|
532 |
testObject[i].RunTests(aTest); // Run the set of tests for each session |
|
533 |
} // Leave each session open |
|
534 |
||
535 |
||
536 |
for (i=0; i<(maxNumberSessions-1); i++) |
|
537 |
{ |
|
538 |
// Alternate tests between open sessions |
|
539 |
testObject[i].testSetVolume(aTest); |
|
540 |
testObject[i+1].testInitialisation(aTest); |
|
541 |
testObject[i].testSubst(aTest); |
|
542 |
testObject[i+1].testInitialisation(aTest); |
|
543 |
testObject[i].testInitialisation(aTest); |
|
544 |
testObject[i].testDriveList(aTest); |
|
545 |
testObject[i].MakeAndDeleteFiles(aTest); |
|
546 |
// Close session[i] and check that session[i+1] is OK |
|
547 |
session[i].Close(); |
|
548 |
testObject[i+1].testInitialisation(aTest); |
|
549 |
testObject[i+1].testSetVolume(aTest); |
|
550 |
testObject[i+1].testInitialisation(aTest); |
|
551 |
testObject[i+1].testSubst(aTest); |
|
552 |
testObject[i+1].testDriveList(aTest); |
|
553 |
// Reconnect session[i] |
|
554 |
r=session[i].Connect(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
555 |
test_KErrNone(r); |
0 | 556 |
testObject[i].Initialise(session[i]); |
557 |
testObject[i].SetSessionPath(aDrive); |
|
558 |
testObject[i].testSetVolume(aTest); |
|
559 |
testObject[i+1].testInitialisation(aTest); |
|
560 |
testObject[i].testSubst(aTest); |
|
561 |
testObject[i+1].testInitialisation(aTest); |
|
562 |
testObject[i].testInitialisation(aTest); |
|
563 |
testObject[i].testDriveList(aTest); |
|
564 |
// Close session[i+1] and check that session[i] is OK |
|
565 |
session[i+1].Close(); |
|
566 |
testObject[i].testInitialisation(aTest); |
|
567 |
testObject[i].testSetVolume(aTest); |
|
568 |
testObject[i].testInitialisation(aTest); |
|
569 |
testObject[i].testSubst(aTest); |
|
570 |
testObject[i].testDriveList(aTest); |
|
571 |
// Reconnect session[i+1] |
|
572 |
r=session[i+1].Connect(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
573 |
test_KErrNone(r); |
0 | 574 |
testObject[i+1].Initialise(session[i+1]); |
575 |
testObject[i+1].SetSessionPath(aDrive); |
|
576 |
testObject[i].testSetVolume(aTest); |
|
577 |
testObject[i+1].testInitialisation(aTest); |
|
578 |
testObject[i].testSubst(aTest); |
|
579 |
testObject[i+1].testInitialisation(aTest); |
|
580 |
// Close session[i] and check that session[i+1] is OK |
|
581 |
session[i].Close(); |
|
582 |
testObject[i+1].testInitialisation(aTest); |
|
583 |
testObject[i+1].testSetVolume(aTest); |
|
584 |
testObject[i+1].testInitialisation(aTest); |
|
585 |
testObject[i+1].testSubst(aTest); |
|
586 |
testObject[i+1].testDriveList(aTest); |
|
587 |
||
588 |
if (i==maxNumberSessions-1) // Tidy up by closing remaining open session |
|
589 |
{ |
|
590 |
session[i+1].Close(); |
|
591 |
} |
|
592 |
} |
|
593 |
} |
|
594 |
||
595 |
GLDEF_C void CallTestsDefaultL(TInt aDrive) |
|
596 |
// |
|
597 |
// Call tests that may leave |
|
598 |
// |
|
599 |
{ |
|
600 |
Test0(test); |
|
601 |
Test1(); |
|
602 |
Test2(); |
|
603 |
Test3(); |
|
604 |
Test4(); |
|
605 |
Test5(); |
|
606 |
MultipleSessions(aDrive,test); |
|
607 |
} |
|
608 |
||
609 |
GLDEF_C void CallTestsXL(TInt aDrive) |
|
610 |
// |
|
611 |
// Call tests for drive X |
|
612 |
// |
|
613 |
{ |
|
614 |
Test0(testx); |
|
615 |
||
616 |
RFile file1; |
|
617 |
TFileName fn; |
|
618 |
fn = _L("Z:\\TEST\\T_FSRV.CPP"); |
|
619 |
fn[0] = gExeFileName[0]; |
|
620 |
TInt r=file1.Open(TheFs,fn,EFileRead|EFileShareReadersOnly); |
|
621 |
testx(r==KErrNone); |
|
622 |
file1.Close(); |
|
623 |
MultipleSessions(aDrive,testx); |
|
624 |
} |
|
625 |
||
626 |
GLDEF_C void CallTestsYL(TInt aDrive) |
|
627 |
// |
|
628 |
// Call tests for drive Y |
|
629 |
// |
|
630 |
{ |
|
631 |
Test0(testy); |
|
632 |
||
633 |
RFile file1; |
|
634 |
TFileName fn; |
|
635 |
fn = _L("Z:\\TEST\\T_FSRV.CPP"); |
|
636 |
fn[0] = gExeFileName[0]; |
|
637 |
TInt r=file1.Open(TheFs,fn,EFileRead|EFileShareReadersOnly); |
|
638 |
testy(r==KErrNone); |
|
639 |
file1.Close(); |
|
640 |
MultipleSessions(aDrive,testy); |
|
641 |
} |
|
642 |
||
643 |
GLDEF_C void CallTestsQL(TInt aDrive) |
|
644 |
// |
|
645 |
// Call tests for remote drive |
|
646 |
// |
|
647 |
{ |
|
648 |
||
649 |
Test0(testq); |
|
650 |
||
651 |
testq.Printf(_L("This may take some time. Please be patient...\n")); |
|
652 |
||
653 |
testq.Next(_L("Test remote drive with multiple sessions")); |
|
654 |
MultipleSessions(aDrive,testq); |
|
655 |
||
656 |
const TInt numberOfTests=10; |
|
657 |
||
658 |
TPtrC record[numberOfTests]; |
|
659 |
||
660 |
TInt i=0; |
|
661 |
for (;i<numberOfTests;i++) |
|
662 |
{ |
|
663 |
if (i%2) |
|
664 |
record[i].Set(_L("Hubble_Bubble")); |
|
665 |
else |
|
666 |
record[i].Set(_L("Toil_and_Trouble")); |
|
667 |
} |
|
668 |
||
669 |
testq.Next(_L("Create a file 'TEXTFILE.TXT' on the remote drive")); |
|
670 |
RFile f; |
|
671 |
TInt r=f.Replace(TheFs,_L("TEXTFILE.TXT"),0); |
|
672 |
testq(r==KErrNone); |
|
673 |
TFileText textFile; |
|
674 |
textFile.Set(f); |
|
675 |
||
676 |
testq.Next(_L("Write to 'TEXTFILE.TXT'")); |
|
677 |
||
678 |
for (i=0;i<numberOfTests;i++) |
|
679 |
{ |
|
680 |
r=textFile.Write(record[i]); |
|
681 |
testq(r==KErrNone); |
|
682 |
testq.Printf(_L("Write %d completed OK\n"),i+1); |
|
683 |
} |
|
684 |
||
685 |
f.Close(); |
|
686 |
||
687 |
RFile file1; |
|
688 |
r=file1.Open(TheFs,_L("Q:\\TEST\\T_FSRV.CPP"),EFileRead|EFileShareReadersOnly); |
|
689 |
testq(r==KErrNone); |
|
690 |
file1.Close(); |
|
691 |
||
692 |
} |