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