0
|
1 |
// Copyright (c) 1995-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_dcdiskadminallfiles.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
189
|
18 |
#define __E32TEST_EXTENSION__
|
0
|
19 |
#include <f32file.h>
|
|
20 |
#include <e32test.h>
|
|
21 |
#include <e32std.h>
|
|
22 |
#include <e32std_private.h>
|
|
23 |
#include <e32def.h>
|
|
24 |
#include <e32def_private.h>
|
|
25 |
#include <e32svr.h>
|
|
26 |
#include "t_server.h"
|
|
27 |
|
|
28 |
GLDEF_D RTest test(_L("T_DCDISKADMINALLFILES"));
|
|
29 |
GLDEF_D TTime gTimeNow;
|
|
30 |
LOCAL_D TInt gTheDriveNum;
|
|
31 |
|
|
32 |
|
|
33 |
const TInt KPathPosition = 2;
|
|
34 |
_LIT(KExpectedPrivatePath, "\\Private\\00000001\\");
|
|
35 |
_LIT(KResourcePath, "?:\\Resource\\");
|
|
36 |
_LIT(KSystemPath, "?:\\Sys\\");
|
|
37 |
_LIT(KPrivatePath, "?:\\Private\\");
|
|
38 |
_LIT(KPrivateFalseID, "?:\\Private\\FFFFFFFF\\");
|
|
39 |
_LIT(KDriveName, "Billy");
|
|
40 |
_LIT(KVolLable, "Benny");
|
|
41 |
_LIT(KFileSys, "systemfile.txt");
|
|
42 |
_LIT(KFileSys3, "sysfile.rna");
|
|
43 |
_LIT(KFilePri, "privatefile.txt");
|
|
44 |
_LIT(KFilePri2, "privatefile.tmp");
|
|
45 |
_LIT(KFilePri3, "prifile.rna");
|
|
46 |
_LIT(KFileRes, "resourcefile.txt");
|
|
47 |
_LIT(KFileRes3, "resfile.rna");
|
|
48 |
_LIT(KMkDirSub,"Subdir\\");
|
|
49 |
_LIT(KOldFile,"?:\\Anyold.txt");
|
|
50 |
|
|
51 |
#ifndef __WINS__
|
|
52 |
_LIT(KWildPath, "Z:\\SYSTEM\\"); // Until Loader is modified to use /Sys/
|
|
53 |
#else
|
|
54 |
_LIT(KWildPath, "Z:\\SYS\\");
|
|
55 |
#endif
|
|
56 |
_LIT(KWildFile, "*");
|
|
57 |
|
|
58 |
TCapability TheCaps;
|
|
59 |
TBuf<4> driveBuf=_L("?:\\");
|
|
60 |
RFormat format;
|
|
61 |
TInt count;
|
|
62 |
RRawDisk rawdisk;
|
|
63 |
RFile file1;
|
|
64 |
RFile file2;
|
|
65 |
RDir dir;
|
|
66 |
|
|
67 |
TInt r;
|
|
68 |
TBuf<40> fsname;
|
|
69 |
TBuf<40> systestname;
|
|
70 |
TBuf<40> pritestname;
|
|
71 |
TBuf<40> restestname;
|
|
72 |
TBuf<40> theprivatepath;
|
|
73 |
TBuf<40> pritestfalseidname;
|
|
74 |
TBuf<40> mkdirname;
|
|
75 |
TFileName fromTemp;
|
|
76 |
|
|
77 |
TBuf<25> sysfilename;
|
|
78 |
TBuf<30> realName;
|
|
79 |
TBuf<40> shortfilename;
|
|
80 |
TBuf<40> longfilename;
|
|
81 |
|
|
82 |
TRequestStatus aStat1;
|
|
83 |
TRequestStatus aStat2;
|
|
84 |
TRequestStatus aStat3;
|
|
85 |
TRequestStatus aStat4;
|
|
86 |
|
|
87 |
TBuf<40> systestfile;
|
|
88 |
TBuf<40> pritestfile;
|
|
89 |
TBuf<40> restestfile;
|
|
90 |
TBuf<40> systestfile1;
|
|
91 |
TBuf<40> pritestfile1;
|
|
92 |
TBuf<40> restestfile1;
|
|
93 |
|
|
94 |
TTime testtime;
|
|
95 |
TBuf<20> oldName;
|
|
96 |
|
|
97 |
TBuf<25> temp;
|
|
98 |
|
|
99 |
TEntry entry;
|
|
100 |
|
|
101 |
|
|
102 |
LOCAL_C void systemRFsTest()
|
|
103 |
//
|
|
104 |
// RFs test on system Directory
|
|
105 |
//
|
|
106 |
{
|
|
107 |
systestname=KSystemPath;
|
|
108 |
systestname[0]=(TText)('A' + gTheDriveNum);
|
|
109 |
|
|
110 |
mkdirname.Zero();
|
|
111 |
mkdirname.Append(systestname);
|
|
112 |
mkdirname.Append(KMkDirSub);
|
|
113 |
r=TheFs.MkDirAll(mkdirname);
|
189
|
114 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
115 |
|
|
116 |
TheFs.RmDir(mkdirname);
|
189
|
117 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
118 |
|
|
119 |
r=TheFs.SetSubst(systestname,EDriveO);
|
189
|
120 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
121 |
|
|
122 |
r=TheFs.SetSessionPath(systestname);
|
189
|
123 |
test_KErrNone(r);
|
0
|
124 |
|
|
125 |
TheFs.NotifyChange(ENotifyAll,aStat1,systestname);
|
|
126 |
test(aStat1==KRequestPending);
|
|
127 |
|
|
128 |
systestfile=KSystemPath;
|
|
129 |
systestfile[0]=(TText)('A' + gTheDriveNum);
|
|
130 |
systestfile1=systestfile;
|
|
131 |
systestfile.Append(KFileSys);
|
|
132 |
systestfile1.Append(KFileSys3);
|
|
133 |
|
|
134 |
oldName=KOldFile;
|
|
135 |
oldName[0]=(TText)gDriveToTest;
|
|
136 |
|
|
137 |
r=TheFs.GetShortName(systestfile, shortfilename);
|
189
|
138 |
test_Value(r, r == KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
0
|
139 |
|
|
140 |
r=TheFs.GetLongName(systestfile1, longfilename);
|
189
|
141 |
test_Value(r, r == KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
0
|
142 |
|
|
143 |
r=file1.Create(TheFs,oldName,EFileWrite);
|
189
|
144 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists);
|
0
|
145 |
file1.Close();
|
|
146 |
|
|
147 |
r=TheFs.Replace(oldName,systestfile);
|
189
|
148 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
149 |
|
|
150 |
r=TheFs.Rename(systestfile,systestfile1);
|
189
|
151 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
152 |
|
|
153 |
r=TheFs.Entry(systestfile1,entry);
|
189
|
154 |
test_Value(r, r == KErrNone || r == KErrNotFound);
|
0
|
155 |
|
|
156 |
r=TheFs.SetEntry(systestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
|
189
|
157 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
158 |
|
|
159 |
r=TheFs.Delete(systestfile1);
|
189
|
160 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
161 |
}
|
|
162 |
|
|
163 |
LOCAL_C void ResourceRFsTest()
|
|
164 |
//
|
|
165 |
//
|
|
166 |
//
|
|
167 |
{
|
|
168 |
restestname=KResourcePath;
|
|
169 |
restestname[0]=(TText)('A' + gTheDriveNum);
|
|
170 |
|
|
171 |
mkdirname.Zero();
|
|
172 |
mkdirname.Append(restestname);
|
|
173 |
mkdirname.Append(KMkDirSub);
|
|
174 |
r=TheFs.MkDirAll(mkdirname);
|
189
|
175 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
176 |
|
|
177 |
TheFs.RmDir(mkdirname);
|
189
|
178 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
179 |
|
|
180 |
// Change due to defect DEF099546 fix
|
|
181 |
// TCB capability is required for following operation.
|
|
182 |
r=TheFs.SetSubst(restestname,EDriveO);
|
189
|
183 |
//test_KErrNone(r);
|
|
184 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
185 |
|
|
186 |
// SetSubst will fail.
|
|
187 |
//r=TheFs.RealName(_L("O:\\File.XXX"),realName);
|
189
|
188 |
//test_KErrNone(r);
|
0
|
189 |
|
|
190 |
//r=TheFs.SetSubst(_L(""),EDriveO);
|
189
|
191 |
//test_KErrNone(r);
|
0
|
192 |
|
|
193 |
r=TheFs.SetSessionPath(restestname);
|
189
|
194 |
test_KErrNone(r);
|
0
|
195 |
|
|
196 |
TheFs.NotifyChange(ENotifyAll,aStat4,restestname);
|
|
197 |
test(aStat4==KRequestPending);
|
|
198 |
|
|
199 |
restestfile=KResourcePath;
|
|
200 |
restestfile[0]=(TText)('A' + gTheDriveNum);
|
|
201 |
restestfile1=restestfile;
|
|
202 |
restestfile.Append(KFileRes);
|
|
203 |
restestfile1.Append(KFileRes3);
|
|
204 |
|
|
205 |
oldName=KOldFile;
|
|
206 |
oldName[0]=(TText)gDriveToTest;
|
|
207 |
|
|
208 |
r=TheFs.GetShortName(restestfile, shortfilename);
|
189
|
209 |
test_Value(r, r == KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
0
|
210 |
|
|
211 |
r=TheFs.GetLongName(restestfile1, longfilename);
|
189
|
212 |
test_Value(r, r == KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
0
|
213 |
|
|
214 |
r=file1.Create(TheFs,oldName,EFileWrite);
|
189
|
215 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists);
|
0
|
216 |
file1.Close();
|
|
217 |
|
|
218 |
r=TheFs.Replace(oldName,restestfile);
|
189
|
219 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
220 |
|
|
221 |
r=TheFs.Rename(restestfile,restestfile1);
|
189
|
222 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
223 |
|
|
224 |
r=TheFs.Entry(restestfile1,entry);
|
189
|
225 |
test_Value(r, r == KErrNone || r==KErrPathNotFound || r==KErrNotFound);
|
0
|
226 |
|
|
227 |
r=TheFs.SetEntry(restestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
|
189
|
228 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
229 |
|
|
230 |
r=TheFs.Delete(restestfile1);
|
189
|
231 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
232 |
|
|
233 |
}
|
|
234 |
|
|
235 |
|
|
236 |
LOCAL_C void privatefalseIDRFsTest()
|
|
237 |
//
|
|
238 |
//
|
|
239 |
//
|
|
240 |
{
|
|
241 |
pritestfalseidname=KPrivateFalseID;
|
|
242 |
pritestfalseidname[0]=(TText)('A' + gTheDriveNum);
|
|
243 |
|
|
244 |
mkdirname.Zero();
|
|
245 |
mkdirname.Append(pritestfalseidname);
|
|
246 |
mkdirname.Append(KMkDirSub);
|
|
247 |
|
|
248 |
r=TheFs.MkDirAll(mkdirname);
|
189
|
249 |
test_KErrNone(r);
|
0
|
250 |
|
|
251 |
r=TheFs.RmDir(mkdirname);
|
189
|
252 |
test_KErrNone(r);
|
0
|
253 |
|
|
254 |
r=TheFs.SetSubst(pritestfalseidname,EDriveO);
|
189
|
255 |
test_KErrNone(r);
|
0
|
256 |
|
|
257 |
r=TheFs.RealName(_L("O:\\File.XXX"),realName);
|
189
|
258 |
test_KErrNone(r);
|
0
|
259 |
|
|
260 |
r=TheFs.SetSubst(_L(""),EDriveO);
|
189
|
261 |
test_KErrNone(r);
|
0
|
262 |
|
|
263 |
r=TheFs.SetSessionPath(pritestfalseidname);
|
189
|
264 |
test_KErrNone(r);
|
0
|
265 |
|
|
266 |
TheFs.NotifyChange(ENotifyAll,aStat2,pritestfalseidname);
|
|
267 |
test(aStat2==KRequestPending);
|
|
268 |
|
|
269 |
|
|
270 |
pritestfile=KPrivateFalseID;
|
|
271 |
pritestfile[0]=(TText)('A' + gTheDriveNum);
|
|
272 |
pritestfile1=pritestfile;
|
|
273 |
pritestfile.Append(KFilePri2);
|
|
274 |
pritestfile1.Append(KFilePri3);
|
|
275 |
|
|
276 |
oldName=KOldFile;
|
|
277 |
oldName[0]=(TText)gDriveToTest;
|
|
278 |
|
|
279 |
r=TheFs.GetShortName(pritestfile, shortfilename);
|
189
|
280 |
test_Value(r, r == KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
0
|
281 |
|
|
282 |
r=TheFs.GetLongName(pritestfile1, longfilename);
|
189
|
283 |
test_Value(r, r == KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
0
|
284 |
|
|
285 |
r=file1.Create(TheFs,oldName,EFileWrite);
|
189
|
286 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists);
|
0
|
287 |
file1.Close();
|
|
288 |
|
|
289 |
r=TheFs.Replace(oldName,pritestfile);
|
189
|
290 |
test_KErrNone(r);
|
0
|
291 |
|
|
292 |
r=TheFs.Rename(pritestfile,pritestfile1);
|
189
|
293 |
test_KErrNone(r);
|
0
|
294 |
|
|
295 |
r=TheFs.Entry(pritestfile1,entry);
|
189
|
296 |
test_KErrNone(r);
|
0
|
297 |
|
|
298 |
r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
|
189
|
299 |
test_KErrNone(r);
|
0
|
300 |
|
|
301 |
r=TheFs.Delete(pritestfile1);
|
189
|
302 |
test_KErrNone(r);
|
0
|
303 |
|
|
304 |
}
|
|
305 |
|
|
306 |
|
|
307 |
LOCAL_C void privateRFsTest()
|
|
308 |
//
|
|
309 |
//
|
|
310 |
//
|
|
311 |
{
|
|
312 |
//private
|
|
313 |
pritestname=KPrivatePath;
|
|
314 |
pritestname[0]=(TText)('A' + gTheDriveNum);
|
|
315 |
|
|
316 |
mkdirname.Zero();
|
|
317 |
mkdirname.Append(pritestname);
|
|
318 |
mkdirname.Append(KMkDirSub);
|
|
319 |
|
|
320 |
r=TheFs.MkDirAll(mkdirname);
|
189
|
321 |
test_KErrNone(r);
|
0
|
322 |
|
|
323 |
r=TheFs.RmDir(mkdirname);
|
189
|
324 |
test_KErrNone(r);
|
0
|
325 |
|
|
326 |
r=TheFs.SetSubst(pritestname,EDriveO);
|
189
|
327 |
test_KErrNone(r);
|
0
|
328 |
|
|
329 |
r=TheFs.RealName(_L("O:\\File.XXX"),realName);
|
189
|
330 |
test_KErrNone(r);
|
0
|
331 |
|
|
332 |
r=TheFs.SetSubst(_L(""),EDriveO);
|
189
|
333 |
test_KErrNone(r);
|
0
|
334 |
|
|
335 |
r=TheFs.SetSessionPath(pritestname);
|
189
|
336 |
test_KErrNone(r);
|
0
|
337 |
|
|
338 |
TheFs.NotifyChange(ENotifyAll,aStat2,pritestname);
|
|
339 |
test(aStat2==KRequestPending);
|
|
340 |
|
|
341 |
|
|
342 |
pritestfile=KPrivatePath;
|
|
343 |
pritestfile[0]=(TText)('A' + gTheDriveNum);
|
|
344 |
pritestfile1=pritestfile;
|
|
345 |
pritestfile.Append(KFilePri2);
|
|
346 |
pritestfile1.Append(KFilePri3);
|
|
347 |
|
|
348 |
oldName=KOldFile;
|
|
349 |
oldName[0]=(TText)gDriveToTest;
|
|
350 |
|
|
351 |
r=TheFs.GetShortName(pritestfile, shortfilename);
|
189
|
352 |
test_Value(r, r == KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
0
|
353 |
|
|
354 |
r=TheFs.GetLongName(pritestfile1, longfilename);
|
189
|
355 |
test_Value(r, r == KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
0
|
356 |
|
|
357 |
r=file1.Create(TheFs,oldName,EFileWrite);
|
189
|
358 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists);
|
0
|
359 |
file1.Close();
|
|
360 |
|
|
361 |
r=TheFs.Replace(oldName,pritestfile);
|
189
|
362 |
test_Value(r, r == KErrNone || r==KErrNotFound);
|
0
|
363 |
|
|
364 |
r=TheFs.Rename(pritestfile,pritestfile1);
|
189
|
365 |
test_KErrNone(r);
|
0
|
366 |
|
|
367 |
r=TheFs.Entry(pritestfile1,entry);
|
189
|
368 |
test_KErrNone(r);
|
0
|
369 |
|
|
370 |
r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
|
189
|
371 |
test_KErrNone(r);
|
0
|
372 |
|
|
373 |
r=TheFs.Delete(pritestfile1);
|
189
|
374 |
test_KErrNone(r);
|
0
|
375 |
|
|
376 |
}
|
|
377 |
|
|
378 |
|
|
379 |
LOCAL_C void privateSIDRFstest()
|
|
380 |
{
|
|
381 |
theprivatepath[0]=(TText)gDriveToTest;
|
|
382 |
test.Printf(_L("the Private Path = %S"),&theprivatepath);
|
|
383 |
|
|
384 |
mkdirname.Zero();
|
|
385 |
mkdirname.Append(theprivatepath);
|
|
386 |
mkdirname.Append(KMkDirSub);
|
|
387 |
r=TheFs.MkDirAll(mkdirname);
|
189
|
388 |
test_KErrNone(r);
|
0
|
389 |
|
|
390 |
r=TheFs.RmDir(mkdirname);
|
189
|
391 |
test_KErrNone(r);
|
0
|
392 |
|
|
393 |
r=TheFs.SetSubst(theprivatepath,EDriveO);
|
189
|
394 |
test_KErrNone(r);
|
0
|
395 |
|
|
396 |
r=TheFs.RealName(_L("O:\\File.XXX"),realName);
|
189
|
397 |
test_KErrNone(r);
|
0
|
398 |
|
|
399 |
r=TheFs.SetSubst(_L(""),EDriveO);
|
189
|
400 |
test_KErrNone(r);
|
0
|
401 |
|
|
402 |
r=TheFs.SetSessionPath(theprivatepath);
|
189
|
403 |
test_KErrNone(r);
|
0
|
404 |
|
|
405 |
TheFs.NotifyChange(ENotifyAll,aStat3,theprivatepath);
|
|
406 |
test(aStat3==KRequestPending);
|
|
407 |
|
|
408 |
pritestfile=theprivatepath;
|
|
409 |
pritestfile[0]=(TText)('A' + gTheDriveNum);
|
|
410 |
pritestfile1=pritestfile;
|
|
411 |
pritestfile.Append(KFilePri2);
|
|
412 |
pritestfile1.Append(KFilePri3);
|
|
413 |
|
|
414 |
oldName=KOldFile;
|
|
415 |
oldName[0]=(TText)gDriveToTest;
|
|
416 |
|
|
417 |
r=TheFs.GetShortName(pritestfile, shortfilename);
|
189
|
418 |
test_Value(r, r == KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
0
|
419 |
|
|
420 |
r=TheFs.GetLongName(pritestfile1, longfilename);
|
189
|
421 |
test_Value(r, r == KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
0
|
422 |
|
|
423 |
r=file1.Create(TheFs,oldName,EFileWrite);
|
189
|
424 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists);
|
0
|
425 |
file1.Close();
|
|
426 |
|
|
427 |
r=TheFs.Replace(oldName,pritestfile);
|
189
|
428 |
test_KErrNone(r);
|
0
|
429 |
|
|
430 |
r=TheFs.Rename(pritestfile,pritestfile1);
|
189
|
431 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists);
|
0
|
432 |
|
|
433 |
r=TheFs.Entry(pritestfile1,entry);
|
189
|
434 |
test_KErrNone(r);
|
0
|
435 |
|
|
436 |
r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
|
189
|
437 |
test_KErrNone(r);
|
0
|
438 |
|
|
439 |
r=TheFs.Delete(pritestfile1);
|
189
|
440 |
test_KErrNone(r);
|
0
|
441 |
}
|
|
442 |
|
|
443 |
|
|
444 |
LOCAL_C void systemRFiletest()
|
|
445 |
//
|
|
446 |
//RFile testing with session path set to //system//
|
|
447 |
//
|
|
448 |
{
|
|
449 |
|
|
450 |
r=TheFs.SetSessionPath(systestname);
|
189
|
451 |
test_KErrNone(r);
|
0
|
452 |
|
|
453 |
r=file1.Temp(TheFs,systestname,fromTemp,EFileWrite);
|
189
|
454 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
455 |
file1.Close();
|
|
456 |
|
|
457 |
systestfile=systestname;
|
|
458 |
systestfile.Append(KFileSys);
|
|
459 |
r=file1.Create(TheFs,systestfile,EFileWrite);
|
189
|
460 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
461 |
file1.Close();
|
|
462 |
|
|
463 |
r=file1.Open(TheFs,systestfile,EFileWrite);
|
189
|
464 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
465 |
|
|
466 |
r=file1.Open(TheFs,systestfile,EFileRead);
|
189
|
467 |
test_Value(r, r == KErrNone|| r==KErrNotFound);
|
0
|
468 |
|
|
469 |
r=file1.Replace(TheFs,systestfile,EFileWrite);
|
189
|
470 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
471 |
|
|
472 |
TFindFile finder(TheFs);
|
|
473 |
CDir* dir = NULL;
|
|
474 |
r=finder.FindWildByDir(KWildFile, KWildPath, dir);
|
|
475 |
if (!(r==KErrNone))
|
|
476 |
test.Printf(_L("T_DCDISKADMINALLFILES: test find wildcards r = %d (expected KErrNone)\n"), r);
|
189
|
477 |
test_KErrNone(r);
|
0
|
478 |
delete dir;
|
|
479 |
}
|
|
480 |
|
|
481 |
LOCAL_C void resourceRFiletest()
|
|
482 |
//
|
|
483 |
//RFile testing with session path set to //resource//
|
|
484 |
//
|
|
485 |
{
|
|
486 |
r=TheFs.SetSessionPath(restestname);
|
189
|
487 |
test_KErrNone(r);
|
0
|
488 |
|
|
489 |
r=file1.Temp(TheFs,restestname,fromTemp,EFileWrite);
|
189
|
490 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
491 |
file1.Close();
|
|
492 |
|
|
493 |
r=file1.Create(TheFs,KFileRes,EFileWrite);
|
189
|
494 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
495 |
file1.Close();
|
|
496 |
|
|
497 |
r=file1.Open(TheFs,KFileRes,EFileWrite|EFileShareExclusive );
|
189
|
498 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
499 |
|
|
500 |
r=file1.Open(TheFs,KFileRes,EFileShareReadersOnly);
|
189
|
501 |
test_Value(r, r == KErrNone || r == KErrPathNotFound || r == KErrNotFound);
|
0
|
502 |
file1.Close();
|
|
503 |
|
|
504 |
r=file1.Open(TheFs,KFileRes,EFileShareReadersOrWriters|EFileRead);
|
189
|
505 |
test_Value(r, r == KErrNone || r == KErrPathNotFound || r == KErrNotFound);
|
0
|
506 |
file1.Close();
|
|
507 |
|
|
508 |
r=file1.Open(TheFs,KFileRes,EFileShareReadersOrWriters|EFileWrite);
|
189
|
509 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
510 |
file1.Close();
|
|
511 |
|
|
512 |
r=file1.Replace(TheFs,KFileRes3,EFileWrite);
|
189
|
513 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
514 |
file1.Close();
|
|
515 |
}
|
|
516 |
|
|
517 |
|
|
518 |
LOCAL_C void privatefalseIDRFiletest()
|
|
519 |
//
|
|
520 |
//RFile testing with session path set to //Private//false ID
|
|
521 |
//
|
|
522 |
{
|
|
523 |
r=TheFs.SetSessionPath(pritestfalseidname);
|
189
|
524 |
test_KErrNone(r);
|
0
|
525 |
|
|
526 |
r=file1.Temp(TheFs,pritestfalseidname,fromTemp,EFileWrite);
|
189
|
527 |
test_KErrNone(r);
|
0
|
528 |
file1.Close();
|
|
529 |
|
|
530 |
r=file1.Create(TheFs,KFilePri,EFileWrite);
|
189
|
531 |
test_KErrNone(r);
|
0
|
532 |
file1.Close();
|
|
533 |
|
|
534 |
r=file1.Open(TheFs,KFilePri,EFileWrite);
|
189
|
535 |
test_KErrNone(r);
|
0
|
536 |
file1.Close();
|
|
537 |
|
|
538 |
r=file1.Open(TheFs,KFilePri,EFileRead);
|
189
|
539 |
test_KErrNone(r);
|
0
|
540 |
file1.Close();
|
|
541 |
|
|
542 |
r=file1.Replace(TheFs,KFilePri,EFileWrite);
|
189
|
543 |
test_KErrNone(r);
|
0
|
544 |
|
|
545 |
r=file1.Rename(KFilePri3);
|
189
|
546 |
test_KErrNone(r);
|
0
|
547 |
file1.Close();
|
|
548 |
}
|
|
549 |
|
|
550 |
|
|
551 |
LOCAL_C void privateRFiletest()
|
|
552 |
//
|
|
553 |
//RFile testing with session path set to //Private//
|
|
554 |
//
|
|
555 |
{
|
|
556 |
r=TheFs.SetSessionPath(pritestname);
|
189
|
557 |
test_KErrNone(r);
|
0
|
558 |
|
|
559 |
r=file1.Temp(TheFs,pritestname,fromTemp,EFileWrite);
|
189
|
560 |
test_KErrNone(r);
|
0
|
561 |
file1.Close();
|
|
562 |
|
|
563 |
r=file1.Create(TheFs,KFilePri,EFileWrite);
|
189
|
564 |
test_KErrNone(r);
|
0
|
565 |
file1.Close();
|
|
566 |
|
|
567 |
r=file1.Open(TheFs,KFilePri,EFileWrite);
|
189
|
568 |
test_KErrNone(r);
|
0
|
569 |
file1.Close();
|
|
570 |
|
|
571 |
r=file1.Open(TheFs,KFilePri,EFileRead);
|
189
|
572 |
test_KErrNone(r);
|
0
|
573 |
file1.Close();
|
|
574 |
|
|
575 |
r=file1.Replace(TheFs,KFilePri,EFileWrite);
|
189
|
576 |
test_KErrNone(r);
|
0
|
577 |
|
|
578 |
r=file1.Rename(KFilePri3);
|
189
|
579 |
test_KErrNone(r);
|
0
|
580 |
file1.Close();
|
|
581 |
}
|
|
582 |
|
|
583 |
|
|
584 |
LOCAL_C void privateSIDRFiletest()
|
|
585 |
//
|
|
586 |
//Rfile Testing with session path set to //Private//UID//
|
|
587 |
//
|
|
588 |
{
|
|
589 |
r=TheFs.SetSessionToPrivate(gTheDriveNum);
|
189
|
590 |
test_KErrNone(r);
|
0
|
591 |
|
|
592 |
r=file1.Temp(TheFs,theprivatepath,fromTemp,EFileWrite);
|
189
|
593 |
test_KErrNone(r);
|
0
|
594 |
file1.Close();
|
|
595 |
|
|
596 |
r=file1.Create(TheFs,KFilePri,EFileWrite);
|
189
|
597 |
test_KErrNone(r);
|
0
|
598 |
file1.Close();
|
|
599 |
|
|
600 |
r=file1.Open(TheFs,KFilePri,EFileWrite);
|
189
|
601 |
test_KErrNone(r);
|
0
|
602 |
file1.Close();
|
|
603 |
|
|
604 |
r=file1.Open(TheFs,KFilePri,EFileRead);
|
189
|
605 |
test_KErrNone(r);
|
0
|
606 |
file1.Close();
|
|
607 |
|
|
608 |
|
|
609 |
r=file1.Replace(TheFs,KFilePri,EFileWrite);
|
189
|
610 |
test_KErrNone(r);
|
0
|
611 |
|
|
612 |
r=file1.Rename(KFilePri3);
|
189
|
613 |
test_KErrNone(r);
|
0
|
614 |
file1.Close();
|
|
615 |
}
|
|
616 |
|
|
617 |
LOCAL_C void RDirtest()
|
|
618 |
//
|
|
619 |
//
|
|
620 |
//
|
|
621 |
{
|
|
622 |
|
|
623 |
//system
|
|
624 |
CDir* dirEntries;
|
|
625 |
TBuf<30> dirNameBuf(KSystemPath);
|
|
626 |
dirNameBuf[0]=(TText)gDriveToTest;
|
|
627 |
r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
|
189
|
628 |
test_Value(r, r == KErrNone || r==KErrPathNotFound || r==KErrNotFound);
|
0
|
629 |
dir.Close();
|
|
630 |
if(r==KErrNone)
|
|
631 |
{
|
|
632 |
r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
|
189
|
633 |
test_KErrNone(r);
|
0
|
634 |
delete dirEntries;
|
|
635 |
}
|
|
636 |
dirNameBuf.Zero();
|
|
637 |
//Private//falseID
|
|
638 |
dirNameBuf=KPrivateFalseID;
|
|
639 |
dirNameBuf[0]=(TText)gDriveToTest;
|
|
640 |
r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
|
189
|
641 |
test_KErrNone(r);
|
0
|
642 |
dir.Close();
|
|
643 |
r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
|
189
|
644 |
test_KErrNone(r);
|
0
|
645 |
dirNameBuf.Zero();
|
|
646 |
delete dirEntries;
|
|
647 |
//Private
|
|
648 |
dirNameBuf=KPrivatePath;
|
|
649 |
dirNameBuf[0]=(TText)gDriveToTest;
|
|
650 |
r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
|
189
|
651 |
test_KErrNone(r);
|
0
|
652 |
dir.Close();
|
|
653 |
r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
|
189
|
654 |
test_KErrNone(r);
|
0
|
655 |
dirNameBuf.Zero();
|
|
656 |
delete dirEntries;
|
|
657 |
//Private/uid
|
|
658 |
TheFs.PrivatePath(dirNameBuf);
|
|
659 |
dirNameBuf.Insert(0,_L("?:"));
|
|
660 |
dirNameBuf[0]=(TText)gDriveToTest;
|
|
661 |
r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
|
189
|
662 |
test_KErrNone(r);
|
0
|
663 |
dir.Close();
|
|
664 |
r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
|
189
|
665 |
test_KErrNone(r);
|
0
|
666 |
dirNameBuf.Zero();
|
|
667 |
delete dirEntries;
|
|
668 |
//Resource
|
|
669 |
dirNameBuf=KResourcePath;
|
|
670 |
dirNameBuf[0]=(TText)gDriveToTest;
|
|
671 |
r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
|
189
|
672 |
test_Value(r, r == KErrNone || r==KErrPathNotFound);
|
0
|
673 |
if(r==KErrNone)
|
|
674 |
{
|
|
675 |
r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
|
189
|
676 |
test_KErrNone(r);
|
0
|
677 |
dir.Close();
|
|
678 |
delete dirEntries;
|
|
679 |
}
|
|
680 |
}
|
|
681 |
|
|
682 |
|
|
683 |
LOCAL_C void TestDiskAdminAllfiles()
|
|
684 |
//
|
|
685 |
// Test with root capabilities
|
|
686 |
//
|
|
687 |
{
|
|
688 |
r=TheFs.FileSystemName(fsname,gTheDriveNum);
|
189
|
689 |
test_KErrNone(r);
|
0
|
690 |
r = DismountFileSystem(TheFs, fsname, gTheDriveNum);
|
189
|
691 |
test_KErrNone(r);
|
0
|
692 |
// r=TheFs.RemoveFileSystem(fsname); //can not test due to bug else where fix exists
|
189
|
693 |
// test_KErrNone(r);
|
0
|
694 |
// r=TheFs.AddFileSystem(fsname);
|
189
|
695 |
// test_KErrNone(r);
|
0
|
696 |
r = MountFileSystem(TheFs, fsname, gTheDriveNum);
|
189
|
697 |
test_KErrNone(r);
|
0
|
698 |
r=TheFs.SetDriveName(gTheDriveNum,KDriveName);
|
189
|
699 |
test_KErrNone(r);
|
0
|
700 |
#ifndef __WINS__
|
|
701 |
r=TheFs.SetVolumeLabel(KVolLable, gTheDriveNum);
|
189
|
702 |
test_KErrNone(r);
|
0
|
703 |
#endif
|
|
704 |
|
|
705 |
systemRFsTest();
|
|
706 |
ResourceRFsTest();
|
|
707 |
privateRFsTest();
|
|
708 |
privateSIDRFstest();
|
|
709 |
privatefalseIDRFsTest();
|
|
710 |
|
|
711 |
systemRFiletest();
|
|
712 |
resourceRFiletest();
|
|
713 |
privateRFiletest();
|
|
714 |
privateSIDRFiletest();
|
|
715 |
privatefalseIDRFiletest();
|
|
716 |
|
|
717 |
//check notifier return values set in rfs testing
|
|
718 |
//User::WaitForRequest(aStat1);
|
|
719 |
User::WaitForRequest(aStat2);
|
|
720 |
User::WaitForRequest(aStat3);
|
|
721 |
//User::WaitForRequest(aStat4);
|
|
722 |
test(aStat2==KErrNone);
|
|
723 |
test(aStat3==KErrNone);
|
|
724 |
|
|
725 |
test(aStat1 == KRequestPending);
|
|
726 |
TheFs.NotifyChangeCancel(aStat1);
|
|
727 |
test(aStat1==KErrCancel);
|
|
728 |
|
|
729 |
test(aStat4 == KRequestPending);
|
|
730 |
TheFs.NotifyChangeCancel(aStat4);
|
|
731 |
test(aStat4==KErrCancel);
|
|
732 |
|
|
733 |
r=TheFs.SetSessionPath(systestname);
|
189
|
734 |
test_KErrNone(r);
|
0
|
735 |
|
|
736 |
//Test RRawDisk class
|
|
737 |
r=rawdisk.Open(TheFs,gTheDriveNum);
|
189
|
738 |
test_Value(r, r == KErrPermissionDenied);
|
0
|
739 |
rawdisk.Close();
|
|
740 |
|
|
741 |
RDirtest();
|
|
742 |
|
|
743 |
#ifdef __WINS__
|
|
744 |
if (User::UpperCase(driveBuf[0]) != 'C')
|
|
745 |
#endif
|
|
746 |
{
|
|
747 |
//Test RFormat class
|
|
748 |
r=format.Open(TheFs,driveBuf,EHighDensity,count);
|
189
|
749 |
test_KErrNone(r);
|
0
|
750 |
while(count)
|
|
751 |
{
|
|
752 |
TInt r=format.Next(count);
|
189
|
753 |
test_KErrNone(r);
|
0
|
754 |
}
|
|
755 |
format.Close();
|
|
756 |
}
|
|
757 |
|
|
758 |
driveBuf[0]=(TText)gDriveToTest;
|
|
759 |
r=TheFs.ScanDrive(driveBuf);
|
189
|
760 |
test_Value(r, r == KErrNone || r==KErrNotSupported || r == KErrInUse);
|
0
|
761 |
r=TheFs.CheckDisk(driveBuf);
|
189
|
762 |
test_Value(r, r == KErrNone || r==KErrNotSupported || r == KErrInUse);
|
0
|
763 |
}
|
|
764 |
|
|
765 |
LOCAL_C void TestCaps()
|
|
766 |
//
|
|
767 |
// test format etc that require certain capabilities
|
|
768 |
//
|
|
769 |
{
|
|
770 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
|
|
771 |
const char myDiagMsg[] = "Capability Check Failure";
|
|
772 |
#endif //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
|
|
773 |
r=RProcess().HasCapability(ECapabilityAllFiles, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg));
|
|
774 |
test(r);
|
|
775 |
r=RProcess().HasCapability(ECapabilityDiskAdmin, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg));
|
|
776 |
test(r);
|
|
777 |
|
|
778 |
driveBuf[0]=(TText)gDriveToTest;
|
|
779 |
r=TheFs.SessionPath(temp);
|
189
|
780 |
test_KErrNone(r);
|
0
|
781 |
|
|
782 |
test.Printf(_L("Session path: %S"),&temp);
|
|
783 |
|
|
784 |
r=TheFs.CreatePrivatePath(gTheDriveNum);
|
189
|
785 |
test_Value(r, r == KErrNone || r== KErrAlreadyExists);
|
0
|
786 |
|
|
787 |
TBuf<18> tempPri;
|
|
788 |
r=TheFs.PrivatePath(tempPri);
|
189
|
789 |
test_KErrNone(r);
|
0
|
790 |
theprivatepath = _L("?:");
|
|
791 |
theprivatepath.Append(tempPri);
|
|
792 |
|
|
793 |
TestDiskAdminAllfiles();
|
|
794 |
|
|
795 |
TFileName thesessionpath;
|
|
796 |
r=TheFs.SetSessionToPrivate(gTheDriveNum);
|
189
|
797 |
test_KErrNone(r);
|
0
|
798 |
r=TheFs.SessionPath(thesessionpath);
|
189
|
799 |
test_KErrNone(r);
|
0
|
800 |
test(thesessionpath == theprivatepath);
|
|
801 |
}
|
|
802 |
|
|
803 |
|
|
804 |
LOCAL_C void CleanupL()
|
|
805 |
//
|
|
806 |
// Clean up tests
|
|
807 |
//
|
|
808 |
{
|
|
809 |
test.Next(_L("Delete test directory"));
|
|
810 |
CFileMan* fMan=CFileMan::NewL(TheFs);
|
|
811 |
TInt r=fMan->RmDir(gSessionPath);
|
189
|
812 |
test_Value(r, r == KErrNone || r == KErrPathNotFound);
|
0
|
813 |
delete fMan;
|
|
814 |
}
|
|
815 |
|
|
816 |
GLDEF_C void CallTestsL(/*TChar aDriveLetter*/)
|
|
817 |
//
|
|
818 |
// Do all tests
|
|
819 |
//
|
|
820 |
{
|
|
821 |
if( !PlatSec::IsCapabilityEnforced(ECapabilityAllFiles) ||
|
|
822 |
!PlatSec::IsCapabilityEnforced(ECapabilityDiskAdmin))
|
|
823 |
{
|
|
824 |
test.Printf(_L("Capabilities insufficient - leaving t_dcdiskadminallfiles"));
|
|
825 |
test.Printf(_L("\n")); // Prevent overwrite by next print
|
|
826 |
return;
|
|
827 |
}
|
|
828 |
TurnAllocFailureOff();
|
|
829 |
TheFs.CharToDrive(gDriveToTest,gTheDriveNum);
|
|
830 |
|
|
831 |
TBuf<30> sesspath;
|
|
832 |
sesspath=_L("?:\\");
|
|
833 |
sesspath[0] = (TText)gDriveToTest;
|
|
834 |
|
|
835 |
TInt r= TheFs.SetSessionPath(sesspath);
|
189
|
836 |
test_KErrNone(r);
|
0
|
837 |
|
|
838 |
TBuf<2> cmd;
|
|
839 |
cmd.SetLength(1);
|
|
840 |
cmd[0] = (TText)gDriveToTest;
|
|
841 |
RProcess tp;
|
|
842 |
r=tp.Create(_L("clean_prepdc.exe"),sesspath);
|
189
|
843 |
test_KErrNone(r);
|
0
|
844 |
{
|
|
845 |
TRequestStatus ps;
|
|
846 |
tp.Logon(ps);
|
|
847 |
tp.Resume();
|
|
848 |
tp.Close();
|
|
849 |
User::WaitForRequest(ps);
|
|
850 |
}
|
|
851 |
|
|
852 |
//check double mode ie that Defpath still works
|
|
853 |
RFs fs1;
|
|
854 |
RFs fs2;
|
|
855 |
|
|
856 |
r=fs1.Connect();
|
189
|
857 |
test_KErrNone(r);
|
0
|
858 |
r=fs1.SessionPath(sesspath);
|
189
|
859 |
test_KErrNone(r);
|
0
|
860 |
test.Printf(_L("session1 Path=%S"),&sesspath);
|
|
861 |
|
|
862 |
TBuf<30> privatepath;
|
|
863 |
r=fs1.SetSessionToPrivate(gTheDriveNum);
|
189
|
864 |
test_KErrNone(r);
|
0
|
865 |
r=fs1.PrivatePath(privatepath);
|
189
|
866 |
test_KErrNone(r);
|
0
|
867 |
r=privatepath.Compare(KExpectedPrivatePath());
|
189
|
868 |
test_Value(r, r == 0);
|
0
|
869 |
r=fs1.SessionPath(sesspath);
|
189
|
870 |
test_KErrNone(r);
|
0
|
871 |
r=privatepath.Compare(sesspath.Mid(KPathPosition));
|
189
|
872 |
test_Value(r, r == 0);
|
0
|
873 |
r=fs1.CreatePrivatePath(gTheDriveNum);
|
189
|
874 |
test_KErrNone(r);
|
0
|
875 |
fs1.Close();
|
|
876 |
|
|
877 |
r=fs2.Connect();
|
189
|
878 |
test_KErrNone(r);
|
0
|
879 |
r=fs2.SessionPath(sesspath);
|
189
|
880 |
test_KErrNone(r);
|
0
|
881 |
test.Printf(_L("session2 Path=%S"),&sesspath);
|
|
882 |
fs2.Close();
|
|
883 |
|
|
884 |
TestCaps();
|
|
885 |
|
|
886 |
test.Printf(_L("No of files open=%d"), TheFs.ResourceCount());
|
|
887 |
|
|
888 |
CleanupL();
|
|
889 |
}
|