author | Mike Kinghan <mikek@symbian.org> |
Mon, 19 Jul 2010 08:40:05 +0100 | |
branch | GCC_SURGE |
changeset 209 | 6035754ebf88 |
parent 109 | b3a1d9898418 |
child 199 | 189ece41fa29 |
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 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
18 |
#define __E32TEST_EXTENSION__ |
0 | 19 |
#include <f32file.h> |
20 |
#include <e32test.h> |
|
21 |
#include "t_server.h" |
|
22 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
23 |
// If there is an NFE media driver present, then because of the way EDeleteNotify requests work, |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
24 |
// the data retrieved from a deleted file will not be a buffer full of zero's, but instead a buffer |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
25 |
// full of decrypted zero's |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
26 |
#define __NFE_MEDIA_DRIVER_PRESENT__ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
27 |
|
0 | 28 |
#ifdef __VC32__ |
29 |
// Solve compilation problem caused by non-English locale |
|
30 |
#pragma setlocale("english") |
|
31 |
#endif |
|
32 |
||
33 |
GLDEF_D RTest test(_L("T_MISC")); |
|
34 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
35 |
const TUint KBufLength = 0x100; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
36 |
|
0 | 37 |
LOCAL_C void Test1() |
38 |
// |
|
39 |
// Open, write to and read from a file |
|
40 |
// |
|
41 |
{ |
|
42 |
||
43 |
test.Next(_L("Open, write to and read from a file")); |
|
44 |
TInt r=TheFs.SetSessionPath(gSessionPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
45 |
test_KErrNone(r); |
0 | 46 |
RFile file; |
47 |
r=file.Create(TheFs,_L("Hello.Wld"),EFileWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
48 |
test_KErrNone(r); |
0 | 49 |
r=file.Write(_L8("Hello World"),11); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
50 |
test_KErrNone(r); |
0 | 51 |
file.Close(); |
52 |
||
53 |
r=file.Open(TheFs,_L("Hello.Wld"),EFileRead); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
54 |
test_KErrNone(r); |
0 | 55 |
TBuf8<256> buf; |
56 |
r=file.Read(buf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
57 |
test_KErrNone(r); |
0 | 58 |
test(buf==_L8("Hello World")); |
59 |
file.Close(); |
|
60 |
} |
|
61 |
||
62 |
LOCAL_C void Test2() |
|
63 |
// |
|
64 |
// Open and read from a file |
|
65 |
// |
|
66 |
{ |
|
67 |
||
68 |
test.Next(_L("Open and read from a file")); |
|
69 |
TInt r=TheFs.SetSessionPath(gSessionPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
70 |
test_KErrNone(r); |
0 | 71 |
RFile file; |
72 |
r=file.Open(TheFs,_L("Hello.Wld"),EFileRead); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
73 |
test_KErrNone(r); |
0 | 74 |
TBuf8<256> buf; |
75 |
r=file.Read(buf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
76 |
test_KErrNone(r); |
0 | 77 |
test(buf==_L8("Hello World")); |
78 |
file.Close(); |
|
79 |
r=TheFs.Delete(_L("HELLO.WLD")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
80 |
test_KErrNone(r); |
0 | 81 |
} |
82 |
||
83 |
LOCAL_C void Test3() |
|
84 |
// |
|
85 |
// Create nested directories |
|
86 |
// |
|
87 |
{ |
|
88 |
||
89 |
test.Next(_L("Create nested directories")); |
|
90 |
TInt r=TheFs.SetSessionPath(gSessionPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
91 |
test_KErrNone(r); |
0 | 92 |
TheFs.ResourceCountMarkStart(); |
93 |
// |
|
94 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\A.B")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
95 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 96 |
r=TheFs.MkDir(_L("\\F32-TST\\RIGHT\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
97 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 98 |
// |
99 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\ONE\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
100 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 101 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\TWO\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
102 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 103 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\THREE\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
104 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 105 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\TWO\\BOTTOM\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
106 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 107 |
// |
108 |
r=TheFs.MkDirAll(_L("\\F32-TST\\RIGHT\\TOP\\MID\\BOT\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
109 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 110 |
} |
111 |
||
112 |
LOCAL_C void Test4() |
|
113 |
// |
|
114 |
// Test returned error values |
|
115 |
// |
|
116 |
{ |
|
117 |
||
118 |
test.Next(_L("Test returned error values")); |
|
119 |
TInt r=TheFs.SetSessionPath(gSessionPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
120 |
test_KErrNone(r); |
0 | 121 |
TheFs.ResourceCountMarkStart(); |
122 |
// |
|
123 |
r=TheFs.MkDir(_L("\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
124 |
test_Value(r, r == KErrAlreadyExists); |
0 | 125 |
r=TheFs.MkDir(_L("\\LEFT")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
126 |
test_Value(r, r == KErrAlreadyExists); |
0 | 127 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
128 |
test_Value(r, r == KErrAlreadyExists); |
0 | 129 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\..\\NEWDIR\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
130 |
test_Value(r, r == KErrBadName); |
0 | 131 |
r=TheFs.MkDir(_L("\\F32-TST\\NEWDIR\\SUBDIR\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
132 |
test_Value(r, r == KErrPathNotFound); |
0 | 133 |
// |
134 |
r=TheFs.RmDir(_L("\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
135 |
test_Value(r, r == KErrInUse); |
0 | 136 |
r=TheFs.RmDir(_L("\\PROG")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
137 |
test_Value(r, r == KErrInUse); |
0 | 138 |
r=TheFs.RmDir(_L("\\F32-TST\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
139 |
test_Value(r, r == KErrInUse); |
0 | 140 |
|
141 |
||
142 |
RDir dir; |
|
143 |
r=dir.Open(TheFs,_L("V:\\asdf"),KEntryAttNormal); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
144 |
test_Value(r, r == KErrNone || r==KErrNotReady || r==KErrNotFound); |
0 | 145 |
if (r==KErrNone) |
146 |
dir.Close(); |
|
147 |
r=dir.Open(TheFs,_L("L:\\asdf"),KEntryAttNormal); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
148 |
test_Value(r, r == KErrNone || r==KErrNotReady || r==KErrNotFound); |
0 | 149 |
dir.Close(); |
150 |
// |
|
151 |
TEntry entry; |
|
152 |
r=TheFs.Entry(_L("z:\\NOTEXiSTS\\file.txt"),entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
153 |
test_Value(r, r == KErrPathNotFound); |
0 | 154 |
r=TheFs.Entry(_L("z:\\NOTEXiSTS\\"),entry); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
155 |
test_Value(r, r == KErrNotFound); |
0 | 156 |
r=TheFs.Entry(_L("z:\\SYSTEM\\"),entry); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
157 |
test_KErrNone(r); |
0 | 158 |
r=TheFs.Entry(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)?_L("z:\\SYS\\BIN\\ESHELL.EXE"):_L("z:\\SYSTEM\\BIN\\ESHELL.EXE"),entry); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
159 |
test_KErrNone(r); |
0 | 160 |
|
161 |
r=dir.Open(TheFs,_L("\\*"),NULL); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
162 |
test_KErrNone(r); |
0 | 163 |
TEntry dirEntry; |
164 |
r=dir.Read(dirEntry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
165 |
test_Value(r, r == KErrNone || r==KErrEof); |
0 | 166 |
if (r==KErrNone) |
167 |
test.Printf(_L("%S\n"),&dirEntry.iName); |
|
168 |
dir.Close(); |
|
169 |
||
170 |
r=dir.Open(TheFs,_L("A:\\*"),NULL); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
171 |
test_Value(r, r == KErrNotReady || r==KErrNone); |
0 | 172 |
dir.Close(); |
173 |
} |
|
174 |
||
175 |
LOCAL_C void Test5() |
|
176 |
// |
|
177 |
// Read files directly from the rom |
|
178 |
// |
|
179 |
||
180 |
{ |
|
181 |
test.Next(_L("Read Files directly from the rom")); |
|
182 |
||
183 |
TInt pos=0; |
|
184 |
TInt r; |
|
185 |
_LIT(KTFileCpp, "Z:\\test\\T_FILE.CPP"); |
|
186 |
_LIT(KTFsrvCpp, "Z:\\test\\T_FSRV.CPP"); |
|
187 |
||
188 |
if ( TheFs.IsFileInRom(KTFileCpp) != NULL && TheFs.IsFileInRom(KTFsrvCpp) != NULL ) |
|
189 |
{ |
|
190 |
RFile f; |
|
191 |
r=f.Open(TheFs,KTFileCpp,EFileRead); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
192 |
test_KErrNone(r); |
0 | 193 |
r=f.Seek(ESeekAddress,pos); |
194 |
TText8* ptrPos=*(TText8**)&pos; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
195 |
test_KErrNone(r); |
0 | 196 |
TBuf8<1024> readBuf; |
197 |
r=f.Read(readBuf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
198 |
test_KErrNone(r); |
0 | 199 |
test(readBuf.Length()==readBuf.MaxLength()); |
200 |
TPtrC8 memBuf(ptrPos,readBuf.Length()); |
|
201 |
test(memBuf==readBuf); |
|
202 |
||
203 |
ptrPos+=9913; |
|
204 |
pos=9913; |
|
205 |
r=f.Seek(ESeekStart,pos); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
206 |
test_KErrNone(r); |
0 | 207 |
readBuf.SetLength(0); |
208 |
r=f.Read(readBuf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
209 |
test_KErrNone(r); |
0 | 210 |
test(readBuf.Length()==readBuf.MaxLength()); |
211 |
memBuf.Set(ptrPos,readBuf.Length()); |
|
212 |
test(memBuf==readBuf); |
|
213 |
||
214 |
RFile f2; |
|
215 |
pos=10; |
|
216 |
r=f2.Open(TheFs,KTFsrvCpp,EFileRead); |
|
217 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
218 |
test_KErrNone(r); |
0 | 219 |
r=f2.Seek(ESeekAddress,pos); |
220 |
ptrPos=*(TText8**)&pos; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
221 |
test_KErrNone(r); |
0 | 222 |
readBuf.SetLength(0); |
223 |
pos=10; |
|
224 |
r=f2.Seek(ESeekStart,pos); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
225 |
test_KErrNone(r); |
0 | 226 |
r=f2.Read(readBuf); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
227 |
test_KErrNone(r); |
0 | 228 |
test(readBuf.Length()==readBuf.MaxLength()); |
229 |
memBuf.Set(ptrPos,readBuf.Length()); |
|
230 |
test(memBuf==readBuf); |
|
231 |
||
232 |
ptrPos+=2445; |
|
233 |
pos=10+2445; |
|
234 |
r=f2.Seek(ESeekStart,pos); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
235 |
test_KErrNone(r); |
0 | 236 |
readBuf.SetLength(0); |
237 |
r=f2.Read(readBuf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
238 |
test_KErrNone(r); |
0 | 239 |
test(readBuf.Length()==readBuf.MaxLength()); |
240 |
memBuf.Set(ptrPos,readBuf.Length()); |
|
241 |
test(memBuf==readBuf); |
|
242 |
||
243 |
pos=0; |
|
244 |
r=f.Seek(ESeekAddress,pos); |
|
245 |
ptrPos=*(TText8**)&pos; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
246 |
test_KErrNone(r); |
0 | 247 |
readBuf.SetLength(0); |
248 |
pos=0; |
|
249 |
r=f.Seek(ESeekStart,pos); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
250 |
test_KErrNone(r); |
0 | 251 |
r=f.Read(readBuf); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
252 |
test_KErrNone(r); |
0 | 253 |
test(readBuf.Length()==readBuf.MaxLength()); |
254 |
memBuf.Set(ptrPos,readBuf.Length()); |
|
255 |
test(memBuf==readBuf); |
|
256 |
||
257 |
ptrPos+=5245; |
|
258 |
pos=5245; |
|
259 |
r=f.Seek(ESeekStart,pos); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
260 |
test_KErrNone(r); |
0 | 261 |
readBuf.SetLength(0); |
262 |
r=f.Read(readBuf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
263 |
test_KErrNone(r); |
0 | 264 |
test(readBuf.Length()==readBuf.MaxLength()); |
265 |
memBuf.Set(ptrPos,readBuf.Length()); |
|
266 |
test(memBuf==readBuf); |
|
267 |
||
268 |
f.Close(); |
|
269 |
f2.Close(); |
|
270 |
} |
|
271 |
} |
|
272 |
||
273 |
LOCAL_C void Test6() |
|
274 |
// |
|
275 |
// Test rom return values |
|
276 |
// |
|
277 |
{ |
|
278 |
test.Next(_L("Test rom return values")); |
|
279 |
||
280 |
RFile f; |
|
281 |
TInt r=f.Replace(TheFs,_L("Z:\\Test\\T_Fsrv.Cpp"),EFileRead); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
282 |
test_Value(r, r == KErrAccessDenied); |
0 | 283 |
r=f.Create(TheFs,_L("Z:\\Test\\newT_Fsrv.Cpp"),EFileRead); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
284 |
test_Value(r, r == KErrAccessDenied); |
0 | 285 |
r=f.Open(TheFs,_L("Z:\\Test\\T_Fsrv.Cpp"),EFileRead); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
286 |
test_KErrNone(r); |
0 | 287 |
f.Close(); |
288 |
r=f.Open(TheFs,_L("Z:\\Test\\T_Fsrv.Cpp"),EFileRead|EFileWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
289 |
test_Value(r, r == KErrAccessDenied); |
0 | 290 |
} |
291 |
||
292 |
LOCAL_C void Test7() |
|
293 |
// |
|
294 |
// Test cache |
|
295 |
// |
|
296 |
{ |
|
297 |
||
298 |
test.Next(_L("Test cache updated when writing to a file")); |
|
299 |
TUidType uid1(TUid::Uid(1),TUid::Uid(2),TUid::Uid(3)); |
|
300 |
TBuf8<32> contents1=_L8("asdf asdf asdf"); |
|
301 |
TBuf<32> file1=_L("\\TMISC\\CACHE.FILE"); |
|
302 |
MakeFile(file1,uid1,contents1); |
|
303 |
||
304 |
TEntry entry; |
|
305 |
TInt r=TheFs.Entry(file1,entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
306 |
test_KErrNone(r); |
0 | 307 |
test(entry.iType==uid1); |
308 |
||
309 |
TUidType uid2(TUid::Uid(4),TUid::Uid(5),TUid::Uid(6)); |
|
310 |
TCheckedUid checkedUid(uid2); |
|
311 |
TPtrC8 uidData((TUint8*)&checkedUid,sizeof(TCheckedUid)); |
|
312 |
RFile f; |
|
313 |
r=f.Open(TheFs,file1,EFileRead|EFileWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
314 |
test_KErrNone(r); |
0 | 315 |
r=f.Write(uidData); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
316 |
test_KErrNone(r); |
0 | 317 |
r = f.Flush(); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
318 |
test_KErrNone(r); |
0 | 319 |
|
320 |
r=TheFs.Entry(file1,entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
321 |
test_KErrNone(r); |
0 | 322 |
test(entry.iType==uid2); |
323 |
||
324 |
f.Close(); |
|
325 |
r=TheFs.Entry(file1,entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
326 |
test_KErrNone(r); |
0 | 327 |
test(entry.iType==uid2); |
328 |
} |
|
329 |
||
330 |
LOCAL_C void Test8() |
|
331 |
// |
|
332 |
// Test IsValidName |
|
333 |
// |
|
334 |
{ |
|
335 |
test.Next(_L("Test RFs::IsValidName(TDesC)")); |
|
336 |
||
337 |
// tests calling IsValidName() with invalid name as first call to session |
|
338 |
// see defect EXT-57KH9K |
|
339 |
_LIT(KInvalidName, "test\\i1.jpg"); |
|
340 |
RFs fs; |
|
341 |
test(KErrNone==fs.Connect()); |
|
342 |
test(fs.IsValidName(KInvalidName)==EFalse); |
|
343 |
fs.Close(); |
|
344 |
||
345 |
test(TheFs.IsValidName(_L("*"))==EFalse); |
|
346 |
test(TheFs.IsValidName(_L("?"))==EFalse); |
|
347 |
test(TheFs.IsValidName(_L(">"))==EFalse); |
|
348 |
test(TheFs.IsValidName(_L("<"))==EFalse); |
|
349 |
test(TheFs.IsValidName(_L(":"))==EFalse); |
|
350 |
test(TheFs.IsValidName(_L("\""))==EFalse); |
|
351 |
test(TheFs.IsValidName(_L("/"))==EFalse); |
|
352 |
test(TheFs.IsValidName(_L("|"))==EFalse); |
|
353 |
test(TheFs.IsValidName(_L("\\"))==EFalse); |
|
354 |
||
355 |
test(TheFs.IsValidName(_L("xx*yy"))==EFalse); |
|
356 |
test(TheFs.IsValidName(_L("xx?yy"))==EFalse); |
|
357 |
test(TheFs.IsValidName(_L("xx>yy"))==EFalse); |
|
358 |
test(TheFs.IsValidName(_L("xx<yy"))==EFalse); |
|
359 |
test(TheFs.IsValidName(_L("xx:yy"))==EFalse); |
|
360 |
test(TheFs.IsValidName(_L("xx\"yy"))==EFalse); |
|
361 |
test(TheFs.IsValidName(_L("xx/yy"))==EFalse); |
|
362 |
test(TheFs.IsValidName(_L("xx|yy"))==EFalse); |
|
363 |
||
364 |
test(TheFs.IsValidName(_L("C:\\*\\group\\release.txt"))==EFalse); |
|
365 |
test(TheFs.IsValidName(_L("C:\\?\\group\\release.txt"))==EFalse); |
|
366 |
test(TheFs.IsValidName(_L("C:\\>\\group\\release.txt"))==EFalse); |
|
367 |
test(TheFs.IsValidName(_L("C:\\<\\group\\release.txt"))==EFalse); |
|
368 |
test(TheFs.IsValidName(_L("C:\\:\\group\\release.txt"))==EFalse); |
|
369 |
test(TheFs.IsValidName(_L("C:\\\"\\group\\release.txt"))==EFalse); |
|
370 |
test(TheFs.IsValidName(_L("C:\\/\\group\\release.txt"))==EFalse); |
|
371 |
test(TheFs.IsValidName(_L("C:\\|\\group\\release.txt"))==EFalse); |
|
372 |
||
373 |
test(TheFs.IsValidName(_L(""))==EFalse); // must be a name or extension present |
|
374 |
test(TheFs.IsValidName(_L(".ext"))); |
|
375 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\"))==EFalse); |
|
376 |
test(TheFs.IsValidName(_L("\\"))==EFalse); |
|
377 |
||
378 |
test(TheFs.IsValidName(_L("as(){}@~#;!\xA3$%^&()df.blarg"))); // Valid names |
|
379 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\asdf.blarg"))); // Valid names |
|
380 |
test(TheFs.IsValidName(_L("\'"))); // Valid names |
|
381 |
||
382 |
test.Next(_L("Test RFs::IsValidName(TDesC, TDes) overload")); |
|
383 |
||
384 |
TText testChar; |
|
385 |
test(TheFs.IsValidName(_L("*"),testChar)==EFalse); |
|
386 |
test(testChar=='*'); |
|
387 |
test(TheFs.IsValidName(_L("?"),testChar)==EFalse); |
|
388 |
test(testChar=='?'); |
|
389 |
test(TheFs.IsValidName(_L(">"),testChar)==EFalse); |
|
390 |
test(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=='\"'); // Tests that " is illegal |
|
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==' '); |
|
403 |
||
404 |
test(TheFs.IsValidName(_L("xx*yy"),testChar)==EFalse); |
|
405 |
test(testChar=='*'); |
|
406 |
test(TheFs.IsValidName(_L("xx?yy"),testChar)==EFalse); |
|
407 |
test(testChar=='?'); |
|
408 |
test(TheFs.IsValidName(_L("xx>yy"),testChar)==EFalse); |
|
409 |
test(testChar=='>'); |
|
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=='\"'); // Tests that " is illegal |
|
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 |
||
421 |
test(TheFs.IsValidName(_L("C:\\*\\group\\release.txt"),testChar)==EFalse); |
|
422 |
test(testChar=='*'); |
|
423 |
test(TheFs.IsValidName(_L("C:\\?\\group\\release.txt"),testChar)==EFalse); |
|
424 |
test(testChar=='?'); |
|
425 |
test(TheFs.IsValidName(_L("C:\\..\\group\\release.txt"),testChar)==EFalse); |
|
426 |
test(testChar=='.'); // Only one "." returned however many are in filename |
|
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=='<'); |
|
433 |
test(TheFs.IsValidName(_L("C:\\HelloWorld\\:\\group\\release.txt"),testChar)==EFalse); |
|
434 |
test(testChar==':'); |
|
435 |
||
436 |
||
437 |
test(TheFs.IsValidName(_L("C::\\group\\release.txt"),testChar)==EFalse); |
|
438 |
test(testChar==':'); |
|
439 |
test(TheFs.IsValidName(_L(">\\group\\release.txt"),testChar)==EFalse); |
|
440 |
test(testChar=='>'); |
|
441 |
test(TheFs.IsValidName(_L("C|group\\release.txt"),testChar)==EFalse); |
|
442 |
test(testChar=='|'); |
|
443 |
test(TheFs.IsValidName(_L("C\\|\\group\\release.txt"),testChar)==EFalse); |
|
444 |
test(testChar=='|'); |
|
445 |
||
446 |
test(TheFs.IsValidName(_L("\\>"),testChar)==EFalse); |
|
447 |
test(testChar=='>'); |
|
448 |
test(TheFs.IsValidName(_L("C:\\|group\\release.txt"),testChar)==EFalse); |
|
449 |
test(testChar=='|'); |
|
450 |
||
451 |
test(TheFs.IsValidName(_L("C:\\\"\\group\\release.txt"),testChar)==EFalse); |
|
452 |
test(testChar=='\"'); |
|
453 |
test(TheFs.IsValidName(_L("C:\\/\\group\\release.txt"),testChar)==EFalse); |
|
454 |
test(testChar=='/'); |
|
455 |
test(TheFs.IsValidName(_L("C:\\|\\group\\release.txt"),testChar)==EFalse); |
|
456 |
test(testChar=='|'); |
|
457 |
test(TheFs.IsValidName(_L("C:\\ \\group\\release.txt"),testChar)==EFalse); // must be a name or extension present |
|
458 |
test(testChar==' '); |
|
459 |
||
460 |
// Test that \ is not allowed in filenames |
|
461 |
TFileName filename; |
|
462 |
filename=_L("C:\\HelloWorld\\\\\\group\\release.txt"); |
|
463 |
TPtr pChar(&testChar,sizeof(TText),sizeof(TText)); |
|
464 |
test(TheFs.IsValidName(filename,testChar)==EFalse); |
|
465 |
test(pChar.Find(_L("\\"))!=KErrNotFound); |
|
466 |
filename=_L("C:\\\\\\group\\release.txt"); |
|
467 |
test(TheFs.IsValidName(filename,testChar)==EFalse); |
|
468 |
test(pChar.Find(_L("\\"))!=KErrNotFound); |
|
469 |
filename=_L("C:\\Hello World\\group\\release.txt"); |
|
470 |
filename[8]=KPathDelimiter; // Makes C:\\Hello World\\group\\release.txt |
|
471 |
test(TheFs.IsValidName(filename,testChar)); |
|
472 |
filename=_L("C:\\HelloWorld\\::\\group\\release.txt"); |
|
473 |
test(TheFs.IsValidName(filename,testChar)==EFalse); |
|
474 |
test(pChar.Find(_L(":"))!=KErrNotFound); |
|
475 |
||
476 |
filename=_L("C:\\>>\\group\\release.txt"); |
|
477 |
test(TheFs.IsValidName(filename,testChar)==EFalse); |
|
478 |
test(pChar.Find(_L(">"))!=KErrNotFound); |
|
479 |
||
480 |
test(TheFs.IsValidName(_L(""),testChar)==EFalse); // Must be a name |
|
481 |
test(testChar==' '); |
|
482 |
test(TheFs.IsValidName(_L(".ext"),testChar)); |
|
483 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\"),testChar)==EFalse); |
|
484 |
test(testChar==' '); // Must be a name else testChar is set to blank |
|
485 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg"),testChar)); |
|
486 |
||
487 |
test(TheFs.IsValidName(_L("C:\\asdf..blarg\\"),testChar)==EFalse); |
|
488 |
test(testChar==' '); // Must be a name else testChar is set to blank |
|
489 |
test(TheFs.IsValidName(_L("C:\\asdf..blarg"),testChar)); |
|
490 |
||
491 |
test(TheFs.IsValidName(_L("\\"),testChar)==EFalse); |
|
492 |
test(testChar==' '); |
|
493 |
||
494 |
// Test multiple evil characters - parsing occurs from right to left |
|
495 |
// except that wildcarded characters take priority and are picked out first |
|
496 |
test(TheFs.IsValidName(_L("abc>def|ghi?jkl:mno<pqr*stu"),testChar)==EFalse); |
|
497 |
test(testChar=='*'); |
|
498 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno?pqr"),testChar)==EFalse); |
|
499 |
test(testChar=='?'); |
|
500 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno"),testChar)==EFalse); |
|
501 |
test(testChar==':'); |
|
502 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl"),testChar)==EFalse); |
|
503 |
test(testChar=='<'); |
|
504 |
test(TheFs.IsValidName(_L("abc>def|ghi"),testChar)==EFalse); |
|
505 |
test(testChar=='|'); |
|
506 |
test(TheFs.IsValidName(_L("abc>def"),testChar)==EFalse); |
|
507 |
test(testChar=='>'); |
|
508 |
||
509 |
test(!TheFs.IsValidName(_L("C:\\v123456.."),testChar)); // Valid name |
|
510 |
test(TheFs.IsValidName(_L("abc"),testChar)); // Valid name |
|
511 |
test(TheFs.IsValidName(_L("as(){}@~#;!\xA3$%^&()df.blarg"),testChar)); // Valid name |
|
512 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\asdf.blarg"),testChar)); // Valid name |
|
513 |
test(TheFs.IsValidName(_L("\'"),testChar)); // Valid name |
|
514 |
||
515 |
//PDEF133084: The wild character in the extension was not being detected. |
|
516 |
_LIT( KTestString, "E:\\My Videos\\Downloads\\1\\1\\Name.3gp?" ); |
|
517 |
TBuf<50> path; |
|
518 |
path = KTestString; |
|
519 |
TBool validName( EFalse ); |
|
520 |
TText badChar; |
|
521 |
TInt badCharLoc( KErrNotFound ); |
|
522 |
||
523 |
while ( ! validName ) |
|
524 |
{ |
|
525 |
validName = TheFs.IsValidName( path, badChar ); |
|
526 |
||
527 |
if ( ! validName ) |
|
528 |
{ |
|
529 |
badCharLoc = path.LocateReverse( badChar ); |
|
530 |
||
531 |
if ( KErrNotFound != badCharLoc ) |
|
532 |
{ |
|
533 |
path[badCharLoc] = '_'; |
|
534 |
} |
|
535 |
} |
|
536 |
} |
|
537 |
} |
|
538 |
||
539 |
LOCAL_C void Test9() |
|
540 |
// |
|
541 |
// Test IsFileInRom |
|
542 |
// |
|
543 |
{ |
|
544 |
||
545 |
test.Next(_L("Test RFs::IsFileInRom")); |
|
546 |
||
547 |
CFileMan* fMan=CFileMan::NewL(TheFs); |
|
548 |
TInt r=fMan->Copy(_L("Z:\\TEST\\T_FILE.CPP"),_L("C:\\T_FILE.CPP")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
549 |
test_Value(r, r == KErrNone || r==KErrAccessDenied); |
0 | 550 |
delete fMan; |
551 |
TUint8* addr=TheFs.IsFileInRom(_L("C:\\ESHELL.EXE")); |
|
552 |
test(addr==NULL); |
|
553 |
addr=TheFs.IsFileInRom(_L("Z:\\TEST\\T_FILE.CPP")); |
|
554 |
if (addr!=NULL) |
|
555 |
{ |
|
556 |
test(addr!=NULL); |
|
557 |
TPtrC8 startOfFile(addr,12); |
|
558 |
test(startOfFile==_L8("// Copyright")); |
|
559 |
} |
|
560 |
else |
|
561 |
{ |
|
562 |
test (addr==NULL); |
|
563 |
} |
|
564 |
} |
|
565 |
||
566 |
LOCAL_C void Test10() |
|
567 |
// |
|
568 |
// Test drive names |
|
569 |
// |
|
570 |
{ |
|
571 |
||
572 |
test.Next(_L("Test Drive Names")); |
|
573 |
TFileName driveName; |
|
574 |
TInt i; |
|
575 |
for(i=0;i<KMaxDrives;i++) |
|
576 |
{ |
|
577 |
TInt r=TheFs.GetDriveName(i,driveName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
578 |
test_KErrNone(r); |
0 | 579 |
if (driveName.Length()) |
580 |
test.Printf(_L("Default name of %c: == %S\n"),'A'+i,&driveName); |
|
581 |
} |
|
582 |
||
583 |
TBuf<64> drive0=_L("Dilbert"); |
|
584 |
TBuf<64> drive4=_L("Dogbert"); |
|
585 |
TBuf<64> drive17=_L("Flibble"); |
|
586 |
TBuf<64> drive25=_L("RAMDRIVE"); |
|
587 |
TInt r=TheFs.SetDriveName(0,drive0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
588 |
test_KErrNone(r); |
0 | 589 |
r=TheFs.SetDriveName(4,drive4); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
590 |
test_KErrNone(r); |
0 | 591 |
r=TheFs.SetDriveName(17,drive17); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
592 |
test_KErrNone(r); |
0 | 593 |
r=TheFs.SetDriveName(25,drive25); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
594 |
test_KErrNone(r); |
0 | 595 |
|
596 |
r=TheFs.GetDriveName(0,driveName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
597 |
test_KErrNone(r); |
0 | 598 |
test(driveName==drive0); |
599 |
r=TheFs.GetDriveName(4,driveName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
600 |
test_KErrNone(r); |
0 | 601 |
test(driveName==drive4); |
602 |
r=TheFs.GetDriveName(17,driveName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
603 |
test_KErrNone(r); |
0 | 604 |
test(driveName==drive17); |
605 |
r=TheFs.GetDriveName(25,driveName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
606 |
test_KErrNone(r); |
0 | 607 |
test(driveName==drive25); |
608 |
||
609 |
drive0=_L("askdjflsdfourewoqiuroiuaksjdvx,cvsdhwjhjhalsjhfshfkjhslj"); |
|
610 |
r=TheFs.SetDriveName(0,drive0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
611 |
test_KErrNone(r); |
0 | 612 |
r=TheFs.GetDriveName(0,driveName); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
613 |
test_KErrNone(r); |
0 | 614 |
test(driveName==drive0); |
615 |
||
616 |
// Test with illegal characters in drive name |
|
617 |
drive0=_L("Dil>bert"); |
|
618 |
drive4=_L("Dog?bert"); |
|
619 |
drive17=_L("Fli*bble"); |
|
620 |
drive25=_L("RAMD//RIVE"); |
|
621 |
||
622 |
r=TheFs.SetDriveName(0,drive0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
623 |
test_Value(r, r == KErrBadName); |
0 | 624 |
r=TheFs.SetDriveName(4,drive4); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
625 |
test_Value(r, r == KErrBadName); |
0 | 626 |
r=TheFs.SetDriveName(17,drive17); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
627 |
test_Value(r, r == KErrBadName); |
0 | 628 |
r=TheFs.SetDriveName(25,drive25); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
629 |
test_Value(r, r == KErrBadName); |
0 | 630 |
|
631 |
// Test that it is OK to set the name to no characters |
|
632 |
||
633 |
drive0=_L(""); |
|
634 |
drive4=_L(""); |
|
635 |
drive17=_L(""); |
|
636 |
drive25=_L(""); |
|
637 |
||
638 |
r=TheFs.SetDriveName(0,drive0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
639 |
test_KErrNone(r); |
0 | 640 |
r=TheFs.SetDriveName(4,drive4); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
641 |
test_KErrNone(r); |
0 | 642 |
r=TheFs.SetDriveName(17,drive17); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
643 |
test_KErrNone(r); |
0 | 644 |
r=TheFs.SetDriveName(25,drive25); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
645 |
test_KErrNone(r); |
0 | 646 |
|
647 |
r=TheFs.GetDriveName(0,driveName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
648 |
test_KErrNone(r); |
0 | 649 |
test(driveName==drive0); |
650 |
r=TheFs.GetDriveName(4,driveName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
651 |
test_KErrNone(r); |
0 | 652 |
test(driveName==drive4); |
653 |
r=TheFs.GetDriveName(17,driveName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
654 |
test_KErrNone(r); |
0 | 655 |
test(driveName==drive17); |
656 |
r=TheFs.GetDriveName(25,driveName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
657 |
test_KErrNone(r); |
0 | 658 |
test(driveName==drive25); |
659 |
||
660 |
||
661 |
} |
|
662 |
||
663 |
LOCAL_C void Test11() |
|
664 |
// |
|
665 |
// Miscellaneous tests |
|
666 |
// |
|
667 |
{ |
|
668 |
||
669 |
test.Next(_L("Miscellaneous tests")); |
|
670 |
TVolumeInfo vol; |
|
671 |
TInt r=TheFs.Volume(vol); |
|
672 |
test.Printf(_L("VolumeName = %S\n"),&vol.iName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
673 |
test_KErrNone(r); |
0 | 674 |
r=TheFs.RmDir(_L("\\asdfasdf.\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
675 |
test_Value(r, r == KErrBadName); |
0 | 676 |
r=TheFs.MkDir(_L("\\asdfasdf.\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
677 |
test_Value(r, r == KErrBadName); |
0 | 678 |
} |
679 |
||
680 |
LOCAL_C void Test12() |
|
681 |
// |
|
682 |
// Test SetNotifyUser and GetNotifyUser |
|
683 |
// |
|
684 |
{ |
|
685 |
||
686 |
test.Next(_L("Test Set and GetNotifyUser")); |
|
687 |
TBool notifyState=TheFs.GetNotifyUser(); |
|
688 |
test(notifyState); |
|
689 |
notifyState=EFalse; |
|
690 |
TheFs.SetNotifyUser(notifyState); |
|
691 |
notifyState=TheFs.GetNotifyUser(); |
|
692 |
test(notifyState==EFalse); |
|
693 |
notifyState=ETrue; |
|
694 |
TheFs.SetNotifyUser(notifyState); |
|
695 |
notifyState=TheFs.GetNotifyUser(); |
|
696 |
test(notifyState); |
|
697 |
} |
|
698 |
||
699 |
LOCAL_C void Test13() |
|
700 |
// |
|
701 |
// Test return values from RFs::Volume on cf-cards |
|
702 |
// |
|
703 |
{ |
|
704 |
||
705 |
test.Next(_L("Test RFs::Volume")); |
|
706 |
TVolumeInfo vol; |
|
707 |
TInt r=TheFs.Volume(vol,EDriveB); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
708 |
test_Value(r, r == KErrNotReady || r==KErrNone || r == KErrPathNotFound); |
0 | 709 |
test.Printf(_L("RFs::Volume EDriveB returned %d\n"),r); |
710 |
||
711 |
r=TheFs.Volume(vol,EDriveC); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
712 |
test_Value(r, r == KErrNotReady || r==KErrNone || r == KErrPathNotFound); |
0 | 713 |
test.Printf(_L("RFs::Volume EDriveC returned %d\n"),r); |
714 |
||
715 |
r=TheFs.Volume(vol,EDriveD); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
716 |
test_Value(r, r == KErrNotReady || r==KErrNone || r == KErrPathNotFound); |
0 | 717 |
test.Printf(_L("RFs::Volume EDriveD returned %d\n"),r); |
718 |
||
719 |
r=TheFs.Volume(vol,EDriveE); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
720 |
test_Value(r, r == KErrNotReady || r==KErrNone || r == KErrPathNotFound); |
0 | 721 |
test.Printf(_L("RFs::Volume EDriveE returned %d\n"),r); |
722 |
||
723 |
r=TheFs.Volume(vol,EDriveF); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
724 |
test_Value(r, r == KErrNotReady || r==KErrNone || r == KErrPathNotFound); |
0 | 725 |
test.Printf(_L("RFs::Volume EDriveF returned %d\n"),r); |
726 |
} |
|
727 |
||
728 |
||
729 |
void DoTest14(TInt aDrvNum); |
|
730 |
TInt CreateStuffedFile(RFs& aFs, const TDesC& aFileName, TUint aFileSize); |
|
731 |
TInt CreateEmptyFile(RFs& aFs, const TDesC& aFileName, TUint aFileSize); |
|
732 |
TBool CheckFileContents(RFs& aFs, const TDesC& aFileName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
733 |
#ifndef __NFE_MEDIA_DRIVER_PRESENT__ |
0 | 734 |
TBool CheckBufferContents(const TDesC8& aBuffer, TUint aPrintBaseAddr=0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
735 |
#endif |
0 | 736 |
|
737 |
/** |
|
738 |
Testing unallocated data initialization vulnerability in RFile |
|
739 |
This test is performed on RAM drives and non-removable media that supports DeleteNotify (KMediaAttDeleteNotify flag) |
|
740 |
e.g. XSR NAND |
|
741 |
*/ |
|
742 |
LOCAL_C void Test14() |
|
743 |
{ |
|
744 |
TInt nRes; |
|
745 |
||
746 |
test.Next(_L("Testing unallocated data initialization vulnerability in RFile")); |
|
747 |
||
748 |
TDriveList driveList; |
|
749 |
TDriveInfo driveInfo; |
|
750 |
||
751 |
//-- 1. get drives list |
|
752 |
nRes=TheFs.DriveList(driveList); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
753 |
test_KErrNone(nRes); |
0 | 754 |
|
755 |
//-- 2. walk through all drives, performing the test only on suitable ones |
|
756 |
for (TInt drvNum=0; drvNum<KMaxDrives; ++drvNum) |
|
757 |
{ |
|
758 |
if(!driveList[drvNum]) |
|
759 |
continue; //-- skip unexisting drive |
|
760 |
||
761 |
//-- get drive info |
|
762 |
test(TheFs.Drive(driveInfo, drvNum) == KErrNone); |
|
763 |
||
764 |
//-- select a suitable drive for the testing. It shall be RAM drive, of FLASH but not removable |
|
765 |
//-- and not read only, if it is FLASH, it shall support "Delete Notify" facility |
|
766 |
switch(driveInfo.iType) |
|
767 |
{ |
|
768 |
//-- RAM drive, OK |
|
769 |
case EMediaRam: |
|
770 |
break; |
|
771 |
||
772 |
//-- FLASH drive, OK |
|
773 |
case EMediaFlash: |
|
774 |
case EMediaNANDFlash: |
|
775 |
if(driveInfo.iMediaAtt & KMediaAttDeleteNotify) |
|
776 |
break; //-- this type of media shall support DeleteNotify flag, otherwise this test is inconsistent |
|
777 |
else continue; |
|
778 |
||
779 |
//break; //unreacable |
|
780 |
||
781 |
default: |
|
782 |
continue; |
|
783 |
}//switch(driveInfo.iType) |
|
784 |
||
785 |
if (driveInfo.iDriveAtt & KDriveAttSubsted) |
|
786 |
{ |
|
787 |
// skip subst drives. |
|
788 |
continue; |
|
789 |
} |
|
790 |
||
791 |
TBool readOnly = driveInfo.iMediaAtt & KMediaAttWriteProtected; |
|
792 |
if(readOnly) |
|
793 |
continue; //-- nothing to do, can't create any file etc. |
|
794 |
||
795 |
//-- skip test on the emulator's C: drive, doesn't make any sense because |
|
796 |
//-- in this case we deal with WIN32 API and filesystem. |
|
797 |
#ifdef __WINS__ |
|
798 |
if(drvNum == 2) |
|
799 |
{ |
|
800 |
test.Printf(_L("Skipping test on emulator's C: drive\n")); |
|
801 |
continue; |
|
802 |
} |
|
803 |
#endif |
|
804 |
||
805 |
DoTest14(drvNum); |
|
806 |
||
807 |
}// for (TInt drvNum=0; ... |
|
808 |
||
809 |
} |
|
810 |
||
811 |
//-------------------------------------------------------- |
|
812 |
||
813 |
/** |
|
814 |
Actually perform the test on a drive aDrvNum. |
|
815 |
@param aDrvNum drive number |
|
816 |
*/ |
|
817 |
void DoTest14(TInt aDrvNum) |
|
818 |
{ |
|
819 |
||
820 |
TFileName fileName; |
|
821 |
fileName.Format(_L("Testing drive %c:"), 'A'+aDrvNum); |
|
822 |
test.Next(fileName); |
|
823 |
||
824 |
const TInt KFileSize = 0x1000; //-- size of the files t be created |
|
825 |
TInt nRes; |
|
826 |
||
827 |
fileName.Format(_L("%c:\\TestFile.bin"), aDrvNum+'A'); |
|
828 |
TheFs.Delete(fileName); //-- just in case |
|
829 |
||
830 |
//============================== |
|
831 |
//== Scenario 1. |
|
832 |
//== Create an empty file; AllocateSingleClusterL, ExtendClusterListL will be involved. |
|
833 |
//== Check that the file doesn't contain any meaningful information |
|
834 |
//============================== |
|
835 |
test.Printf(_L("Testing scenario 1\n")); |
|
836 |
||
837 |
//-- 1. create an empty file |
|
838 |
nRes = CreateEmptyFile(TheFs, fileName, KFileSize); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
839 |
test_KErrNone(nRes); |
0 | 840 |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
841 |
#ifndef __NFE_MEDIA_DRIVER_PRESENT__ // can't easily check for illegitimate information if drive is encrypted |
0 | 842 |
//-- 1.1 check that this file doesn't contain illegitimate information. |
843 |
nRes = CheckFileContents(TheFs, fileName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
844 |
test_KErrNone(nRes); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
845 |
#endif |
0 | 846 |
|
847 |
//-- 1.2 delete the empty file |
|
848 |
nRes = TheFs.Delete(fileName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
849 |
test_KErrNone(nRes); |
0 | 850 |
|
851 |
//============================== |
|
852 |
//== Scenario 2. |
|
853 |
//== Create file, filling it with some pattern. |
|
854 |
//== Delete this file, FreeClusterListL() will be involved. |
|
855 |
//== Create an empty file supposedly of the place of just deleted one |
|
856 |
//== Check that the file doesn't contain any meaningful information |
|
857 |
//============================== |
|
858 |
test.Printf(_L("Testing scenario 2\n")); |
|
859 |
||
860 |
//-- 2. create file filled with some data pattern |
|
861 |
nRes = CreateStuffedFile(TheFs, fileName, KFileSize); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
862 |
test_KErrNone(nRes); |
0 | 863 |
|
864 |
//-- 2.1 delete this file |
|
865 |
TheFs.Delete(fileName); |
|
866 |
||
867 |
//-- 2.1 create an empty file on the place of just deleted one (hopefully) |
|
868 |
nRes = CreateEmptyFile(TheFs, fileName, KFileSize); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
869 |
test_KErrNone(nRes); |
0 | 870 |
|
871 |
//-- 2.2 check that this file doesn't contain illegitimate information. |
|
872 |
nRes = CheckFileContents(TheFs, fileName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
873 |
test_KErrNone(nRes); |
0 | 874 |
|
875 |
//-- 2.3 delete this file |
|
876 |
TheFs.Delete(fileName); |
|
877 |
||
878 |
} |
|
879 |
||
880 |
LOCAL_C void Test15() |
|
881 |
// |
|
882 |
// Test IsValidName |
|
883 |
// |
|
884 |
{ |
|
885 |
test.Next(_L("Test RFs::IsValidName(TDesC& ,RFs::TNameValidParam& )")); |
|
886 |
TBool useDefaultSessionPath = EFalse; |
|
887 |
//tests under this loop are run twice |
|
888 |
//first, when the sessionPath is not used. |
|
889 |
//second, when the sessionPath is used. |
|
890 |
for(TInt i = 0; i<2; i++) |
|
891 |
{ |
|
892 |
RFs::TNameValidParam param(useDefaultSessionPath); |
|
893 |
test(TheFs.IsValidName(_L("*"),param)==EFalse); |
|
894 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
895 |
test(param.InvalidCharPos() == 1); |
|
896 |
||
897 |
test(TheFs.IsValidName(_L("?"),param)==EFalse); |
|
898 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
899 |
test(param.InvalidCharPos() == 1); |
|
900 |
||
901 |
test(TheFs.IsValidName(_L(">"),param)==EFalse); |
|
902 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
903 |
test(param.InvalidCharPos() == 1); |
|
904 |
||
905 |
test(TheFs.IsValidName(_L("<"),param)==EFalse); |
|
906 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
907 |
test(param.InvalidCharPos() == 1); |
|
908 |
||
909 |
test(TheFs.IsValidName(_L(":"),param)==EFalse); |
|
910 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
911 |
test(param.InvalidCharPos() == 1); |
|
912 |
||
913 |
test(TheFs.IsValidName(_L("\""),param)==EFalse); |
|
914 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
915 |
test(param.InvalidCharPos() == 1); |
|
916 |
||
917 |
test(TheFs.IsValidName(_L("/"),param)==EFalse); |
|
918 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
919 |
test(param.InvalidCharPos() == 1); |
|
920 |
||
921 |
test(TheFs.IsValidName(_L("|"),param)==EFalse); |
|
922 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
923 |
test(param.InvalidCharPos() == 1); |
|
924 |
||
925 |
test(TheFs.IsValidName(_L("xx*yy"),param)==EFalse); |
|
926 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
927 |
test(param.InvalidCharPos() == 3); |
|
928 |
||
929 |
test(TheFs.IsValidName(_L("xx?yy"),param)==EFalse); |
|
930 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
931 |
test(param.InvalidCharPos() == 3); |
|
932 |
||
933 |
test(TheFs.IsValidName(_L("xx>yy"),param)==EFalse); |
|
934 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
935 |
test(param.InvalidCharPos() == 3); |
|
936 |
||
937 |
test(TheFs.IsValidName(_L("xx<yy"),param)==EFalse); |
|
938 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
939 |
test(param.InvalidCharPos() == 3); |
|
940 |
||
941 |
test(TheFs.IsValidName(_L("xx:yy"),param)==EFalse); |
|
942 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
943 |
test(param.InvalidCharPos() == 3); |
|
944 |
||
945 |
test(TheFs.IsValidName(_L("xx\"yy"),param)==EFalse); |
|
946 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
947 |
test(param.InvalidCharPos() == 3); |
|
948 |
||
949 |
test(TheFs.IsValidName(_L("xx/yy"),param)==EFalse); |
|
950 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
951 |
test(param.InvalidCharPos() == 3); |
|
952 |
||
953 |
test(TheFs.IsValidName(_L("xx|yy"),param)==EFalse); |
|
954 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
955 |
test(param.InvalidCharPos() == 3); |
|
956 |
||
957 |
test(TheFs.IsValidName(_L("C:\\*\\group\\release.txt"),param)==EFalse); |
|
958 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
959 |
test(param.InvalidCharPos() == 4); |
|
960 |
||
961 |
test(TheFs.IsValidName(_L("C:\\?\\group\\release.txt"),param)==EFalse); |
|
962 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
963 |
test(param.InvalidCharPos() == 4); |
|
964 |
||
965 |
test(TheFs.IsValidName(_L("C:\\..\\group\\release.txt"),param)==EFalse); |
|
966 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
967 |
test(param.InvalidCharPos() == 4); |
|
968 |
||
969 |
test(TheFs.IsValidName(_L("C:\\.\\group\\release.txt"),param)==EFalse); |
|
970 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
971 |
test(param.InvalidCharPos() == 4); |
|
972 |
||
973 |
test(TheFs.IsValidName(_L("C:\\>\\group\\release.txt"),param)==EFalse); |
|
974 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
975 |
test(param.InvalidCharPos() == 4); |
|
976 |
||
977 |
test(TheFs.IsValidName(_L("C:\\<\\group\\release.txt"),param)==EFalse); |
|
978 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
979 |
test(param.InvalidCharPos() == 4); |
|
980 |
||
981 |
test(TheFs.IsValidName(_L("C:\\HelloWorld\\:\\group\\release.txt"),param)==EFalse); |
|
982 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
983 |
test(param.InvalidCharPos() == 15); |
|
984 |
||
985 |
test(TheFs.IsValidName(_L("C::\\group\\release.txt"),param)==EFalse); |
|
986 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
987 |
test(param.InvalidCharPos() == 3); |
|
988 |
||
989 |
test(TheFs.IsValidName(_L(">\\group\\release.txt"),param)==EFalse); |
|
990 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
991 |
test(param.InvalidCharPos() == 1); |
|
992 |
||
993 |
test(TheFs.IsValidName(_L("C|group\\release.txt"),param)==EFalse); |
|
994 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
995 |
test(param.InvalidCharPos() == 2); |
|
996 |
||
997 |
test(TheFs.IsValidName(_L("C\\|\\group\\release.txt"),param)==EFalse); |
|
998 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
999 |
test(param.InvalidCharPos() == 3); |
|
1000 |
||
1001 |
test(TheFs.IsValidName(_L("\\>"),param)==EFalse); |
|
1002 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1003 |
test(param.InvalidCharPos() == 2); |
|
1004 |
||
1005 |
test(TheFs.IsValidName(_L("C:\\|group\\release.txt"),param)==EFalse); |
|
1006 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1007 |
test(param.InvalidCharPos() == 4); |
|
1008 |
||
1009 |
test(TheFs.IsValidName(_L("C:\\\"\\group\\release.txt"),param)==EFalse); |
|
1010 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1011 |
test(param.InvalidCharPos() == 4); |
|
1012 |
||
1013 |
test(TheFs.IsValidName(_L("C:\\/\\group\\release.txt"),param)==EFalse); |
|
1014 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1015 |
test(param.InvalidCharPos() == 4); |
|
1016 |
||
1017 |
test(TheFs.IsValidName(_L("C:\\|\\group\\release.txt"),param)==EFalse); |
|
1018 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1019 |
test(param.InvalidCharPos() == 4); |
|
1020 |
||
1021 |
test(TheFs.IsValidName(_L("C:\\ \\group\\release.txt"),param)==EFalse);//intermediate directory names cannot be blank |
|
1022 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadName); |
|
1023 |
||
1024 |
// Test that \ is not allowed in filenames |
|
1025 |
TFileName filename; |
|
1026 |
filename=_L("C:\\HelloWorld\\\\\\group\\release.txt"); |
|
1027 |
||
1028 |
test(TheFs.IsValidName(filename,param)==EFalse); |
|
1029 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1030 |
test(param.InvalidCharPos() == 22); |
|
1031 |
||
1032 |
filename=_L("C:\\\\\\group\\release.txt"); |
|
1033 |
test(TheFs.IsValidName(filename,param)==EFalse); |
|
1034 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1035 |
test(param.InvalidCharPos() == 11); |
|
1036 |
||
1037 |
filename=_L("C:\\Hello World\\group\\release.txt"); |
|
1038 |
filename[8]=KPathDelimiter; |
|
1039 |
test(TheFs.IsValidName(filename,param)); |
|
1040 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1041 |
||
1042 |
filename=_L("C:\\HelloWorld\\::\\group\\release.txt"); |
|
1043 |
test(TheFs.IsValidName(filename,param)==EFalse); |
|
1044 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1045 |
test(param.InvalidCharPos() == 16); |
|
1046 |
||
1047 |
filename=_L("C:\\>>\\group\\release.txt"); |
|
1048 |
test(TheFs.IsValidName(filename,param)==EFalse); |
|
1049 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1050 |
test(param.InvalidCharPos() == 5); |
|
1051 |
||
1052 |
test(TheFs.IsValidName(_L(""),param)==EFalse); // Must be a name |
|
1053 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadName); |
|
1054 |
||
1055 |
test(TheFs.IsValidName(_L(".ext"),param)); |
|
1056 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1057 |
||
1058 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg"),param)); |
|
1059 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1060 |
||
1061 |
test(TheFs.IsValidName(_L("C:\\asdf..blarg"),param)); |
|
1062 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1063 |
||
1064 |
// Test multiple evil characters - parsing occurs from right to left |
|
1065 |
// except that wildcarded characters take priority and are picked out first |
|
1066 |
||
1067 |
test(TheFs.IsValidName(_L("abc>def|ghi?jkl:mno<pqr*stu"),param)==EFalse); |
|
1068 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1069 |
test(param.InvalidCharPos() == 24); |
|
1070 |
||
1071 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno?pqr"),param)==EFalse); |
|
1072 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1073 |
test(param.InvalidCharPos() == 20); |
|
1074 |
||
1075 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno"),param)==EFalse); |
|
1076 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1077 |
test(param.InvalidCharPos() == 16); |
|
1078 |
||
1079 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno"),param)==EFalse); |
|
1080 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1081 |
test(param.InvalidCharPos() == 16); |
|
1082 |
||
1083 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl"),param)==EFalse); |
|
1084 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1085 |
test(param.InvalidCharPos() == 12); |
|
1086 |
||
1087 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl"),param)==EFalse); |
|
1088 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1089 |
test(param.InvalidCharPos() == 12); |
|
1090 |
||
1091 |
test(TheFs.IsValidName(_L("abc>def|ghi"),param)==EFalse); |
|
1092 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1093 |
test(param.InvalidCharPos() == 8); |
|
1094 |
||
1095 |
test(TheFs.IsValidName(_L("abc>def|ghi"),param)==EFalse); |
|
1096 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1097 |
test(param.InvalidCharPos() == 8); |
|
1098 |
||
1099 |
test(TheFs.IsValidName(_L("abc>def"),param)==EFalse); |
|
1100 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1101 |
test(param.InvalidCharPos() == 4); |
|
1102 |
||
1103 |
test(TheFs.IsValidName(_L("abc>def"),param)==EFalse); |
|
1104 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1105 |
test(param.InvalidCharPos() == 4); |
|
1106 |
||
1107 |
test(!TheFs.IsValidName(_L("C:\\v123456.."),param)); |
|
1108 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1109 |
test(param.InvalidCharPos() == 11); |
|
1110 |
||
1111 |
test(!TheFs.IsValidName(_L("C:\\v123456.."),param)); |
|
1112 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter); |
|
1113 |
test(param.InvalidCharPos() == 11); |
|
1114 |
||
1115 |
test(TheFs.IsValidName(_L("abc"),param)); // Valid name |
|
1116 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1117 |
||
1118 |
test(TheFs.IsValidName(_L("abc"),param)); // Valid name |
|
1119 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1120 |
||
1121 |
test(TheFs.IsValidName(_L("as(){}@~#;!\xA3$%^&()df.blarg"),param)); // Valid name |
|
1122 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1123 |
||
1124 |
test(TheFs.IsValidName(_L("as(){}@~#;!\xA3$%^&()df.blarg"),param)); // Valid name |
|
1125 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1126 |
||
1127 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\asdf.blarg"),param)); // Valid name |
|
1128 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1129 |
||
1130 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\asdf.blarg"),param)); // Valid name |
|
1131 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1132 |
||
1133 |
test(TheFs.IsValidName(_L("\'"),param)); // Valid name |
|
1134 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1135 |
||
1136 |
test(TheFs.IsValidName(_L("\'"),param)); // Valid name |
|
1137 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1138 |
||
1139 |
//testing directory names |
|
1140 |
test(TheFs.IsValidName(_L("\\"),param)); |
|
1141 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); // Valid Name |
|
1142 |
||
1143 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\"),param)); |
|
1144 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); // Valid Name |
|
1145 |
||
1146 |
||
1147 |
test(TheFs.IsValidName(_L("C:\\asdf..blarg\\"),param)); |
|
1148 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); // Valid Name |
|
1149 |
||
1150 |
test(TheFs.IsValidName(_L("file1.txt\\\\"),param) == EFalse); |
|
1151 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadName); |
|
1152 |
||
1153 |
// test name which exceeds KMaxFileName only on prepending the session path |
|
1154 |
_LIT(KNameLength250, "AAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAA"); |
|
1155 |
if(useDefaultSessionPath) |
|
1156 |
{ |
|
1157 |
test(TheFs.IsValidName(KNameLength250, param)==EFalse); |
|
1158 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNameTooLong); |
|
1159 |
break; |
|
1160 |
} |
|
1161 |
else |
|
1162 |
{ |
|
1163 |
test(TheFs.IsValidName(KNameLength250, param)); |
|
1164 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); |
|
1165 |
} |
|
1166 |
useDefaultSessionPath = ETrue; |
|
1167 |
} |
|
1168 |
} |
|
1169 |
||
1170 |
||
1171 |
||
1172 |
void TestGetMediaSerialNumber() |
|
1173 |
{ |
|
1174 |
test.Next(_L("Test RFs::GetMediaSerialNumber")); |
|
1175 |
TInt theDrive; |
|
1176 |
TInt r = TheFs.CharToDrive(gDriveToTest,theDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1177 |
test_KErrNone(r); |
0 | 1178 |
TMediaSerialNumber serNum; |
1179 |
r = TheFs.GetMediaSerialNumber(serNum, theDrive); |
|
1180 |
if (r) test.Printf(_L("RFs::GetMediaSerialNumber returned error %d"), r); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1181 |
test_Value(r, r == KErrNotSupported || r == KErrNotReady || r == KErrNone); |
0 | 1182 |
if (r == KErrNotSupported) |
1183 |
{ |
|
1184 |
test.Printf(_L("MediaSerialNumber: Not Supported\n")); |
|
1185 |
} |
|
1186 |
else |
|
1187 |
{ |
|
1188 |
test.Printf(_L("MediaSerialNumber: length=%d\n"), serNum.Length()); |
|
1189 |
TBuf<20> str; |
|
1190 |
_LIT(KNumberString, "%02X"); |
|
1191 |
_LIT(KNewLine, "\n"); |
|
1192 |
TInt i; |
|
1193 |
for (i = 0; i < serNum.Length(); i++) |
|
1194 |
{ |
|
1195 |
str.AppendFormat(KNumberString, serNum[i]); |
|
1196 |
if (i%8 == 7) |
|
1197 |
{ |
|
1198 |
str.Append(KNewLine); |
|
1199 |
test.Printf(_L("%S"), &str); |
|
1200 |
str.SetLength(0); |
|
1201 |
} |
|
1202 |
} |
|
1203 |
if (i%8 != 7) |
|
1204 |
{ |
|
1205 |
test.Printf(KNewLine); |
|
1206 |
} |
|
1207 |
} |
|
1208 |
} |
|
1209 |
||
1210 |
||
1211 |
//-------------------------------------------------------- |
|
1212 |
||
1213 |
/** |
|
1214 |
Create an empty file of specified size. |
|
1215 |
@param aFs ref. to the FS |
|
1216 |
@param aFileName name of the file |
|
1217 |
@param aFileSize size of the file to be created |
|
1218 |
@return KErrNone on success, system-wide error code otherwise |
|
1219 |
*/ |
|
1220 |
TInt CreateEmptyFile(RFs& aFs, const TDesC& aFileName, TUint aFileSize) |
|
1221 |
{ |
|
1222 |
RFile file; |
|
1223 |
TInt nRes; |
|
1224 |
||
1225 |
nRes = file.Create(aFs, aFileName, EFileRead|EFileWrite); |
|
1226 |
if(nRes != KErrNone) |
|
1227 |
return nRes; |
|
1228 |
||
1229 |
nRes = file.SetSize(aFileSize); |
|
1230 |
if(nRes != KErrNone) |
|
1231 |
return nRes; |
|
1232 |
||
1233 |
file.Close(); |
|
1234 |
||
1235 |
return KErrNone; |
|
1236 |
} |
|
1237 |
||
1238 |
//-------------------------------------------------------- |
|
1239 |
||
1240 |
/** |
|
1241 |
Create a file of specified size filled with some data pattern. |
|
1242 |
@param aFs ref. to the FS |
|
1243 |
@param aFileName name of the file |
|
1244 |
@param aFileSize size of the file to be created |
|
1245 |
@return KErrNone on success, system-wide error code otherwise |
|
1246 |
*/ |
|
1247 |
TInt CreateStuffedFile(RFs& aFs, const TDesC& aFileName, TUint aFileSize) |
|
1248 |
{ |
|
1249 |
TInt nRes; |
|
1250 |
RFile file; |
|
1251 |
||
1252 |
//-- create a buffer with some data |
|
1253 |
TBuf8<KBufLength> buffer; |
|
1254 |
buffer.SetLength(KBufLength); |
|
1255 |
||
1256 |
TUint i; |
|
1257 |
||
1258 |
for(i = 0; i < KBufLength; i++) |
|
1259 |
buffer[i] = static_cast<TUint8> (i) ; |
|
1260 |
||
1261 |
//-- create a file |
|
1262 |
nRes = file.Create(aFs, aFileName, EFileRead|EFileWrite); |
|
1263 |
if(nRes != KErrNone) |
|
1264 |
return nRes; |
|
1265 |
||
1266 |
const TUint n1 = aFileSize / KBufLength; |
|
1267 |
const TUint n2 = aFileSize % KBufLength; |
|
1268 |
||
1269 |
//-- fill the file with the data from buffer |
|
1270 |
for(i=0; i<n1; ++i) |
|
1271 |
{ |
|
1272 |
nRes = file.Write(buffer); |
|
1273 |
if(nRes != KErrNone) |
|
1274 |
return nRes; |
|
1275 |
} |
|
1276 |
||
1277 |
if(n2) |
|
1278 |
{ |
|
1279 |
nRes = file.Write(buffer, n2); //-- write the rest of the data |
|
1280 |
if(nRes != KErrNone) |
|
1281 |
return nRes; |
|
1282 |
} |
|
1283 |
||
1284 |
file.Close(); |
|
1285 |
||
1286 |
return KErrNone; |
|
1287 |
} |
|
1288 |
||
1289 |
//-------------------------------------------------------- |
|
1290 |
||
1291 |
/** |
|
1292 |
Check if the specified file contains illegitimate information i.e. something different from 0x00, 0xff, 0x03, 0xcc |
|
1293 |
||
1294 |
@param aFs ref. to the FS |
|
1295 |
@param aFileName name of the file |
|
1296 |
@return KErrNone on success, KErrCorrupt otherwise |
|
1297 |
*/ |
|
1298 |
TInt CheckFileContents(RFs& aFs, const TDesC& aFileName) |
|
1299 |
{ |
|
1300 |
TInt nRes = KErrNone; |
|
1301 |
RFile file; |
|
1302 |
||
1303 |
TBuf8<KBufLength> buffer; |
|
1304 |
buffer.SetLength(0); |
|
1305 |
||
1306 |
//-- open the file |
|
1307 |
nRes = file.Open(aFs, aFileName, EFileRead); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1308 |
test_KErrNone(nRes); |
0 | 1309 |
|
1310 |
//-- check file contents |
|
1311 |
TUint nFilePos=0; |
|
1312 |
for(;;) |
|
1313 |
{ |
|
1314 |
//-- read data from the file into the buffer |
|
1315 |
nRes = file.Read(buffer); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1316 |
test_KErrNone(nRes); |
0 | 1317 |
|
1318 |
if(buffer.Length() == 0) |
|
1319 |
{ |
|
1320 |
nRes = KErrNone; //-- read all the file, no illegitimate information found |
|
1321 |
break; //EOF |
|
1322 |
} |
|
1323 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1324 |
#ifdef __NFE_MEDIA_DRIVER_PRESENT__ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1325 |
// check the buffer doesn't contain the same pattern written to it by CreateStuffedFile() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1326 |
TUint i; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1327 |
for(i = 0; i < KBufLength; i++) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1328 |
if (buffer[i] != static_cast<TUint8> (i)) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1329 |
break; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1330 |
if (i == KBufLength) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1331 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1332 |
nRes = KErrCorrupt; //-- indicate that the read buffer contains illegitimate information |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1333 |
break; //-- comment this out if you need a full dump of the file |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1334 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1335 |
#else |
0 | 1336 |
//-- check if the buffer contains only allowed data (RAM page initialisation data, etc. e.g. 0x00, 0xff, 0x03, 0xcc) |
1337 |
if(!CheckBufferContents(buffer, nFilePos)) |
|
1338 |
{ |
|
1339 |
test.Printf(_L("\nCheckFileContents failed ! The file contains illegitimate information!\n")); |
|
1340 |
nRes = KErrCorrupt; //-- indicate that the read buffer contains illegitimate information |
|
1341 |
break; //-- comment this out if you need a full dump of the file |
|
1342 |
} |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1343 |
#endif |
0 | 1344 |
|
1345 |
nFilePos+=buffer.Length(); |
|
1346 |
} |
|
1347 |
||
1348 |
file.Close(); |
|
1349 |
return nRes; |
|
1350 |
} |
|
1351 |
||
1352 |
//-------------------------------------------------------- |
|
1353 |
||
1354 |
/** |
|
1355 |
Check if the buffer contains illegitimate information i.e. something different from 0x00, 0xff, 0x03, 0xcc |
|
1356 |
||
1357 |
@param aBuffer buffer descriptor to check |
|
1358 |
@param aPrintBaseAddr dump base address, used for dumping buffer only |
|
1359 |
@return ETrue on success |
|
1360 |
*/ |
|
1361 |
TBool CheckBufferContents(const TDesC8& aBuffer, TUint aPrintBaseAddr/*=0*/) |
|
1362 |
{ |
|
1363 |
TBool bRes = ETrue; |
|
1364 |
||
1365 |
//-- check if the buffer filled with allowable data (RAM page initialisation data or something similar) |
|
1366 |
//-- but not something meaningful. |
|
1367 |
//-- allowable bytes: 0x00, 0x03, 0xff, 0xcc |
|
1368 |
for(TInt i=0; i<aBuffer.Size(); ++i) |
|
1369 |
{ |
|
1370 |
TUint8 byte = aBuffer[i]; |
|
1371 |
if(byte != 0x00 && byte != 0x03 && byte != 0xff && byte != 0xcc ) |
|
1372 |
{ |
|
1373 |
bRes = EFalse; |
|
1374 |
break; |
|
1375 |
} |
|
1376 |
} |
|
1377 |
||
1378 |
//-- dump the buffer if it contains anything different than allowed data |
|
1379 |
if (!bRes) |
|
1380 |
{ |
|
1381 |
for (TInt n=0; n<aBuffer.Size(); ) |
|
1382 |
{ |
|
1383 |
TBuf16<3> byteBuffer; |
|
1384 |
TBuf16<256> lineBuffer; |
|
1385 |
lineBuffer.Format(_L("%08X: "), aPrintBaseAddr+n); |
|
1386 |
for (TInt m=0; m<16 && n<aBuffer.Size(); m++, n++) |
|
1387 |
{ |
|
1388 |
byteBuffer.Format(_L("%02X "), aBuffer[n]); |
|
1389 |
lineBuffer.Append(byteBuffer); |
|
1390 |
} |
|
1391 |
test.Printf(lineBuffer); |
|
1392 |
} |
|
1393 |
} |
|
1394 |
||
1395 |
return bRes; |
|
1396 |
} |
|
1397 |
||
1398 |
||
1399 |
GLDEF_C void CallTestsL() |
|
1400 |
// |
|
1401 |
// Call tests that may leave |
|
1402 |
// |
|
1403 |
{ |
|
1404 |
||
1405 |
Test1(); |
|
1406 |
Test2(); |
|
1407 |
Test3(); |
|
1408 |
Test4(); |
|
1409 |
Test5(); |
|
1410 |
Test6(); |
|
1411 |
Test7(); |
|
1412 |
Test8(); |
|
1413 |
Test9(); |
|
1414 |
Test10(); |
|
1415 |
Test11(); |
|
1416 |
Test12(); |
|
1417 |
Test13(); |
|
1418 |
Test14(); |
|
1419 |
Test15(); |
|
1420 |
TestGetMediaSerialNumber(); |
|
1421 |
} |