kerneltest/f32test/server/t_fatcharsetconv_main.cpp
changeset 43 96e5fb8b040d
child 33 0173bcd7697c
equal deleted inserted replaced
-1:000000000000 43:96e5fb8b040d
       
     1 // Copyright (c) 2008-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_FatCharSetConv_Main.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #define __E32TEST_EXTENSION__
       
    19 
       
    20 #include <e32test.h>
       
    21 //#include <hal.h>
       
    22 #include <f32fsys.h>
       
    23 #include <f32dbg.h>
       
    24 #include "t_server.h"
       
    25 #include "t_chlffs.h"
       
    26 #include "fat_utils.h"
       
    27 #include "T_Fatcharsetconv_Cases.h"
       
    28 
       
    29 
       
    30 RTest test(_L("T_FatCharSetConv"));
       
    31 
       
    32 using namespace Fat_Test_Utils;
       
    33 
       
    34 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
    35 
       
    36 template <class C>
       
    37 TInt controlIo(RFs &fs, TInt drv, TInt fkn, C &c)
       
    38 	{
       
    39     TPtr8 ptrC((TUint8 *)&c, sizeof(C), sizeof(C));
       
    40     TInt r = fs.ControlIo(drv, fkn, ptrC);
       
    41     return r;
       
    42 	}
       
    43 
       
    44 /*
       
    45  * Presetting module, presets initial source, target and comparing direcotries.
       
    46  * @param	aParam	test param that contains all information about a test case
       
    47  */
       
    48 void DataGenerationL(const TTestParamAll& aParam)
       
    49 	{
       
    50 	// Setup source files
       
    51 	RBuf path;
       
    52 	path.CreateL(aParam.iSrcPrsPath);
       
    53 	
       
    54 	path[0] = (TUint16)*aParam.iSrcDrvChar;
       
    55 	if(path[0] == (TUint8)gDriveToTest)
       
    56 		{
       
    57 		SetupDirFiles(path, aParam.iSrcPrsFiles);
       
    58 		}
       
    59 	
       
    60 	if (aParam.iAPI == EGetShortName || aParam.iAPI == EGetShortNameWithDLL || aParam.iAPI == EGetShortNameWithoutDLL || aParam.iAPI == ERFsReplace || aParam.iAPI == ERFsRename ||aParam.iAPI == ERenameFile )
       
    61 		{
       
    62 		path[0] = (TUint16)*aParam.iTrgDrvChar;
       
    63 		}
       
    64 	path.Close();
       
    65 	CheckDisk();
       
    66 	}
       
    67 
       
    68 /*
       
    69  * Test execution module
       
    70  * @param	aParam	test param that contains all information about a test case
       
    71  * @panic	USER:84	if return codes do not match the expected values. 	
       
    72  */
       
    73 void DataExecutionL(const TTestParamAll& aParam, const TTCType aTCType)
       
    74 	{
       
    75 	RBuf srcCmdFile;
       
    76 	srcCmdFile.CreateL(aParam.iSrcCmdPath);
       
    77 	RBuf trgCmdFile;
       
    78 	trgCmdFile.CreateL(aParam.iTrgCmdPath);
       
    79 	RBuf srcCmd;
       
    80 	srcCmd.CreateL(aParam.iSrcPrsPath);
       
    81 	
       
    82 	if (srcCmdFile.Length() > 0)
       
    83 		{
       
    84 		srcCmdFile[0] = (TUint16)*aParam.iSrcDrvChar;
       
    85 		}
       
    86 	else
       
    87 		{
       
    88 		// srcCmdFile= gSessionPath;
       
    89 		srcCmdFile[0] = (TUint16)*aParam.iSrcDrvChar;
       
    90 		}
       
    91 	if (srcCmd.Length() > 0)
       
    92 		{
       
    93 		srcCmd[0] = (TUint16)*aParam.iSrcDrvChar;
       
    94 		}
       
    95 	else
       
    96 		{
       
    97 		// srcCmd= gSessionPath;
       
    98 		srcCmd[0] = (TUint16)*aParam.iSrcDrvChar;
       
    99 		}
       
   100 
       
   101 	// logging for failure
       
   102 	gTCType = aTCType;
       
   103 	RBuf failedOnBuf;
       
   104 	failedOnBuf.CreateL(KExecution());
       
   105 	gTCId = aParam.iTestCaseID;
       
   106 	RBuf tcUniquePath;
       
   107 	tcUniquePath.CreateL(aParam.iSrcPrsPath);
       
   108 
       
   109 	TInt r = KErrNone;
       
   110 
       
   111 	switch(aParam.iAPI)
       
   112 		{
       
   113 		case EGetShortName:
       
   114 		case EGetShortNameWithDLL:
       
   115 		case EGetShortNameWithoutDLL:
       
   116 			{
       
   117 			__UHEAP_MARK;
       
   118 			if(aParam.iAPI == EGetShortName )
       
   119 				gLogFailureData.iAPIName = KGetShortName;
       
   120 			else if(aParam.iAPI == EGetShortNameWithDLL )
       
   121 				gLogFailureData.iAPIName = KGetShortNameWithDLL;
       
   122 			else if(aParam.iAPI == EGetShortNameWithoutDLL )
       
   123 				gLogFailureData.iAPIName = KGetShortNameWithoutDLL;
       
   124 
       
   125 				if (trgCmdFile.Length() > 0)
       
   126 					{
       
   127 					trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   128 					}
       
   129 				else
       
   130 					{
       
   131 					//trgCmdFile= gSessionPath;
       
   132 					trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   133 					}
       
   134 
       
   135 			TBuf<0x10> shortName;
       
   136 			r=TheFs.GetShortName(srcCmdFile,shortName);
       
   137 			testAndLog(r==KErrNone);
       
   138 			srcCmd.ReAllocL(srcCmd.Length() + shortName.Length());
       
   139 			srcCmd+= shortName;
       
   140 			testAndLog(srcCmd==trgCmdFile);
       
   141 			__UHEAP_MARKEND;
       
   142 			}
       
   143 			break;
       
   144 		case ELongShortConversion:
       
   145 			{
       
   146 			__UHEAP_MARK;
       
   147 			gLogFailureData.iAPIName = KLongShortConversion;
       
   148 			if (trgCmdFile.Length() > 0)
       
   149 				{
       
   150 				trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   151 				}
       
   152 			else
       
   153 				{
       
   154 				//trgCmdFile= gSessionPath;
       
   155 				trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   156 				}
       
   157 
       
   158 			RBuf lgnFullPath;
       
   159 			RBuf shnFullPath;
       
   160 			TFileName longName;
       
   161 			TBuf<0x10> shortName;
       
   162 	
       
   163 			r = TheFs.GetShortName(srcCmdFile, shortName);
       
   164 			testAndLog(r==KErrNone);
       
   165 	
       
   166 			shnFullPath.CreateL(srcCmd);
       
   167 			shnFullPath.ReAllocL(srcCmd.Length() + shortName.Length());
       
   168 			shnFullPath.Append(shortName);
       
   169 			r = shnFullPath.Compare(trgCmdFile);
       
   170 			testAndLog(r==KErrNone);
       
   171 
       
   172 			r = TheFs.GetLongName(shnFullPath, longName);
       
   173 			testAndLog(r==KErrNone);
       
   174 			
       
   175 			lgnFullPath.CreateL(srcCmd);
       
   176 			lgnFullPath.ReAllocL(srcCmd.Length() + longName.Length());
       
   177 			lgnFullPath.Append(longName);
       
   178 			r = lgnFullPath.Compare(srcCmdFile);
       
   179 			testAndLog(r==KErrNone);
       
   180 			
       
   181 			lgnFullPath.Close();
       
   182 			shnFullPath.Close();
       
   183 			__UHEAP_MARKEND;
       
   184 			}
       
   185 			break;
       
   186 		case ECreateFile:
       
   187 			{
       
   188 			__UHEAP_MARK;
       
   189 			gLogFailureData.iAPIName  = KCreateFile;
       
   190 			r = TheFile.Create(TheFs,srcCmdFile,EFileWrite);
       
   191 			testAndLog(r==KErrNone);
       
   192 			TheFile.Close();
       
   193 			__UHEAP_MARKEND;
       
   194 			}
       
   195 			break;
       
   196 		case EIsValidName:
       
   197 			{
       
   198 			__UHEAP_MARK;
       
   199 			gLogFailureData.iAPIName = KIsValidName;
       
   200 			TText badChar;
       
   201 			r=TheFs.IsValidName(srcCmdFile,badChar);
       
   202 			testAndLog(r==(TInt)ETrue);
       
   203 			r=TheFs.IsValidName(srcCmdFile);
       
   204 			testAndLog(r==(TInt)ETrue);
       
   205 			__UHEAP_MARKEND;
       
   206 			}
       
   207 			break;
       
   208 		case EMkDir:
       
   209 			{
       
   210 			__UHEAP_MARK;
       
   211 			gLogFailureData.iAPIName = KMkDir;
       
   212 			r=TheFs.MkDir(srcCmdFile);
       
   213 			testAndLog(r==KErrNone);
       
   214 			__UHEAP_MARKEND;
       
   215 			}
       
   216 			break;		
       
   217 		case EMkDirAll:
       
   218 			{
       
   219 			__UHEAP_MARK;
       
   220 			gLogFailureData.iAPIName = KMkDirAll;
       
   221 			r=TheFs.MkDirAll(srcCmdFile);
       
   222 			testAndLog(r==KErrNone);
       
   223 			__UHEAP_MARKEND;
       
   224 			}
       
   225 			break;		
       
   226 		case ERenameFile:
       
   227 			{
       
   228 			__UHEAP_MARK;
       
   229 			gLogFailureData.iAPIName = KRenameFile;
       
   230 			if (trgCmdFile.Length() > 0)
       
   231 				{
       
   232 				trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   233 				}
       
   234 			else
       
   235 				{
       
   236 				//trgCmdFile= gSessionPath;
       
   237 				trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   238 				}
       
   239 				
       
   240 			r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite);
       
   241 			testAndLog(r == KErrNone);
       
   242 			r=TheFile.Rename(trgCmdFile);
       
   243 			testAndLog(r==KErrNone);
       
   244 			TheFile.Close();
       
   245 			__UHEAP_MARKEND;
       
   246 			}
       
   247 			break;
       
   248 		case EReadFileSection:
       
   249 			{
       
   250 			__UHEAP_MARK;
       
   251 			gLogFailureData.iAPIName = KReadFileSection;
       
   252 			r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite);
       
   253 			testAndLog(r == KErrNone);
       
   254 			
       
   255 			TInt numWrite = 15;
       
   256 			TBuf8<50> writeBuf = _L8("I am going to write some junk for testing purpose");
       
   257 			TheFile.Write(writeBuf, numWrite);
       
   258    			r=TheFile.Flush();
       
   259    			testAndLog(r==KErrNone);
       
   260   			TheFile.Close();
       
   261 			__UHEAP_MARKEND;
       
   262 			}
       
   263 			break;
       
   264 		case EDeleteFile:
       
   265 			{
       
   266 			__UHEAP_MARK;
       
   267 			gLogFailureData.iAPIName = KDeleteFile;
       
   268 			r=TheFs.Delete(srcCmdFile);
       
   269 			testAndLog(r==KErrNone);
       
   270 			__UHEAP_MARKEND;
       
   271 			}
       
   272 			break;
       
   273 		case EOpenDir:
       
   274 			{
       
   275 			__UHEAP_MARK;
       
   276 			gLogFailureData.iAPIName = KOpenDir;
       
   277 			r=TheDir.Open(TheFs,srcCmdFile,KEntryAttMaskSupported);
       
   278 			testAndLog(r==KErrNone);
       
   279 			TheDir.Close();
       
   280 			__UHEAP_MARKEND;
       
   281 			}
       
   282 			break;
       
   283 		case EReadDir:
       
   284 			{
       
   285 			__UHEAP_MARK;
       
   286 			gLogFailureData.iAPIName = KReadDir;
       
   287 			r=TheDir.Open(TheFs,srcCmdFile,KEntryAttMaskSupported);
       
   288 			testAndLog(r==KErrNone);
       
   289 			TheDir.Close();
       
   290 			__UHEAP_MARKEND;
       
   291 			}
       
   292 			break;
       
   293 		case ERemoveDir:
       
   294 			{
       
   295 			__UHEAP_MARK;
       
   296 			gLogFailureData.iAPIName = KRemoveDir;
       
   297 			r=TheFs.RmDir(srcCmdFile);
       
   298 			testAndLog(r==KErrNone);
       
   299 			__UHEAP_MARKEND;
       
   300 			}
       
   301 			break;		
       
   302 		case EIsFileInRom:
       
   303 			{
       
   304 			__UHEAP_MARK;
       
   305 			gLogFailureData.iAPIName = KIsFileInRom;
       
   306 			// The tested files are created on non-rom drives, which should not be found 
       
   307 			//	on rom drives
       
   308 			TUint8* ptr=TheFs.IsFileInRom(srcCmdFile);
       
   309 			testAndLog(ptr==NULL);
       
   310 			__UHEAP_MARKEND;
       
   311 			}
       
   312 			break;
       
   313 		case EReplaceFile:
       
   314 			{
       
   315 			__UHEAP_MARK;
       
   316 			gLogFailureData.iAPIName = KReplaceFile;
       
   317 			r=TheFile.Replace(TheFs, srcCmdFile ,EFileWrite);
       
   318 			testAndLog(r==KErrNone);
       
   319 			TheFile.Close();
       
   320 			__UHEAP_MARKEND;
       
   321 			}
       
   322 			break;
       
   323 		case EOperateOnFileNames:
       
   324 			{
       
   325 			__UHEAP_MARK;
       
   326 			gLogFailureData.iAPIName = KOperateOnFileNames;
       
   327 			r = TheFile.Open(TheFs, srcCmdFile, EFileRead);
       
   328 			testAndLog(r == KErrNone);
       
   329 			TheFile.Close();
       
   330 			__UHEAP_MARKEND;
       
   331 			}
       
   332 			break;
       
   333 		case EFileModify:
       
   334 			{
       
   335 			__UHEAP_MARK;
       
   336 			gLogFailureData.iAPIName = KFileModify;
       
   337 			TTime time;
       
   338 			r=TheFs.Modified(srcCmdFile,time);
       
   339 			testAndLog(r==KErrNone);
       
   340 			__UHEAP_MARKEND;
       
   341 			}
       
   342 			break;
       
   343 		case EFileAttributes:
       
   344 			{
       
   345 			__UHEAP_MARK;
       
   346 			gLogFailureData.iAPIName = KFileAttributes;
       
   347 			TUint att;
       
   348 			r=TheFs.Att(srcCmdFile,att);
       
   349 			testAndLog(r==KErrNone);
       
   350 			__UHEAP_MARKEND;
       
   351 			}
       
   352 			break;
       
   353 		case ERFsEntry:
       
   354 			{
       
   355 			__UHEAP_MARK;
       
   356 			gLogFailureData.iAPIName = KRFsEntry;
       
   357 			TEntry entryDetail;
       
   358 			r=TheFs.Entry(srcCmdFile, entryDetail);
       
   359 			testAndLog(r==KErrNone);
       
   360 			__UHEAP_MARKEND;
       
   361 			}
       
   362 			break;
       
   363 		case ERFsReplace:
       
   364 			{
       
   365 			__UHEAP_MARK;	
       
   366 			gLogFailureData.iAPIName = KRFsReplace;
       
   367 			if (trgCmdFile.Length() > 0)
       
   368 				{
       
   369 				trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   370 				}
       
   371 			else
       
   372 				{
       
   373 				//trgCmdFile= gSessionPath;
       
   374 				trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   375 				}
       
   376 			r=TheFs.Replace(srcCmdFile,trgCmdFile);
       
   377 			testAndLog(r==KErrNone);
       
   378 			__UHEAP_MARKEND;
       
   379 			}
       
   380 			break;
       
   381 		case ERFsRename:
       
   382 			{
       
   383 			__UHEAP_MARK;
       
   384 			gLogFailureData.iAPIName = KRFsRename;
       
   385 			if (trgCmdFile.Length() > 0)
       
   386 				{
       
   387 				trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   388 				}
       
   389 			else
       
   390 				{
       
   391 				//trgCmdFile= gSessionPath;
       
   392 				trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   393 				} 
       
   394 			r=TheFs.Rename(srcCmdFile,trgCmdFile);
       
   395 			testAndLog(r==KErrNone);
       
   396 			__UHEAP_MARKEND;
       
   397 			}	
       
   398 			break;
       
   399 		case EGetDir:	
       
   400 			{
       
   401 			__UHEAP_MARK;
       
   402 			gLogFailureData.iAPIName = KGetDir;
       
   403 			CDir *anEntryList;
       
   404 			r=TheFs.GetDir(srcCmdFile,KEntryAttNormal,ESortByName,anEntryList);
       
   405 			testAndLog(r==KErrNone);
       
   406 			delete anEntryList;
       
   407 			__UHEAP_MARKEND;
       
   408 			}
       
   409 			break;
       
   410 		case EFileTemp:
       
   411 			{
       
   412 			__UHEAP_MARK;
       
   413 			gLogFailureData.iAPIName = KFileTemp;
       
   414 			TFileName tempFileName;
       
   415 			r=TheFile.Temp(TheFs,srcCmdFile,tempFileName,EFileWrite);
       
   416 			testAndLog(r == KErrNone);
       
   417 			TheFile.Close();
       
   418 			__UHEAP_MARKEND;
       
   419 			}
       
   420 			break;
       
   421 		case EReadFromFile:
       
   422 			{
       
   423 			__UHEAP_MARK;
       
   424 			gLogFailureData.iAPIName = KReadFromFile;
       
   425 			r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite);
       
   426 			testAndLog(r == KErrNone);
       
   427 			
       
   428 			TBuf8<200> writeBuf = _L8("I am going to write something to the file and then read from the specified position to test an overload of RFIle::Read");
       
   429 			TInt numWrite = 50;
       
   430    			TheFile.Write(writeBuf, numWrite);
       
   431    			testAndLog(r==KErrNone);
       
   432 			TheFile.Close();
       
   433 			__UHEAP_MARKEND;
       
   434 			}	
       
   435 		break;
       
   436 		case EWriteToFile:
       
   437 			{
       
   438 			__UHEAP_MARK;						
       
   439 			gLogFailureData.iAPIName = KWriteToFile;
       
   440 
       
   441 			r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite);
       
   442 			testAndLog(r == KErrNone);
       
   443 
       
   444 			TBuf8<200> writeBuf = _L8("I am going to write something to the file and then read from the specified position to test an overload of RFIle::Read");
       
   445 			TInt numWrite = 50;
       
   446    			TheFile.Write(writeBuf, numWrite);
       
   447    			testAndLog(r==KErrNone);
       
   448    			r=TheFile.Flush();
       
   449    			testAndLog(r==KErrNone);
       
   450 			TheFile.Close();
       
   451    			__UHEAP_MARKEND;
       
   452 			}	
       
   453 			
       
   454 		break;
       
   455 	 	default:
       
   456 		break;
       
   457 
       
   458 		}
       
   459 //	test.Printf(_L("DataExecution::\tTest case %d passed\n"),aParam.iTestCaseID);
       
   460 
       
   461 	failedOnBuf.Close();
       
   462 	tcUniquePath.Close();
       
   463 
       
   464 	srcCmdFile.Close();
       
   465 	trgCmdFile.Close();
       
   466 	srcCmd.Close();
       
   467 	CheckDisk();
       
   468 	}
       
   469 
       
   470 void DataVerificationL(const TTestParamAll& aParam, const TTCType aTCType)
       
   471 	{
       
   472 	RBuf srcCmdFile;
       
   473 	srcCmdFile.CreateL(aParam.iSrcCmdPath);
       
   474 	RBuf trgCmdFile;
       
   475 	trgCmdFile.CreateL(aParam.iTrgCmdPath);
       
   476 	RBuf srcCmd;
       
   477 	srcCmd.CreateL(aParam.iSrcPrsPath);
       
   478 
       
   479 	if (srcCmdFile.Length() > 0)
       
   480 		{
       
   481 		srcCmdFile[0] = (TUint16)*aParam.iSrcDrvChar;
       
   482 		}
       
   483 	else
       
   484 		{
       
   485 		//srcCmdFile= gSessionPath;
       
   486 		srcCmdFile[0] = (TUint16)*aParam.iSrcDrvChar;
       
   487 		}
       
   488 		
       
   489 	if (srcCmd.Length() > 0)
       
   490 		{
       
   491 		srcCmd[0] = (TUint16)*aParam.iSrcDrvChar;
       
   492 		}
       
   493 	else
       
   494 		{
       
   495 		//srcCmd= gSessionPath;
       
   496 		srcCmd[0] = (TUint16)*aParam.iSrcDrvChar;
       
   497 		}
       
   498 
       
   499 	// logging for failure
       
   500 	gTCType = aTCType;
       
   501 	RBuf failedOnBuf;
       
   502 	failedOnBuf.CreateL(KVerification());
       
   503 	gTCId = aParam.iTestCaseID;
       
   504 	RBuf tcUniquePath;
       
   505 	tcUniquePath.CreateL(aParam.iSrcPrsPath);
       
   506 
       
   507 	TInt r = KErrNone;
       
   508 	switch(aParam.iAPI)
       
   509 		{
       
   510 		case EGetShortName:
       
   511 		case EGetShortNameWithDLL:
       
   512 		case EGetShortNameWithoutDLL:
       
   513 			{
       
   514 			__UHEAP_MARK;
       
   515 			if(aParam.iAPI == EGetShortName )
       
   516 				gLogFailureData.iAPIName = KGetShortName;
       
   517 			else if(aParam.iAPI == EGetShortNameWithDLL )
       
   518 				gLogFailureData.iAPIName = KGetShortNameWithDLL;
       
   519 			else if(aParam.iAPI == EGetShortNameWithoutDLL )
       
   520 				gLogFailureData.iAPIName = KGetShortNameWithoutDLL;
       
   521 
       
   522 				if (trgCmdFile.Length() > 0)
       
   523 					{
       
   524 					trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   525 					}
       
   526 				else
       
   527 					{
       
   528 					//trgCmdFile= gSessionPath;
       
   529 					trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   530 					}
       
   531 
       
   532 			TBuf<0x10> shortName;
       
   533 			r=TheFs.GetShortName(srcCmdFile,shortName);
       
   534 			testAndLog(r==KErrNone);
       
   535 			if(r==KErrNone)
       
   536 				{
       
   537 				srcCmd.ReAllocL(srcCmd.Length() + shortName.Length());
       
   538 				srcCmd+= shortName;
       
   539 				testAndLog(srcCmd==trgCmdFile);
       
   540 				}
       
   541 			__UHEAP_MARKEND;
       
   542 			}
       
   543 			break;
       
   544 		case ELongShortConversion:
       
   545 			{
       
   546 			__UHEAP_MARK;
       
   547 			gLogFailureData.iAPIName = KLongShortConversion;
       
   548 			if (trgCmdFile.Length() > 0)
       
   549 				{
       
   550 				trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   551 				}
       
   552 			else
       
   553 				{
       
   554 				//trgCmdFile= gSessionPath;
       
   555 				trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   556 				}
       
   557 
       
   558 			RBuf lgnFullPath;
       
   559 			RBuf shnFullPath;
       
   560 			TFileName longName;
       
   561 			TBuf<0x10> shortName;
       
   562 	
       
   563 			r = TheFs.GetShortName(srcCmdFile, shortName);
       
   564 			testAndLog(r==KErrNone);
       
   565 	
       
   566 			if(r==KErrNone)
       
   567 				{
       
   568 				shnFullPath.CreateL(srcCmd);
       
   569 				shnFullPath.ReAllocL(srcCmd.Length() + shortName.Length());
       
   570 				shnFullPath.Append(shortName);
       
   571 				r = shnFullPath.Compare(trgCmdFile);
       
   572 				testAndLog(r==KErrNone);
       
   573 
       
   574 				r = TheFs.GetLongName(shnFullPath, longName);
       
   575 				testAndLog(r==KErrNone);
       
   576 				
       
   577 				lgnFullPath.CreateL(srcCmd);
       
   578 				lgnFullPath.ReAllocL(srcCmd.Length() + longName.Length());
       
   579 				lgnFullPath.Append(longName);
       
   580 				r = lgnFullPath.Compare(srcCmdFile);
       
   581 				testAndLog(r==KErrNone);
       
   582 
       
   583 				lgnFullPath.Close();
       
   584 				shnFullPath.Close();
       
   585 				}
       
   586 			__UHEAP_MARKEND;
       
   587 			}
       
   588 			break;
       
   589 		case ECreateFile:
       
   590 			{
       
   591 			__UHEAP_MARK;
       
   592 			gLogFailureData.iAPIName = KCreateFile;
       
   593 			r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite);
       
   594 			testAndLog(r == KErrNone);
       
   595 			TheFile.Close();
       
   596 			__UHEAP_MARKEND;
       
   597 			}
       
   598 			break;
       
   599 		case EIsValidName:
       
   600 			{
       
   601 			__UHEAP_MARK;
       
   602 			gLogFailureData.iAPIName = KIsValidName;
       
   603 			TText badChar;
       
   604 			r=TheFs.IsValidName(srcCmdFile,badChar);
       
   605 			testAndLog(r);
       
   606 			r=TheFs.IsValidName(srcCmdFile);
       
   607 			testAndLog(r);
       
   608 			__UHEAP_MARKEND;
       
   609 			}
       
   610 			break;
       
   611 		case EMkDir:
       
   612 			{
       
   613 			__UHEAP_MARK;
       
   614 			gLogFailureData.iAPIName = KMkDir;
       
   615 			r=TheDir.Open(TheFs,srcCmdFile,KEntryAttMaskSupported);
       
   616 			testAndLog(r==KErrNone);
       
   617 			TheDir.Close();
       
   618 			__UHEAP_MARKEND;
       
   619 			}
       
   620 			break;
       
   621 		case EMkDirAll:
       
   622 			{
       
   623 			__UHEAP_MARK;
       
   624 			gLogFailureData.iAPIName = KMkDirAll;
       
   625 			r=TheDir.Open(TheFs,srcCmdFile,KEntryAttMaskSupported);
       
   626 			testAndLog(r==KErrNone);
       
   627 			TheDir.Close();
       
   628 			__UHEAP_MARKEND;
       
   629 			}
       
   630 			break;
       
   631 		case ERenameFile:
       
   632 			{
       
   633 			__UHEAP_MARK;
       
   634 			gLogFailureData.iAPIName = KRenameFile;
       
   635 			if (trgCmdFile.Length() > 0)
       
   636 				{
       
   637 				trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   638 				}
       
   639 			else
       
   640 				{
       
   641 				//trgCmdFile= gSessionPath;
       
   642 				trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   643 				}
       
   644 			r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite);
       
   645 			testAndLog(r == KErrNotFound);
       
   646 			// r = TheFile.Open(TheFs, trgCmdFile, EFileRead|EFileWrite);
       
   647 			// testAndLog(r == KErrNone);
       
   648 			// TheFile.Close();
       
   649 			__UHEAP_MARKEND;
       
   650 			}
       
   651 			break;
       
   652 		case EReadFileSection:
       
   653 			{
       
   654 			__UHEAP_MARK;
       
   655 			gLogFailureData.iAPIName = KReadFileSection;
       
   656 			TBool isFileOpen = EFalse;
       
   657 			r=TheFs.IsFileOpen(srcCmdFile,isFileOpen);
       
   658 			testAndLog(r==KErrNone);
       
   659 			if(isFileOpen)
       
   660 				{
       
   661 				TheFile.Close();
       
   662 				}
       
   663 			else
       
   664 				{
       
   665 				TInt numRead = 15;
       
   666 				TBuf8<50> readBuf;
       
   667 				r=TheFs.ReadFileSection(srcCmdFile, 0, readBuf, numRead);
       
   668 				testAndLog(r==KErrNone);
       
   669 				}
       
   670 			__UHEAP_MARKEND;
       
   671 			}
       
   672 			break;
       
   673 		case EDeleteFile:
       
   674 			{
       
   675 			__UHEAP_MARK;
       
   676 			gLogFailureData.iAPIName = KDeleteFile;
       
   677 			r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite);
       
   678 			testAndLog(r == KErrNotFound);
       
   679 			// TheFile.Close();
       
   680 			__UHEAP_MARKEND;
       
   681 			}
       
   682 			break;
       
   683 		case EOpenDir:
       
   684 			{
       
   685 			__UHEAP_MARK;
       
   686 			gLogFailureData.iAPIName = KOpenDir;
       
   687 			r=TheDir.Open(TheFs,srcCmdFile,KEntryAttMaskSupported);
       
   688 			testAndLog(r==KErrNone);
       
   689 			TheDir.Close();
       
   690 			__UHEAP_MARKEND;
       
   691 			}
       
   692 			break;
       
   693 		case EReadDir:
       
   694 			{
       
   695 			__UHEAP_MARK;
       
   696 			gLogFailureData.iAPIName = KReadDir;
       
   697 			TEntry entry;
       
   698 			TInt dirEntryCount = 0;
       
   699 			r=TheDir.Open(TheFs,srcCmdFile,KEntryAttMaskSupported);
       
   700 			testAndLog(r==KErrNone);
       
   701 			FOREVER
       
   702 				{
       
   703 				r = TheDir.Read(entry);
       
   704 				if(r == KErrEof)
       
   705 					{
       
   706 					break;
       
   707 					}
       
   708 				dirEntryCount++;
       
   709 				}
       
   710 			TheDir.Close();
       
   711 			testAndLog(dirEntryCount == 4);
       
   712 			__UHEAP_MARKEND;
       
   713 			}
       
   714 			break;
       
   715 		case ERemoveDir:
       
   716 			{
       
   717 			__UHEAP_MARK;
       
   718 			gLogFailureData.iAPIName = KRemoveDir;
       
   719 			r = TheDir.Open(TheFs, srcCmdFile, KEntryAttMaskSupported);
       
   720 			testAndLog(r == KErrPathNotFound);
       
   721 			// TheDir.Close();
       
   722 			__UHEAP_MARKEND;
       
   723 			}
       
   724 			break;
       
   725 		case EIsFileInRom:
       
   726 			{
       
   727 			__UHEAP_MARK;
       
   728 			gLogFailureData.iAPIName = KIsFileInRom;
       
   729 			TUint8* ptr=TheFs.IsFileInRom(srcCmdFile);
       
   730 			// file should not be in ROM
       
   731 			testAndLog(ptr==NULL)
       
   732 			__UHEAP_MARKEND;
       
   733 			}
       
   734 			break;
       
   735 		case EReplaceFile:
       
   736 			{
       
   737 			__UHEAP_MARK;
       
   738 			gLogFailureData.iAPIName = KReplaceFile;
       
   739 			r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite);
       
   740 			testAndLog(r == KErrNone);
       
   741 			TheFile.Close();
       
   742 			__UHEAP_MARKEND;
       
   743 			}
       
   744 			break;
       
   745 		case EOperateOnFileNames:
       
   746 			{
       
   747 			__UHEAP_MARK;
       
   748 			gLogFailureData.iAPIName = KOperateOnFileNames;
       
   749 			
       
   750 			TFileName realFileNameInFS;
       
   751 			TFileName fullFileName;
       
   752 			TFileName fileName;
       
   753 
       
   754 			r = TheFile.Open(TheFs, srcCmdFile, EFileRead);
       
   755 			testAndLog(r == KErrNone);
       
   756 
       
   757 			if(r==KErrNone)
       
   758 				{
       
   759 				r=TheFile.FullName(fullFileName);
       
   760 				testAndLog(r==KErrNone);
       
   761 				testAndLog(fullFileName==srcCmdFile);
       
   762 				
       
   763 				TInt length = srcCmdFile.Length()-srcCmd.Length();
       
   764 				
       
   765 				r=TheFile.Name(fileName);
       
   766 				testAndLog(r==KErrNone);
       
   767 				
       
   768 				TBuf<50> tempFileName;
       
   769 				tempFileName = srcCmdFile.Right(length);
       
   770 				testAndLog(fileName==tempFileName);
       
   771 				testAndLog(length==fileName.Length());
       
   772 
       
   773 				r=TheFs.RealName(srcCmdFile,realFileNameInFS);
       
   774 				testAndLog(r==KErrNone);
       
   775 				testAndLog(realFileNameInFS==srcCmdFile);
       
   776 				TheFile.Close();
       
   777 				}
       
   778 			__UHEAP_MARKEND;
       
   779 			}
       
   780 			break;
       
   781 		case EFileModify:
       
   782 			{
       
   783 			__UHEAP_MARK;
       
   784 			gLogFailureData.iAPIName = KFileModify;
       
   785 			TTime tempTime;
       
   786 			r=TheFs.Modified(srcCmdFile,tempTime);
       
   787 			testAndLog(r==KErrNone);
       
   788 			tempTime.HomeTime();
       
   789 			r=TheFs.SetModified(srcCmdFile,tempTime);
       
   790 			testAndLog(r==KErrNone);
       
   791 			__UHEAP_MARKEND;
       
   792 			}
       
   793 			break;
       
   794 		case EFileAttributes:
       
   795 			{
       
   796 			__UHEAP_MARK;
       
   797 			gLogFailureData.iAPIName = KFileAttributes;
       
   798 			TUint att;
       
   799 			r=TheFs.Att(srcCmdFile,att);
       
   800 			testAndLog(r==KErrNone);
       
   801 			r=TheFs.SetAtt(srcCmdFile,KEntryAttHidden,0);
       
   802 			testAndLog(r==KErrNone);
       
   803 			r=TheFs.Att(srcCmdFile,att);
       
   804 			testAndLog(r==KErrNone);
       
   805 			__UHEAP_MARKEND;
       
   806 			}
       
   807 			break;
       
   808 		case ERFsEntry:
       
   809 			{
       
   810 			__UHEAP_MARK;
       
   811 			gLogFailureData.iAPIName = KRFsEntry;
       
   812 			TEntry entryDetail;
       
   813 			r=TheFs.Entry(srcCmdFile,entryDetail);
       
   814 			testAndLog(r==KErrNone);
       
   815 			TTime time;
       
   816 			time.HomeTime();
       
   817 			r=TheFs.SetEntry(srcCmdFile, time, KEntryAttHidden, KEntryAttNormal);
       
   818 			testAndLog(r==KErrNone);
       
   819 			r=TheFs.Entry(srcCmdFile, entryDetail);
       
   820 			testAndLog(r==KErrNone);
       
   821 			__UHEAP_MARKEND;
       
   822 			}
       
   823 			break;
       
   824 		case ERFsReplace:
       
   825 			{
       
   826 			__UHEAP_MARK;	
       
   827 			gLogFailureData.iAPIName = KRFsReplace;
       
   828 			if (trgCmdFile.Length() > 0)
       
   829 				{
       
   830 				trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   831 				}
       
   832 			else
       
   833 				{
       
   834 				//trgCmdFile= gSessionPath;
       
   835 				trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   836 				}
       
   837 			r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite);
       
   838 			testAndLog(r == KErrNotFound);
       
   839 			// r = TheFile.Open(TheFs, trgCmdFile, EFileRead|EFileWrite);
       
   840 			// testAndLog(r == KErrNone);
       
   841 			// TheFile.Close();
       
   842 			__UHEAP_MARKEND;
       
   843 			}
       
   844 			break;
       
   845 		case ERFsRename:
       
   846 			{
       
   847 			__UHEAP_MARK;
       
   848 			gLogFailureData.iAPIName = KRFsRename;
       
   849 			if (trgCmdFile.Length() > 0)
       
   850 				{
       
   851 				trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   852 				}
       
   853 			else
       
   854 				{
       
   855 				//trgCmdFile= gSessionPath;
       
   856 				trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar;
       
   857 				} 
       
   858 			TInt len=srcCmdFile.Length();
       
   859 			if(srcCmdFile[--len]=='\\')
       
   860 				{
       
   861 				r = TheDir.Open(TheFs, srcCmdFile, KEntryAttMaskSupported);
       
   862 				testAndLog(r == KErrPathNotFound);
       
   863 				// r = TheDir.Open(TheFs, trgCmdFile, KEntryAttMaskSupported);
       
   864 				// testAndLog(r == KErrNone);			
       
   865 				// TheDir.Close();
       
   866 				}
       
   867 			else
       
   868 				{
       
   869 				r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite);
       
   870 				testAndLog(r == KErrNotFound);
       
   871 				// r = TheFile.Open(TheFs, trgCmdFile, EFileRead|EFileWrite);
       
   872 				// testAndLog(r == KErrNone);
       
   873 				// TheFile.Close();
       
   874 				}
       
   875 			__UHEAP_MARKEND;			
       
   876 			}
       
   877 			break;
       
   878 		case EGetDir:
       
   879 			{
       
   880 			__UHEAP_MARK;
       
   881 			gLogFailureData.iAPIName = KGetDir;
       
   882 			CDir *anEntryList;
       
   883 			r=TheFs.GetDir(srcCmdFile,KEntryAttNormal,ESortByName,anEntryList);
       
   884 			testAndLog(r==KErrNone);
       
   885 			delete anEntryList;
       
   886 			__UHEAP_MARKEND;
       
   887 			}
       
   888 			break;
       
   889 		case EFileTemp:
       
   890 			{
       
   891 			__UHEAP_MARK;
       
   892 			gLogFailureData.iAPIName = KFileTemp;
       
   893 			TFileName tempFileName;
       
   894 			r=TheFile.Temp(TheFs,srcCmdFile,tempFileName,EFileWrite);
       
   895 			testAndLog(r == KErrNone);
       
   896 			TheFile.Close();
       
   897 			r = TheFile.Create(TheFs, tempFileName, EFileRead|EFileWrite);
       
   898 			testAndLog(r == KErrAlreadyExists);
       
   899 			__UHEAP_MARKEND;
       
   900 			}			
       
   901 			break;
       
   902 		case EReadFromFile:
       
   903 			{
       
   904 			__UHEAP_MARK;
       
   905 			gLogFailureData.iAPIName = KReadFromFile;
       
   906 			
       
   907 			TInt start=0, readLen=15, readPos=10;
       
   908 			TBuf8<200> readBuf;
       
   909 			TInt numWritten = 50;
       
   910 
       
   911 			r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite);
       
   912 			testAndLog(r == KErrNone);
       
   913 
       
   914 			if(r==KErrNone)
       
   915 				{
       
   916 				r=TheFile.Seek(ESeekStart,start);
       
   917 		  		testAndLog(r==KErrNone);
       
   918 
       
   919 				readBuf.SetLength(0);
       
   920 				r=TheFile.Read(readBuf);
       
   921 				testAndLog(r == KErrNone);
       
   922 				testAndLog(numWritten == readBuf.Length());
       
   923 				
       
   924 				//An overload of RFile::Read(), read specified no.of bytes.
       
   925 	   			r=TheFile.Seek(ESeekStart,start);
       
   926 	  			testAndLog(r==KErrNone);
       
   927 	  			
       
   928 				readBuf.SetLength(0);
       
   929 				TheFile.Read(readBuf,readLen);
       
   930 				testAndLog(r == KErrNone);
       
   931 				testAndLog(readLen == readBuf.Length());
       
   932 				
       
   933 				//An overload of RFile::Read(), read from the specified position.
       
   934 				readBuf.SetLength(0);
       
   935 				r=TheFile.Read(readPos,readBuf);
       
   936 				testAndLog(r == KErrNone);
       
   937 				testAndLog(numWritten-readPos == readBuf.Length());
       
   938 				TheFile.Close();
       
   939 				}
       
   940 			__UHEAP_MARKEND;
       
   941 			}	
       
   942 			break;	
       
   943 		case EWriteToFile:
       
   944 			{
       
   945 			__UHEAP_MARK;
       
   946 			gLogFailureData.iAPIName = KWriteToFile;
       
   947 			
       
   948 			r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite);
       
   949 			testAndLog(r == KErrNone);
       
   950 
       
   951 			if(r==KErrNone)
       
   952 				{
       
   953 				TInt writeLen=20, writePos=10, start=0, readLen=0;
       
   954 				TBuf8<200> writeBuf = _L8("I am going to write something to the file and then read from the specified position to test an overload of RFIle::Read");
       
   955 				TInt numWritten = writeBuf.Length();
       
   956 				TBuf8<200> readBuf;
       
   957 				
       
   958 	   			TheFile.Write(writeBuf);
       
   959 	   			r=TheFile.Flush();
       
   960 	   			testAndLog(r==KErrNone);
       
   961 	   			
       
   962 	   			r=TheFile.Seek(ESeekStart,start);
       
   963 	  			testAndLog(r==KErrNone);
       
   964 	  		
       
   965 	   			readBuf.SetLength(0);
       
   966 	   			r=TheFile.Read(readBuf);
       
   967 	   			testAndLog(r==KErrNone);
       
   968 	   			readLen = readBuf.Length();
       
   969 	   			testAndLog(numWritten == readLen);
       
   970 	   			
       
   971 	   			r=TheFile.SetSize(0);
       
   972 	   			testAndLog(r==KErrNone);
       
   973 	   			
       
   974 	   			//An overload of RFile::Write(), write specified no.of bytes.
       
   975 	   			TheFile.Write(writeBuf,writeLen);
       
   976 	   			r=TheFile.Flush();
       
   977 	   			testAndLog(r==KErrNone);
       
   978 	   			
       
   979 	   			r=TheFile.Seek(ESeekStart,start);
       
   980 	  			testAndLog(r==KErrNone);
       
   981 				
       
   982 				readBuf.SetLength(0);
       
   983 	   			r=TheFile.Read(readBuf);
       
   984 	   			testAndLog(r==KErrNone);
       
   985 	   			readLen = readBuf.Length();
       
   986 	   			testAndLog(writeLen==readLen);
       
   987 	   			
       
   988 				r=TheFile.SetSize(0);
       
   989 	   			testAndLog(r==KErrNone);
       
   990 	   			
       
   991 	   			//An overload of RFile::Write(), write to a particular position.
       
   992 	   			TBuf8<50> testBuf = _L8("Testing different variants of RFile::Write APIs");   		
       
   993 	    		TheFile.Write(testBuf);
       
   994 	    		r=TheFile.Flush();
       
   995 	   			testAndLog(r==KErrNone);
       
   996 				
       
   997 	   			TheFile.Write(writePos,writeBuf);
       
   998 	   			r=TheFile.Flush();
       
   999 	   			testAndLog(r==KErrNone);
       
  1000 	   			
       
  1001 	      		r=TheFile.Seek(ESeekStart,start);
       
  1002 	  			testAndLog(r==KErrNone);
       
  1003 	  			
       
  1004 	  			readBuf.SetLength(0);
       
  1005 	   			r=TheFile.Read(readBuf);
       
  1006 	   			testAndLog(r==KErrNone);
       
  1007 	   			readLen = readBuf.Length();
       
  1008 	   			testAndLog(numWritten + writePos == readLen);
       
  1009 	   			
       
  1010 				r=TheFile.SetSize(0);
       
  1011 	   			testAndLog(r==KErrNone);
       
  1012 	   			
       
  1013 	   			//An overload of RFile::Write(), write to a particular position and specified no. of bytes.
       
  1014 	   			TInt size;
       
  1015 	    		TheFile.Write(testBuf);
       
  1016 	    		r=TheFile.Flush();
       
  1017 	   			testAndLog(r==KErrNone);
       
  1018 			
       
  1019 	   			TheFile.Write(writePos,writeBuf,writeLen);
       
  1020 	   			r=TheFile.Flush();
       
  1021 	   			testAndLog(r==KErrNone);
       
  1022 	   			
       
  1023 	   			r=TheFile.Seek(ESeekStart,start);
       
  1024 	  			testAndLog(r==KErrNone);
       
  1025 	  			
       
  1026 	  			readBuf.SetLength(0);
       
  1027 	   			r=TheFile.Read(readBuf);
       
  1028 	   			testAndLog(r==KErrNone);
       
  1029 	   			
       
  1030 	   			TInt newSize = testBuf.Length()-(writePos+writeLen);
       
  1031 	   			if(newSize < testBuf.Length())
       
  1032 	   				{
       
  1033 	   				size = testBuf.Length();
       
  1034 	   				}
       
  1035 	   			else
       
  1036 	   				size = newSize;
       
  1037 	   			readLen = readBuf.Length();
       
  1038 	   			testAndLog(readLen==size);
       
  1039 
       
  1040 	   			r=TheFile.SetSize(0);
       
  1041 	   			testAndLog(r==KErrNone);
       
  1042 
       
  1043 	   			TheFile.Close();
       
  1044 				}
       
  1045    			__UHEAP_MARKEND;
       
  1046 			}
       
  1047 			break;
       
  1048 	 	default:
       
  1049 			break;
       
  1050 		}
       
  1051 //	test.Printf(_L("DataVerification::\tTest case %d passed\n"),aParam.iTestCaseID);
       
  1052 
       
  1053 	failedOnBuf.Close();
       
  1054 	tcUniquePath.Close();
       
  1055 
       
  1056 	srcCmdFile.Close();
       
  1057 	trgCmdFile.Close();
       
  1058 	srcCmd.Close();
       
  1059 	CheckDisk();
       
  1060 	}
       
  1061 	
       
  1062 void DeletePathAfterTest(const TTestParamAll& aParam)
       
  1063 	{
       
  1064 	TFileName path = aParam.iSrcPrsPath;
       
  1065 	if (path.Length() == 0)
       
  1066 		{
       
  1067 		test.Printf(_L("ERROR<SetupDirFiles()>: Zero length src path!\n"));
       
  1068 		test(EFalse);
       
  1069 		}
       
  1070 
       
  1071 	path[0] = (TUint16)*aParam.iSrcDrvChar;
       
  1072 	TInt idx = path.Find(_L("Src\\"));
       
  1073 	path.Delete(idx,path.Length()-idx);
       
  1074 	RmDir(path);
       
  1075 	}
       
  1076 
       
  1077 
       
  1078 /*
       
  1079  * Do all basic binary test cases defined in gBasicUnitaryTestCases[]
       
  1080  */
       
  1081 void DoAllBasicUnitaryTestsL(const TTestCaseUnitaryBasic aBasicUnitaryTestCaseGroup[],
       
  1082 									TTestSwitches& aSwitches, TBool aIsWithDLL)
       
  1083 	{
       
  1084 	TTestParamAll* 	nextTestCase = new(ELeave) TTestParamAll();
       
  1085 	
       
  1086 	TInt i = 0;
       
  1087 	
       
  1088 	// Reset the Test Log Data
       
  1089 	ClearTCLogData();
       
  1090 
       
  1091 	while(SearchTestCaseByArrayIdx(i, aBasicUnitaryTestCaseGroup,
       
  1092 							*nextTestCase, aIsWithDLL) == KErrNone)
       
  1093 		{
       
  1094 		TTime startTime;
       
  1095 		TTime endTime;
       
  1096 		startTime.HomeTime();
       
  1097 		if(aSwitches.iExeOnSymbian || aSwitches.iExeOnWindows)
       
  1098 			{
       
  1099 			DataGenerationL(*nextTestCase);
       
  1100 			DataExecutionL(*nextTestCase, EUnitaryTest);
       
  1101 			}
       
  1102 		if(aSwitches.iVerOnSymbian || aSwitches.iVerOnWindows)
       
  1103 			{
       
  1104 			DataVerificationL(*nextTestCase, EUnitaryTest);
       
  1105 			DeletePathAfterTest(*nextTestCase);
       
  1106 			}
       
  1107 			
       
  1108 		CheckDisk();
       
  1109 		endTime.HomeTime();
       
  1110 		TTimeIntervalMicroSeconds timeTaken(0);
       
  1111 		timeTaken = endTime.MicroSecondsFrom(startTime);
       
  1112 
       
  1113 //		test.Printf(_L("Test Case Id : %d\n"),(*nextTestCase).iTestCaseID);
       
  1114 //		TInt time=0;
       
  1115 //		time=I64LOW(timeTaken.Int64()/1000);
       
  1116 //		test.Printf(_L("Time Taken by test case %d = %d mS \n"),nextTestCase.iTestCaseID,time);
       
  1117 		++i;
       
  1118 		}
       
  1119 	delete nextTestCase;
       
  1120 	}
       
  1121 		
       
  1122 /*
       
  1123  * Do all basic binary test cases defined in gBasicBinaryTestCases[]
       
  1124  */
       
  1125 void DoAllBasicBinaryTestsL(const TTestCaseBinaryBasic aBasicBinaryTestCaseGroup[],
       
  1126 							TTestSwitches& aSwitches, TBool aIsWithDLL)
       
  1127 	{
       
  1128 	TTestParamAll*	nextTestCase = new(ELeave) TTestParamAll();
       
  1129 	
       
  1130 	TInt i = 0;
       
  1131 	
       
  1132 	// Reset the Test Log Data
       
  1133 	ClearTCLogData();
       
  1134 	
       
  1135 	while (SearchTestCaseByArrayIdx(i, aBasicBinaryTestCaseGroup,
       
  1136 							*nextTestCase, aIsWithDLL) == KErrNone)
       
  1137 		{
       
  1138 		if (aIsWithDLL)
       
  1139 			{
       
  1140 			if(((aBasicBinaryTestCaseGroup[i].iBasic.iAPI==EGetShortNameWithoutDLL)))
       
  1141 				{
       
  1142 				++i;
       
  1143 				continue;
       
  1144 				}
       
  1145 			}
       
  1146 		else
       
  1147 			{
       
  1148 			if(((aBasicBinaryTestCaseGroup[i].iBasic.iAPI== EGetShortNameWithDLL) || (aBasicBinaryTestCaseGroup[i].iBasic.iAPI==ELongShortConversion)) )
       
  1149 				{
       
  1150 				++i;
       
  1151 				continue;
       
  1152 				}
       
  1153 			}
       
  1154 		TTime startTime;
       
  1155 		TTime endTime;
       
  1156 		startTime.HomeTime();
       
  1157 
       
  1158 		if(aSwitches.iExeOnSymbian || aSwitches.iExeOnWindows) 
       
  1159 			{
       
  1160 			DataGenerationL(*nextTestCase);
       
  1161 			DataExecutionL(*nextTestCase, EBinaryTest);
       
  1162 			}
       
  1163 		if(aSwitches.iVerOnSymbian || aSwitches.iVerOnWindows)
       
  1164 			{
       
  1165 			DataVerificationL(*nextTestCase, EBinaryTest);
       
  1166 			DeletePathAfterTest(*nextTestCase);
       
  1167 			}
       
  1168 
       
  1169 		endTime.HomeTime();
       
  1170 		TTimeIntervalMicroSeconds timeTaken(0);
       
  1171 		timeTaken = endTime.MicroSecondsFrom(startTime);
       
  1172 
       
  1173 //		test.Printf(_L("Test Case Id : %d\n"),(*nextTestCase).iTestCaseID);
       
  1174 //		TInt time2=0;
       
  1175 //		time2=I64LOW(timeTaken.Int64()/1000);
       
  1176 //		test.Printf(_L("Time Taken by test id %d = %d mS \n"),nextTestCase.iTestCaseID,time2);
       
  1177 		++i;
       
  1178 		}
       
  1179 
       
  1180 	delete nextTestCase;
       
  1181 	}
       
  1182 
       
  1183 /*
       
  1184  * Main testing control unit
       
  1185  */
       
  1186 void TestMainWithDLLL(TTestSwitches& aSwitches)
       
  1187 	{
       
  1188 	// Enables codepage dll implementation of LocaleUtils functions for this test only
       
  1189 	TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions);
       
  1190 	test(r == KErrNone);
       
  1191 		
       
  1192 	test.Printf(_L("Load the Code Page DLL"));
       
  1193 	r = UserSvr::ChangeLocale(KTestLocale);
       
  1194 	test(r == KErrNone);
       
  1195 			
       
  1196 	test.Next(_L("Test Unitary APIs with only Sync Variant with DLL"));
       
  1197 	gLogFailureData.iFuncName = KDoAllBasicUnitaryTestsL;
       
  1198 	DoAllBasicUnitaryTestsL(gBasicUnitaryTestCases, aSwitches, ETrue);
       
  1199 	
       
  1200 	test.Next(_L("Test Binary Tests with DLL"));
       
  1201 	gLogFailureData.iFuncName = KDoAllBasicBinaryTestsL;
       
  1202 	DoAllBasicBinaryTestsL(gBasicBinaryTestCases, aSwitches, ETrue);
       
  1203 	
       
  1204 	// Disables codepage dll implementation of LocaleUtils functions for other base tests
       
  1205 	r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
       
  1206 	test(r == KErrNone);
       
  1207 	}
       
  1208 	
       
  1209 void TestMainWithoutDLLL(TTestSwitches& aSwitches)
       
  1210 	{
       
  1211 	test.Next(_L("Test Unitary APIs with only Sync Variant without DLL"));
       
  1212 
       
  1213 	// Disables codepage dll implementation of LocaleUtils functions
       
  1214 	TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
       
  1215 	test(r == KErrNone);
       
  1216 
       
  1217 	gLogFailureData.iFuncName = KDoAllBasicUnitaryTestsL;
       
  1218 	DoAllBasicUnitaryTestsL(gBasicUnitaryTestCases, aSwitches, EFalse);
       
  1219 	
       
  1220 	test.Next(_L("Test Binary Tests without DLL"));
       
  1221 	gLogFailureData.iFuncName = KDoAllBasicBinaryTestsL;
       
  1222 	DoAllBasicBinaryTestsL(gBasicBinaryTestCases, aSwitches, EFalse);
       
  1223 	}
       
  1224 
       
  1225 void TestCompatibility(const TTestSwitches& aSwitches)
       
  1226 	{
       
  1227 	test.Next(_L("test compatibility"));
       
  1228 
       
  1229 	// logging for failure
       
  1230 	gTCType = ESymbianFATSpecific;
       
  1231 	RBuf failedOnBuf;
       
  1232 	failedOnBuf.CreateL(gLogFailureData.iFuncName);
       
  1233 	gTCId = 0;
       
  1234 	RBuf tcUniquePath;
       
  1235 	tcUniquePath.CreateL(KNone());
       
  1236 
       
  1237 	// original file name in DBCS
       
  1238 	TFileName fn1 = _L("\\\x798F\x5C71\x96C5\x6CBB");
       
  1239 	if (aSwitches.iExeOnSymbian)
       
  1240 		{
       
  1241 		GetBootInfo();
       
  1242 		RFile file;
       
  1243 		TFileName fn = _L("\\ABCD");
       
  1244 		
       
  1245 		TInt r=file.Create(TheFs,fn,EFileRead);
       
  1246 		testAndLog(r==KErrNone);
       
  1247 		file.Close();
       
  1248 
       
  1249 		//	Assume this file is the first entry in the root directory
       
  1250 		r=TheDisk.Open(TheFs,CurrentDrive());
       
  1251 		testAndLog(r==KErrNone);
       
  1252 		
       
  1253 	    //-- read the 1st dir entry, it should be a DOS entry 
       
  1254 	    const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
       
  1255 	    
       
  1256 	    TFatDirEntry fatEntry1;
       
  1257 		TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry));
       
  1258 	    testAndLog(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone); 
       
  1259 	    testAndLog(!fatEntry1.IsVFatEntry());
       
  1260 
       
  1261 	    // Manually modify the short name into unicode characters
       
  1262 	    // 	Unicode: 	0x(798F 5C71 96C5 6CBB)
       
  1263 	    //	Shift-JIS: 	0x(959F 8E52 89EB 8EA1)
       
  1264 
       
  1265 	    TBuf8<8> unicodeSN = _L8("ABCD1234");
       
  1266 	    unicodeSN[0] = 0x95;
       
  1267 	    unicodeSN[1] = 0x9F;
       
  1268 	    unicodeSN[2] = 0x8E;
       
  1269 	    unicodeSN[3] = 0x52;
       
  1270 	    unicodeSN[4] = 0x89;
       
  1271 	    unicodeSN[5] = 0xEB;
       
  1272 	    unicodeSN[6] = 0x8E;
       
  1273 	    unicodeSN[7] = 0xA1;
       
  1274 	    
       
  1275 	    fatEntry1.SetName(unicodeSN);
       
  1276 	    testAndLog(TheDisk.Write(posEntry1, ptrEntry1)==KErrNone);
       
  1277 	    TheDisk.Close();
       
  1278 		}
       
  1279 	if (aSwitches.iVerOnSymbian)
       
  1280 		{
       
  1281 		// Access the file without the DLL loaded.
       
  1282 	    TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
       
  1283 		testAndLog(r==KErrNone);
       
  1284 		
       
  1285 		TEntry entry;
       
  1286 		r = TheFs.Entry(fn1, entry);
       
  1287 		testAndLog(r==KErrNotFound);
       
  1288 		
       
  1289 	    // Access the file with the DLL loaded.
       
  1290 	    r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions);
       
  1291 		testAndLog(r==KErrNone);
       
  1292 		r = UserSvr::ChangeLocale(KTestLocale);
       
  1293 		testAndLog(r==KErrNone);
       
  1294 
       
  1295 		r = TheFs.Entry(fn1, entry);
       
  1296 		testAndLog(r==KErrNone);
       
  1297 		
       
  1298 	    r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
       
  1299 		testAndLog(r==KErrNone);
       
  1300 		}
       
  1301 	failedOnBuf.Close();
       
  1302 	tcUniquePath.Close();
       
  1303 	}
       
  1304 
       
  1305 #endif //defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
  1306 
       
  1307 /*
       
  1308  * Initialise test 
       
  1309 */
       
  1310 void CallTestsL(TTestSwitches& aSwitches)
       
  1311 	{
       
  1312 	test.Title();
       
  1313 	test.Start(_L("Starting T_FATCHARSETCONV tests"));
       
  1314 	(void) aSwitches;
       
  1315 #ifdef LOG_FAILURE_DATA
       
  1316 	test.Printf(_L("LOG_FAILURE_DATA: ON\n"));
       
  1317 #else
       
  1318 	test.Printf(_L("LOG_FAILURE_DATA: OFF\n"));
       
  1319 #endif
       
  1320 
       
  1321 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
  1322 	// Test only runs on Fat file systems
       
  1323 	TheFs.SessionPath(gSessionPath);
       
  1324 	TInt r = TheFs.FileSystemName(aSwitches.iMountedFSName, CurrentDrive());
       
  1325 	if (KErrNone == r)
       
  1326 		{
       
  1327 		// For automated testing this test should run on FAT file systems only.
       
  1328 		// For inter-operability testing on FAT and Win32 file systems.
       
  1329 		// if ((AUTO && FAT) || (IOT && (FAT || Win32))
       
  1330 		test.Printf(_L("Current File System: \"%S\"\n"), &aSwitches.iMountedFSName);
       
  1331 		if( (gAutoTest && isFAT(aSwitches.iMountedFSName)) ||
       
  1332 			(gIOTesting && (isFAT(aSwitches.iMountedFSName) || isWin32(aSwitches.iMountedFSName))))
       
  1333 			{
       
  1334 			// Log File System Name
       
  1335 			gLogFailureData.iFSName = aSwitches.iMountedFSName;
       
  1336 			
       
  1337 			// Store current file name
       
  1338 			TFileName fileName;
       
  1339 			TInt i=0;
       
  1340 			while(__FILE__[i]!='\0')
       
  1341 				{
       
  1342 				fileName.SetLength(i+1);
       
  1343 				fileName[i] = __FILE__[i++];
       
  1344 				}
       
  1345 			gFileName.Append(fileName);
       
  1346 			
       
  1347 			InitialiseL();
       
  1348 			// Special Cases	- Non-Symbian
       
  1349 			// Note: this case MUST be run as the first case as it performs formatting!!
       
  1350 			TestCompatibility(aSwitches);
       
  1351 			CreateTestDirectory(_L("\\F32-TST\\T_FATCHARSETCONV\\"));
       
  1352 			//Special Cases	- Only Symbian Specific
       
  1353 			if(!gIOTesting && aSwitches.iMountedFSName.Compare(KFAT) == 0)
       
  1354 				{
       
  1355 				DoSymbianSpecificCases();
       
  1356 				}
       
  1357 
       
  1358 			test.Next(_L("Test without DLL loaded"));
       
  1359 			if(gAutoTest)
       
  1360 				{
       
  1361 				QuickFormat();
       
  1362 				}
       
  1363 			TestMainWithoutDLLL(aSwitches);
       
  1364 							
       
  1365 			test.Next(_L("Test with DLL loaded"));
       
  1366 			if(gAutoTest)
       
  1367 				{
       
  1368 				QuickFormat();
       
  1369 				}
       
  1370 			TestMainWithDLLL(aSwitches);
       
  1371 			Cleanup();
       
  1372 			}
       
  1373 		else
       
  1374 			{
       
  1375 			if(gAutoTest)
       
  1376 				test.Printf(_L("Test only runs on \"FAT\" File Systems !!!\n"));
       
  1377 			if(gIOTesting)
       
  1378 				test.Printf(_L("Test only runs on \"FAT\" and \"Win32\" File Systems !!!\n"));
       
  1379 			}
       
  1380 		}
       
  1381 	else
       
  1382 		{
       
  1383 		test.Printf(_L("Drive %C: is not ready!\n"), 'A'+CurrentDrive());
       
  1384 		test(EFalse);
       
  1385 		}
       
  1386 #else
       
  1387 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.\n"));
       
  1388 #endif  // _DEBUG) || _DEBUG_RELEASE
       
  1389 	test.End();
       
  1390 	}
       
  1391 
       
  1392 LOCAL_C void PushLotsL()
       
  1393 //
       
  1394 // Expand the cleanup stack
       
  1395 //
       
  1396 	{
       
  1397 	TInt i;
       
  1398 	for(i=0;i<1000;i++)
       
  1399 		CleanupStack::PushL((CBase*)NULL);
       
  1400 	CleanupStack::Pop(1000);
       
  1401 	}
       
  1402 
       
  1403 
       
  1404 LOCAL_C void DoTests(TInt aDrive, TTestSwitches& aSwitches)
       
  1405 //
       
  1406 // Do testing on aDrive
       
  1407 //
       
  1408 	{
       
  1409 	gSessionPath=_L("?:\\F32-TST\\");
       
  1410 	TChar driveLetter;
       
  1411 	TInt r=TheFs.DriveToChar(aDrive,driveLetter);
       
  1412 	test(r==KErrNone);
       
  1413 	gSessionPath[0]=(TText)driveLetter;
       
  1414 	r=TheFs.SetSessionPath(gSessionPath);
       
  1415 	test(r==KErrNone);
       
  1416 	test.Printf(_L("gSessionPath = \"%S\"\n"), &gSessionPath);
       
  1417 
       
  1418 // !!! Disable platform security tests until we get the new APIs
       
  1419 //	if(User::Capability() & KCapabilityRoot)
       
  1420 		CheckMountLFFS(TheFs,driveLetter);
       
  1421 	
       
  1422 	User::After(1000000);
       
  1423 
       
  1424 //	Format(CurrentDrive());
       
  1425 
       
  1426 	r=TheFs.MkDirAll(gSessionPath);
       
  1427 	if(r == KErrCorrupt)
       
  1428 		{
       
  1429 		Format(aDrive);
       
  1430 		r=TheFs.MkDirAll(gSessionPath);
       
  1431 		test(r==KErrNone);
       
  1432 		}
       
  1433 	if (r!=KErrNone && r!=KErrAlreadyExists)
       
  1434 		{
       
  1435 		test.Printf(_L("MkDirAll() r %d\n"),r);
       
  1436 		test(EFalse);
       
  1437 		}
       
  1438 	TheFs.ResourceCountMarkStart();
       
  1439 	TRAP(r,CallTestsL(aSwitches));
       
  1440 	if (r==KErrNone)
       
  1441 		TheFs.ResourceCountMarkEnd();
       
  1442 	else
       
  1443 		{
       
  1444 		test.Printf(_L("Error: Leave %d\n"),r);
       
  1445 		test(EFalse);
       
  1446 		}
       
  1447 
       
  1448 	CheckDisk();
       
  1449 	TestingLFFS(EFalse);
       
  1450 	}
       
  1451 
       
  1452 	
       
  1453 GLDEF_C TInt E32Main()
       
  1454 //
       
  1455 // Test with drive nearly full
       
  1456 //
       
  1457     {
       
  1458 	CTrapCleanup* cleanup;
       
  1459 	cleanup=CTrapCleanup::New();
       
  1460 	TRAPD(r,PushLotsL());
       
  1461 	__UHEAP_MARK;
       
  1462 
       
  1463 	test.Title();
       
  1464 	test.Start(_L("Starting tests..."));
       
  1465 
       
  1466 	gSessionPath=_L("?:\\F32-TST\\");
       
  1467 	TTestSwitches testSwitches;
       
  1468 	ParseCommandArguments(testSwitches);
       
  1469 
       
  1470 	r=TheFs.Connect();
       
  1471 	test(r==KErrNone);
       
  1472 	TheFs.SetAllocFailure(gAllocFailOn);
       
  1473 
       
  1474 	TTime timerC;
       
  1475 	timerC.HomeTime();
       
  1476 
       
  1477 	TInt theDrive;
       
  1478 	r=TheFs.CharToDrive(gDriveToTest,theDrive);
       
  1479 	test(r==KErrNone);
       
  1480 	
       
  1481 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
  1482 	TPckgBuf<TIOCacheValues> pkgOrgValues;
       
  1483 	TIOCacheValues& orgValues=pkgOrgValues();
       
  1484 	r = controlIo(TheFs,theDrive, KControlIoCacheCount, orgValues);
       
  1485 	test(r==KErrNone);
       
  1486 
       
  1487 	test.Printf(_L("\n"));
       
  1488 	test.Printf(_L("Requests on close queue at start=%d\n"),orgValues.iCloseCount);
       
  1489 	test.Printf(_L("Requests on free queue at start=%d\n"),orgValues.iFreeCount);
       
  1490 	test.Printf(_L("Requests dynamically allocated at start=%d\n"),orgValues.iAllocated);
       
  1491 	test.Printf(_L("Requests in total at start=%d\n"),orgValues.iTotalCount);
       
  1492 #endif
       
  1493 
       
  1494 	DoTests(theDrive, testSwitches);
       
  1495 
       
  1496 	TTime endTimeC;
       
  1497 	endTimeC.HomeTime();
       
  1498 	TTimeIntervalSeconds timeTakenC;
       
  1499 	r=endTimeC.SecondsFrom(timerC,timeTakenC);
       
  1500 	test(r==KErrNone);
       
  1501 
       
  1502 	test.Printf(_L("Time taken for test = %d seconds\n"),timeTakenC.Int());
       
  1503 	TheFs.SetAllocFailure(gAllocFailOff);
       
  1504 	
       
  1505 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
  1506 	TPckgBuf<TIOCacheValues> pkgValues;
       
  1507 	TIOCacheValues& values=pkgValues();
       
  1508 	r = controlIo(TheFs,theDrive, KControlIoCacheCount, values);
       
  1509 	test(r==KErrNone);
       
  1510 	
       
  1511 	test.Printf(_L("Requests on close queue at end=%d\n"),values.iCloseCount);
       
  1512 	test.Printf(_L("Requests on free queue at end=%d\n"),values.iFreeCount);
       
  1513 	test.Printf(_L("Requests dynamically allocated at end=%d\n"),values.iAllocated);
       
  1514 	test.Printf(_L("Requests in total at end=%d\n"),values.iTotalCount);
       
  1515 	
       
  1516 	test(orgValues.iCloseCount==values.iCloseCount);
       
  1517 	test(orgValues.iAllocated == values.iAllocated);
       
  1518 #endif
       
  1519 
       
  1520 	TheFs.Close();
       
  1521 	test.End();
       
  1522 	test.Close();
       
  1523 	__UHEAP_MARKEND;
       
  1524 	delete cleanup;
       
  1525 	return(KErrNone);
       
  1526     }