author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 256 | c1f20ce4abcf |
parent 249 | a179b74831c9 |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1996-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_misc.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
18 |
#define __E32TEST_EXTENSION__ |
0 | 19 |
#include <f32file.h> |
20 |
#include <e32test.h> |
|
21 |
#include "t_server.h" |
|
22 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
23 |
#include "f32_test_utils.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
24 |
using namespace F32_Test_Utils; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
25 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
26 |
|
249
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
27 |
// If there is an NFE media driver present, then because of the way EDeleteNotify requests work, |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
28 |
// the data retrieved from a deleted file will not be a buffer full of zero's, but instead a buffer |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
29 |
// full of decrypted zero's |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
30 |
#define __NFE_MEDIA_DRIVER_PRESENT__ |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
31 |
|
0 | 32 |
#ifdef __VC32__ |
33 |
// Solve compilation problem caused by non-English locale |
|
34 |
#pragma setlocale("english") |
|
35 |
#endif |
|
36 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
37 |
RTest test(_L("T_MISC")); |
0 | 38 |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
39 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
40 |
TInt gDriveNum = -1; |
249
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
41 |
const TUint KBufLength = 0x100; |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
42 |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
43 |
static void Test1() |
0 | 44 |
// |
45 |
// Open, write to and read from a file |
|
46 |
// |
|
47 |
{ |
|
48 |
||
49 |
test.Next(_L("Open, write to and read from a file")); |
|
50 |
TInt r=TheFs.SetSessionPath(gSessionPath); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
51 |
test_KErrNone(r); |
0 | 52 |
RFile file; |
53 |
r=file.Create(TheFs,_L("Hello.Wld"),EFileWrite); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
54 |
test_KErrNone(r); |
0 | 55 |
r=file.Write(_L8("Hello World"),11); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
56 |
test_KErrNone(r); |
0 | 57 |
file.Close(); |
58 |
||
59 |
r=file.Open(TheFs,_L("Hello.Wld"),EFileRead); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
60 |
test_KErrNone(r); |
0 | 61 |
TBuf8<256> buf; |
62 |
r=file.Read(buf); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
63 |
test_KErrNone(r); |
0 | 64 |
test(buf==_L8("Hello World")); |
65 |
file.Close(); |
|
66 |
} |
|
67 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
68 |
static void Test2() |
0 | 69 |
// |
70 |
// Open and read from a file |
|
71 |
// |
|
72 |
{ |
|
73 |
||
74 |
test.Next(_L("Open and read from a file")); |
|
75 |
TInt r=TheFs.SetSessionPath(gSessionPath); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
76 |
test_KErrNone(r); |
0 | 77 |
RFile file; |
78 |
r=file.Open(TheFs,_L("Hello.Wld"),EFileRead); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
79 |
test_KErrNone(r); |
0 | 80 |
TBuf8<256> buf; |
81 |
r=file.Read(buf); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
82 |
test_KErrNone(r); |
0 | 83 |
test(buf==_L8("Hello World")); |
84 |
file.Close(); |
|
85 |
r=TheFs.Delete(_L("HELLO.WLD")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
86 |
test_KErrNone(r); |
0 | 87 |
} |
88 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
89 |
static void Test3() |
0 | 90 |
// |
91 |
// Create nested directories |
|
92 |
// |
|
93 |
{ |
|
94 |
||
95 |
test.Next(_L("Create nested directories")); |
|
96 |
TInt r=TheFs.SetSessionPath(gSessionPath); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
97 |
test_KErrNone(r); |
0 | 98 |
TheFs.ResourceCountMarkStart(); |
99 |
// |
|
100 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\A.B")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
101 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 102 |
r=TheFs.MkDir(_L("\\F32-TST\\RIGHT\\")); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
103 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 104 |
// |
105 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\ONE\\")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
106 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 107 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\TWO\\")); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
108 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 109 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\THREE\\")); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
110 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 111 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\TWO\\BOTTOM\\")); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
112 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 113 |
// |
114 |
r=TheFs.MkDirAll(_L("\\F32-TST\\RIGHT\\TOP\\MID\\BOT\\")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
115 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 116 |
} |
117 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
118 |
static void Test4() |
0 | 119 |
// |
120 |
// Test returned error values |
|
121 |
// |
|
122 |
{ |
|
123 |
||
124 |
test.Next(_L("Test returned error values")); |
|
125 |
TInt r=TheFs.SetSessionPath(gSessionPath); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
126 |
test_KErrNone(r); |
0 | 127 |
TheFs.ResourceCountMarkStart(); |
128 |
// |
|
129 |
r=TheFs.MkDir(_L("\\")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
130 |
test_Value(r, r == KErrAlreadyExists); |
0 | 131 |
r=TheFs.MkDir(_L("\\LEFT")); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
132 |
test_Value(r, r == KErrAlreadyExists); |
0 | 133 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\")); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
134 |
test_Value(r, r == KErrAlreadyExists); |
0 | 135 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\..\\NEWDIR\\")); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
136 |
test_Value(r, r == KErrBadName); |
0 | 137 |
r=TheFs.MkDir(_L("\\F32-TST\\NEWDIR\\SUBDIR\\")); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
138 |
test_Value(r, r == KErrPathNotFound); |
0 | 139 |
// |
140 |
r=TheFs.RmDir(_L("\\")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
141 |
test_Value(r, r == KErrInUse); |
0 | 142 |
r=TheFs.RmDir(_L("\\PROG")); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
143 |
test_Value(r, r == KErrInUse); |
0 | 144 |
r=TheFs.RmDir(_L("\\F32-TST\\")); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
145 |
test_Value(r, r == KErrInUse); |
0 | 146 |
|
147 |
||
148 |
RDir dir; |
|
149 |
r=dir.Open(TheFs,_L("V:\\asdf"),KEntryAttNormal); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
150 |
test_Value(r, r == KErrNone || r==KErrNotReady || r==KErrNotFound); |
0 | 151 |
if (r==KErrNone) |
152 |
dir.Close(); |
|
153 |
r=dir.Open(TheFs,_L("L:\\asdf"),KEntryAttNormal); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
154 |
test_Value(r, r == KErrNone || r==KErrNotReady || r==KErrNotFound); |
0 | 155 |
dir.Close(); |
156 |
// |
|
157 |
TEntry entry; |
|
158 |
r=TheFs.Entry(_L("z:\\NOTEXiSTS\\file.txt"),entry); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
159 |
test_Value(r, r == KErrPathNotFound); |
0 | 160 |
r=TheFs.Entry(_L("z:\\NOTEXiSTS\\"),entry); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
161 |
test_Value(r, r == KErrNotFound); |
0 | 162 |
r=TheFs.Entry(_L("z:\\SYSTEM\\"),entry); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
163 |
test_KErrNone(r); |
0 | 164 |
r=TheFs.Entry(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)?_L("z:\\SYS\\BIN\\ESHELL.EXE"):_L("z:\\SYSTEM\\BIN\\ESHELL.EXE"),entry); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
165 |
test_KErrNone(r); |
0 | 166 |
|
167 |
r=dir.Open(TheFs,_L("\\*"),NULL); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
168 |
test_KErrNone(r); |
0 | 169 |
TEntry dirEntry; |
170 |
r=dir.Read(dirEntry); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
171 |
test_Value(r, r == KErrNone || r==KErrEof); |
0 | 172 |
if (r==KErrNone) |
173 |
test.Printf(_L("%S\n"),&dirEntry.iName); |
|
174 |
dir.Close(); |
|
175 |
||
176 |
r=dir.Open(TheFs,_L("A:\\*"),NULL); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
177 |
test_Value(r, r == KErrNotReady || r==KErrNone); |
0 | 178 |
dir.Close(); |
179 |
} |
|
180 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
181 |
static void Test5() |
0 | 182 |
// |
183 |
// Read files directly from the rom |
|
184 |
// |
|
185 |
||
186 |
{ |
|
187 |
test.Next(_L("Read Files directly from the rom")); |
|
188 |
||
189 |
TInt pos=0; |
|
190 |
TInt r; |
|
191 |
_LIT(KTFileCpp, "Z:\\test\\T_FILE.CPP"); |
|
192 |
_LIT(KTFsrvCpp, "Z:\\test\\T_FSRV.CPP"); |
|
193 |
||
194 |
if ( TheFs.IsFileInRom(KTFileCpp) != NULL && TheFs.IsFileInRom(KTFsrvCpp) != NULL ) |
|
195 |
{ |
|
196 |
RFile f; |
|
197 |
r=f.Open(TheFs,KTFileCpp,EFileRead); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
198 |
test_KErrNone(r); |
0 | 199 |
r=f.Seek(ESeekAddress,pos); |
200 |
TText8* ptrPos=*(TText8**)&pos; |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
201 |
test_KErrNone(r); |
0 | 202 |
TBuf8<1024> readBuf; |
203 |
r=f.Read(readBuf); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
204 |
test_KErrNone(r); |
0 | 205 |
test(readBuf.Length()==readBuf.MaxLength()); |
206 |
TPtrC8 memBuf(ptrPos,readBuf.Length()); |
|
207 |
test(memBuf==readBuf); |
|
208 |
||
209 |
ptrPos+=9913; |
|
210 |
pos=9913; |
|
211 |
r=f.Seek(ESeekStart,pos); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
212 |
test_KErrNone(r); |
0 | 213 |
readBuf.SetLength(0); |
214 |
r=f.Read(readBuf); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
215 |
test_KErrNone(r); |
0 | 216 |
test(readBuf.Length()==readBuf.MaxLength()); |
217 |
memBuf.Set(ptrPos,readBuf.Length()); |
|
218 |
test(memBuf==readBuf); |
|
219 |
||
220 |
RFile f2; |
|
221 |
pos=10; |
|
222 |
r=f2.Open(TheFs,KTFsrvCpp,EFileRead); |
|
223 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
224 |
test_KErrNone(r); |
0 | 225 |
r=f2.Seek(ESeekAddress,pos); |
226 |
ptrPos=*(TText8**)&pos; |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
227 |
test_KErrNone(r); |
0 | 228 |
readBuf.SetLength(0); |
229 |
pos=10; |
|
230 |
r=f2.Seek(ESeekStart,pos); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
231 |
test_KErrNone(r); |
0 | 232 |
r=f2.Read(readBuf); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
233 |
test_KErrNone(r); |
0 | 234 |
test(readBuf.Length()==readBuf.MaxLength()); |
235 |
memBuf.Set(ptrPos,readBuf.Length()); |
|
236 |
test(memBuf==readBuf); |
|
237 |
||
238 |
ptrPos+=2445; |
|
239 |
pos=10+2445; |
|
240 |
r=f2.Seek(ESeekStart,pos); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
241 |
test_KErrNone(r); |
0 | 242 |
readBuf.SetLength(0); |
243 |
r=f2.Read(readBuf); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
244 |
test_KErrNone(r); |
0 | 245 |
test(readBuf.Length()==readBuf.MaxLength()); |
246 |
memBuf.Set(ptrPos,readBuf.Length()); |
|
247 |
test(memBuf==readBuf); |
|
248 |
||
249 |
pos=0; |
|
250 |
r=f.Seek(ESeekAddress,pos); |
|
251 |
ptrPos=*(TText8**)&pos; |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
252 |
test_KErrNone(r); |
0 | 253 |
readBuf.SetLength(0); |
254 |
pos=0; |
|
255 |
r=f.Seek(ESeekStart,pos); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
256 |
test_KErrNone(r); |
0 | 257 |
r=f.Read(readBuf); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
258 |
test_KErrNone(r); |
0 | 259 |
test(readBuf.Length()==readBuf.MaxLength()); |
260 |
memBuf.Set(ptrPos,readBuf.Length()); |
|
261 |
test(memBuf==readBuf); |
|
262 |
||
263 |
ptrPos+=5245; |
|
264 |
pos=5245; |
|
265 |
r=f.Seek(ESeekStart,pos); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
266 |
test_KErrNone(r); |
0 | 267 |
readBuf.SetLength(0); |
268 |
r=f.Read(readBuf); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
269 |
test_KErrNone(r); |
0 | 270 |
test(readBuf.Length()==readBuf.MaxLength()); |
271 |
memBuf.Set(ptrPos,readBuf.Length()); |
|
272 |
test(memBuf==readBuf); |
|
273 |
||
274 |
f.Close(); |
|
275 |
f2.Close(); |
|
276 |
} |
|
277 |
} |
|
278 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
279 |
static void Test6() |
0 | 280 |
// |
281 |
// Test rom return values |
|
282 |
// |
|
283 |
{ |
|
284 |
test.Next(_L("Test rom return values")); |
|
285 |
||
286 |
RFile f; |
|
287 |
TInt r=f.Replace(TheFs,_L("Z:\\Test\\T_Fsrv.Cpp"),EFileRead); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
288 |
test_Value(r, r == KErrAccessDenied); |
0 | 289 |
r=f.Create(TheFs,_L("Z:\\Test\\newT_Fsrv.Cpp"),EFileRead); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
290 |
test_Value(r, r == KErrAccessDenied); |
0 | 291 |
r=f.Open(TheFs,_L("Z:\\Test\\T_Fsrv.Cpp"),EFileRead); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
292 |
test_KErrNone(r); |
0 | 293 |
f.Close(); |
294 |
r=f.Open(TheFs,_L("Z:\\Test\\T_Fsrv.Cpp"),EFileRead|EFileWrite); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
295 |
test_Value(r, r == KErrAccessDenied); |
0 | 296 |
} |
297 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
298 |
static void Test7() |
0 | 299 |
// |
300 |
// Test cache |
|
301 |
// |
|
302 |
{ |
|
303 |
||
304 |
test.Next(_L("Test cache updated when writing to a file")); |
|
305 |
TUidType uid1(TUid::Uid(1),TUid::Uid(2),TUid::Uid(3)); |
|
306 |
TBuf8<32> contents1=_L8("asdf asdf asdf"); |
|
307 |
TBuf<32> file1=_L("\\TMISC\\CACHE.FILE"); |
|
308 |
MakeFile(file1,uid1,contents1); |
|
309 |
||
310 |
TEntry entry; |
|
311 |
TInt r=TheFs.Entry(file1,entry); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
312 |
test_KErrNone(r); |
0 | 313 |
test(entry.iType==uid1); |
314 |
||
315 |
TUidType uid2(TUid::Uid(4),TUid::Uid(5),TUid::Uid(6)); |
|
316 |
TCheckedUid checkedUid(uid2); |
|
317 |
TPtrC8 uidData((TUint8*)&checkedUid,sizeof(TCheckedUid)); |
|
318 |
RFile f; |
|
319 |
r=f.Open(TheFs,file1,EFileRead|EFileWrite); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
320 |
test_KErrNone(r); |
0 | 321 |
r=f.Write(uidData); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
322 |
test_KErrNone(r); |
0 | 323 |
r = f.Flush(); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
324 |
test_KErrNone(r); |
0 | 325 |
|
326 |
r=TheFs.Entry(file1,entry); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
327 |
test_KErrNone(r); |
0 | 328 |
test(entry.iType==uid2); |
329 |
||
330 |
f.Close(); |
|
331 |
r=TheFs.Entry(file1,entry); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
332 |
test_KErrNone(r); |
0 | 333 |
test(entry.iType==uid2); |
334 |
} |
|
335 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
336 |
static void Test8() |
0 | 337 |
// |
338 |
// Test IsValidName |
|
339 |
// |
|
340 |
{ |
|
341 |
test.Next(_L("Test RFs::IsValidName(TDesC)")); |
|
342 |
||
343 |
// tests calling IsValidName() with invalid name as first call to session |
|
344 |
// see defect EXT-57KH9K |
|
345 |
_LIT(KInvalidName, "test\\i1.jpg"); |
|
346 |
RFs fs; |
|
347 |
test(KErrNone==fs.Connect()); |
|
348 |
test(fs.IsValidName(KInvalidName)==EFalse); |
|
349 |
fs.Close(); |
|
350 |
||
351 |
test(TheFs.IsValidName(_L("*"))==EFalse); |
|
352 |
test(TheFs.IsValidName(_L("?"))==EFalse); |
|
353 |
test(TheFs.IsValidName(_L(">"))==EFalse); |
|
354 |
test(TheFs.IsValidName(_L("<"))==EFalse); |
|
355 |
test(TheFs.IsValidName(_L(":"))==EFalse); |
|
356 |
test(TheFs.IsValidName(_L("\""))==EFalse); |
|
357 |
test(TheFs.IsValidName(_L("/"))==EFalse); |
|
358 |
test(TheFs.IsValidName(_L("|"))==EFalse); |
|
359 |
test(TheFs.IsValidName(_L("\\"))==EFalse); |
|
360 |
||
361 |
test(TheFs.IsValidName(_L("xx*yy"))==EFalse); |
|
362 |
test(TheFs.IsValidName(_L("xx?yy"))==EFalse); |
|
363 |
test(TheFs.IsValidName(_L("xx>yy"))==EFalse); |
|
364 |
test(TheFs.IsValidName(_L("xx<yy"))==EFalse); |
|
365 |
test(TheFs.IsValidName(_L("xx:yy"))==EFalse); |
|
366 |
test(TheFs.IsValidName(_L("xx\"yy"))==EFalse); |
|
367 |
test(TheFs.IsValidName(_L("xx/yy"))==EFalse); |
|
368 |
test(TheFs.IsValidName(_L("xx|yy"))==EFalse); |
|
369 |
||
370 |
test(TheFs.IsValidName(_L("C:\\*\\group\\release.txt"))==EFalse); |
|
371 |
test(TheFs.IsValidName(_L("C:\\?\\group\\release.txt"))==EFalse); |
|
372 |
test(TheFs.IsValidName(_L("C:\\>\\group\\release.txt"))==EFalse); |
|
373 |
test(TheFs.IsValidName(_L("C:\\<\\group\\release.txt"))==EFalse); |
|
374 |
test(TheFs.IsValidName(_L("C:\\:\\group\\release.txt"))==EFalse); |
|
375 |
test(TheFs.IsValidName(_L("C:\\\"\\group\\release.txt"))==EFalse); |
|
376 |
test(TheFs.IsValidName(_L("C:\\/\\group\\release.txt"))==EFalse); |
|
377 |
test(TheFs.IsValidName(_L("C:\\|\\group\\release.txt"))==EFalse); |
|
378 |
||
379 |
test(TheFs.IsValidName(_L(""))==EFalse); // must be a name or extension present |
|
380 |
test(TheFs.IsValidName(_L(".ext"))); |
|
381 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\"))==EFalse); |
|
382 |
test(TheFs.IsValidName(_L("\\"))==EFalse); |
|
383 |
||
384 |
test(TheFs.IsValidName(_L("as(){}@~#;!\xA3$%^&()df.blarg"))); // Valid names |
|
385 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\asdf.blarg"))); // Valid names |
|
386 |
test(TheFs.IsValidName(_L("\'"))); // Valid names |
|
387 |
||
388 |
test.Next(_L("Test RFs::IsValidName(TDesC, TDes) overload")); |
|
389 |
||
390 |
TText testChar; |
|
391 |
test(TheFs.IsValidName(_L("*"),testChar)==EFalse); |
|
392 |
test(testChar=='*'); |
|
393 |
test(TheFs.IsValidName(_L("?"),testChar)==EFalse); |
|
394 |
test(testChar=='?'); |
|
395 |
test(TheFs.IsValidName(_L(">"),testChar)==EFalse); |
|
396 |
test(testChar=='>'); |
|
397 |
test(TheFs.IsValidName(_L("<"),testChar)==EFalse); |
|
398 |
test(testChar=='<'); |
|
399 |
test(TheFs.IsValidName(_L(":"),testChar)==EFalse); |
|
400 |
test(testChar==':'); |
|
401 |
test(TheFs.IsValidName(_L("\""),testChar)==EFalse); |
|
402 |
test(testChar=='\"'); // Tests that " is illegal |
|
403 |
test(TheFs.IsValidName(_L("/"),testChar)==EFalse); |
|
404 |
test(testChar=='/'); |
|
405 |
test(TheFs.IsValidName(_L("|"),testChar)==EFalse); |
|
406 |
test(testChar=='|'); |
|
407 |
test(TheFs.IsValidName(_L("\\"),testChar)==EFalse); |
|
408 |
test(testChar==' '); |
|
409 |
||
410 |
test(TheFs.IsValidName(_L("xx*yy"),testChar)==EFalse); |
|
411 |
test(testChar=='*'); |
|
412 |
test(TheFs.IsValidName(_L("xx?yy"),testChar)==EFalse); |
|
413 |
test(testChar=='?'); |
|
414 |
test(TheFs.IsValidName(_L("xx>yy"),testChar)==EFalse); |
|
415 |
test(testChar=='>'); |
|
416 |
test(TheFs.IsValidName(_L("xx<yy"),testChar)==EFalse); |
|
417 |
test(testChar=='<'); |
|
418 |
test(TheFs.IsValidName(_L("xx:yy"),testChar)==EFalse); |
|
419 |
test(testChar==':'); |
|
420 |
test(TheFs.IsValidName(_L("xx\"yy"),testChar)==EFalse); |
|
421 |
test(testChar=='\"'); // Tests that " is illegal |
|
422 |
test(TheFs.IsValidName(_L("xx/yy"),testChar)==EFalse); |
|
423 |
test(testChar=='/'); |
|
424 |
test(TheFs.IsValidName(_L("xx|yy"),testChar)==EFalse); |
|
425 |
test(testChar=='|'); |
|
426 |
||
427 |
test(TheFs.IsValidName(_L("C:\\*\\group\\release.txt"),testChar)==EFalse); |
|
428 |
test(testChar=='*'); |
|
429 |
test(TheFs.IsValidName(_L("C:\\?\\group\\release.txt"),testChar)==EFalse); |
|
430 |
test(testChar=='?'); |
|
431 |
test(TheFs.IsValidName(_L("C:\\..\\group\\release.txt"),testChar)==EFalse); |
|
432 |
test(testChar=='.'); // Only one "." returned however many are in filename |
|
433 |
test(TheFs.IsValidName(_L("C:\\.\\group\\release.txt"),testChar)==EFalse); |
|
434 |
test(testChar=='.'); |
|
435 |
test(TheFs.IsValidName(_L("C:\\>\\group\\release.txt"),testChar)==EFalse); |
|
436 |
test(testChar=='>'); |
|
437 |
test(TheFs.IsValidName(_L("C:\\<\\group\\release.txt"),testChar)==EFalse); |
|
438 |
test(testChar=='<'); |
|
439 |
test(TheFs.IsValidName(_L("C:\\HelloWorld\\:\\group\\release.txt"),testChar)==EFalse); |
|
440 |
test(testChar==':'); |
|
441 |
||
442 |
||
443 |
test(TheFs.IsValidName(_L("C::\\group\\release.txt"),testChar)==EFalse); |
|
444 |
test(testChar==':'); |
|
445 |
test(TheFs.IsValidName(_L(">\\group\\release.txt"),testChar)==EFalse); |
|
446 |
test(testChar=='>'); |
|
447 |
test(TheFs.IsValidName(_L("C|group\\release.txt"),testChar)==EFalse); |
|
448 |
test(testChar=='|'); |
|
449 |
test(TheFs.IsValidName(_L("C\\|\\group\\release.txt"),testChar)==EFalse); |
|
450 |
test(testChar=='|'); |
|
451 |
||
452 |
test(TheFs.IsValidName(_L("\\>"),testChar)==EFalse); |
|
453 |
test(testChar=='>'); |
|
454 |
test(TheFs.IsValidName(_L("C:\\|group\\release.txt"),testChar)==EFalse); |
|
455 |
test(testChar=='|'); |
|
456 |
||
457 |
test(TheFs.IsValidName(_L("C:\\\"\\group\\release.txt"),testChar)==EFalse); |
|
458 |
test(testChar=='\"'); |
|
459 |
test(TheFs.IsValidName(_L("C:\\/\\group\\release.txt"),testChar)==EFalse); |
|
460 |
test(testChar=='/'); |
|
461 |
test(TheFs.IsValidName(_L("C:\\|\\group\\release.txt"),testChar)==EFalse); |
|
462 |
test(testChar=='|'); |
|
463 |
test(TheFs.IsValidName(_L("C:\\ \\group\\release.txt"),testChar)==EFalse); // must be a name or extension present |
|
464 |
test(testChar==' '); |
|
465 |
||
466 |
// Test that \ is not allowed in filenames |
|
467 |
TFileName filename; |
|
468 |
filename=_L("C:\\HelloWorld\\\\\\group\\release.txt"); |
|
469 |
TPtr pChar(&testChar,sizeof(TText),sizeof(TText)); |
|
470 |
test(TheFs.IsValidName(filename,testChar)==EFalse); |
|
471 |
test(pChar.Find(_L("\\"))!=KErrNotFound); |
|
472 |
filename=_L("C:\\\\\\group\\release.txt"); |
|
473 |
test(TheFs.IsValidName(filename,testChar)==EFalse); |
|
474 |
test(pChar.Find(_L("\\"))!=KErrNotFound); |
|
475 |
filename=_L("C:\\Hello World\\group\\release.txt"); |
|
476 |
filename[8]=KPathDelimiter; // Makes C:\\Hello World\\group\\release.txt |
|
477 |
test(TheFs.IsValidName(filename,testChar)); |
|
478 |
filename=_L("C:\\HelloWorld\\::\\group\\release.txt"); |
|
479 |
test(TheFs.IsValidName(filename,testChar)==EFalse); |
|
480 |
test(pChar.Find(_L(":"))!=KErrNotFound); |
|
481 |
||
482 |
filename=_L("C:\\>>\\group\\release.txt"); |
|
483 |
test(TheFs.IsValidName(filename,testChar)==EFalse); |
|
484 |
test(pChar.Find(_L(">"))!=KErrNotFound); |
|
485 |
||
486 |
test(TheFs.IsValidName(_L(""),testChar)==EFalse); // Must be a name |
|
487 |
test(testChar==' '); |
|
488 |
test(TheFs.IsValidName(_L(".ext"),testChar)); |
|
489 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\"),testChar)==EFalse); |
|
490 |
test(testChar==' '); // Must be a name else testChar is set to blank |
|
491 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg"),testChar)); |
|
492 |
||
493 |
test(TheFs.IsValidName(_L("C:\\asdf..blarg\\"),testChar)==EFalse); |
|
494 |
test(testChar==' '); // Must be a name else testChar is set to blank |
|
495 |
test(TheFs.IsValidName(_L("C:\\asdf..blarg"),testChar)); |
|
496 |
||
497 |
test(TheFs.IsValidName(_L("\\"),testChar)==EFalse); |
|
498 |
test(testChar==' '); |
|
499 |
||
500 |
// Test multiple evil characters - parsing occurs from right to left |
|
501 |
// except that wildcarded characters take priority and are picked out first |
|
502 |
test(TheFs.IsValidName(_L("abc>def|ghi?jkl:mno<pqr*stu"),testChar)==EFalse); |
|
503 |
test(testChar=='*'); |
|
504 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno?pqr"),testChar)==EFalse); |
|
505 |
test(testChar=='?'); |
|
506 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno"),testChar)==EFalse); |
|
507 |
test(testChar==':'); |
|
508 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl"),testChar)==EFalse); |
|
509 |
test(testChar=='<'); |
|
510 |
test(TheFs.IsValidName(_L("abc>def|ghi"),testChar)==EFalse); |
|
511 |
test(testChar=='|'); |
|
512 |
test(TheFs.IsValidName(_L("abc>def"),testChar)==EFalse); |
|
513 |
test(testChar=='>'); |
|
514 |
||
515 |
test(!TheFs.IsValidName(_L("C:\\v123456.."),testChar)); // Valid name |
|
516 |
test(TheFs.IsValidName(_L("abc"),testChar)); // Valid name |
|
517 |
test(TheFs.IsValidName(_L("as(){}@~#;!\xA3$%^&()df.blarg"),testChar)); // Valid name |
|
518 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\asdf.blarg"),testChar)); // Valid name |
|
519 |
test(TheFs.IsValidName(_L("\'"),testChar)); // Valid name |
|
520 |
||
521 |
//PDEF133084: The wild character in the extension was not being detected. |
|
522 |
_LIT( KTestString, "E:\\My Videos\\Downloads\\1\\1\\Name.3gp?" ); |
|
523 |
TBuf<50> path; |
|
524 |
path = KTestString; |
|
525 |
TBool validName( EFalse ); |
|
526 |
TText badChar; |
|
527 |
TInt badCharLoc( KErrNotFound ); |
|
528 |
||
529 |
while ( ! validName ) |
|
530 |
{ |
|
531 |
validName = TheFs.IsValidName( path, badChar ); |
|
532 |
||
533 |
if ( ! validName ) |
|
534 |
{ |
|
535 |
badCharLoc = path.LocateReverse( badChar ); |
|
536 |
||
537 |
if ( KErrNotFound != badCharLoc ) |
|
538 |
{ |
|
539 |
path[badCharLoc] = '_'; |
|
540 |
} |
|
541 |
} |
|
542 |
} |
|
543 |
} |
|
544 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
545 |
static void Test9() |
0 | 546 |
// |
547 |
// Test IsFileInRom |
|
548 |
// |
|
549 |
{ |
|
550 |
||
551 |
test.Next(_L("Test RFs::IsFileInRom")); |
|
552 |
||
553 |
CFileMan* fMan=CFileMan::NewL(TheFs); |
|
554 |
TInt r=fMan->Copy(_L("Z:\\TEST\\T_FILE.CPP"),_L("C:\\T_FILE.CPP")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
555 |
test_Value(r, r == KErrNone || r==KErrAccessDenied); |
0 | 556 |
delete fMan; |
557 |
TUint8* addr=TheFs.IsFileInRom(_L("C:\\ESHELL.EXE")); |
|
558 |
test(addr==NULL); |
|
559 |
addr=TheFs.IsFileInRom(_L("Z:\\TEST\\T_FILE.CPP")); |
|
560 |
if (addr!=NULL) |
|
561 |
{ |
|
562 |
test(addr!=NULL); |
|
563 |
TPtrC8 startOfFile(addr,12); |
|
564 |
test(startOfFile==_L8("// Copyright")); |
|
565 |
} |
|
566 |
else |
|
567 |
{ |
|
568 |
test (addr==NULL); |
|
569 |
} |
|
570 |
} |
|
571 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
572 |
static void Test10() |
0 | 573 |
// |
574 |
// Test drive names |
|
575 |
// |
|
576 |
{ |
|
577 |
||
578 |
test.Next(_L("Test Drive Names")); |
|
579 |
TFileName driveName; |
|
580 |
TInt i; |
|
581 |
for(i=0;i<KMaxDrives;i++) |
|
582 |
{ |
|
583 |
TInt r=TheFs.GetDriveName(i,driveName); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
584 |
test_KErrNone(r); |
0 | 585 |
if (driveName.Length()) |
586 |
test.Printf(_L("Default name of %c: == %S\n"),'A'+i,&driveName); |
|
587 |
} |
|
588 |
||
589 |
TBuf<64> drive0=_L("Dilbert"); |
|
590 |
TBuf<64> drive4=_L("Dogbert"); |
|
591 |
TBuf<64> drive17=_L("Flibble"); |
|
592 |
TBuf<64> drive25=_L("RAMDRIVE"); |
|
593 |
TInt r=TheFs.SetDriveName(0,drive0); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
594 |
test_KErrNone(r); |
0 | 595 |
r=TheFs.SetDriveName(4,drive4); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
596 |
test_KErrNone(r); |
0 | 597 |
r=TheFs.SetDriveName(17,drive17); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
598 |
test_KErrNone(r); |
0 | 599 |
r=TheFs.SetDriveName(25,drive25); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
600 |
test_KErrNone(r); |
0 | 601 |
|
602 |
r=TheFs.GetDriveName(0,driveName); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
603 |
test_KErrNone(r); |
0 | 604 |
test(driveName==drive0); |
605 |
r=TheFs.GetDriveName(4,driveName); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
606 |
test_KErrNone(r); |
0 | 607 |
test(driveName==drive4); |
608 |
r=TheFs.GetDriveName(17,driveName); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
609 |
test_KErrNone(r); |
0 | 610 |
test(driveName==drive17); |
611 |
r=TheFs.GetDriveName(25,driveName); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
612 |
test_KErrNone(r); |
0 | 613 |
test(driveName==drive25); |
614 |
||
615 |
drive0=_L("askdjflsdfourewoqiuroiuaksjdvx,cvsdhwjhjhalsjhfshfkjhslj"); |
|
616 |
r=TheFs.SetDriveName(0,drive0); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
617 |
test_KErrNone(r); |
0 | 618 |
r=TheFs.GetDriveName(0,driveName); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
619 |
test_KErrNone(r); |
0 | 620 |
test(driveName==drive0); |
621 |
||
622 |
// Test with illegal characters in drive name |
|
623 |
drive0=_L("Dil>bert"); |
|
624 |
drive4=_L("Dog?bert"); |
|
625 |
drive17=_L("Fli*bble"); |
|
626 |
drive25=_L("RAMD//RIVE"); |
|
627 |
||
628 |
r=TheFs.SetDriveName(0,drive0); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
629 |
test_Value(r, r == KErrBadName); |
0 | 630 |
r=TheFs.SetDriveName(4,drive4); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
631 |
test_Value(r, r == KErrBadName); |
0 | 632 |
r=TheFs.SetDriveName(17,drive17); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
633 |
test_Value(r, r == KErrBadName); |
0 | 634 |
r=TheFs.SetDriveName(25,drive25); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
635 |
test_Value(r, r == KErrBadName); |
0 | 636 |
|
637 |
// Test that it is OK to set the name to no characters |
|
638 |
||
639 |
drive0=_L(""); |
|
640 |
drive4=_L(""); |
|
641 |
drive17=_L(""); |
|
642 |
drive25=_L(""); |
|
643 |
||
644 |
r=TheFs.SetDriveName(0,drive0); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
645 |
test_KErrNone(r); |
0 | 646 |
r=TheFs.SetDriveName(4,drive4); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
647 |
test_KErrNone(r); |
0 | 648 |
r=TheFs.SetDriveName(17,drive17); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
649 |
test_KErrNone(r); |
0 | 650 |
r=TheFs.SetDriveName(25,drive25); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
651 |
test_KErrNone(r); |
0 | 652 |
|
653 |
r=TheFs.GetDriveName(0,driveName); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
654 |
test_KErrNone(r); |
0 | 655 |
test(driveName==drive0); |
656 |
r=TheFs.GetDriveName(4,driveName); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
657 |
test_KErrNone(r); |
0 | 658 |
test(driveName==drive4); |
659 |
r=TheFs.GetDriveName(17,driveName); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
660 |
test_KErrNone(r); |
0 | 661 |
test(driveName==drive17); |
662 |
r=TheFs.GetDriveName(25,driveName); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
663 |
test_KErrNone(r); |
0 | 664 |
test(driveName==drive25); |
665 |
||
666 |
||
667 |
} |
|
668 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
669 |
static void Test11() |
0 | 670 |
// |
671 |
// Miscellaneous tests |
|
672 |
// |
|
673 |
{ |
|
674 |
||
675 |
test.Next(_L("Miscellaneous tests")); |
|
676 |
TVolumeInfo vol; |
|
677 |
TInt r=TheFs.Volume(vol); |
|
678 |
test.Printf(_L("VolumeName = %S\n"),&vol.iName); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
679 |
test_KErrNone(r); |
0 | 680 |
r=TheFs.RmDir(_L("\\asdfasdf.\\")); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
681 |
test_Value(r, r == KErrBadName); |
0 | 682 |
r=TheFs.MkDir(_L("\\asdfasdf.\\")); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
683 |
test_Value(r, r == KErrBadName); |
0 | 684 |
} |
685 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
686 |
static void Test12() |
0 | 687 |
// |
688 |
// Test SetNotifyUser and GetNotifyUser |
|
689 |
// |
|
690 |
{ |
|
691 |
||
692 |
test.Next(_L("Test Set and GetNotifyUser")); |
|
693 |
TBool notifyState=TheFs.GetNotifyUser(); |
|
694 |
test(notifyState); |
|
695 |
notifyState=EFalse; |
|
696 |
TheFs.SetNotifyUser(notifyState); |
|
697 |
notifyState=TheFs.GetNotifyUser(); |
|
698 |
test(notifyState==EFalse); |
|
699 |
notifyState=ETrue; |
|
700 |
TheFs.SetNotifyUser(notifyState); |
|
701 |
notifyState=TheFs.GetNotifyUser(); |
|
702 |
test(notifyState); |
|
703 |
} |
|
704 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
705 |
static void Test13() |
0 | 706 |
// |
707 |
// Test return values from RFs::Volume on cf-cards |
|
708 |
// |
|
709 |
{ |
|
710 |
||
711 |
test.Next(_L("Test RFs::Volume")); |
|
712 |
TVolumeInfo vol; |
|
713 |
TInt r=TheFs.Volume(vol,EDriveB); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
714 |
test_Value(r, r == KErrNotReady || r==KErrNone || r == KErrPathNotFound); |
0 | 715 |
test.Printf(_L("RFs::Volume EDriveB returned %d\n"),r); |
716 |
||
717 |
r=TheFs.Volume(vol,EDriveC); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
718 |
test_Value(r, r == KErrNotReady || r==KErrNone || r == KErrPathNotFound); |
0 | 719 |
test.Printf(_L("RFs::Volume EDriveC returned %d\n"),r); |
720 |
||
721 |
r=TheFs.Volume(vol,EDriveD); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
722 |
test_Value(r, r == KErrNotReady || r==KErrNone || r == KErrPathNotFound); |
0 | 723 |
test.Printf(_L("RFs::Volume EDriveD returned %d\n"),r); |
724 |
||
725 |
r=TheFs.Volume(vol,EDriveE); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
726 |
test_Value(r, r == KErrNotReady || r==KErrNone || r == KErrPathNotFound); |
0 | 727 |
test.Printf(_L("RFs::Volume EDriveE returned %d\n"),r); |
728 |
||
729 |
r=TheFs.Volume(vol,EDriveF); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
730 |
test_Value(r, r == KErrNotReady || r==KErrNone || r == KErrPathNotFound); |
0 | 731 |
test.Printf(_L("RFs::Volume EDriveF returned %d\n"),r); |
732 |
} |
|
733 |
||
734 |
||
735 |
void DoTest14(TInt aDrvNum); |
|
736 |
TInt CreateStuffedFile(RFs& aFs, const TDesC& aFileName, TUint aFileSize); |
|
737 |
TBool CheckFileContents(RFs& aFs, const TDesC& aFileName); |
|
249
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
738 |
#ifndef __NFE_MEDIA_DRIVER_PRESENT__ |
0 | 739 |
TBool CheckBufferContents(const TDesC8& aBuffer, TUint aPrintBaseAddr=0); |
249
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
740 |
#endif |
0 | 741 |
|
742 |
/** |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
743 |
Testing unallocated data initialization vulnerability in RFile |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
744 |
This test is performed on RAM drives and non-removable media that supports DeleteNotify (KMediaAttDeleteNotify flag) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
745 |
e.g. XSR NAND |
0 | 746 |
*/ |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
747 |
static void Test14() |
0 | 748 |
{ |
749 |
||
750 |
test.Next(_L("Testing unallocated data initialization vulnerability in RFile")); |
|
751 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
752 |
TDriveInfo driveInfo; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
753 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
754 |
//-- get drive info |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
755 |
test(TheFs.Drive(driveInfo, gDriveNum) == KErrNone); |
0 | 756 |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
757 |
const TBool bMediaSuitable = (driveInfo.iType == EMediaRam) || //-- RAM drives should be tested |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
758 |
(driveInfo.iType == EMediaFlash) || //-- NOR FLASH drives should be tested |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
759 |
(driveInfo.iType == EMediaNANDFlash && driveInfo.iMediaAtt & KMediaAttDeleteNotify); //-- NAND media with DeleteNotify support |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
760 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
761 |
if(!bMediaSuitable) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
762 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
763 |
test.Printf(_L("This test can't be performed on this type of the media! Skipping.\n")); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
764 |
return; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
765 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
766 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
767 |
DoTest14(gDriveNum); |
0 | 768 |
} |
769 |
||
770 |
//-------------------------------------------------------- |
|
771 |
||
772 |
/** |
|
773 |
Actually perform the test on a drive aDrvNum. |
|
774 |
@param aDrvNum drive number |
|
775 |
*/ |
|
776 |
void DoTest14(TInt aDrvNum) |
|
777 |
{ |
|
778 |
||
779 |
TFileName fileName; |
|
780 |
fileName.Format(_L("Testing drive %c:"), 'A'+aDrvNum); |
|
781 |
test.Next(fileName); |
|
782 |
||
783 |
const TInt KFileSize = 0x1000; //-- size of the files t be created |
|
784 |
TInt nRes; |
|
785 |
||
786 |
fileName.Format(_L("%c:\\TestFile.bin"), aDrvNum+'A'); |
|
787 |
TheFs.Delete(fileName); //-- just in case |
|
788 |
||
789 |
//============================== |
|
790 |
//== Scenario 1. |
|
791 |
//== Create an empty file; AllocateSingleClusterL, ExtendClusterListL will be involved. |
|
792 |
//== Check that the file doesn't contain any meaningful information |
|
793 |
//============================== |
|
794 |
test.Printf(_L("Testing scenario 1\n")); |
|
795 |
||
796 |
//-- 1. create an empty file |
|
797 |
nRes = CreateEmptyFile(TheFs, fileName, KFileSize); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
798 |
test_KErrNone(nRes); |
0 | 799 |
|
249
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
800 |
#ifndef __NFE_MEDIA_DRIVER_PRESENT__ // can't easily check for illegitimate information if drive is encrypted |
0 | 801 |
//-- 1.1 check that this file doesn't contain illegitimate information. |
802 |
nRes = CheckFileContents(TheFs, fileName); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
803 |
test_KErrNone(nRes); |
249
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
804 |
#endif |
0 | 805 |
|
806 |
//-- 1.2 delete the empty file |
|
807 |
nRes = TheFs.Delete(fileName); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
808 |
test_KErrNone(nRes); |
0 | 809 |
|
810 |
//============================== |
|
811 |
//== Scenario 2. |
|
812 |
//== Create file, filling it with some pattern. |
|
813 |
//== Delete this file, FreeClusterListL() will be involved. |
|
814 |
//== Create an empty file supposedly of the place of just deleted one |
|
815 |
//== Check that the file doesn't contain any meaningful information |
|
816 |
//============================== |
|
817 |
test.Printf(_L("Testing scenario 2\n")); |
|
818 |
||
819 |
//-- 2. create file filled with some data pattern |
|
820 |
nRes = CreateStuffedFile(TheFs, fileName, KFileSize); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
821 |
test_KErrNone(nRes); |
0 | 822 |
|
823 |
//-- 2.1 delete this file |
|
824 |
TheFs.Delete(fileName); |
|
825 |
||
826 |
//-- 2.1 create an empty file on the place of just deleted one (hopefully) |
|
827 |
nRes = CreateEmptyFile(TheFs, fileName, KFileSize); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
828 |
test_KErrNone(nRes); |
0 | 829 |
|
830 |
//-- 2.2 check that this file doesn't contain illegitimate information. |
|
831 |
nRes = CheckFileContents(TheFs, fileName); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
832 |
test_KErrNone(nRes); |
0 | 833 |
|
834 |
//-- 2.3 delete this file |
|
835 |
TheFs.Delete(fileName); |
|
836 |
||
837 |
} |
|
838 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
839 |
static void Test15() |
0 | 840 |
// |
841 |
// Test IsValidName |
|
842 |
// |
|
843 |
{ |
|
844 |
test.Next(_L("Test RFs::IsValidName(TDesC& ,RFs::TNameValidParam& )")); |
|
845 |
TBool useDefaultSessionPath = EFalse; |
|
846 |
//tests under this loop are run twice |
|
847 |
//first, when the sessionPath is not used. |
|
848 |
//second, when the sessionPath is used. |
|
849 |
for(TInt i = 0; i<2; i++) |
|
850 |
{ |
|
851 |
RFs::TNameValidParam param(useDefaultSessionPath); |
|
852 |
test(TheFs.IsValidName(_L("*"),param)==EFalse); |
|
853 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
854 |
test(param.InvalidCharPos() == 1); |
|
855 |
||
856 |
test(TheFs.IsValidName(_L("?"),param)==EFalse); |
|
857 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
858 |
test(param.InvalidCharPos() == 1); |
|
859 |
||
860 |
test(TheFs.IsValidName(_L(">"),param)==EFalse); |
|
861 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
862 |
test(param.InvalidCharPos() == 1); |
|
863 |
||
864 |
test(TheFs.IsValidName(_L("<"),param)==EFalse); |
|
865 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
866 |
test(param.InvalidCharPos() == 1); |
|
867 |
||
868 |
test(TheFs.IsValidName(_L(":"),param)==EFalse); |
|
869 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
870 |
test(param.InvalidCharPos() == 1); |
|
871 |
||
872 |
test(TheFs.IsValidName(_L("\""),param)==EFalse); |
|
873 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
874 |
test(param.InvalidCharPos() == 1); |
|
875 |
||
876 |
test(TheFs.IsValidName(_L("/"),param)==EFalse); |
|
877 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
878 |
test(param.InvalidCharPos() == 1); |
|
879 |
||
880 |
test(TheFs.IsValidName(_L("|"),param)==EFalse); |
|
881 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
882 |
test(param.InvalidCharPos() == 1); |
|
883 |
||
884 |
test(TheFs.IsValidName(_L("xx*yy"),param)==EFalse); |
|
885 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
886 |
test(param.InvalidCharPos() == 3); |
|
887 |
||
888 |
test(TheFs.IsValidName(_L("xx?yy"),param)==EFalse); |
|
889 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
890 |
test(param.InvalidCharPos() == 3); |
|
891 |
||
892 |
test(TheFs.IsValidName(_L("xx>yy"),param)==EFalse); |
|
893 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
894 |
test(param.InvalidCharPos() == 3); |
|
895 |
||
896 |
test(TheFs.IsValidName(_L("xx<yy"),param)==EFalse); |
|
897 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
898 |
test(param.InvalidCharPos() == 3); |
|
899 |
||
900 |
test(TheFs.IsValidName(_L("xx:yy"),param)==EFalse); |
|
901 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
902 |
test(param.InvalidCharPos() == 3); |
|
903 |
||
904 |
test(TheFs.IsValidName(_L("xx\"yy"),param)==EFalse); |
|
905 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
906 |
test(param.InvalidCharPos() == 3); |
|
907 |
||
908 |
test(TheFs.IsValidName(_L("xx/yy"),param)==EFalse); |
|
909 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
910 |
test(param.InvalidCharPos() == 3); |
|
911 |
||
912 |
test(TheFs.IsValidName(_L("xx|yy"),param)==EFalse); |
|
913 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
914 |
test(param.InvalidCharPos() == 3); |
|
915 |
||
916 |
test(TheFs.IsValidName(_L("C:\\*\\group\\release.txt"),param)==EFalse); |
|
917 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
918 |
test(param.InvalidCharPos() == 4); |
|
919 |
||
920 |
test(TheFs.IsValidName(_L("C:\\?\\group\\release.txt"),param)==EFalse); |
|
921 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
922 |
test(param.InvalidCharPos() == 4); |
|
923 |
||
924 |
test(TheFs.IsValidName(_L("C:\\..\\group\\release.txt"),param)==EFalse); |
|
925 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
926 |
test(param.InvalidCharPos() == 4); |
|
927 |
||
928 |
test(TheFs.IsValidName(_L("C:\\.\\group\\release.txt"),param)==EFalse); |
|
929 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
930 |
test(param.InvalidCharPos() == 4); |
|
931 |
||
932 |
test(TheFs.IsValidName(_L("C:\\>\\group\\release.txt"),param)==EFalse); |
|
933 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
934 |
test(param.InvalidCharPos() == 4); |
|
935 |
||
936 |
test(TheFs.IsValidName(_L("C:\\<\\group\\release.txt"),param)==EFalse); |
|
937 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
938 |
test(param.InvalidCharPos() == 4); |
|
939 |
||
940 |
test(TheFs.IsValidName(_L("C:\\HelloWorld\\:\\group\\release.txt"),param)==EFalse); |
|
941 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
942 |
test(param.InvalidCharPos() == 15); |
|
943 |
||
944 |
test(TheFs.IsValidName(_L("C::\\group\\release.txt"),param)==EFalse); |
|
945 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
946 |
test(param.InvalidCharPos() == 3); |
|
947 |
||
948 |
test(TheFs.IsValidName(_L(">\\group\\release.txt"),param)==EFalse); |
|
949 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
950 |
test(param.InvalidCharPos() == 1); |
|
951 |
||
952 |
test(TheFs.IsValidName(_L("C|group\\release.txt"),param)==EFalse); |
|
953 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
954 |
test(param.InvalidCharPos() == 2); |
|
955 |
||
956 |
test(TheFs.IsValidName(_L("C\\|\\group\\release.txt"),param)==EFalse); |
|
957 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
958 |
test(param.InvalidCharPos() == 3); |
|
959 |
||
960 |
test(TheFs.IsValidName(_L("\\>"),param)==EFalse); |
|
961 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
962 |
test(param.InvalidCharPos() == 2); |
|
963 |
||
964 |
test(TheFs.IsValidName(_L("C:\\|group\\release.txt"),param)==EFalse); |
|
965 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
966 |
test(param.InvalidCharPos() == 4); |
|
967 |
||
968 |
test(TheFs.IsValidName(_L("C:\\\"\\group\\release.txt"),param)==EFalse); |
|
969 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
970 |
test(param.InvalidCharPos() == 4); |
|
971 |
||
972 |
test(TheFs.IsValidName(_L("C:\\/\\group\\release.txt"),param)==EFalse); |
|
973 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
974 |
test(param.InvalidCharPos() == 4); |
|
975 |
||
976 |
test(TheFs.IsValidName(_L("C:\\|\\group\\release.txt"),param)==EFalse); |
|
977 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
978 |
test(param.InvalidCharPos() == 4); |
|
979 |
||
980 |
test(TheFs.IsValidName(_L("C:\\ \\group\\release.txt"),param)==EFalse);//intermediate directory names cannot be blank |
|
981 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadName); |
|
982 |
||
983 |
// Test that \ is not allowed in filenames |
|
984 |
TFileName filename; |
|
985 |
filename=_L("C:\\HelloWorld\\\\\\group\\release.txt"); |
|
986 |
||
987 |
test(TheFs.IsValidName(filename,param)==EFalse); |
|
988 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
989 |
test(param.InvalidCharPos() == 22); |
|
990 |
||
991 |
filename=_L("C:\\\\\\group\\release.txt"); |
|
992 |
test(TheFs.IsValidName(filename,param)==EFalse); |
|
993 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
994 |
test(param.InvalidCharPos() == 11); |
|
995 |
||
996 |
filename=_L("C:\\Hello World\\group\\release.txt"); |
|
997 |
filename[8]=KPathDelimiter; |
|
998 |
test(TheFs.IsValidName(filename,param)); |
|
999 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1000 |
||
1001 |
filename=_L("C:\\HelloWorld\\::\\group\\release.txt"); |
|
1002 |
test(TheFs.IsValidName(filename,param)==EFalse); |
|
1003 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1004 |
test(param.InvalidCharPos() == 16); |
|
1005 |
||
1006 |
filename=_L("C:\\>>\\group\\release.txt"); |
|
1007 |
test(TheFs.IsValidName(filename,param)==EFalse); |
|
1008 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1009 |
test(param.InvalidCharPos() == 5); |
|
1010 |
||
1011 |
test(TheFs.IsValidName(_L(""),param)==EFalse); // Must be a name |
|
1012 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadName); |
|
1013 |
||
1014 |
test(TheFs.IsValidName(_L(".ext"),param)); |
|
1015 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1016 |
||
1017 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg"),param)); |
|
1018 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1019 |
||
1020 |
test(TheFs.IsValidName(_L("C:\\asdf..blarg"),param)); |
|
1021 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1022 |
||
1023 |
// Test multiple evil characters - parsing occurs from right to left |
|
1024 |
// except that wildcarded characters take priority and are picked out first |
|
1025 |
||
1026 |
test(TheFs.IsValidName(_L("abc>def|ghi?jkl:mno<pqr*stu"),param)==EFalse); |
|
1027 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1028 |
test(param.InvalidCharPos() == 24); |
|
1029 |
||
1030 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno?pqr"),param)==EFalse); |
|
1031 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1032 |
test(param.InvalidCharPos() == 20); |
|
1033 |
||
1034 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno"),param)==EFalse); |
|
1035 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1036 |
test(param.InvalidCharPos() == 16); |
|
1037 |
||
1038 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno"),param)==EFalse); |
|
1039 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1040 |
test(param.InvalidCharPos() == 16); |
|
1041 |
||
1042 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl"),param)==EFalse); |
|
1043 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1044 |
test(param.InvalidCharPos() == 12); |
|
1045 |
||
1046 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl"),param)==EFalse); |
|
1047 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1048 |
test(param.InvalidCharPos() == 12); |
|
1049 |
||
1050 |
test(TheFs.IsValidName(_L("abc>def|ghi"),param)==EFalse); |
|
1051 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1052 |
test(param.InvalidCharPos() == 8); |
|
1053 |
||
1054 |
test(TheFs.IsValidName(_L("abc>def|ghi"),param)==EFalse); |
|
1055 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1056 |
test(param.InvalidCharPos() == 8); |
|
1057 |
||
1058 |
test(TheFs.IsValidName(_L("abc>def"),param)==EFalse); |
|
1059 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1060 |
test(param.InvalidCharPos() == 4); |
|
1061 |
||
1062 |
test(TheFs.IsValidName(_L("abc>def"),param)==EFalse); |
|
1063 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1064 |
test(param.InvalidCharPos() == 4); |
|
1065 |
||
1066 |
test(!TheFs.IsValidName(_L("C:\\v123456.."),param)); |
|
1067 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1068 |
test(param.InvalidCharPos() == 11); |
|
1069 |
||
1070 |
test(!TheFs.IsValidName(_L("C:\\v123456.."),param)); |
|
1071 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1072 |
test(param.InvalidCharPos() == 11); |
|
1073 |
||
1074 |
test(TheFs.IsValidName(_L("abc"),param)); // Valid name |
|
1075 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1076 |
||
1077 |
test(TheFs.IsValidName(_L("abc"),param)); // Valid name |
|
1078 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1079 |
||
1080 |
test(TheFs.IsValidName(_L("as(){}@~#;!\xA3$%^&()df.blarg"),param)); // Valid name |
|
1081 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1082 |
||
1083 |
test(TheFs.IsValidName(_L("as(){}@~#;!\xA3$%^&()df.blarg"),param)); // Valid name |
|
1084 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1085 |
||
1086 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\asdf.blarg"),param)); // Valid name |
|
1087 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1088 |
||
1089 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\asdf.blarg"),param)); // Valid name |
|
1090 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1091 |
||
1092 |
test(TheFs.IsValidName(_L("\'"),param)); // Valid name |
|
1093 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1094 |
||
1095 |
test(TheFs.IsValidName(_L("\'"),param)); // Valid name |
|
1096 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1097 |
||
1098 |
//testing directory names |
|
1099 |
test(TheFs.IsValidName(_L("\\"),param)); |
|
1100 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); // Valid Name |
|
1101 |
||
1102 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\"),param)); |
|
1103 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); // Valid Name |
|
1104 |
||
1105 |
||
1106 |
test(TheFs.IsValidName(_L("C:\\asdf..blarg\\"),param)); |
|
1107 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); // Valid Name |
|
1108 |
||
1109 |
test(TheFs.IsValidName(_L("file1.txt\\\\"),param) == EFalse); |
|
1110 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadName); |
|
1111 |
||
1112 |
// test name which exceeds KMaxFileName only on prepending the session path |
|
1113 |
_LIT(KNameLength250, "AAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAA"); |
|
1114 |
if(useDefaultSessionPath) |
|
1115 |
{ |
|
1116 |
test(TheFs.IsValidName(KNameLength250, param)==EFalse); |
|
1117 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNameTooLong); |
|
1118 |
break; |
|
1119 |
} |
|
1120 |
else |
|
1121 |
{ |
|
1122 |
test(TheFs.IsValidName(KNameLength250, param)); |
|
1123 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1124 |
} |
|
1125 |
useDefaultSessionPath = ETrue; |
|
1126 |
} |
|
1127 |
} |
|
1128 |
||
1129 |
||
1130 |
||
1131 |
void TestGetMediaSerialNumber() |
|
1132 |
{ |
|
1133 |
test.Next(_L("Test RFs::GetMediaSerialNumber")); |
|
1134 |
TInt theDrive; |
|
1135 |
TInt r = TheFs.CharToDrive(gDriveToTest,theDrive); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1136 |
test_KErrNone(r); |
0 | 1137 |
TMediaSerialNumber serNum; |
1138 |
r = TheFs.GetMediaSerialNumber(serNum, theDrive); |
|
1139 |
if (r) test.Printf(_L("RFs::GetMediaSerialNumber returned error %d"), r); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1140 |
test_Value(r, r == KErrNotSupported || r == KErrNotReady || r == KErrNone); |
0 | 1141 |
if (r == KErrNotSupported) |
1142 |
{ |
|
1143 |
test.Printf(_L("MediaSerialNumber: Not Supported\n")); |
|
1144 |
} |
|
1145 |
else |
|
1146 |
{ |
|
1147 |
test.Printf(_L("MediaSerialNumber: length=%d\n"), serNum.Length()); |
|
1148 |
TBuf<20> str; |
|
1149 |
_LIT(KNumberString, "%02X"); |
|
1150 |
_LIT(KNewLine, "\n"); |
|
1151 |
TInt i; |
|
1152 |
for (i = 0; i < serNum.Length(); i++) |
|
1153 |
{ |
|
1154 |
str.AppendFormat(KNumberString, serNum[i]); |
|
1155 |
if (i%8 == 7) |
|
1156 |
{ |
|
1157 |
str.Append(KNewLine); |
|
1158 |
test.Printf(_L("%S"), &str); |
|
1159 |
str.SetLength(0); |
|
1160 |
} |
|
1161 |
} |
|
1162 |
if (i%8 != 7) |
|
1163 |
{ |
|
1164 |
test.Printf(KNewLine); |
|
1165 |
} |
|
1166 |
} |
|
1167 |
} |
|
1168 |
||
1169 |
||
1170 |
//-------------------------------------------------------- |
|
1171 |
||
1172 |
||
1173 |
/** |
|
1174 |
Create a file of specified size filled with some data pattern. |
|
1175 |
@param aFs ref. to the FS |
|
1176 |
@param aFileName name of the file |
|
1177 |
@param aFileSize size of the file to be created |
|
1178 |
@return KErrNone on success, system-wide error code otherwise |
|
1179 |
*/ |
|
1180 |
TInt CreateStuffedFile(RFs& aFs, const TDesC& aFileName, TUint aFileSize) |
|
1181 |
{ |
|
1182 |
TInt nRes; |
|
1183 |
RFile file; |
|
1184 |
||
1185 |
//-- create a buffer with some data |
|
1186 |
TBuf8<KBufLength> buffer; |
|
1187 |
buffer.SetLength(KBufLength); |
|
1188 |
||
1189 |
TUint i; |
|
1190 |
||
1191 |
for(i = 0; i < KBufLength; i++) |
|
1192 |
buffer[i] = static_cast<TUint8> (i) ; |
|
1193 |
||
1194 |
//-- create a file |
|
1195 |
nRes = file.Create(aFs, aFileName, EFileRead|EFileWrite); |
|
1196 |
if(nRes != KErrNone) |
|
1197 |
return nRes; |
|
1198 |
||
1199 |
const TUint n1 = aFileSize / KBufLength; |
|
1200 |
const TUint n2 = aFileSize % KBufLength; |
|
1201 |
||
1202 |
//-- fill the file with the data from buffer |
|
1203 |
for(i=0; i<n1; ++i) |
|
1204 |
{ |
|
1205 |
nRes = file.Write(buffer); |
|
1206 |
if(nRes != KErrNone) |
|
1207 |
return nRes; |
|
1208 |
} |
|
1209 |
||
1210 |
if(n2) |
|
1211 |
{ |
|
1212 |
nRes = file.Write(buffer, n2); //-- write the rest of the data |
|
1213 |
if(nRes != KErrNone) |
|
1214 |
return nRes; |
|
1215 |
} |
|
1216 |
||
1217 |
file.Close(); |
|
1218 |
||
1219 |
return KErrNone; |
|
1220 |
} |
|
1221 |
||
1222 |
//-------------------------------------------------------- |
|
1223 |
||
1224 |
/** |
|
1225 |
Check if the specified file contains illegitimate information i.e. something different from 0x00, 0xff, 0x03, 0xcc |
|
1226 |
||
1227 |
@param aFs ref. to the FS |
|
1228 |
@param aFileName name of the file |
|
1229 |
@return KErrNone on success, KErrCorrupt otherwise |
|
1230 |
*/ |
|
1231 |
TInt CheckFileContents(RFs& aFs, const TDesC& aFileName) |
|
1232 |
{ |
|
1233 |
TInt nRes = KErrNone; |
|
1234 |
RFile file; |
|
1235 |
||
1236 |
TBuf8<KBufLength> buffer; |
|
1237 |
buffer.SetLength(0); |
|
1238 |
||
1239 |
//-- open the file |
|
1240 |
nRes = file.Open(aFs, aFileName, EFileRead); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1241 |
test_KErrNone(nRes); |
0 | 1242 |
|
1243 |
//-- check file contents |
|
1244 |
TUint nFilePos=0; |
|
1245 |
for(;;) |
|
1246 |
{ |
|
1247 |
//-- read data from the file into the buffer |
|
1248 |
nRes = file.Read(buffer); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1249 |
test_KErrNone(nRes); |
0 | 1250 |
|
1251 |
if(buffer.Length() == 0) |
|
1252 |
{ |
|
1253 |
nRes = KErrNone; //-- read all the file, no illegitimate information found |
|
1254 |
break; //EOF |
|
1255 |
} |
|
1256 |
||
249
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1257 |
#ifdef __NFE_MEDIA_DRIVER_PRESENT__ |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1258 |
// check the buffer doesn't contain the same pattern written to it by CreateStuffedFile() |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1259 |
TUint i; |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1260 |
for(i = 0; i < KBufLength; i++) |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1261 |
if (buffer[i] != static_cast<TUint8> (i)) |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1262 |
break; |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1263 |
if (i == KBufLength) |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1264 |
{ |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1265 |
nRes = KErrCorrupt; //-- indicate that the read buffer contains illegitimate information |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1266 |
break; //-- comment this out if you need a full dump of the file |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1267 |
} |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1268 |
#else |
0 | 1269 |
//-- check if the buffer contains only allowed data (RAM page initialisation data, etc. e.g. 0x00, 0xff, 0x03, 0xcc) |
1270 |
if(!CheckBufferContents(buffer, nFilePos)) |
|
1271 |
{ |
|
1272 |
test.Printf(_L("\nCheckFileContents failed ! The file contains illegitimate information!\n")); |
|
1273 |
nRes = KErrCorrupt; //-- indicate that the read buffer contains illegitimate information |
|
1274 |
break; //-- comment this out if you need a full dump of the file |
|
1275 |
} |
|
249
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1276 |
#endif |
0 | 1277 |
|
1278 |
nFilePos+=buffer.Length(); |
|
1279 |
} |
|
1280 |
||
1281 |
file.Close(); |
|
1282 |
return nRes; |
|
1283 |
} |
|
1284 |
||
1285 |
//-------------------------------------------------------- |
|
1286 |
||
1287 |
/** |
|
1288 |
Check if the buffer contains illegitimate information i.e. something different from 0x00, 0xff, 0x03, 0xcc |
|
1289 |
||
1290 |
@param aBuffer buffer descriptor to check |
|
1291 |
@param aPrintBaseAddr dump base address, used for dumping buffer only |
|
1292 |
@return ETrue on success |
|
1293 |
*/ |
|
1294 |
TBool CheckBufferContents(const TDesC8& aBuffer, TUint aPrintBaseAddr/*=0*/) |
|
1295 |
{ |
|
1296 |
TBool bRes = ETrue; |
|
1297 |
||
1298 |
//-- check if the buffer filled with allowable data (RAM page initialisation data or something similar) |
|
1299 |
//-- but not something meaningful. |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1300 |
//-- Actually, the buffer should be filled with uniformed bytes (most probably, 0x00) |
0 | 1301 |
for(TInt i=0; i<aBuffer.Size(); ++i) |
1302 |
{ |
|
1303 |
TUint8 byte = aBuffer[i]; |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1304 |
if(byte != aBuffer[0]) |
0 | 1305 |
{ |
1306 |
bRes = EFalse; |
|
1307 |
break; |
|
1308 |
} |
|
1309 |
} |
|
1310 |
||
1311 |
//-- dump the buffer if it contains anything different than allowed data |
|
1312 |
if (!bRes) |
|
1313 |
{ |
|
1314 |
for (TInt n=0; n<aBuffer.Size(); ) |
|
1315 |
{ |
|
1316 |
TBuf16<3> byteBuffer; |
|
1317 |
TBuf16<256> lineBuffer; |
|
1318 |
lineBuffer.Format(_L("%08X: "), aPrintBaseAddr+n); |
|
1319 |
for (TInt m=0; m<16 && n<aBuffer.Size(); m++, n++) |
|
1320 |
{ |
|
1321 |
byteBuffer.Format(_L("%02X "), aBuffer[n]); |
|
1322 |
lineBuffer.Append(byteBuffer); |
|
1323 |
} |
|
1324 |
test.Printf(lineBuffer); |
|
1325 |
} |
|
1326 |
} |
|
1327 |
||
1328 |
return bRes; |
|
1329 |
} |
|
1330 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1331 |
//-------------------------------------------------------- |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1332 |
/** |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1333 |
Check if the drive aDriveNo is finalised or not. |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1334 |
The "CleanShutDown" is obtained by QueryVolumeInfoExt API which is FS-agnostic. |
0 | 1335 |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1336 |
@param aDriveNo drive number to query. |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1337 |
@return ETrue if the drive if finalised |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1338 |
*/ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1339 |
static TBool IsVolumeFinalised(TInt aDriveNo) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1340 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1341 |
TInt nRes; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1342 |
TPckgBuf<TBool> boolPckg; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1343 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1344 |
//-- 1. get "Finalised" state by using the API |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1345 |
nRes = TheFs.QueryVolumeInfoExt(aDriveNo, EIsDriveFinalised, boolPckg); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1346 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1347 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1348 |
return boolPckg(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1349 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1350 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1351 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1352 |
//-------------------------------------------------------- |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1353 |
/** |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1354 |
This is a file system - agnostic test that verifies RFs::FinaliseDrive() API |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1355 |
There are also file system - specific tests that check similar functionallity (see t_mount for example) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1356 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1357 |
*/ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1358 |
void TestDriveFinalisation() |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1359 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1360 |
test.Next(_L("TestDriveFinalisation(). Testing RFs::FinaliseDrives() API\n")); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1361 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1362 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1363 |
if((!Is_Fat(TheFs, gDriveNum) && !Is_ExFat(TheFs, gDriveNum)) || Is_Fat12(TheFs, gDriveNum) ) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1364 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1365 |
test.Printf(_L("This test can't be performed on current file system, skipping.\n")); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1366 |
return; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1367 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1368 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1369 |
TVolumeInfo v; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1370 |
TInt nRes; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1371 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1372 |
nRes = TheFs.Volume(v); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1373 |
test(nRes==KErrNone); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1374 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1375 |
if(v.iDrive.iMediaAtt & KMediaAttVariableSize) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1376 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1377 |
test.Printf(_L("Skipping. RAM drive not tested.\n")); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1378 |
return; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1379 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1380 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1381 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1382 |
TBool bDriveFinalised; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1383 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1384 |
//============= 1. finalise the drive (RW mode) and check the result |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1385 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1386 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1387 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1388 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1389 |
test(bDriveFinalised); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1390 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1391 |
//-- 1.1 finalise the drive second time EFinal_RW -> EFinal_RW shall work |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1392 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1393 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1394 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1395 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1396 |
test(bDriveFinalised); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1397 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1398 |
//============= 2. create a file. Shall succeed (EFinal_RW), the volume shall become unfinalised |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1399 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1400 |
RFile file; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1401 |
_LIT(KFileName, "\\my_file1.dat"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1402 |
_LIT8(KSomeData, "this is some data"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1403 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1404 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1405 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1406 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1407 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1408 |
test(!bDriveFinalised); //-- the volume has become "unfinalised" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1409 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1410 |
//---------------------------------------------------------------------------------- |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1411 |
//-- test volume finalisation with opened objects |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1412 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1413 |
//-- 2.1 having opened files should be OK for volume finalisation |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1414 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1415 |
//-- 2.1.1 RW finalisation; after the volume finalised it should be possible to write to the opened file |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1416 |
nRes = file.Open(TheFs, KFileName, EFileWrite | EFileWriteDirectIO); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1417 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1418 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1419 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1420 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1421 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1422 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1423 |
test(bDriveFinalised); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1424 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1425 |
nRes = file.Write(0, KSomeData); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1426 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1427 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1428 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1429 |
test(!bDriveFinalised); //-- the volume should become "unfinalised" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1430 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1431 |
//-- 2.1.2 RO finalisation; after the volume finalised it shouldn't be possible to write to the opened file |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1432 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RO); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1433 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1434 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1435 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1436 |
test(bDriveFinalised); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1437 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1438 |
nRes = file.Write(0, KSomeData); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1439 |
test(nRes == KErrAccessDenied); //-- no write access to the volume |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1440 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1441 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1442 |
test(bDriveFinalised); //-- the volume should become "unfinalised" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1443 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1444 |
file.Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1445 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1446 |
//-- remount FS, the drive shall become RW |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1447 |
nRes = RemountFS(TheFs, gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1448 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1449 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1450 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1451 |
//-- 2.2 having opened directories should be OK for volume finalisation |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1452 |
_LIT(KDirName, "\\Dir11235tt\\"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1453 |
MakeDir(KDirName); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1454 |
RDir dir; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1455 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1456 |
//-- 2.2.1 RW finalisation; after the volume finalised it should be possible to have write access to it |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1457 |
nRes = dir.Open(TheFs, KDirName, KEntryAttNormal); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1458 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1459 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1460 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1461 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1462 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1463 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1464 |
test(bDriveFinalised); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1465 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1466 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1467 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1468 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1469 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1470 |
test(!bDriveFinalised); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1471 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1472 |
//-- 2.1.2 RO finalisation; after the volume finalised it shouldn't be possible to write to it |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1473 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RO); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1474 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1475 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1476 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1477 |
test(bDriveFinalised); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1478 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1479 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1480 |
test(nRes == KErrAccessDenied); //-- no write access to the volume |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1481 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1482 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1483 |
test(bDriveFinalised); //-- the volume should become "unfinalised" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1484 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1485 |
dir.Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1486 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1487 |
//-- remount FS, the drive shall become RW |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1488 |
nRes = RemountFS(TheFs, gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1489 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1490 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1491 |
//-- 2.3 having opened disk access objects, like formats or raw disks makes finalisation impossible |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1492 |
RFormat format; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1493 |
RRawDisk rawDisk; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1494 |
TInt fmtCnt; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1495 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1496 |
//-- 2.3.1 format |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1497 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1498 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1499 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1500 |
nRes = format.Open(TheFs, gSessionPath, EFullFormat, fmtCnt); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1501 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1502 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1503 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1504 |
test(nRes == KErrInUse); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1505 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1506 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RO); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1507 |
test(nRes == KErrInUse); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1508 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1509 |
format.Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1510 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1511 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1512 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1513 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1514 |
//-- 2.3.2 raw disk |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1515 |
nRes = rawDisk.Open(TheFs, gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1516 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1517 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1518 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1519 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1520 |
test(nRes == KErrInUse); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1521 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1522 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RO); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1523 |
test(nRes == KErrInUse); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1524 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1525 |
rawDisk.Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1526 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1527 |
//-- 2.4 Volume finalisation and file system dismounting |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1528 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1529 |
//-- 2.4.1 "graceful" dismounting should finalise the drive correctly |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1530 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1531 |
//-- "unfinalise the volume" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1532 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1533 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1534 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1535 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1536 |
test(!bDriveFinalised); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1537 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1538 |
TFSDescriptor fsDesc; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1539 |
nRes = GetFileSystemDescriptor(TheFs, gDriveNum, fsDesc); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1540 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1541 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1542 |
//-- gracefully dismount the file system |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1543 |
nRes = TheFs.DismountFileSystem(fsDesc.iFsName, gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1544 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1545 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1546 |
//-- mount it back |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1547 |
nRes = MountFileSystem(TheFs, gDriveNum, fsDesc); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1548 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1549 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1550 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1551 |
test(bDriveFinalised); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1552 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1553 |
//-- 2.4.2 "forced" dismounting, usually happens when "graceful doesn't work, because there are files opened on the volume. |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1554 |
//-- Should also finalise the drive correctly |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1555 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1556 |
//-- "unfinalise the volume" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1557 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1558 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1559 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1560 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1561 |
test(!bDriveFinalised); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1562 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1563 |
//-- open a file on the volume, this will prevent graceful dismounting |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1564 |
nRes = file.Open(TheFs, KFileName, EFileWrite | EFileWriteDirectIO); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1565 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1566 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1567 |
nRes = GetFileSystemDescriptor(TheFs, gDriveNum, fsDesc); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1568 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1569 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1570 |
//-- try gracefully dismount the file system |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1571 |
nRes = TheFs.DismountFileSystem(fsDesc.iFsName, gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1572 |
test(nRes == KErrInUse); //-- no luck, as expected |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1573 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1574 |
//-- now do dismounting by force |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1575 |
TRequestStatus rqStat; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1576 |
TheFs.NotifyDismount(gDriveNum, rqStat, EFsDismountForceDismount); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1577 |
User::WaitForRequest(rqStat); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1578 |
test_KErrNone(rqStat.Int()); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1579 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1580 |
nRes = file.Write(0, KSomeData); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1581 |
test(nRes == KErrNotReady); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1582 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1583 |
file.Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1584 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1585 |
//-- mount it back |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1586 |
nRes = MountFileSystem(TheFs, gDriveNum, fsDesc); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1587 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1588 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1589 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1590 |
test(bDriveFinalised); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1591 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1592 |
//============= 3. test "unfinalise API" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1593 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EForceUnfinalise); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1594 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1595 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1596 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1597 |
test(!bDriveFinalised); //-- the volume has become "unfinalised" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1598 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1599 |
//============= 4. test finalisation into RO mode |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1600 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RO); //-- the volume becomes RO |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1601 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1602 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1603 |
//-- try to write a file on RO volume; it shall fail with KErrAccessDenied |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1604 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1605 |
test(nRes == KErrAccessDenied); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1606 |
file.Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1607 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1608 |
//-- 4.1 try to finalise into EFinal_RW mode, shall fail with KErrAccessDenied |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1609 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1610 |
test(nRes == KErrAccessDenied); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1611 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1612 |
//-- 4.2 "unfinalise" the volume, it still shall remain RO |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1613 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EForceUnfinalise); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1614 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1615 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1616 |
//-- try to write a file on RO volume; it shall fail with KErrAccessDenied |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1617 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1618 |
test(nRes == KErrAccessDenied); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1619 |
file.Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1620 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1621 |
//-- remount FS, the drive shall become RW |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1622 |
nRes = RemountFS(TheFs, gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1623 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1624 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1625 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1626 |
test(bDriveFinalised); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1627 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1628 |
//-- try to write a file on RW volume, shall be OK |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1629 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1630 |
test(nRes == KErrNone); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1631 |
file.Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1632 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1633 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1634 |
test(!bDriveFinalised); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1635 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1636 |
//============= 5. test various finalisation modes |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1637 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1638 |
//-- 5.1 Not finalised -> EFinal_RW (KErrNone) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1639 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1640 |
test(nRes == KErrNone); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1641 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1642 |
test(bDriveFinalised); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1643 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1644 |
//-- 5.2 EFinal_RW -> EFinal_RO (KErrNone) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1645 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RO); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1646 |
test(nRes == KErrNone); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1647 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1648 |
test(bDriveFinalised); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1649 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1650 |
//-- 5.2 EFinal_RO -> EFinal_RW (KErrAccessDenied) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1651 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1652 |
test(nRes == KErrAccessDenied); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1653 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1654 |
test(bDriveFinalised); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1655 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1656 |
//-- 5.3 restore |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1657 |
nRes = RemountFS(TheFs, gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1658 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1659 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1660 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1661 |
//============= 6. test old RFs::FinaliseDrives API |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1662 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1663 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1664 |
test(nRes == KErrNone); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1665 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1666 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1667 |
test(!bDriveFinalised); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1668 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1669 |
TheFs.FinaliseDrives(); //-- shall work as TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW) but for ALL drives |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1670 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1671 |
bDriveFinalised = IsVolumeFinalised(gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1672 |
test(bDriveFinalised); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1673 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1674 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1675 |
test(nRes == KErrNone); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1676 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1677 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1678 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1679 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1680 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1681 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1682 |
void CallTestsL() |
0 | 1683 |
{ |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1684 |
//-- set up console output |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1685 |
F32_Test_Utils::SetConsole(test.Console()); |
0 | 1686 |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1687 |
TInt nRes=TheFs.CharToDrive(gDriveToTest, gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1688 |
test_KErrNone(nRes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1689 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1690 |
PrintDrvInfo(TheFs, gDriveNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1691 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1692 |
TestDriveFinalisation(); |
0 | 1693 |
Test1(); |
1694 |
Test2(); |
|
1695 |
Test3(); |
|
1696 |
Test4(); |
|
1697 |
Test5(); |
|
1698 |
Test6(); |
|
1699 |
Test7(); |
|
1700 |
Test8(); |
|
1701 |
Test9(); |
|
1702 |
Test10(); |
|
1703 |
Test11(); |
|
1704 |
Test12(); |
|
1705 |
Test13(); |
|
1706 |
Test14(); |
|
1707 |
Test15(); |
|
1708 |
TestGetMediaSerialNumber(); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
249
diff
changeset
|
1709 |
|
0 | 1710 |
} |