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