author | Mike Kinghan <mikek@symbian.org> |
Mon, 19 Jul 2010 08:40:05 +0100 | |
branch | GCC_SURGE |
changeset 209 | 6035754ebf88 |
parent 109 | b3a1d9898418 |
child 200 | 73ea206103e6 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2002-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\ext\t_ext1.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
18 |
#define __E32TEST_EXTENSION__ |
0 | 19 |
#include <f32file.h> |
20 |
#include <e32test.h> |
|
21 |
#include <e32svr.h> |
|
22 |
#include "t_server.h" |
|
23 |
#include "f32_test_utils.h" |
|
24 |
||
25 |
using namespace F32_Test_Utils; |
|
26 |
||
27 |
||
28 |
GLDEF_D RTest test(_L("T_EXT1")); |
|
29 |
||
30 |
_LIT(KExtensionLog,"T_LOGEXT"); |
|
31 |
_LIT(KExtensionLogName,"Logger"); |
|
32 |
_LIT(KExtensionEmpty,"T_EMPTYEXT"); |
|
33 |
_LIT(KExtensionEmptyName,"Empty"); |
|
34 |
_LIT(KExtensionBit,"T_BITEXT"); |
|
35 |
_LIT(KExtensionBitName,"Bitchange"); |
|
36 |
_LIT(KExtensionRubbish,"T_RUBBISH"); |
|
37 |
_LIT(dir1,"\\dir1\\"); |
|
38 |
_LIT(file1Name,"\\dir1\\file1.doc"); |
|
39 |
_LIT8(toWrite,"abcdefghijklmnop"); |
|
40 |
||
41 |
void TestSecondaryExtensions() |
|
42 |
// |
|
43 |
// a secondary extension is one that is added to a drive with an existing file system |
|
44 |
// therefore a mount is successful with or without the extension |
|
45 |
// |
|
46 |
{ |
|
47 |
test.Next(_L("TestSecondaryExtensions()")); |
|
48 |
TInt drive; |
|
49 |
TInt err=RFs::CharToDrive(gDriveToTest,drive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
50 |
test_KErrNone(err); |
0 | 51 |
|
52 |
TPckgBuf<TBool> drvSyncBuf; |
|
53 |
err = TheFs.QueryVolumeInfoExt(drive, EIsDriveSync, drvSyncBuf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
54 |
test_KErrNone(err); |
0 | 55 |
const TBool bDrvSync = drvSyncBuf(); |
56 |
||
57 |
||
58 |
TFullName fsName; |
|
59 |
TInt r=TheFs.FileSystemName(fsName,drive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
60 |
test_KErrNone(r); |
0 | 61 |
test.Printf(_L("fsName=%S\n"),&fsName); |
62 |
||
63 |
#if defined(__WINS__) |
|
64 |
if(drive==EDriveC) |
|
65 |
{ |
|
66 |
// check that the extension cannot be mounted since not supported by the file system |
|
67 |
r=TheFs.AddExtension(KExtensionLog); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
68 |
test_KErrNone(r); |
0 | 69 |
r=TheFs.MountExtension(KExtensionLogName,drive); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
70 |
test_Value(r, r == KErrNotSupported); |
0 | 71 |
r=TheFs.RemoveExtension(KExtensionLogName); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
72 |
test_KErrNone(r); |
0 | 73 |
return; |
74 |
} |
|
75 |
#endif |
|
76 |
||
77 |
test.Next(_L("RFs::AddExtension()")); |
|
78 |
r=TheFs.AddExtension(KExtensionLog); |
|
79 |
RDebug::Print(_L("addext=%d"),r); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
80 |
test_KErrNone(r); |
0 | 81 |
r=TheFs.AddExtension(KExtensionLog); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
82 |
test_Value(r, r == KErrAlreadyExists); |
0 | 83 |
r=TheFs.AddExtension(KExtensionRubbish); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
84 |
test_Value(r, r == KErrNotFound); |
0 | 85 |
r=TheFs.AddExtension(KExtensionEmpty); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
86 |
test_KErrNone(r); |
0 | 87 |
|
88 |
test.Next(_L("RFs::MountExtension()")); |
|
89 |
#if !defined(__WINS__) |
|
90 |
// check that the extension cannot be mounted on file system that does not support extensions |
|
91 |
r=TheFs.MountExtension(KExtensionLogName,EDriveZ); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
92 |
test_Value(r, r == KErrNotSupported); |
0 | 93 |
#endif |
94 |
// test mounting on drive with no file system |
|
95 |
r=TheFs.DismountFileSystem(fsName,drive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
96 |
test_KErrNone(r); |
0 | 97 |
r=TheFs.MountExtension(KExtensionLogName,drive); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
98 |
test_Value(r, r == KErrNotReady); |
0 | 99 |
r=TheFs.MountFileSystem(fsName,drive,bDrvSync); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
100 |
test_KErrNone(r); |
0 | 101 |
// test with a resource open |
102 |
_LIT(KFileName,"testing.doc"); |
|
103 |
RFile file; |
|
104 |
r=file.Replace(TheFs,KFileName,EFileShareExclusive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
105 |
test_KErrNone(r); |
0 | 106 |
r=TheFs.MountExtension(KExtensionLogName,drive); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
107 |
test_Value(r, r == KErrInUse); |
0 | 108 |
file.Close(); |
109 |
r=TheFs.Delete(KFileName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
110 |
test_KErrNone(r); |
0 | 111 |
// test with a format open |
112 |
TBuf<4> driveBuf=_L("?:\\"); |
|
113 |
driveBuf[0]=(TText)(drive+'A'); |
|
114 |
RFormat format; |
|
115 |
TInt count; |
|
116 |
r=format.Open(TheFs,driveBuf,EHighDensity,count); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
117 |
test_KErrNone(r); |
0 | 118 |
r=TheFs.MountExtension(KExtensionLogName,drive); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
119 |
test_Value(r, r == KErrInUse); |
0 | 120 |
format.Close(); |
121 |
// get the extension name |
|
122 |
TFullName extName; |
|
123 |
r=TheFs.ExtensionName(extName,drive,0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
124 |
test_Value(r, r == KErrNotFound); |
0 | 125 |
// now load the extension |
126 |
r=TheFs.MountExtension(KExtensionLogName,drive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
127 |
test_KErrNone(r); |
0 | 128 |
r=TheFs.ExtensionName(extName,drive,0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
129 |
test_Value(r, r == KErrNone && extName==KExtensionLogName); |
0 | 130 |
r=TheFs.ExtensionName(extName,drive,1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
131 |
test_Value(r, r == KErrNotFound); |
0 | 132 |
// try remounting the same extension |
133 |
r=TheFs.MountExtension(KExtensionLogName,drive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
134 |
test_Value(r, r == KErrAlreadyExists); |
0 | 135 |
// mount a second extension |
136 |
r=TheFs.MountExtension(KExtensionEmptyName,drive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
137 |
test_KErrNone(r); |
0 | 138 |
r=TheFs.ExtensionName(extName,drive,0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
139 |
test_Value(r, r == KErrNone && extName==KExtensionLogName); |
0 | 140 |
r=TheFs.ExtensionName(extName,drive,1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
141 |
test_Value(r, r == KErrNone && extName==KExtensionEmptyName); |
0 | 142 |
|
143 |
// force a remount on a removable media and check that extensions both exist |
|
144 |
test.Printf(_L("Test forcing remount\n")); |
|
145 |
TDriveInfo info; |
|
146 |
r=TheFs.Drive(info,drive); |
|
147 |
if(info.iDriveAtt&KDriveAttRemovable) |
|
148 |
{ |
|
149 |
const TInt KMediaRemountForceMediaChange = 0x00000001; |
|
150 |
||
151 |
||
152 |
TRequestStatus changeStatus; |
|
153 |
TheFs.NotifyChange(ENotifyAll, changeStatus); |
|
154 |
||
155 |
test.Printf(_L("Remounting the drive\n"), r); |
|
156 |
r = TheFs.RemountDrive(drive, NULL, (TUint) KMediaRemountForceMediaChange); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
157 |
test_Value(r, r == KErrNotReady || r == KErrNone); |
0 | 158 |
|
159 |
do |
|
160 |
{ |
|
161 |
test.Printf(_L("Waiting for media change...\n")); |
|
162 |
User::WaitForRequest(changeStatus); |
|
163 |
||
164 |
r=TheFs.Drive(info,drive); |
|
165 |
test.Printf(_L("Drive() returned %d\n"), r); |
|
166 |
||
167 |
TheFs.NotifyChange(ENotifyAll, changeStatus); |
|
168 |
} |
|
169 |
while (r == KErrNotReady); |
|
170 |
TheFs.NotifyChangeCancel(changeStatus); |
|
171 |
||
172 |
User::After(1000000); //-- don't know why we need this, otherwise for WINS mediadriver returns -18 |
|
173 |
||
174 |
||
175 |
||
176 |
/* |
|
177 |
//-- strange, but this variant caused Media Driver to always return -18 |
|
178 |
//-- and the media have become inaccessible forever (on H2). |
|
179 |
//-- funny enough, but turning ON heavy logging from the drivers (PBUS & KLOCDRV) helped the problem |
|
180 |
||
181 |
test.Printf(_L("Force media change\n")); |
|
182 |
RLocalDrive d; |
|
183 |
TBool flag=EFalse; |
|
184 |
r=d.Connect(1,flag); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
185 |
test_KErrNone(r); |
0 | 186 |
d.ForceMediaChange(); |
187 |
d.Close(); |
|
188 |
//#if defined(__WINS__) |
|
189 |
// ??? seems to work, find out why |
|
190 |
//User::After(500000); |
|
191 |
User::After(2000000); |
|
192 |
//#endif |
|
193 |
*/ |
|
194 |
} |
|
195 |
||
196 |
||
197 |
||
198 |
r=TheFs.ExtensionName(extName,drive,0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
199 |
test_Value(r, r == KErrNone && extName==KExtensionLogName); |
0 | 200 |
r=TheFs.ExtensionName(extName,drive,1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
201 |
test_Value(r, r == KErrNone && extName==KExtensionEmptyName); |
0 | 202 |
|
203 |
test.Printf(_L("Accessing media...\n")); |
|
204 |
// and now do some file system operations |
|
205 |
TBuf8<16> readBuf; |
|
206 |
r=TheFs.MkDir(dir1); |
|
207 |
||
208 |
test.Printf(_L("res=%d\n"), r); |
|
209 |
||
210 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
211 |
test_Value(r, r == KErrNone||r==KErrAlreadyExists); |
0 | 212 |
RFile file1; |
213 |
r=file1.Replace(TheFs,file1Name,EFileShareExclusive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
214 |
test_KErrNone(r); |
0 | 215 |
r=file1.Write(toWrite); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
216 |
test_KErrNone(r); |
0 | 217 |
r=file1.Read(0,readBuf); |
218 |
test(readBuf==toWrite); |
|
219 |
r=file1.SetSize(0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
220 |
test_KErrNone(r); |
0 | 221 |
file1.Close(); |
222 |
r=TheFs.Delete(file1Name); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
223 |
test_KErrNone(r); |
0 | 224 |
r=TheFs.RmDir(dir1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
225 |
test_KErrNone(r); |
0 | 226 |
|
227 |
test.Next(_L("RFs::DismountExtension()")); |
|
228 |
// test with a resource open |
|
229 |
r=file.Replace(TheFs,KFileName,EFileShareExclusive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
230 |
test_KErrNone(r); |
0 | 231 |
r=TheFs.DismountExtension(KExtensionLogName,drive); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
232 |
test_Value(r, r == KErrInUse); |
0 | 233 |
file.Close(); |
234 |
r=TheFs.Delete(KFileName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
235 |
test_KErrNone(r); |
0 | 236 |
// test with a format open |
237 |
r=format.Open(TheFs,driveBuf,EHighDensity,count); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
238 |
test_KErrNone(r); |
0 | 239 |
r=TheFs.DismountExtension(KExtensionLogName,drive); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
240 |
test_Value(r, r == KErrInUse); |
0 | 241 |
format.Close(); |
242 |
// now dismount an extension |
|
243 |
r=TheFs.DismountExtension(KExtensionLogName,drive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
244 |
test_KErrNone(r); |
0 | 245 |
r=TheFs.ExtensionName(extName,drive,0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
246 |
test_Value(r, r == KErrNone && extName==KExtensionEmptyName); |
0 | 247 |
r=TheFs.ExtensionName(extName,drive,1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
248 |
test_Value(r, r == KErrNotFound); |
0 | 249 |
// try to dismount an extension that is not mounted |
250 |
r=TheFs.DismountExtension(KExtensionLogName,drive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
251 |
test_Value(r, r == KErrNotFound); |
0 | 252 |
r=TheFs.ExtensionName(extName,drive,0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
253 |
test_Value(r, r == KErrNone && extName==KExtensionEmptyName); |
0 | 254 |
r=TheFs.ExtensionName(extName,drive,1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
255 |
test_Value(r, r == KErrNotFound); |
0 | 256 |
// dismount the remaining extension |
257 |
r=TheFs.DismountExtension(KExtensionEmptyName,drive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
258 |
test_KErrNone(r); |
0 | 259 |
r=TheFs.ExtensionName(extName,drive,0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
260 |
test_Value(r, r == KErrNotFound); |
0 | 261 |
r=TheFs.ExtensionName(extName,drive,1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
262 |
test_Value(r, r == KErrNotFound); |
0 | 263 |
|
264 |
test.Next(_L("RFs::RemoveExtension()")); |
|
265 |
r=TheFs.RemoveExtension(KExtensionLogName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
266 |
test_KErrNone(r); |
0 | 267 |
r=TheFs.RemoveExtension(KExtensionEmptyName); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
268 |
test_KErrNone(r); |
0 | 269 |
} |
270 |
||
271 |
void TestPrimaryExtensions() |
|
272 |
// |
|
273 |
// a primary extension is one that is added to a drive before a file system is mounted |
|
274 |
// must be present for the mount to be successful (eg. FTL) |
|
275 |
// |
|
276 |
{ |
|
277 |
test.Next(_L("TestPrimaryExtensions()")); |
|
278 |
TInt drive; |
|
279 |
TInt err=RFs::CharToDrive(gDriveToTest,drive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
280 |
test_KErrNone(err); |
0 | 281 |
|
282 |
#if defined(__WINS__) |
|
283 |
if(drive==EDriveC) |
|
284 |
return; |
|
285 |
#endif |
|
286 |
||
287 |
TPckgBuf<TBool> drvSyncBuf; |
|
288 |
err = TheFs.QueryVolumeInfoExt(drive, EIsDriveSync, drvSyncBuf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
289 |
test_KErrNone(err); |
0 | 290 |
const TBool bDrvSync = drvSyncBuf(); |
291 |
||
292 |
// don't test on ram drive since accesses memory directly |
|
293 |
TDriveInfo info; |
|
294 |
TInt r=TheFs.Drive(info,drive); |
|
295 |
if(info.iMediaAtt&KMediaAttVariableSize) |
|
296 |
return; |
|
297 |
||
298 |
TFullName fsName; |
|
299 |
r=TheFs.FileSystemName(fsName,drive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
300 |
test_KErrNone(r); |
0 | 301 |
test.Printf(_L("fsName=%S\n"),&fsName); |
302 |
||
303 |
test.Next(_L("RFs::AddExtension()")); |
|
304 |
r=TheFs.AddExtension(KExtensionLog); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
305 |
test_KErrNone(r); |
0 | 306 |
r=TheFs.AddExtension(KExtensionEmpty); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
307 |
test_KErrNone(r); |
0 | 308 |
r=TheFs.AddExtension(KExtensionBit); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
309 |
test_KErrNone(r); |
0 | 310 |
|
311 |
test.Next(_L("RFs::MountFileSystem()")); |
|
312 |
// test with file system that already exists |
|
313 |
r=TheFs.MountFileSystem(fsName,KExtensionBitName,drive,bDrvSync); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
314 |
test_Value(r, r == KErrAccessDenied); |
0 | 315 |
// unmount drive and mount primary extension along with file system |
316 |
r=TheFs.DismountFileSystem(fsName,drive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
317 |
test_KErrNone(r); |
0 | 318 |
|
319 |
//-- !! N.B this extension mangles data read/written ftom/to the media, for some file systems it is OK and mounting succeeds |
|
320 |
//-- for others - this will result in KErrCorrupt |
|
321 |
r=TheFs.MountFileSystem(fsName,KExtensionBitName,drive,bDrvSync); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
322 |
test_Value(r, r == KErrNone||r==KErrCorrupt); |
0 | 323 |
|
324 |
// and now format |
|
325 |
Format(drive); |
|
326 |
TFullName extName; |
|
327 |
r=TheFs.ExtensionName(extName,drive,0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
328 |
test_Value(r, r == KErrNone && extName==KExtensionBitName); |
0 | 329 |
r=TheFs.ExtensionName(extName,drive,1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
330 |
test_Value(r, r == KErrNotFound); |
0 | 331 |
|
332 |
// and now do some file system operations |
|
333 |
TBuf8<16> readBuf; |
|
334 |
r=TheFs.MkDir(dir1); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
335 |
test_Value(r, r == KErrNone||r==KErrAlreadyExists); |
0 | 336 |
RFile file1; |
337 |
r=file1.Replace(TheFs,file1Name,EFileShareExclusive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
338 |
test_KErrNone(r); |
0 | 339 |
r=file1.Write(toWrite); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
340 |
test_KErrNone(r); |
0 | 341 |
r=file1.Read(0,readBuf); |
342 |
test(readBuf==toWrite); |
|
343 |
r=file1.SetSize(0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
344 |
test_KErrNone(r); |
0 | 345 |
file1.Close(); |
346 |
r=TheFs.Delete(file1Name); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
347 |
test_KErrNone(r); |
0 | 348 |
r=TheFs.RmDir(dir1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
349 |
test_KErrNone(r); |
0 | 350 |
|
351 |
// add a secondary extension |
|
352 |
test.Printf(_L("RFs::MountExtension()")); |
|
353 |
r=TheFs.MountExtension(KExtensionLogName,drive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
354 |
test_KErrNone(r); |
0 | 355 |
r=TheFs.ExtensionName(extName,drive,0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
356 |
test_Value(r, r == KErrNone && extName==KExtensionBitName); |
0 | 357 |
r=TheFs.ExtensionName(extName,drive,1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
358 |
test_Value(r, r == KErrNone && extName==KExtensionLogName); |
0 | 359 |
// try to add the same extension |
360 |
r=TheFs.MountExtension(KExtensionBitName,drive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
361 |
test_Value(r, r == KErrAlreadyExists); |
0 | 362 |
r=TheFs.ExtensionName(extName,drive,0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
363 |
test_Value(r, r == KErrNone && extName==KExtensionBitName); |
0 | 364 |
r=TheFs.ExtensionName(extName,drive,1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
365 |
test_Value(r, r == KErrNone && extName==KExtensionLogName); |
0 | 366 |
// try to add a third extension |
367 |
r=TheFs.MountExtension(KExtensionEmptyName,drive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
368 |
test_Value(r, r == KErrAccessDenied); |
0 | 369 |
r=TheFs.ExtensionName(extName,drive,0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
370 |
test_Value(r, r == KErrNone && extName==KExtensionBitName); |
0 | 371 |
r=TheFs.ExtensionName(extName,drive,1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
372 |
test_Value(r, r == KErrNone && extName==KExtensionLogName); |
0 | 373 |
|
374 |
// and now do some file system operations |
|
375 |
r=TheFs.MkDir(dir1); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
376 |
test_Value(r, r == KErrNone||r==KErrAlreadyExists); |
0 | 377 |
r=file1.Replace(TheFs,file1Name,EFileShareExclusive); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
378 |
test_KErrNone(r); |
0 | 379 |
r=file1.Write(toWrite); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
380 |
test_KErrNone(r); |
0 | 381 |
r=file1.Read(0,readBuf); |
382 |
test(readBuf==toWrite); |
|
383 |
r=file1.SetSize(0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
384 |
test_KErrNone(r); |
0 | 385 |
file1.Close(); |
386 |
r=TheFs.Delete(file1Name); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
387 |
test_KErrNone(r); |
0 | 388 |
r=TheFs.RmDir(dir1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
389 |
test_KErrNone(r); |
0 | 390 |
|
391 |
test.Printf(_L("RFs::DismountExtension()")); |
|
392 |
// test that can't dismount a primary extension via this method |
|
393 |
r=TheFs.DismountExtension(KExtensionLogName,drive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
394 |
test_KErrNone(r); |
0 | 395 |
r=TheFs.ExtensionName(extName,drive,0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
396 |
test_Value(r, r == KErrNone && extName==KExtensionBitName); |
0 | 397 |
r=TheFs.ExtensionName(extName,drive,1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
398 |
test_Value(r, r == KErrNotFound); |
0 | 399 |
r=TheFs.DismountExtension(KExtensionBitName,drive); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
400 |
test_Value(r, r == KErrAccessDenied); |
0 | 401 |
r=TheFs.ExtensionName(extName,drive,0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
402 |
test_Value(r, r == KErrNone && extName==KExtensionBitName); |
0 | 403 |
r=TheFs.ExtensionName(extName,drive,1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
404 |
test_Value(r, r == KErrNotFound); |
0 | 405 |
|
406 |
test.Printf(_L("RFs::DismountFileSystem()")); |
|
407 |
r=TheFs.MountExtension(KExtensionLogName,drive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
408 |
test_KErrNone(r); |
0 | 409 |
r=TheFs.ExtensionName(extName,drive,0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
410 |
test_Value(r, r == KErrNone && extName==KExtensionBitName); |
0 | 411 |
r=TheFs.ExtensionName(extName,drive,1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
412 |
test_Value(r, r == KErrNone && extName==KExtensionLogName); |
0 | 413 |
// and now dismount |
414 |
r=TheFs.DismountFileSystem(fsName,drive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
415 |
test_KErrNone(r); |
0 | 416 |
r=TheFs.ExtensionName(extName,drive,0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
417 |
test_Value(r, r == KErrNotReady); |
0 | 418 |
r=TheFs.ExtensionName(extName,drive,1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
419 |
test_Value(r, r == KErrNotReady); |
0 | 420 |
// remount the file system |
421 |
r=TheFs.MountFileSystem(fsName,drive,bDrvSync); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
422 |
test_Value(r, r == KErrNone||r==KErrCorrupt); |
0 | 423 |
r=TheFs.ExtensionName(extName,drive,0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
424 |
test_Value(r, r == KErrNotFound); |
0 | 425 |
r=TheFs.ExtensionName(extName,drive,1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
426 |
test_Value(r, r == KErrNotFound); |
0 | 427 |
Format(drive); |
428 |
||
429 |
test.Next(_L("RFs::RemoveExtension()")); |
|
430 |
r=TheFs.RemoveExtension(KExtensionLogName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
431 |
test_KErrNone(r); |
0 | 432 |
r=TheFs.RemoveExtension(KExtensionEmptyName); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
433 |
test_KErrNone(r); |
0 | 434 |
r=TheFs.RemoveExtension(KExtensionBitName); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
435 |
test_KErrNone(r); |
0 | 436 |
} |
437 |
||
438 |
||
439 |
GLDEF_C void CallTestsL() |
|
440 |
// |
|
441 |
// Do tests relative to the session path |
|
442 |
// |
|
443 |
{ |
|
444 |
//-- set up console output |
|
445 |
F32_Test_Utils::SetConsole(test.Console()); |
|
446 |
||
447 |
TInt drive; |
|
448 |
TInt err=RFs::CharToDrive(gDriveToTest,drive); |
|
449 |
test.Start(_L("Starting Test - T_EXT1")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
450 |
test_KErrNone(err); |
0 | 451 |
|
102
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
452 |
// Check that the drive supports extensions. |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
453 |
TBool extensionsSupported = EFalse; |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
454 |
TPckg<TBool> dataBuf(extensionsSupported); |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
455 |
err = TheFs.QueryVolumeInfoExt(drive,EFSysExtensionsSupported,dataBuf); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
456 |
test_KErrNone(err); |
102
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
457 |
if(!extensionsSupported) |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
458 |
{ |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
459 |
test.Printf(_L("Drive %d does not support file sys extensions. Skipping test."), drive); |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
460 |
test.End(); |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
461 |
test.Close(); |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
462 |
return; |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
463 |
} |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
464 |
|
0 | 465 |
PrintDrvInfo(TheFs, drive); |
466 |
||
467 |
//Do not run this test on the NAND drive, as |
|
468 |
//this has the FTL mounted as a primary extension |
|
469 |
//which causes the test to fail |
|
470 |
#if defined(__WINS__) |
|
471 |
if (drive==EDriveU) |
|
472 |
return; |
|
473 |
#else |
|
474 |
TDriveInfo driveInfo; |
|
475 |
TheFs.Drive(driveInfo,drive); |
|
476 |
if (driveInfo.iType == EMediaNANDFlash) |
|
477 |
{ |
|
478 |
return; |
|
479 |
} |
|
480 |
#endif |
|
481 |
TestSecondaryExtensions(); |
|
482 |
||
483 |
//-- the t_bitext extension mangles data from the media, which may make FS mounting fail because of "corrupted" data. |
|
484 |
//-- Then this step formats the media, automounter doesn't support it straightforward way |
|
485 |
if(!Is_Lffs(TheFs, drive) && !Is_Automounter(TheFs, drive)) |
|
486 |
{ |
|
487 |
TestPrimaryExtensions(); |
|
488 |
} |
|
489 |
||
490 |
test.End(); |
|
491 |
test.Close(); |
|
492 |
} |