os/kernelhwsrv/kerneltest/f32test/server/t_fsrv.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) 1995-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_fsrv.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
#define __E32TEST_EXTENSION__
sl@0
    18
#include <f32file.h>
sl@0
    19
#include <e32test.h>
sl@0
    20
#include "t_server.h"
sl@0
    21
#include "t_chlffs.h"
sl@0
    22
sl@0
    23
#include "f32_test_utils.h"
sl@0
    24
sl@0
    25
using namespace F32_Test_Utils;
sl@0
    26
sl@0
    27
sl@0
    28
RTest test(_L("T_FSRV"));
sl@0
    29
sl@0
    30
                 
sl@0
    31
sl@0
    32
const TInt KMaxParses=7;
sl@0
    33
const TInt KHeapSize=0x2000;
sl@0
    34
TFileName tPath;
sl@0
    35
TBool gFirstTime=ETrue;
sl@0
    36
const TInt KMaxVolumeName=11;
sl@0
    37
sl@0
    38
TInt substDrive=0;
sl@0
    39
sl@0
    40
TFileName gTestSessionPath;
sl@0
    41
sl@0
    42
TInt LargeFileSize;
sl@0
    43
TInt gDrive=-1;
sl@0
    44
sl@0
    45
struct SParse
sl@0
    46
	{
sl@0
    47
	const TText* src;
sl@0
    48
	const TText* rel;
sl@0
    49
	const TText* def;
sl@0
    50
	const TText* fullName;
sl@0
    51
	const TText* drive;
sl@0
    52
	const TText* path;
sl@0
    53
	const TText* name;
sl@0
    54
	const TText* ext;
sl@0
    55
	};
sl@0
    56
sl@0
    57
struct SParseServer
sl@0
    58
	{
sl@0
    59
	const TText* src;
sl@0
    60
	const TText* rel;
sl@0
    61
	const TText* fullName;
sl@0
    62
	const TText* drive;
sl@0
    63
	const TText* path;
sl@0
    64
	const TText* name;
sl@0
    65
	const TText* ext;
sl@0
    66
	};
sl@0
    67
sl@0
    68
LOCAL_D SParse parse[KMaxParses] =
sl@0
    69
	{
sl@0
    70
	{_S("A:\\PATH\\NAME.EXT"),NULL,NULL,_S("A:\\PATH\\NAME.EXT"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S(".EXT")},
sl@0
    71
	{_S("A:\\PATH\\NAME"),NULL,NULL,_S("A:\\PATH\\NAME"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S("")},
sl@0
    72
	{_S("A:\\PATH\\"),NULL,NULL,_S("A:\\PATH\\"),_S("A:"),_S("\\PATH\\"),_S(""),_S("")},
sl@0
    73
	{_S("A:"),NULL,NULL,_S("A:"),_S("A:"),_S(""),_S(""),_S("")},
sl@0
    74
	{_S(""),NULL,NULL,_S(""),_S(""),_S(""),_S(""),_S("")},
sl@0
    75
	{_S("A:\\PATH\\NAME"),_S("A:\\ZZZZ\\YYYY.XXX"),NULL,_S("A:\\PATH\\NAME.XXX"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S(".XXX")},
sl@0
    76
	{_S("NAME"),_S(".YYY"),_S("A:\\PATH\\"),_S("A:\\PATH\\NAME.YYY"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S(".YYY")}
sl@0
    77
	};
sl@0
    78
sl@0
    79
LOCAL_D SParseServer parseServer[KMaxParses] =
sl@0
    80
	{
sl@0
    81
	{_S("A:\\PATH\\NAME.EXT"),NULL,_S("A:\\PATH\\NAME.EXT"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S(".EXT")},
sl@0
    82
	{_S("A:\\PATH\\NAME"),NULL,_S("A:\\PATH\\NAME"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S("")},
sl@0
    83
	{_S("A:\\PATH\\"),NULL,_S("A:\\PATH\\"),_S("A:"),_S("\\PATH\\"),_S(""),_S("")},
sl@0
    84
	{_S("A:"),NULL,_S("A:\\ABCDEF\\"),_S("A:"),_S("\\ABCDEF\\"),_S(""),_S("")},
sl@0
    85
	{_S(""),NULL,_S("C:\\ABCDEF\\"),_S("C:"),_S("\\ABCDEF\\"),_S(""),_S("")},
sl@0
    86
	{_S("A:\\PATH\\NAME"),_S("A:\\ZZZZ\\YYYY.XXX"),_S("A:\\PATH\\NAME.XXX"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S(".XXX")},
sl@0
    87
	{_S("NAME"),_S(".YYY"),_S("C:\\ABCDEF\\NAME.YYY"),_S("C:"),_S("\\ABCDEF\\"),_S("NAME"),_S(".YYY")}
sl@0
    88
	};
sl@0
    89
sl@0
    90
LOCAL_C TInt pathTestThread(TAny*)
sl@0
    91
//
sl@0
    92
// The entry point for the producer thread.
sl@0
    93
//
sl@0
    94
	{
sl@0
    95
sl@0
    96
	RTest test(_L("Second thread path handling"));
sl@0
    97
	test.Title();
sl@0
    98
sl@0
    99
	test.Start(_L("Path test thread"));
sl@0
   100
	RFs f;
sl@0
   101
	TInt r=f.Connect();
sl@0
   102
	test(r==KErrNone);
sl@0
   103
	r=f.SessionPath(tPath);
sl@0
   104
	test(r==KErrNone);
sl@0
   105
	f.Close();
sl@0
   106
sl@0
   107
	return(KErrNone);
sl@0
   108
	}
sl@0
   109
sl@0
   110
LOCAL_C void printDriveAtt(TInt aDrive,TUint anAtt)
sl@0
   111
//
sl@0
   112
// Print a drive attribute.
sl@0
   113
//
sl@0
   114
	{
sl@0
   115
sl@0
   116
	test.Printf(_L("%c: "),aDrive+'A');
sl@0
   117
	if (anAtt&KDriveAttLocal)
sl@0
   118
		test.Printf(_L("LOCAL "));
sl@0
   119
	if (anAtt&KDriveAttRom)
sl@0
   120
		test.Printf(_L("ROM "));
sl@0
   121
	if (anAtt&KDriveAttRedirected)
sl@0
   122
		test.Printf(_L("REDIR "));
sl@0
   123
	if (anAtt&KDriveAttSubsted)
sl@0
   124
		test.Printf(_L("SUBST "));
sl@0
   125
	if (anAtt&KDriveAttInternal)
sl@0
   126
		test.Printf(_L("INTERNAL "));
sl@0
   127
	if (anAtt&KDriveAttHidden)
sl@0
   128
		test.Printf(_L("HIDDEN "));
sl@0
   129
	if ((anAtt&KDriveAttRemovable) && !(anAtt&KDriveAttLogicallyRemovable))
sl@0
   130
		test.Printf(_L("PHYSICALLYREMOVABLE "));
sl@0
   131
	if ((anAtt&KDriveAttRemovable) && (anAtt&KDriveAttLogicallyRemovable))
sl@0
   132
		test.Printf(_L("LOGICALLYREMOVABLE "));
sl@0
   133
	
sl@0
   134
	test.Printf(_L("\n"));
sl@0
   135
	}
sl@0
   136
sl@0
   137
LOCAL_C void printDriveInfo(TInt aDrive,TDriveInfo& anInfo)
sl@0
   138
//
sl@0
   139
// Print a drive info.
sl@0
   140
//
sl@0
   141
	{
sl@0
   142
sl@0
   143
	printDriveAtt(aDrive,anInfo.iDriveAtt);
sl@0
   144
	test.Printf(_L("   MEDIA-ATT="));
sl@0
   145
	if (anInfo.iMediaAtt==0)
sl@0
   146
		test.Printf(_L("<none>"));
sl@0
   147
	if (anInfo.iMediaAtt&KMediaAttVariableSize)
sl@0
   148
		test.Printf(_L("VariableSize "));
sl@0
   149
	if (anInfo.iMediaAtt&KMediaAttDualDensity)
sl@0
   150
		test.Printf(_L("DualDensity "));
sl@0
   151
	if (anInfo.iMediaAtt&KMediaAttFormattable)
sl@0
   152
		test.Printf(_L("Formattable "));
sl@0
   153
	if (anInfo.iMediaAtt&KMediaAttWriteProtected)
sl@0
   154
		test.Printf(_L("WProtected "));
sl@0
   155
	test.Printf(_L("\n   CONNECTION BUS="));
sl@0
   156
	switch(anInfo.iConnectionBusType)
sl@0
   157
		{
sl@0
   158
	case EConnectionBusInternal: test.Printf(_L("Internal\n")); break;
sl@0
   159
	case EConnectionBusUsb: test.Printf(_L("USB\n")); break;
sl@0
   160
	default:
sl@0
   161
		test.Printf(_L("Unknown value\n"));
sl@0
   162
		}
sl@0
   163
	test.Printf(_L("   MEDIA="));
sl@0
   164
	switch(anInfo.iType)
sl@0
   165
		{
sl@0
   166
	case EMediaNotPresent: test.Printf(_L("Not present\n")); break;
sl@0
   167
	case EMediaUnknown: test.Printf(_L("Unknown\n")); break;
sl@0
   168
	case EMediaFloppy: test.Printf(_L("Floppy\n")); break;
sl@0
   169
	case EMediaHardDisk: test.Printf(_L("Hard disk\n")); break;
sl@0
   170
	case EMediaCdRom: test.Printf(_L("CD Rom\n")); break;
sl@0
   171
	case EMediaRam: test.Printf(_L("Ram\n")); break;
sl@0
   172
	case EMediaFlash: test.Printf(_L("Flash\n")); break;
sl@0
   173
	case EMediaRom: test.Printf(_L("Rom\n")); break;
sl@0
   174
	case EMediaRemote: test.Printf(_L("Remote\n")); break;
sl@0
   175
	case EMediaNANDFlash:  test.Printf(_L("NANDFlash\n")); break;
sl@0
   176
	default:
sl@0
   177
		test.Printf(_L("Unknown value\n"));
sl@0
   178
		}
sl@0
   179
	}
sl@0
   180
	
sl@0
   181
	
sl@0
   182
			
sl@0
   183
	
sl@0
   184
LOCAL_C void MountRemoteFilesystem()
sl@0
   185
	{
sl@0
   186
	test.Next(_L("Mount Remote Drive simulator on Q:"));
sl@0
   187
sl@0
   188
	TInt r=TheFs.AddFileSystem(_L("CFAFSDLY"));
sl@0
   189
	test.Printf(_L("Add remote file system"));
sl@0
   190
	test.Printf(_L("AddFileSystem returned %d\n"),r);
sl@0
   191
	test_Value(r, r==KErrNone || r==KErrAlreadyExists);
sl@0
   192
sl@0
   193
	r=TheFs.MountFileSystem(_L("DELAYFS"),EDriveQ);
sl@0
   194
sl@0
   195
	
sl@0
   196
	test.Printf(_L("Mount remote file system"));
sl@0
   197
	test.Printf(_L("MountFileSystem returned %d\n"),r);
sl@0
   198
	test_Value(r, r==KErrNone || r==KErrCorrupt || r==KErrNotReady || r==KErrAlreadyExists);
sl@0
   199
sl@0
   200
	}	
sl@0
   201
sl@0
   202
sl@0
   203
LOCAL_C void DisMountRemoteFilesystem()	
sl@0
   204
	{
sl@0
   205
sl@0
   206
	test.Printf(_L("Dismounting the remote Drives \n"));
sl@0
   207
 	
sl@0
   208
 	TInt r=TheFs.DismountFileSystem(_L("DELAYFS"),EDriveQ);
sl@0
   209
 	 
sl@0
   210
 	test.Printf(_L("Dismounting the Remote Drive returned %d\n"),r);
sl@0
   211
 	
sl@0
   212
 	test(r==KErrNone );
sl@0
   213
	}
sl@0
   214
sl@0
   215
sl@0
   216
LOCAL_C void CreateSubstDrive()
sl@0
   217
	{
sl@0
   218
     test.Printf(_L("Create Substitute Drive \n"));
sl@0
   219
    
sl@0
   220
    TDriveList driveList;   
sl@0
   221
    TInt i ;
sl@0
   222
      
sl@0
   223
    TInt r=TheFs.SessionPath(gTestSessionPath);
sl@0
   224
	test(r==KErrNone);  
sl@0
   225
 	
sl@0
   226
 	r=TheFs.DriveList(driveList, KDriveAttExclude|KDriveAttLocal);
sl@0
   227
   	test( r==KErrNone );
sl@0
   228
   
sl@0
   229
sl@0
   230
   	for ( i = EDriveO; i < KMaxDrives; i++) 
sl@0
   231
      	{
sl@0
   232
    
sl@0
   233
      	if ( driveList[i] == 0) 
sl@0
   234
          	{
sl@0
   235
          	if (i == EDriveQ) continue;  // Q reserved to mount a virtual Remote Drive, as part of the test.
sl@0
   236
        	substDrive = i;
sl@0
   237
          	break;          
sl@0
   238
          	}
sl@0
   239
      	}
sl@0
   240
           
sl@0
   241
   
sl@0
   242
   	if (substDrive)
sl@0
   243
   		{
sl@0
   244
 		TDriveInfo driveInfo;
sl@0
   245
		r=TheFs.Drive(driveInfo,substDrive);
sl@0
   246
		test(r==KErrNone);
sl@0
   247
	
sl@0
   248
		if (driveInfo.iDriveAtt==KDriveAttLocal)
sl@0
   249
			{	
sl@0
   250
			return;	//	Subst local drives fails
sl@0
   251
			}
sl@0
   252
	
sl@0
   253
		TFileName n;
sl@0
   254
		r=TheFs.Subst(n,substDrive);
sl@0
   255
		test(r==KErrNone);
sl@0
   256
		test(n.Length()==0);	
sl@0
   257
		r=TheFs.SetSubst(gTestSessionPath,substDrive);
sl@0
   258
		test(r==KErrNone);
sl@0
   259
		r=TheFs.Subst(n,substDrive);
sl@0
   260
		test(r==KErrNone);
sl@0
   261
		test(n==gTestSessionPath);   		
sl@0
   262
   		}
sl@0
   263
sl@0
   264
	
sl@0
   265
	}
sl@0
   266
sl@0
   267
		
sl@0
   268
LOCAL_C void RemoveSubstDrive()
sl@0
   269
	{
sl@0
   270
	 	if( substDrive)
sl@0
   271
	 		{
sl@0
   272
	 		test.Printf(_L("Removing Substitute Drive \n"));	 	 
sl@0
   273
	 		TInt r =TheFs.SetSubst(_L(""),substDrive);	
sl@0
   274
			test(r ==KErrNone);	 		
sl@0
   275
	 		}
sl@0
   276
sl@0
   277
	}
sl@0
   278
sl@0
   279
sl@0
   280
sl@0
   281
LOCAL_C void testDriveInfo(TInt aDrive,TDriveInfo& anInfo)
sl@0
   282
//
sl@0
   283
// Test the drive info is reasonable
sl@0
   284
//
sl@0
   285
	{
sl@0
   286
sl@0
   287
	test(anInfo.iConnectionBusType==EConnectionBusInternal || anInfo.iConnectionBusType==EConnectionBusUsb);
sl@0
   288
	
sl@0
   289
	if (aDrive==EDriveZ)
sl@0
   290
		{
sl@0
   291
		if (anInfo.iType==EMediaNotPresent)
sl@0
   292
			return;
sl@0
   293
		
sl@0
   294
		test(anInfo.iMediaAtt==KMediaAttWriteProtected);
sl@0
   295
		test(anInfo.iDriveAtt==(KDriveAttRom|KDriveAttInternal));
sl@0
   296
		test(anInfo.iType==EMediaRom);
sl@0
   297
		}
sl@0
   298
sl@0
   299
	else if (GetDriveLFFS()==aDrive)
sl@0
   300
		{
sl@0
   301
        if (anInfo.iType==EMediaNotPresent)
sl@0
   302
            return;
sl@0
   303
sl@0
   304
		test(anInfo.iDriveAtt&(KDriveAttLocal|KDriveAttInternal)==KDriveAttLocal|KDriveAttInternal);	// LFFS sets KDriveAttTransaction as well
sl@0
   305
        test(anInfo.iType==EMediaFlash);
sl@0
   306
        test(anInfo.iMediaAtt==KMediaAttFormattable);
sl@0
   307
		}
sl@0
   308
/*
sl@0
   309
Why assume certain drive letters can only refer to certain drive types?
sl@0
   310
	else if (aDrive==EDriveC || aDrive==EDriveY)
sl@0
   311
		{
sl@0
   312
		if (anInfo.iType==EMediaNotPresent)
sl@0
   313
			return;
sl@0
   314
sl@0
   315
//		test(anInfo.iDriveAtt==(KDriveAttLocal|KDriveAttInternal));
sl@0
   316
sl@0
   317
		test(anInfo.iDriveAtt&(KDriveAttLocal|KDriveAttInternal)==KDriveAttLocal|KDriveAttInternal);	// LFFS sets KDriveAttTransaction as well
sl@0
   318
		test(anInfo.iType==EMediaRam || anInfo.iType==EMediaFlash);
sl@0
   319
		if(anInfo.iType==EMediaRam)	test(anInfo.iMediaAtt==(KMediaAttVariableSize|KMediaAttFormattable));
sl@0
   320
		else if(anInfo.iType==EMediaFlash) test(anInfo.iMediaAtt==KMediaAttFormattable);
sl@0
   321
		}
sl@0
   322
	
sl@0
   323
	else if (aDrive==EDriveD || aDrive==EDriveX)
sl@0
   324
		{
sl@0
   325
		if (anInfo.iType==EMediaNotPresent)
sl@0
   326
			return;
sl@0
   327
sl@0
   328
		test(anInfo.iDriveAtt==(KDriveAttLocal|KDriveAttRemovable));
sl@0
   329
		test(anInfo.iType==EMediaHardDisk);
sl@0
   330
		test(anInfo.iMediaAtt & KMediaAttFormattable);
sl@0
   331
		}
sl@0
   332
*/
sl@0
   333
	}
sl@0
   334
sl@0
   335
sl@0
   336
/*
sl@0
   337
*  The following test has the requirement that the only remote drive is the one we mount 
sl@0
   338
*  during the test and which doesn't have any other attributes set. If this is not the
sl@0
   339
* case then the test conditions must be changed, in order for the test to stop failing.
sl@0
   340
*/
sl@0
   341
sl@0
   342
sl@0
   343
LOCAL_C void testDriveList()
sl@0
   344
//
sl@0
   345
// Test the drive list.
sl@0
   346
//
sl@0
   347
	{
sl@0
   348
sl@0
   349
	test.Start(_L("The drive list\n"));
sl@0
   350
sl@0
   351
sl@0
   352
    TInt err;
sl@0
   353
    TInt drivecount = 0;
sl@0
   354
    TDriveList driveList;
sl@0
   355
    TDriveInfo info;
sl@0
   356
    TUint flags;
sl@0
   357
    TInt removableDriveCount =0;
sl@0
   358
	TInt nonHiddenRemovableDriveCount =0;
sl@0
   359
	TInt logicallyRemovableDriveCount =0;
sl@0
   360
    TInt substDriveCount =0;
sl@0
   361
    TInt exclusiveSubstDriveCount =0;
sl@0
   362
	TInt hiddenDriveCount = 0;
sl@0
   363
	TInt hiddenOrRemoteDriveCount = 0;
sl@0
   364
    
sl@0
   365
    TInt i ;
sl@0
   366
sl@0
   367
  
sl@0
   368
 	//--------------------------------------------- 
sl@0
   369
	//! @SYMTestCaseID			PBASE-T_FSRV-0544
sl@0
   370
	//! @SYMTestType			UT 
sl@0
   371
	//! @SYMREQ					CR909, CR1086
sl@0
   372
	//! @SYMTestCaseDesc		Test that RFs::DriveList(TDriveList& aList) does not return remote or hidden drives.
sl@0
   373
	//! @SYMTestActions			Call DriveList to get the drive list.
sl@0
   374
	//! @SYMTestExpectedResults	Check that no remote or hidden drive was returned. Count the number of drives we got 
sl@0
   375
	//!							and seperately the number of none hidden removable ones.
sl@0
   376
	//! @SYMTestPriority		High
sl@0
   377
	//! @SYMTestStatus			Implemented 
sl@0
   378
	//--------------------------------------------- 
sl@0
   379
 
sl@0
   380
    
sl@0
   381
    test.Printf(_L("Test existing DriveList \n"));
sl@0
   382
    
sl@0
   383
    err = TheFs.DriveList(driveList);
sl@0
   384
    test( err == KErrNone );
sl@0
   385
    
sl@0
   386
    for ( i = 0; i < KMaxDrives; i++) 
sl@0
   387
        {
sl@0
   388
        if (driveList[i]) 
sl@0
   389
            {
sl@0
   390
            err = TheFs.Drive(info, i);
sl@0
   391
            test( err == KErrNone );
sl@0
   392
            test( info.iType  !=  EMediaRemote  );
sl@0
   393
            test( !(info.iDriveAtt & KDriveAttRemote ) ); 
sl@0
   394
			test( !(info.iDriveAtt & KDriveAttHidden ) );
sl@0
   395
            drivecount++; 
sl@0
   396
            
sl@0
   397
            if( info.iDriveAtt  & KDriveAttRemovable) 
sl@0
   398
           	nonHiddenRemovableDriveCount++;
sl@0
   399
sl@0
   400
           	printDriveAtt(i,info.iDriveAtt);
sl@0
   401
            
sl@0
   402
            }
sl@0
   403
    
sl@0
   404
        }
sl@0
   405
        
sl@0
   406
    
sl@0
   407
    TInt nonHiddenNonRemovables = drivecount -  nonHiddenRemovableDriveCount;
sl@0
   408
	test.Printf(_L("Found %d non hidden non removable drives\n"), nonHiddenNonRemovables);
sl@0
   409
	test.Printf(_L("Found %d non hidden removable drives \n"),nonHiddenRemovableDriveCount);
sl@0
   410
sl@0
   411
sl@0
   412
  
sl@0
   413
 	//--------------------------------------------- 
sl@0
   414
	//! @SYMTestCaseID			PBASE-T_FSRV-0545
sl@0
   415
	//! @SYMTestType			UT 
sl@0
   416
	//! @SYMREQ					CR909, CR1086
sl@0
   417
	//! @SYMTestCaseDesc		Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can be used to return all
sl@0
   418
	//! 						available drives, including the remote and the hidden ones.
sl@0
   419
	//! @SYMTestActions			Call DriveList by passing to aFlags a value of KDriveAttAll.
sl@0
   420
	//! @SYMTestExpectedResults	Check that the number of drives is increased by the number of hidden and remote drives and also that the number of remote drives is one (one remote drive we mounted). 
sl@0
   421
	//!							Also count the number of substitute, exclusively substitute, removable, physically removable and logically removable drives.
sl@0
   422
	//! @SYMTestPriority		High
sl@0
   423
	//! @SYMTestStatus			Implemented 
sl@0
   424
	//--------------------------------------------- 
sl@0
   425
 
sl@0
   426
sl@0
   427
   test.Printf(_L("Return all available drives\n"));
sl@0
   428
      
sl@0
   429
   TInt allDrivecount = 0;
sl@0
   430
   flags = KDriveAttAll;
sl@0
   431
   err = TheFs.DriveList(driveList, flags);
sl@0
   432
sl@0
   433
   test( err == KErrNone );
sl@0
   434
   for ( i = 0; i < KMaxDrives; i++) 
sl@0
   435
       {
sl@0
   436
       if (driveList[i]) 
sl@0
   437
           {
sl@0
   438
           err = TheFs.Drive(info,i);
sl@0
   439
           test( err == KErrNone );
sl@0
   440
           allDrivecount++;
sl@0
   441
           
sl@0
   442
           if( info.iDriveAtt  & KDriveAttSubsted ) 
sl@0
   443
           		substDriveCount++;
sl@0
   444
            
sl@0
   445
           if( info.iDriveAtt  == KDriveAttSubsted) 
sl@0
   446
           		exclusiveSubstDriveCount++;
sl@0
   447
sl@0
   448
		   if( info.iDriveAtt  & KDriveAttHidden) 
sl@0
   449
           		hiddenDriveCount++;
sl@0
   450
sl@0
   451
		   if( info.iDriveAtt  & (KDriveAttHidden|KDriveAttRemote))
sl@0
   452
           		hiddenOrRemoteDriveCount++;
sl@0
   453
sl@0
   454
		   if( info.iDriveAtt  & KDriveAttRemovable) 
sl@0
   455
           		removableDriveCount++;
sl@0
   456
sl@0
   457
			if( info.iDriveAtt  & KDriveAttLogicallyRemovable) 
sl@0
   458
           		logicallyRemovableDriveCount++;
sl@0
   459
				           	
sl@0
   460
           
sl@0
   461
            printDriveAtt(i,info.iDriveAtt);
sl@0
   462
           }
sl@0
   463
        }  
sl@0
   464
sl@0
   465
 	test(allDrivecount == drivecount + hiddenOrRemoteDriveCount);
sl@0
   466
	test(hiddenOrRemoteDriveCount - hiddenDriveCount == 1);
sl@0
   467
sl@0
   468
	test.Printf(_L("Found %d substitute drives\n"), substDriveCount);
sl@0
   469
	test.Printf(_L("Found %d exclusively substitute  drives \n"),exclusiveSubstDriveCount);
sl@0
   470
	test.Printf(_L("Found %d hidden drives\n"), hiddenDriveCount);
sl@0
   471
sl@0
   472
	TInt nonRemovables = drivecount -  removableDriveCount;
sl@0
   473
	TInt physicallyRemovable = removableDriveCount - logicallyRemovableDriveCount;
sl@0
   474
	test.Printf(_L("Found %d non removables drives\n"), nonRemovables);
sl@0
   475
	test.Printf(_L("Found %d physically removable drives \n"),physicallyRemovable);
sl@0
   476
	test.Printf(_L("Found %d logically removable drives \n"),logicallyRemovableDriveCount);
sl@0
   477
  
sl@0
   478
  
sl@0
   479
  	//--------------------------------------------- 
sl@0
   480
	//! @SYMTestCaseID			PBASE-T_FSRV-0546
sl@0
   481
	//! @SYMTestType			UT 
sl@0
   482
	//! @SYMREQ					CR909
sl@0
   483
	//! @SYMTestCaseDesc		Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can be used to specify
sl@0
   484
	//! 						certain attributes that drives to be returned should have.
sl@0
   485
	//! @SYMTestActions			Call DriveList by passing to aFlags a value of KDriveAttRemovable.
sl@0
   486
	//! @SYMTestExpectedResults	Check that the number of drives returned is the same, since no removable drive was added.
sl@0
   487
	//! @SYMTestPriority		High
sl@0
   488
	//! @SYMTestStatus			Implemented 
sl@0
   489
	//--------------------------------------------- 
sl@0
   490
sl@0
   491
 
sl@0
   492
    test.Printf(_L("Return only Removable \n"));
sl@0
   493
	
sl@0
   494
	drivecount = 0;
sl@0
   495
	
sl@0
   496
    flags = KDriveAttRemovable;
sl@0
   497
    err = TheFs.DriveList(driveList, flags);
sl@0
   498
    test( err == KErrNone );
sl@0
   499
    for ( i = 0; i < KMaxDrives; i++) 
sl@0
   500
        {
sl@0
   501
        if (driveList[i]) 
sl@0
   502
            {
sl@0
   503
            err = TheFs.Drive(info, i);
sl@0
   504
            test( err == KErrNone );
sl@0
   505
            test( info.iDriveAtt & KDriveAttRemovable );
sl@0
   506
            drivecount++; 
sl@0
   507
      
sl@0
   508
            printDriveAtt(i,info.iDriveAtt);
sl@0
   509
            }
sl@0
   510
sl@0
   511
        }
sl@0
   512
sl@0
   513
    test( drivecount == removableDriveCount ); // no removable drive was added
sl@0
   514
sl@0
   515
sl@0
   516
  	//--------------------------------------------- 
sl@0
   517
	//! @SYMTestCaseID			PBASE-T_FSRV-0547
sl@0
   518
	//! @SYMTestType			UT 
sl@0
   519
	//! @SYMREQ					CR909
sl@0
   520
	//! @SYMTestCaseDesc		Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can be used to specify
sl@0
   521
	//! 						certain attributes(as a combination)that drives to be returned should have.
sl@0
   522
	//! @SYMTestActions			Call DriveList by passing to aFlags a value of KDriveAttRemovable | KDriveAttRemote
sl@0
   523
	//! @SYMTestExpectedResults	Check that the number of drives is increased by one, since we also allow remote drives.
sl@0
   524
	//! @SYMTestPriority		High
sl@0
   525
	//! @SYMTestStatus			Implemented 
sl@0
   526
	//--------------------------------------------- 
sl@0
   527
sl@0
   528
sl@0
   529
 	test.Printf(_L("Return only Removable and Remote \n"));
sl@0
   530
 	
sl@0
   531
    drivecount = 0;
sl@0
   532
    flags = KDriveAttRemovable | KDriveAttRemote;
sl@0
   533
    err = TheFs.DriveList(driveList, flags);
sl@0
   534
    test( err == KErrNone );
sl@0
   535
    for ( i = 0; i < KMaxDrives; i++) 
sl@0
   536
        {
sl@0
   537
        if (driveList[i]) 
sl@0
   538
            {
sl@0
   539
            err = TheFs.Drive(info, i);
sl@0
   540
            test( err == KErrNone );
sl@0
   541
            test( (info.iDriveAtt & KDriveAttRemovable ) || (info.iDriveAtt & KDriveAttRemote)); 
sl@0
   542
            drivecount++; 
sl@0
   543
           
sl@0
   544
           	printDriveAtt(i,info.iDriveAtt);
sl@0
   545
            
sl@0
   546
            }
sl@0
   547
sl@0
   548
        }
sl@0
   549
    test( drivecount == removableDriveCount + 1 );  //contains the remote drive we mounted
sl@0
   550
    
sl@0
   551
sl@0
   552
  	//--------------------------------------------- 
sl@0
   553
	//! @SYMTestCaseID			PBASE-T_FSRV-0548
sl@0
   554
	//! @SYMTestType			UT 
sl@0
   555
	//! @SYMREQ					CR909
sl@0
   556
	//! @SYMTestCaseDesc		Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can be used to exclusively 
sl@0
   557
	//!							return drives with certain attributes.
sl@0
   558
	//! @SYMTestActions			Call DriveList by passing to aFlags a value of KDriveAttExclusive | KDriveAttRemote.
sl@0
   559
	//! @SYMTestExpectedResults	Check that only the remote drive that was mounted is returned.
sl@0
   560
	//! @SYMTestPriority		High
sl@0
   561
	//! @SYMTestStatus			Implemented 
sl@0
   562
	//--------------------------------------------- 
sl@0
   563
sl@0
   564
 	
sl@0
   565
 	test.Printf(_L("Return Exclusively Remote drives \n"));
sl@0
   566
 	
sl@0
   567
 	drivecount = 0;
sl@0
   568
    flags = KDriveAttExclusive | KDriveAttRemote;
sl@0
   569
    TUint match = KDriveAttRemote;
sl@0
   570
    err = TheFs.DriveList(driveList, flags);
sl@0
   571
    test( err == KErrNone );
sl@0
   572
    for ( i = 0; i < KMaxDrives; i++) 
sl@0
   573
        {
sl@0
   574
        if (driveList[i]) 
sl@0
   575
            {
sl@0
   576
            err = TheFs.Drive(info, i);
sl@0
   577
            test( err == KErrNone );
sl@0
   578
            test( (info.iDriveAtt == match)); 
sl@0
   579
            drivecount++;
sl@0
   580
            
sl@0
   581
            printDriveAtt(i,info.iDriveAtt);
sl@0
   582
            }
sl@0
   583
sl@0
   584
        }
sl@0
   585
   	test( drivecount == 1 ); //The remote drive we mounted.
sl@0
   586
sl@0
   587
sl@0
   588
  	//--------------------------------------------- 
sl@0
   589
	//! @SYMTestCaseID			PBASE-T_FSRV-0549
sl@0
   590
	//! @SYMTestType			UT 
sl@0
   591
	//! @SYMREQ					CR909
sl@0
   592
	//! @SYMTestCaseDesc		Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can be used to exclude drives 
sl@0
   593
	//!							to be returned with certain attributes.
sl@0
   594
	//! @SYMTestActions			Call DriveList by passing to aFlags a value of KDriveAttExclude | KDriveAttRemovable.
sl@0
   595
	//! @SYMTestExpectedResults	Check that the remote drive we mounted is included as a non removable one.
sl@0
   596
	//! @SYMTestPriority		High
sl@0
   597
	//! @SYMTestStatus			Implemented 
sl@0
   598
	//--------------------------------------------- 
sl@0
   599
sl@0
   600
	
sl@0
   601
   test.Printf(_L("Exclude Removable\n"));
sl@0
   602
sl@0
   603
   drivecount = 0; 	
sl@0
   604
   flags = KDriveAttExclude | KDriveAttRemovable;
sl@0
   605
   err = TheFs.DriveList(driveList, flags);
sl@0
   606
   test( err == KErrNone );
sl@0
   607
   for (i = 0; i < KMaxDrives; i++) 
sl@0
   608
       {
sl@0
   609
       if (driveList[i]) 
sl@0
   610
           {
sl@0
   611
           err = TheFs.Drive(info, i);
sl@0
   612
           test( err == KErrNone );
sl@0
   613
           test( (!(info.iDriveAtt & KDriveAttRemovable ) )); 
sl@0
   614
           drivecount++;
sl@0
   615
           
sl@0
   616
           printDriveAtt(i,info.iDriveAtt);
sl@0
   617
           }
sl@0
   618
sl@0
   619
       }  
sl@0
   620
     test ( drivecount == allDrivecount - removableDriveCount); 
sl@0
   621
	 test ( drivecount == nonRemovables + hiddenDriveCount + 1) ;   //The remote drive we added is non removable  
sl@0
   622
sl@0
   623
sl@0
   624
sl@0
   625
  	//--------------------------------------------- 
sl@0
   626
	//! @SYMTestCaseID			PBASE-T_FSRV-0550
sl@0
   627
	//! @SYMTestType			UT 
sl@0
   628
	//! @SYMREQ					CR909
sl@0
   629
	//! @SYMTestCaseDesc		Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can be used to exclude 
sl@0
   630
	//! 					    drives to be returned with certain attributes(as a combination).
sl@0
   631
	//! @SYMTestActions			Call DriveList by passing to aFlags a value of 
sl@0
   632
	//!							KDriveAttExclude | KDriveAttRemovable | KDriveAttRemote. 						
sl@0
   633
	//! @SYMTestExpectedResults	Test that only the remote drive that was mounted is returned.
sl@0
   634
	//! @SYMTestPriority		High
sl@0
   635
	//! @SYMTestStatus			Implemented 
sl@0
   636
	//--------------------------------------------- 
sl@0
   637
  
sl@0
   638
 
sl@0
   639
 
sl@0
   640
   test.Printf(_L("Exclude Removable and Remote\n"));
sl@0
   641
   
sl@0
   642
   drivecount = 0;
sl@0
   643
   flags = KDriveAttExclude | KDriveAttRemovable | KDriveAttRemote;
sl@0
   644
   err = TheFs.DriveList(driveList, flags);
sl@0
   645
   
sl@0
   646
   test( err == KErrNone );
sl@0
   647
   
sl@0
   648
   for ( i = 0; i < KMaxDrives; i++) 
sl@0
   649
       {
sl@0
   650
       if (driveList[i]) 
sl@0
   651
           {
sl@0
   652
           err = TheFs.Drive(info,i);
sl@0
   653
           test( err == KErrNone );
sl@0
   654
           test( (!(info.iDriveAtt & KDriveAttRemovable ) && (!(info.iDriveAtt & KDriveAttRemote ))));
sl@0
   655
           drivecount++;
sl@0
   656
           
sl@0
   657
           printDriveAtt(i,info.iDriveAtt);
sl@0
   658
           }
sl@0
   659
       }
sl@0
   660
   test(drivecount == (allDrivecount - removableDriveCount - 1)  ); // also excluding the removables and the remote drive   
sl@0
   661
  
sl@0
   662
  
sl@0
   663
sl@0
   664
sl@0
   665
sl@0
   666
  	//--------------------------------------------- 
sl@0
   667
	//! @SYMTestCaseID			PBASE-T_FSRV-0551
sl@0
   668
	//! @SYMTestType			UT 
sl@0
   669
	//! @SYMREQ					CR909
sl@0
   670
	//! @SYMTestCaseDesc		Test RFs::DriveList(TDriveList& aList, TUint aFlags) with substitute drives.  	
sl@0
   671
	//! @SYMTestActions			Call DriveList by passing to aFlags combinations of attributes that exclude, exclusive or
sl@0
   672
	//!							not substitute drives.
sl@0
   673
	//! @SYMTestExpectedResults	Test that only the appropriate drives are returned.
sl@0
   674
	//! @SYMTestPriority		High
sl@0
   675
	//! @SYMTestStatus			Implemented 
sl@0
   676
	//--------------------------------------------- 
sl@0
   677
sl@0
   678
sl@0
   679
sl@0
   680
	if (substDrive)
sl@0
   681
		{
sl@0
   682
sl@0
   683
sl@0
   684
   		test.Printf(_L("Exclude Remote and Substed\n"));
sl@0
   685
   
sl@0
   686
   		drivecount = 0;
sl@0
   687
   		flags = KDriveAttExclude | KDriveAttRemote | KDriveAttSubsted;
sl@0
   688
   		err = TheFs.DriveList(driveList, flags);
sl@0
   689
   
sl@0
   690
   		test( err == KErrNone );
sl@0
   691
   
sl@0
   692
   		for ( i = 0; i < KMaxDrives; i++) 
sl@0
   693
       		{
sl@0
   694
       		if (driveList[i]) 
sl@0
   695
           		{
sl@0
   696
           		err = TheFs.Drive(info,i);
sl@0
   697
           		test( err == KErrNone );
sl@0
   698
           		test( (!(info.iDriveAtt & KDriveAttRemote )  && (!(info.iDriveAtt & KDriveAttSubsted ))));
sl@0
   699
           		drivecount++;
sl@0
   700
           
sl@0
   701
           		printDriveAtt(i,info.iDriveAtt);
sl@0
   702
           		}
sl@0
   703
       		}
sl@0
   704
    	test(drivecount == (allDrivecount - substDriveCount- 1)  );    
sl@0
   705
sl@0
   706
sl@0
   707
		
sl@0
   708
   		test.Printf(_L("Exclusively Exclude Substed drives\n"));
sl@0
   709
   
sl@0
   710
   		drivecount = 0;
sl@0
   711
   		flags = KDriveAttExclusive | KDriveAttExclude | KDriveAttSubsted;
sl@0
   712
   		err = TheFs.DriveList(driveList, flags);
sl@0
   713
   
sl@0
   714
   		test( err == KErrNone );
sl@0
   715
   
sl@0
   716
   		for ( i = 0; i < KMaxDrives; i++) 
sl@0
   717
       		{
sl@0
   718
       		if (driveList[i]) 
sl@0
   719
           		{
sl@0
   720
           		err = TheFs.Drive(info,i);
sl@0
   721
           		test( err == KErrNone );
sl@0
   722
           		test( info.iDriveAtt != KDriveAttSubsted );
sl@0
   723
           		drivecount++;
sl@0
   724
           
sl@0
   725
           		printDriveAtt(i,info.iDriveAtt);
sl@0
   726
           		}		
sl@0
   727
   		    
sl@0
   728
   		    }
sl@0
   729
    
sl@0
   730
		test(drivecount == (allDrivecount - exclusiveSubstDriveCount)  );        
sl@0
   731
		
sl@0
   732
		}
sl@0
   733
sl@0
   734
sl@0
   735
  	//--------------------------------------------- 
sl@0
   736
	//! @SYMTestCaseID			PBASE-T_FSRV-0552
sl@0
   737
	//! @SYMTestType			UT 
sl@0
   738
	//! @SYMREQ					CR909
sl@0
   739
	//! @SYMTestCaseDesc		Test that RFs::DriveList(TDriveList& aList, TUint aFlags) returns the correct value for every
sl@0
   740
	//!							combination of matching mask.
sl@0
   741
	//! @SYMTestActions			Call DriveList for every combination of mask and check that the correct value is returned.   
sl@0
   742
	//!							A structure is used to store the expected value for each combination.
sl@0
   743
	//! @SYMTestExpectedResults	Test for every combination that only drives with the correct attributes are retruned.
sl@0
   744
	//! @SYMTestPriority		High
sl@0
   745
	//! @SYMTestStatus			Implemented 
sl@0
   746
	//--------------------------------------------- 
sl@0
   747
sl@0
   748
   
sl@0
   749
  	test.Printf(_L("Test All Combinations \n"));
sl@0
   750
sl@0
   751
	struct TCombinations
sl@0
   752
		{
sl@0
   753
		TUint iMatchMask;			  // The Match Mask to be combined with drive attributes
sl@0
   754
		TInt  iExpectedResultNoAtts;	  // Expected result when flag used on it's own
sl@0
   755
		TInt  iExpectedResultWithAtts;  // Expected result when flag used in combination with drive flags
sl@0
   756
		};
sl@0
   757
sl@0
   758
	TCombinations testCombinations[] = {
sl@0
   759
		{ 0,														KErrNone,     KErrNone},
sl@0
   760
		{ KDriveAttAll,												KErrNone,     KErrArgument },
sl@0
   761
		{ KDriveAttExclude,											KErrArgument, KErrNone },
sl@0
   762
		{ KDriveAttExclusive,										KErrArgument, KErrNone },
sl@0
   763
		{ KDriveAttExclude | KDriveAttExclusive,					KErrArgument, KErrNone },
sl@0
   764
		{ KDriveAttAll	   | KDriveAttExclude,						KErrArgument, KErrArgument },
sl@0
   765
		{ KDriveAttAll     | KDriveAttExclusive,					KErrArgument, KErrArgument},
sl@0
   766
		{ KDriveAttAll     | KDriveAttExclude | KDriveAttExclusive, KErrArgument, KErrArgument}};
sl@0
   767
sl@0
   768
	TDriveList fullDriveList;
sl@0
   769
	err = TheFs.DriveList(fullDriveList, KDriveAttAll);
sl@0
   770
	test( err == KErrNone );
sl@0
   771
sl@0
   772
	for ( i = 0; i < KMaxDrives; i++) 
sl@0
   773
		{
sl@0
   774
		if (driveList[i]) 
sl@0
   775
			{
sl@0
   776
			err = TheFs.Drive(info,i);
sl@0
   777
			test( err == KErrNone );
sl@0
   778
			printDriveAtt(i,info.iDriveAtt);
sl@0
   779
			}
sl@0
   780
		}
sl@0
   781
sl@0
   782
	for(TUint matchIdx = 0; matchIdx < sizeof(testCombinations) / sizeof(TCombinations); matchIdx++)
sl@0
   783
		{
sl@0
   784
		test.Printf(_L("\nMatch Flags: KDriveAttAll[%c] KDriveAttExclude[%c] KDriveAttExclusive[%c]\n"), testCombinations[matchIdx].iMatchMask & KDriveAttAll       ? 'X' : ' ',
sl@0
   785
																										 testCombinations[matchIdx].iMatchMask & KDriveAttExclude   ? 'X' : ' ',
sl@0
   786
																										 testCombinations[matchIdx].iMatchMask & KDriveAttExclusive ? 'X' : ' ');
sl@0
   787
sl@0
   788
		for(TUint testAtt = 0; testAtt <= KMaxTUint8; testAtt++)
sl@0
   789
			{
sl@0
   790
			TDriveList newDriveList;
sl@0
   791
			err = TheFs.DriveList(newDriveList, testCombinations[matchIdx].iMatchMask | testAtt);
sl@0
   792
	 		
sl@0
   793
			//test.Printf(_L("            ATT : 0x%08x \n"), testAtt);
sl@0
   794
			//test.Printf(_L("Expected Result : %d     \n"), testAtt == 0 ? testCombinations[matchIdx].iExpectedResultNoAtts : testCombinations[matchIdx].iExpectedResultWithAtts);
sl@0
   795
			//test.Printf(_L("  Actual Result : 0x%08x \n"), err);
sl@0
   796
sl@0
   797
			test( err == (testAtt == 0 ? testCombinations[matchIdx].iExpectedResultNoAtts : testCombinations[matchIdx].iExpectedResultWithAtts) );
sl@0
   798
sl@0
   799
			if(err == KErrNone)
sl@0
   800
				{
sl@0
   801
				//printDriveAtt(0, testAtt);  //Prints attributes   
sl@0
   802
				for ( i = 0; i < KMaxDrives; i++) 
sl@0
   803
					{
sl@0
   804
					TBool expectMatch = EFalse;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
sl@0
   805
sl@0
   806
					switch(testCombinations[matchIdx].iMatchMask)
sl@0
   807
						{
sl@0
   808
						case 0:
sl@0
   809
							expectMatch = (fullDriveList[i] & testAtt) != 0;                                                                                                                                                           
sl@0
   810
							break;
sl@0
   811
sl@0
   812
						case KDriveAttAll:
sl@0
   813
							expectMatch = ETrue;
sl@0
   814
							break;
sl@0
   815
sl@0
   816
						case KDriveAttExclude :
sl@0
   817
							expectMatch = (fullDriveList[i] & testAtt) == 0;
sl@0
   818
							break;
sl@0
   819
sl@0
   820
						case KDriveAttExclusive :
sl@0
   821
							expectMatch = (fullDriveList[i] == testAtt);
sl@0
   822
							break;
sl@0
   823
sl@0
   824
						case KDriveAttExclude | KDriveAttExclusive:
sl@0
   825
							expectMatch = (fullDriveList[i] != testAtt);
sl@0
   826
							break;
sl@0
   827
	
sl@0
   828
						case KDriveAttAll | KDriveAttExclude :
sl@0
   829
							test(0);	// Invalid - should never get here as this returns KErrArgument for all cases
sl@0
   830
							break;
sl@0
   831
sl@0
   832
						case KDriveAttAll | KDriveAttExclusive :
sl@0
   833
							test(0);	// Invalid - should never get here as this returns KErrArgument for all cases
sl@0
   834
							break;
sl@0
   835
sl@0
   836
						case KDriveAttAll | KDriveAttExclude | KDriveAttExclusive :
sl@0
   837
							test(0);	// Invalid - should never get here as this returns KErrArgument for all cases
sl@0
   838
							break;
sl@0
   839
sl@0
   840
						default:
sl@0
   841
							test.Printf(_L("Unexpected Match Mask %08x"), testCombinations[matchIdx].iMatchMask);
sl@0
   842
							test(0);
sl@0
   843
							break;
sl@0
   844
						}
sl@0
   845
sl@0
   846
					if(expectMatch) 
sl@0
   847
						{
sl@0
   848
						//test.Printf(_L(" %c MATCHED OK "), 'A' + i);
sl@0
   849
						test(newDriveList[i] == fullDriveList[i]);
sl@0
   850
						}
sl@0
   851
					else
sl@0
   852
						{
sl@0
   853
						/*if(fullDriveList[i] == 0)
sl@0
   854
							{
sl@0
   855
							test.Printf(_L(" %c NOT PRESENT "), 'A' + i);
sl@0
   856
							}
sl@0
   857
						else
sl@0
   858
							{
sl@0
   859
							test.Printf(_L(" %c NOT MATCHED "), 'A' + i);
sl@0
   860
							}
sl@0
   861
						*/
sl@0
   862
						test(newDriveList[i] == 0);
sl@0
   863
						}
sl@0
   864
					}
sl@0
   865
				}
sl@0
   866
			}
sl@0
   867
		}
sl@0
   868
sl@0
   869
sl@0
   870
sl@0
   871
	//--------------------------------------------- 
sl@0
   872
	//! @SYMTestCaseID			PBASE-T_FSRV-0605
sl@0
   873
	//! @SYMTestType			UT
sl@0
   874
	//! @SYMREQ					CR1086
sl@0
   875
	//! @SYMTestCaseDesc		Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can identify the 
sl@0
   876
	//!							logically removable drives.
sl@0
   877
	//! @SYMTestActions			Call DriveList by passing to aFlags a value of KDriveAttLogicallyRemovable.
sl@0
   878
	//! @SYMTestExpectedResults	Check that only the logically removable drives specified in estart.txt are returned.
sl@0
   879
	//! @SYMTestPriority		High
sl@0
   880
	//! @SYMTestStatus			Implemented
sl@0
   881
	//--------------------------------------------- 
sl@0
   882
sl@0
   883
	test.Printf(_L("Return only Logically Removable drives \n"));
sl@0
   884
 	
sl@0
   885
 	drivecount = 0;
sl@0
   886
    flags = KDriveAttLogicallyRemovable;
sl@0
   887
    err = TheFs.DriveList(driveList, flags);
sl@0
   888
    test( err == KErrNone );
sl@0
   889
    for ( i = 0; i < KMaxDrives; i++) 
sl@0
   890
        {
sl@0
   891
        if (driveList[i]) 
sl@0
   892
            {
sl@0
   893
            err = TheFs.Drive(info, i);
sl@0
   894
            test( err == KErrNone );
sl@0
   895
            test( info.iDriveAtt & KDriveAttLogicallyRemovable );
sl@0
   896
            drivecount++; 
sl@0
   897
      
sl@0
   898
            printDriveAtt(i,info.iDriveAtt);
sl@0
   899
            }
sl@0
   900
sl@0
   901
        }
sl@0
   902
sl@0
   903
    test( drivecount == logicallyRemovableDriveCount ); // no logically removable drive was added
sl@0
   904
 
sl@0
   905
sl@0
   906
	test.End();
sl@0
   907
	}
sl@0
   908
	
sl@0
   909
sl@0
   910
sl@0
   911
sl@0
   912
sl@0
   913
sl@0
   914
sl@0
   915
LOCAL_C void testDriveInfo()
sl@0
   916
//
sl@0
   917
// Test the drive info.
sl@0
   918
//
sl@0
   919
	{
sl@0
   920
sl@0
   921
	test.Start(_L("The drive info"));
sl@0
   922
	TDriveList list;
sl@0
   923
	TInt r=TheFs.DriveList(list);
sl@0
   924
	test(r==KErrNone);
sl@0
   925
	for (TInt i=0;i<KMaxDrives;i++)
sl@0
   926
		{
sl@0
   927
		TInt att=list[i];
sl@0
   928
		if (att)
sl@0
   929
			{
sl@0
   930
			TDriveInfo d;
sl@0
   931
			r=TheFs.Drive(d,i);
sl@0
   932
			test(r==KErrNone);
sl@0
   933
			printDriveInfo(i,d);
sl@0
   934
			test.Printf(_L("\n"));
sl@0
   935
			testDriveInfo(i,d);
sl@0
   936
			}
sl@0
   937
		}
sl@0
   938
sl@0
   939
	test.End();
sl@0
   940
	}
sl@0
   941
sl@0
   942
LOCAL_C void testVolumeInfo()
sl@0
   943
//
sl@0
   944
// Test volume info.
sl@0
   945
//
sl@0
   946
	{
sl@0
   947
sl@0
   948
	test.Start(_L("The volume info"));
sl@0
   949
	TDriveList list;
sl@0
   950
	TInt r=TheFs.DriveList(list);
sl@0
   951
	test(r==KErrNone);
sl@0
   952
	for (TInt i=0;i<KMaxDrives;i++)
sl@0
   953
		{
sl@0
   954
		TVolumeInfo v;
sl@0
   955
		TDriveInfo d;
sl@0
   956
		switch (r=TheFs.Volume(v,i))
sl@0
   957
			{
sl@0
   958
			case KErrNone:
sl@0
   959
				printDriveInfo(i,v.iDrive);
sl@0
   960
				test.Printf(_L("   VOL=\"%S\" ID=%08x\n"),&v.iName,v.iUniqueID);
sl@0
   961
				test.Printf(_L("   SIZE=%ldK FREE=%ldK\n"),v.iSize/1024,v.iFree/1024);
sl@0
   962
				break;
sl@0
   963
			case KErrNotReady:
sl@0
   964
				r=TheFs.Drive(d, i);
sl@0
   965
				test_KErrNone(r);
sl@0
   966
				if (d.iType == EMediaNotPresent)
sl@0
   967
					test.Printf(_L("%c: Medium not present - cannot perform test.\n"), i + 'A');
sl@0
   968
				else
sl@0
   969
					test.Printf(_L("medium found (type %d) but drive %c: not ready\nPrevious test may have hung; else, check hardware.\n"), (TInt)d.iType, i + 'A');
sl@0
   970
				break;
sl@0
   971
			case KErrPathNotFound:
sl@0
   972
				test.Printf(_L("%c: Not Found\n"), i + 'A');
sl@0
   973
				break;
sl@0
   974
			case KErrCorrupt:
sl@0
   975
				test.Printf(_L("%c: Media corruption; previous test may have aborted; else, check hardware\n"), i + 'A');
sl@0
   976
			default:
sl@0
   977
				test_KErrNone(r);
sl@0
   978
			}
sl@0
   979
		test.Printf(_L("\n"));
sl@0
   980
		}
sl@0
   981
sl@0
   982
	test.End();
sl@0
   983
	}
sl@0
   984
sl@0
   985
LOCAL_C void testClientParse()
sl@0
   986
//
sl@0
   987
// Test the client side parse.
sl@0
   988
//
sl@0
   989
	{
sl@0
   990
sl@0
   991
	test.Start(_L("Test client side parsing"));
sl@0
   992
sl@0
   993
	for (TInt i=0;i<KMaxParses;i++)
sl@0
   994
		{
sl@0
   995
		TInt r;
sl@0
   996
		TParse f;
sl@0
   997
		SParse& p=parse[i];
sl@0
   998
		TPtrC name(p.src);
sl@0
   999
		if (p.rel)
sl@0
  1000
			{
sl@0
  1001
			if (p.def)
sl@0
  1002
                {
sl@0
  1003
                TPtrC rel(p.rel);
sl@0
  1004
                TPtrC def(p.def);
sl@0
  1005
				r=f.Set(name,&rel,&def);
sl@0
  1006
                }
sl@0
  1007
			else
sl@0
  1008
                {
sl@0
  1009
                TPtrC rel(p.rel);
sl@0
  1010
				r=f.Set(name,&rel,NULL);
sl@0
  1011
                }
sl@0
  1012
			}
sl@0
  1013
		else
sl@0
  1014
			r=f.Set(name,NULL,NULL);
sl@0
  1015
		test(r==KErrNone);
sl@0
  1016
		test(TPtrC(p.fullName)==f.FullName());
sl@0
  1017
		test(TPtrC(p.drive)==f.Drive());
sl@0
  1018
		test(TPtrC(p.path)==f.Path());
sl@0
  1019
		test(TPtrC(p.name)==f.Name());
sl@0
  1020
		test(TPtrC(p.ext)==f.Ext());
sl@0
  1021
		}
sl@0
  1022
sl@0
  1023
	test.End();
sl@0
  1024
	}
sl@0
  1025
sl@0
  1026
LOCAL_C void testPath()
sl@0
  1027
//
sl@0
  1028
// Test the path handling.
sl@0
  1029
//
sl@0
  1030
	{
sl@0
  1031
sl@0
  1032
	test.Start(_L("Test path handling"));
sl@0
  1033
	TFileName p;
sl@0
  1034
	TInt r=TheFs.SessionPath(p);
sl@0
  1035
	test(r==KErrNone);
sl@0
  1036
	test.Printf(_L("SESSION=\"%S\"\n"),&p);
sl@0
  1037
	r=TheFs.SetSessionPath(_L("A:\\TEST\\"));
sl@0
  1038
	test(r==KErrNone);
sl@0
  1039
	r=TheFs.SessionPath(p);
sl@0
  1040
	test(r==KErrNone);
sl@0
  1041
	test(p==_L("A:\\TEST\\"));
sl@0
  1042
	r=TheFs.SetSessionPath(gSessionPath);
sl@0
  1043
	test(r==KErrNone);
sl@0
  1044
sl@0
  1045
sl@0
  1046
	TheFs.SetAllocFailure(gAllocFailOff);
sl@0
  1047
sl@0
  1048
	RThread t;
sl@0
  1049
	r=t.Create(_L("PathTest"),pathTestThread,KDefaultStackSize,KHeapSize,KHeapSize,NULL);
sl@0
  1050
	test(r==KErrNone);
sl@0
  1051
	TRequestStatus tStat;
sl@0
  1052
	t.Logon(tStat);
sl@0
  1053
	t.Resume();
sl@0
  1054
	User::WaitForRequest(tStat);
sl@0
  1055
	test(tStat==KErrNone);
sl@0
  1056
	test(r==KErrNone);
sl@0
  1057
	t.Close();
sl@0
  1058
sl@0
  1059
	TheFs.SetAllocFailure(gAllocFailOn);
sl@0
  1060
sl@0
  1061
	test.End();
sl@0
  1062
	}
sl@0
  1063
sl@0
  1064
LOCAL_C void testServerParse()
sl@0
  1065
//
sl@0
  1066
// Test the client side parse.
sl@0
  1067
//
sl@0
  1068
	{
sl@0
  1069
sl@0
  1070
	test.Start(_L("Test server side parsing"));
sl@0
  1071
sl@0
  1072
	TFileName old;
sl@0
  1073
	TInt r=TheFs.SessionPath(old);
sl@0
  1074
	test(r==KErrNone);
sl@0
  1075
	r=TheFs.SetSessionPath(_L("C:\\ABCDEF\\"));
sl@0
  1076
	test(r==KErrNone);
sl@0
  1077
	for (TInt i=0;i<KMaxParses;i++)
sl@0
  1078
		{
sl@0
  1079
		TInt r;
sl@0
  1080
		TParse f;
sl@0
  1081
		SParseServer& p=parseServer[i];
sl@0
  1082
		TPtrC name(p.src);
sl@0
  1083
		if (p.rel)
sl@0
  1084
			r=TheFs.Parse(name,TPtrC(p.rel),f);
sl@0
  1085
		else
sl@0
  1086
			r=TheFs.Parse(name,f);
sl@0
  1087
		test(r==KErrNone);
sl@0
  1088
		test(TPtrC(p.fullName)==f.FullName());
sl@0
  1089
		test(TPtrC(p.drive)==f.Drive());
sl@0
  1090
		test(TPtrC(p.path)==f.Path());
sl@0
  1091
		test(TPtrC(p.name)==f.Name());
sl@0
  1092
		test(TPtrC(p.ext)==f.Ext());
sl@0
  1093
		}
sl@0
  1094
	r=TheFs.SetSessionPath(old);
sl@0
  1095
	test(r==KErrNone);
sl@0
  1096
sl@0
  1097
	test.End();
sl@0
  1098
	}
sl@0
  1099
sl@0
  1100
LOCAL_C void testSubst()
sl@0
  1101
//
sl@0
  1102
// Test the substitute functions.
sl@0
  1103
//
sl@0
  1104
	{
sl@0
  1105
sl@0
  1106
	test.Printf(_L("Test subst"));
sl@0
  1107
	TVolumeInfo v;
sl@0
  1108
	TInt r=TheFs.Volume(v);
sl@0
  1109
	test(r==KErrNone);
sl@0
  1110
	TDriveInfo origDI;
sl@0
  1111
	r=TheFs.Drive(origDI);
sl@0
  1112
	test(r==KErrNone);
sl@0
  1113
	
sl@0
  1114
	TDriveInfo driveInfo;
sl@0
  1115
	r=TheFs.Drive(driveInfo,EDriveO);
sl@0
  1116
	test(r==KErrNone);
sl@0
  1117
	
sl@0
  1118
	if (driveInfo.iDriveAtt==KDriveAttLocal)
sl@0
  1119
		{	
sl@0
  1120
		return;	//	Subst local drives fails
sl@0
  1121
		}
sl@0
  1122
	
sl@0
  1123
	TFileName n;
sl@0
  1124
	r=TheFs.Subst(n,EDriveO);
sl@0
  1125
	test(r==KErrNone);
sl@0
  1126
	test(n.Length()==0);
sl@0
  1127
	r=TheFs.SetSubst(gSessionPath,EDriveO);
sl@0
  1128
	test(r==KErrNone);
sl@0
  1129
	r=TheFs.Subst(n,EDriveO);
sl@0
  1130
	test(r==KErrNone);
sl@0
  1131
	test(n==gSessionPath);
sl@0
  1132
	TVolumeInfo w;
sl@0
  1133
	r=TheFs.Volume(w,EDriveO);
sl@0
  1134
	test(r==KErrNone);
sl@0
  1135
	test(w.iDrive.iType==v.iDrive.iType);
sl@0
  1136
	test(w.iDrive.iConnectionBusType==v.iDrive.iConnectionBusType);
sl@0
  1137
	test(w.iDrive.iDriveAtt==KDriveAttSubsted);
sl@0
  1138
	test(w.iDrive.iMediaAtt==v.iDrive.iMediaAtt);
sl@0
  1139
	test(w.iUniqueID==v.iUniqueID);
sl@0
  1140
	test(w.iSize==v.iSize);
sl@0
  1141
	test(w.iFree==v.iFree);
sl@0
  1142
	test(w.iName==v.iName);
sl@0
  1143
	TDriveList driveList;
sl@0
  1144
	r=TheFs.DriveList(driveList);
sl@0
  1145
	test(r==KErrNone);
sl@0
  1146
	test(driveList[EDriveO]==KDriveAttSubsted);
sl@0
  1147
	TDriveInfo d;
sl@0
  1148
	r=TheFs.Drive(d,EDriveO);
sl@0
  1149
	test(r==KErrNone);
sl@0
  1150
	test(d.iDriveAtt==KDriveAttSubsted);
sl@0
  1151
	test(d.iMediaAtt==origDI.iMediaAtt);
sl@0
  1152
	test(d.iType==origDI.iType);
sl@0
  1153
	test(d.iConnectionBusType==origDI.iConnectionBusType);
sl@0
  1154
sl@0
  1155
sl@0
  1156
	test.Next(_L("Test real name"));
sl@0
  1157
	r=TheFs.RealName(_L("O:\\FILE.XXX"),n);
sl@0
  1158
	test(r==KErrNone);
sl@0
  1159
	TFileName substedPath=gSessionPath;
sl@0
  1160
	substedPath.Append(_L("FILE.XXX"));
sl@0
  1161
	test(n.CompareF(substedPath)==KErrNone);
sl@0
  1162
//
sl@0
  1163
	test.Next(_L("Test MkDir, Rename and RmDir on Substed drive"));
sl@0
  1164
	_LIT(KTurgid,"turgid\\");
sl@0
  1165
	TFileName dir=gSessionPath;
sl@0
  1166
	dir+=KTurgid;
sl@0
  1167
	r=TheFs.MkDirAll(dir);
sl@0
  1168
	test(r==KErrNone);
sl@0
  1169
	dir+=_L("subdir\\");
sl@0
  1170
	r=TheFs.MkDir(dir);
sl@0
  1171
	test(r==KErrNone);
sl@0
  1172
	r=TheFs.RmDir(_L("O:\\turgid\\subdir\\"));
sl@0
  1173
	test(r==KErrNone);
sl@0
  1174
	r=TheFs.Rename(_L("O:\\turgid"), _L("O:\\facile"));
sl@0
  1175
	test(r==KErrNone);
sl@0
  1176
	r=TheFs.MkDir(_L("O:\\insipid\\"));
sl@0
  1177
	test(r==KErrNone);
sl@0
  1178
	r=TheFs.Rename(_L("O:\\insipid"), _L("O:\\glib"));
sl@0
  1179
	test(r==KErrNone);
sl@0
  1180
	r=TheFs.RmDir(_L("O:\\facile\\"));
sl@0
  1181
	test(r==KErrNone);
sl@0
  1182
	_LIT(KGlib,"glib\\");
sl@0
  1183
	dir=gSessionPath;
sl@0
  1184
	dir+=KGlib;
sl@0
  1185
	r=TheFs.RmDir(dir);
sl@0
  1186
	test(r==KErrNone);
sl@0
  1187
//	
sl@0
  1188
	test.Next(_L("Test file operations on Substed drive"));
sl@0
  1189
	_LIT(File1,"File1.txt");
sl@0
  1190
	_LIT(File2,"File2.txt");
sl@0
  1191
	_LIT(SubstRoot,"O:\\");
sl@0
  1192
	_LIT(Subdir,"subdir\\");
sl@0
  1193
	TFileName name1,name2;
sl@0
  1194
	name1=gSessionPath;
sl@0
  1195
	name1+=File1;
sl@0
  1196
	RFile f1;
sl@0
  1197
	r=f1.Replace(TheFs,name1,EFileShareExclusive|EFileWrite);
sl@0
  1198
	test(r==KErrNone);
sl@0
  1199
	name2=SubstRoot;
sl@0
  1200
	name2+=File2;
sl@0
  1201
	TBool isValid=TheFs.IsValidName(name2);
sl@0
  1202
	test(isValid);
sl@0
  1203
	r=f1.Rename(name2);
sl@0
  1204
	test(r==KErrNone);
sl@0
  1205
	f1.Close();
sl@0
  1206
	r=f1.Create(TheFs,name1,EFileShareExclusive|EFileWrite);
sl@0
  1207
	test(r==KErrNone);
sl@0
  1208
	f1.Close();
sl@0
  1209
	r=TheFs.Replace(name2,name1);
sl@0
  1210
	test(r==KErrNone);
sl@0
  1211
	r=TheFs.Delete(name1);
sl@0
  1212
	test(r==KErrNone);
sl@0
  1213
	test.Next(_L("Test notifications on Substed drive"));
sl@0
  1214
	name1=gSessionPath;
sl@0
  1215
	name1+=Subdir;
sl@0
  1216
	name2=SubstRoot;
sl@0
  1217
	name2+=Subdir;
sl@0
  1218
	// set up some extended notifications
sl@0
  1219
	TRequestStatus status1;
sl@0
  1220
	TRequestStatus status2;
sl@0
  1221
	TRequestStatus status3;
sl@0
  1222
	TheFs.NotifyChange(ENotifyDir,status1,name1);
sl@0
  1223
	test(status1==KRequestPending);
sl@0
  1224
	TheFs.NotifyChange(ENotifyDir,status2,name2);
sl@0
  1225
	test(status2==KRequestPending);
sl@0
  1226
	r=TheFs.MkDirAll(name1);
sl@0
  1227
	test(r==KErrNone);
sl@0
  1228
	User::WaitForRequest(status1);
sl@0
  1229
	User::WaitForRequest(status2);
sl@0
  1230
	test(status1==KErrNone && status2==KErrNone);
sl@0
  1231
	TheFs.NotifyChange(ENotifyDir,status1,name1);
sl@0
  1232
	test(status1==KRequestPending);
sl@0
  1233
	TheFs.NotifyChange(ENotifyDir,status2,name2);
sl@0
  1234
	test(status2==KRequestPending);
sl@0
  1235
	TheFs.NotifyChange(ENotifyAll,status3,name2);
sl@0
  1236
	test(status3==KRequestPending);
sl@0
  1237
	r=f1.Temp(TheFs,name2,n,EFileShareAny|EFileWrite);
sl@0
  1238
	test(r==KErrNone);
sl@0
  1239
	User::WaitForRequest(status3);
sl@0
  1240
	test(status3==KErrNone && status1==KRequestPending && status2==KRequestPending);
sl@0
  1241
	f1.Close();
sl@0
  1242
	TheFs.NotifyChangeCancel();
sl@0
  1243
	test(status1==KErrCancel && status2==KErrCancel);
sl@0
  1244
	r=TheFs.Delete(n);
sl@0
  1245
	test(r==KErrNone);
sl@0
  1246
	r=TheFs.RmDir(name1);
sl@0
  1247
	test(r==KErrNone);
sl@0
  1248
//
sl@0
  1249
	test.Next(_L("Test file systems on Substed drive"));
sl@0
  1250
	// test cannot mount file system on substituted drive
sl@0
  1251
	TInt sessionDrv;
sl@0
  1252
	r=TheFs.CharToDrive(gSessionPath[0],sessionDrv);
sl@0
  1253
	test(r==KErrNone);
sl@0
  1254
	r=TheFs.FileSystemName(n,sessionDrv);
sl@0
  1255
	test(r==KErrNone || r==KErrNotFound);
sl@0
  1256
	r=TheFs.MountFileSystem(n,EDriveO);
sl@0
  1257
	test(r==KErrAccessDenied);
sl@0
  1258
	// test file system name on substitued drive is null
sl@0
  1259
	r=TheFs.FileSystemName(n,EDriveO);
sl@0
  1260
	test(r==KErrNotFound && n==KNullDesC);
sl@0
  1261
	// test cannot format a substitued drive
sl@0
  1262
	RFormat format;
sl@0
  1263
	TInt count;
sl@0
  1264
	r=format.Open(TheFs,SubstRoot,EHighDensity,count);
sl@0
  1265
	test(r==KErrAccessDenied);
sl@0
  1266
	
sl@0
  1267
	r=TheFs.SetSubst(_L(""),EDriveO);
sl@0
  1268
	test(r==KErrNone);
sl@0
  1269
	r=TheFs.Subst(n,EDriveO);
sl@0
  1270
	test(r==KErrNone);
sl@0
  1271
	test(n==_L(""));
sl@0
  1272
	r=TheFs.Drive(d,EDriveO);
sl@0
  1273
	test(r==KErrNone);
sl@0
  1274
	test(d.iDriveAtt==0);
sl@0
  1275
	}
sl@0
  1276
sl@0
  1277
LOCAL_C void testSetVolume()
sl@0
  1278
//
sl@0
  1279
// Test setting the volume info.
sl@0
  1280
//
sl@0
  1281
	{
sl@0
  1282
sl@0
  1283
	test.Start(_L("Test setting the volume label"));
sl@0
  1284
sl@0
  1285
	const TInt driveNum=CurrentDrive();
sl@0
  1286
sl@0
  1287
	TVolumeInfo v;
sl@0
  1288
	TInt r=TheFs.Volume(v,driveNum);
sl@0
  1289
	test(r==KErrNone);
sl@0
  1290
	TFileName n=v.iName;
sl@0
  1291
	test.Printf(_L("VOL=\"%S\"\n"),&n);
sl@0
  1292
sl@0
  1293
	test.Next(_L("Set volume label to nothing"));
sl@0
  1294
	r=TheFs.SetVolumeLabel(_L(""),driveNum);
sl@0
  1295
sl@0
  1296
	if(Is_Win32(TheFs, gDrive) && (r==KErrGeneral || r==KErrAccessDenied || r==KErrNotSupported))
sl@0
  1297
		{
sl@0
  1298
		test.Printf(_L("Error %d: Set volume label not testing on WINS\n"),r);
sl@0
  1299
		test.End();
sl@0
  1300
		return;
sl@0
  1301
		}
sl@0
  1302
sl@0
  1303
	test(r==KErrNone);
sl@0
  1304
	r=TheFs.Volume(v,driveNum);
sl@0
  1305
	test(r==KErrNone );
sl@0
  1306
	test(v.iName==_L(""));
sl@0
  1307
	test.Printf(_L("VOL=\"%S\"\n"),&v.iName);
sl@0
  1308
sl@0
  1309
	test.Next(_L("Set volume label to ABCDEFGHIJK"));
sl@0
  1310
	r=TheFs.SetVolumeLabel(_L("ABCDEFGHIJK"),driveNum);
sl@0
  1311
	test(r==KErrNone);
sl@0
  1312
	r=TheFs.Volume(v,driveNum);
sl@0
  1313
	test(r==KErrNone);
sl@0
  1314
	test(v.iName==_L("ABCDEFGHIJK"));
sl@0
  1315
	test.Printf(_L("VOL=\"%S\"\n"),&v.iName);
sl@0
  1316
sl@0
  1317
	test.Next(_L("Set volume label to ABCDE"));
sl@0
  1318
	r=TheFs.SetVolumeLabel(_L("ABCDE"),driveNum);
sl@0
  1319
	test(r==KErrNone);
sl@0
  1320
	r=TheFs.Volume(v,driveNum);
sl@0
  1321
	test(r==KErrNone);
sl@0
  1322
	test(v.iName==_L("ABCDE"));
sl@0
  1323
	test.Printf(_L("VOL=\"%S\"\n"),&v.iName);
sl@0
  1324
sl@0
  1325
sl@0
  1326
	test.Next(_L("Test replacement of non-ascii chars"));
sl@0
  1327
	TBuf<KMaxVolumeName> uBuf(KMaxVolumeName);
sl@0
  1328
	uBuf.FillZ();
sl@0
  1329
	uBuf[0]='a';
sl@0
  1330
	uBuf[1]=0x100;
sl@0
  1331
	uBuf[2]='b';
sl@0
  1332
	uBuf[3]=0x101;
sl@0
  1333
	uBuf[4]='c';
sl@0
  1334
	uBuf[5]=0x102;
sl@0
  1335
	uBuf[6]='d';
sl@0
  1336
	uBuf[7]=0x103;
sl@0
  1337
	uBuf[8]='e';
sl@0
  1338
	uBuf[9]=0x104;
sl@0
  1339
	uBuf[10]='f';
sl@0
  1340
	r=TheFs.SetVolumeLabel(uBuf,driveNum);
sl@0
  1341
	test(r==KErrNone);
sl@0
  1342
	TFileName drive=_L("?:");
sl@0
  1343
	drive[0]=gSessionPath[0];
sl@0
  1344
sl@0
  1345
// ??? this needs to be replaced
sl@0
  1346
//	UserSvr::ForceRemountMedia(ERemovableMedia0);
sl@0
  1347
	User::After(1000000);
sl@0
  1348
sl@0
  1349
	TFileName sess;
sl@0
  1350
	r=TheFs.SessionPath(sess);
sl@0
  1351
	test(r==KErrNone);
sl@0
  1352
	r=TheFs.Volume(v,driveNum);
sl@0
  1353
	test(r==KErrNone);
sl@0
  1354
sl@0
  1355
	if(Is_Fat(TheFs, gDrive)) //-- FAT doesn't support normal UNICODE in volume labels
sl@0
  1356
		test(v.iName==_L("a_b_c_d_e_f"));
sl@0
  1357
	else
sl@0
  1358
		test(v.iName == uBuf);
sl@0
  1359
sl@0
  1360
sl@0
  1361
	test.Printf(_L("VOL=\"%S\"\n"),&v.iName);
sl@0
  1362
sl@0
  1363
sl@0
  1364
	test.Next(_L("Set volume label back to nothing"));
sl@0
  1365
	r=TheFs.SetVolumeLabel(_L(""),driveNum);
sl@0
  1366
	test(r==KErrNone);
sl@0
  1367
	r=TheFs.Volume(v,driveNum);
sl@0
  1368
	test(r==KErrNone);
sl@0
  1369
	test(v.iName==_L(""));
sl@0
  1370
	test.Printf(_L("VOL=\"%S\"\n"),&v.iName);
sl@0
  1371
sl@0
  1372
	test.Next(_L("Attempt to set volume label containing illegal characters"));
sl@0
  1373
	r=TheFs.SetVolumeLabel(_L("abc>def"),driveNum);
sl@0
  1374
	test(r==KErrBadName);
sl@0
  1375
	r=TheFs.SetVolumeLabel(_L("ghi*jkl"),driveNum);
sl@0
  1376
	test(r==KErrBadName);
sl@0
  1377
	r=TheFs.SetVolumeLabel(_L("mno?pqr"),driveNum);
sl@0
  1378
	test(r==KErrBadName);
sl@0
  1379
	r=TheFs.SetVolumeLabel(_L("stu|vwx"),driveNum);
sl@0
  1380
	test(r==KErrBadName);
sl@0
  1381
	r=TheFs.SetVolumeLabel(_L("yz<abc"),driveNum);
sl@0
  1382
	test(r==KErrBadName);
sl@0
  1383
	r=TheFs.SetVolumeLabel(_L("def//ghi"),driveNum);
sl@0
  1384
	test(r==KErrBadName);
sl@0
  1385
sl@0
  1386
	r=TheFs.Volume(v,driveNum);
sl@0
  1387
	test(r==KErrNone);
sl@0
  1388
	test(v.iName==_L(""));
sl@0
  1389
	test.Printf(_L("VOL=\"%S\"\n"),&v.iName);
sl@0
  1390
sl@0
  1391
	// test volume label after remount (for removable media only)
sl@0
  1392
	test.Next(_L("Test volume label after remount"));
sl@0
  1393
sl@0
  1394
	TDriveInfo info;
sl@0
  1395
	test(TheFs.Drive(info, driveNum) == KErrNone);
sl@0
  1396
sl@0
  1397
	if((info.iDriveAtt & KDriveAttRemovable) != 0)
sl@0
  1398
		{
sl@0
  1399
		// 1. set volume label
sl@0
  1400
		test(TheFs.SetVolumeLabel(_L("XXX"), driveNum) == KErrNone);
sl@0
  1401
sl@0
  1402
		// 2. change bootsector volume label
sl@0
  1403
		const TInt	offset = IsFileSystemFAT32(TheFs, driveNum)? 
sl@0
  1404
			71 /*KFat32VolumeLabelPos*/ 
sl@0
  1405
			: 
sl@0
  1406
			43 /*KFat16VolumeLabelPos*/;	// both from sfat32\inc\sl_bpb.h
sl@0
  1407
sl@0
  1408
		RRawDisk	rdisk;
sl@0
  1409
		TPtrC8		label(_S8("Z"), 1);
sl@0
  1410
sl@0
  1411
		test(rdisk.Open(TheFs, driveNum) == KErrNone);
sl@0
  1412
		test(rdisk.Write(offset, label) == KErrNone);
sl@0
  1413
		rdisk.Close();
sl@0
  1414
sl@0
  1415
		// 3. remount the drive
sl@0
  1416
		test(TheFs.RemountDrive(driveNum) == KErrNone);
sl@0
  1417
sl@0
  1418
		// 4. check volume label
sl@0
  1419
		test(TheFs.Volume(v, driveNum) == KErrNone);
sl@0
  1420
		test(v.iName == _L("XXX"));
sl@0
  1421
		test.Printf(_L("- Passed.\n"));
sl@0
  1422
		}
sl@0
  1423
	else
sl@0
  1424
		test.Printf(_L("- Skipped (drive is not removable).\n"));
sl@0
  1425
sl@0
  1426
	// clean up
sl@0
  1427
	test.Next(_L("Set volume label to original"));
sl@0
  1428
	r=TheFs.SetVolumeLabel(n,driveNum);
sl@0
  1429
	test(r==KErrNone);
sl@0
  1430
	r=TheFs.Volume(v,driveNum);
sl@0
  1431
	test(r==KErrNone);
sl@0
  1432
	test(v.iName==n);
sl@0
  1433
	test.Printf(_L("VOL=\"%S\"\n"),&v.iName);
sl@0
  1434
sl@0
  1435
	test.End();
sl@0
  1436
	}
sl@0
  1437
sl@0
  1438
LOCAL_C void testModified()
sl@0
  1439
//
sl@0
  1440
// Test the Modified/SetModified functions.
sl@0
  1441
//
sl@0
  1442
	{
sl@0
  1443
	
sl@0
  1444
	test.Start(_L("Test modified/SetModified functions"));
sl@0
  1445
	TTime savedTime;
sl@0
  1446
	TInt r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),savedTime);
sl@0
  1447
	test(r==KErrNone);
sl@0
  1448
	TDateTime dateTime=savedTime.DateTime();
sl@0
  1449
	test.Printf(_L("T_FSRV.CPP last modified %d/%d/%d %d:%d:%d.%-06d\n"),dateTime.Day()+1,dateTime.Month()+1,dateTime.Year(),dateTime.Hour(),dateTime.Minute(),dateTime.Second(),dateTime.MicroSecond());
sl@0
  1450
	test.Next(_L("Set modified"));
sl@0
  1451
	dateTime.Set(1993,EAugust,23,1,13,54,123456);
sl@0
  1452
	TTime newTime(dateTime);
sl@0
  1453
	r=TheFs.SetModified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),newTime);
sl@0
  1454
	test(r==KErrNone);
sl@0
  1455
	TTime checkTime;
sl@0
  1456
	r=TheFs.Modified(_L("\\XXXX\\YYYY\\ZZZZ.CPP"),checkTime);
sl@0
  1457
	test(r==KErrPathNotFound);
sl@0
  1458
	r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),checkTime);
sl@0
  1459
	test(r==KErrNone);
sl@0
  1460
	dateTime=checkTime.DateTime();	
sl@0
  1461
	test(dateTime.Year()==1993);
sl@0
  1462
	test(dateTime.Month()==EAugust);
sl@0
  1463
	test(dateTime.Day()==23);
sl@0
  1464
	test(dateTime.Hour()==1);
sl@0
  1465
	test(dateTime.Minute()==13);
sl@0
  1466
	test(dateTime.Second()==54);
sl@0
  1467
	test.Printf(_L("T_FSRV.CPP last modified %d/%d/%d %d:%d:%d.%-06d\n"),dateTime.Day()+1,dateTime.Month()+1,dateTime.Year(),dateTime.Hour(),dateTime.Minute(),dateTime.Second(),dateTime.MicroSecond());
sl@0
  1468
//		test(dateTime.MicroSecond()==123456); // dos is not accurate enough
sl@0
  1469
	r=TheFs.SetModified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),savedTime);
sl@0
  1470
	test(r==KErrNone);
sl@0
  1471
	r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),checkTime);
sl@0
  1472
	test(r==KErrNone);
sl@0
  1473
	test(checkTime==savedTime);
sl@0
  1474
sl@0
  1475
	RFile f;
sl@0
  1476
	r=f.Open(TheFs,_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),EFileWrite);
sl@0
  1477
	test(r==KErrNone);
sl@0
  1478
	dateTime.Set(1997,EJanuary,1,2,55,51,999999);
sl@0
  1479
	newTime=dateTime;
sl@0
  1480
	r=f.SetModified(newTime);
sl@0
  1481
	test(r==KErrNone);
sl@0
  1482
	r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),checkTime);
sl@0
  1483
	test(r==KErrNone);
sl@0
  1484
sl@0
  1485
	dateTime=checkTime.DateTime();	
sl@0
  1486
	test(dateTime.Year()==1997);
sl@0
  1487
	test(dateTime.Month()==EJanuary);
sl@0
  1488
	test(dateTime.Day()==1);
sl@0
  1489
	test(dateTime.Hour()==2);
sl@0
  1490
	test(dateTime.Minute()==55);
sl@0
  1491
	test(dateTime.Second()>=50 && dateTime.Second()<=51); // Dos stores seconds %2
sl@0
  1492
sl@0
  1493
	r=f.Modified(checkTime);
sl@0
  1494
	test(r==KErrNone);
sl@0
  1495
sl@0
  1496
	dateTime=checkTime.DateTime();	
sl@0
  1497
	test(dateTime.Year()==1997);
sl@0
  1498
	test(dateTime.Month()==EJanuary);
sl@0
  1499
	test(dateTime.Day()==1);
sl@0
  1500
	test(dateTime.Hour()==2);
sl@0
  1501
	test(dateTime.Minute()==55);
sl@0
  1502
	test(dateTime.Second()>=50 && dateTime.Second()<=51); // Dos stores seconds %2
sl@0
  1503
	f.Close();
sl@0
  1504
sl@0
  1505
	r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),checkTime);
sl@0
  1506
	test(r==KErrNone);
sl@0
  1507
sl@0
  1508
	dateTime=checkTime.DateTime();	
sl@0
  1509
	test(dateTime.Year()==1997);
sl@0
  1510
	test(dateTime.Month()==EJanuary);
sl@0
  1511
	test(dateTime.Day()==1);
sl@0
  1512
	test(dateTime.Hour()==2);
sl@0
  1513
	test(dateTime.Minute()==55);
sl@0
  1514
	test(dateTime.Second()>=50 && dateTime.Second()<=51); // Dos stores seconds %2
sl@0
  1515
	test.End();
sl@0
  1516
	}
sl@0
  1517
sl@0
  1518
LOCAL_C void testName()
sl@0
  1519
//
sl@0
  1520
// Test the Modified/SetModified functions.
sl@0
  1521
//
sl@0
  1522
	{
sl@0
  1523
	test.Start(_L("Test file name functions"));
sl@0
  1524
sl@0
  1525
sl@0
  1526
	_LIT(KFileNameAndPath, "\\F32-TST\\TFSRV\\T_FSRV.CPP");
sl@0
  1527
	_LIT(KFileName, "T_FSRV.CPP");
sl@0
  1528
	
sl@0
  1529
	RFile file;
sl@0
  1530
	
sl@0
  1531
	TInt r=file.Open(TheFs, KFileName, 0 );
sl@0
  1532
	if (r!=KErrNone)
sl@0
  1533
		{
sl@0
  1534
		test.Printf(_L("Error %d opening file %S\n"), r, &KFileName);
sl@0
  1535
		test(0);
sl@0
  1536
		}
sl@0
  1537
	
sl@0
  1538
	TFileName fileName;
sl@0
  1539
sl@0
  1540
	// Check RFile::Name just retuns the file name, without path and drive
sl@0
  1541
	r=file.Name(fileName);
sl@0
  1542
	test(r==KErrNone);
sl@0
  1543
	test(fileName==KFileName());
sl@0
  1544
sl@0
  1545
	// Check RFile::FullName returns the complete file name and path
sl@0
  1546
	r=file.FullName(fileName);
sl@0
  1547
	test(r==KErrNone);
sl@0
  1548
	test(fileName.Mid(2)==KFileNameAndPath); // chop off drive letter + ':'
sl@0
  1549
	
sl@0
  1550
	file.Close();
sl@0
  1551
	
sl@0
  1552
	test.End();
sl@0
  1553
	}
sl@0
  1554
	
sl@0
  1555
LOCAL_C TInt CreateFileX(const TDesC& aBaseName,TInt aX)
sl@0
  1556
//
sl@0
  1557
// Create a large file. Return KErrEof or KErrNone
sl@0
  1558
//
sl@0
  1559
	{
sl@0
  1560
sl@0
  1561
	TBuf<128> fileName=aBaseName;
sl@0
  1562
	fileName.AppendNum(aX);
sl@0
  1563
	RFile file;
sl@0
  1564
sl@0
  1565
	TInt r=file.Replace(TheFs,fileName,EFileWrite);
sl@0
  1566
	if (r==KErrDiskFull)
sl@0
  1567
		return(r);
sl@0
  1568
	if (r!=KErrNone)
sl@0
  1569
		{
sl@0
  1570
		test.Printf(_L("ERROR:: Replace returned %d\n"),r);
sl@0
  1571
		test(0);
sl@0
  1572
		//test.Getch();
sl@0
  1573
		return(KErrDiskFull);
sl@0
  1574
		}
sl@0
  1575
sl@0
  1576
	if (!IsTestingLFFS())
sl@0
  1577
		r=file.SetSize(LargeFileSize);
sl@0
  1578
	else
sl@0
  1579
		{ // ??? Whats wrong with setsize 
sl@0
  1580
    	TBuf8<1024> testdata(1024);
sl@0
  1581
    	TInt count=(LargeFileSize/testdata.Length());
sl@0
  1582
    	r=KErrNone;
sl@0
  1583
    	while (count-- && r==KErrNone) 
sl@0
  1584
        	r=file.Write(testdata);
sl@0
  1585
		}
sl@0
  1586
	if (r==KErrDiskFull)
sl@0
  1587
		{
sl@0
  1588
		file.Close();
sl@0
  1589
		return(r);
sl@0
  1590
		}
sl@0
  1591
	if (r!=KErrNone)
sl@0
  1592
		{
sl@0
  1593
		test.Printf(_L("ERROR:: SetSize/Write returned %d\n"),r);
sl@0
  1594
		test(0);
sl@0
  1595
		//test.Getch();
sl@0
  1596
		file.Close();
sl@0
  1597
		return(KErrDiskFull);
sl@0
  1598
		}
sl@0
  1599
sl@0
  1600
	file.Close();
sl@0
  1601
//	r=TheFs.CheckDisk(fileName);
sl@0
  1602
//	if (r!=KErrNone && r!=KErrNotSupported)
sl@0
  1603
//		{
sl@0
  1604
//		test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r);
sl@0
  1605
//		test.Getch();
sl@0
  1606
//		return(KErrDiskFull);
sl@0
  1607
//		}
sl@0
  1608
	test.Printf(_L("Created file %d size %d\n"),aX,LargeFileSize);
sl@0
  1609
	return(KErrNone);
sl@0
  1610
	}
sl@0
  1611
sl@0
  1612
LOCAL_C TInt DeleteFileX(TBuf<128>& aBaseName,TInt aX)
sl@0
  1613
//
sl@0
  1614
// Delete a file.
sl@0
  1615
//
sl@0
  1616
	{
sl@0
  1617
sl@0
  1618
	TBuf<128> fileName=aBaseName;
sl@0
  1619
	fileName.AppendNum(aX);
sl@0
  1620
	TInt r=TheFs.Delete(fileName);
sl@0
  1621
	test(r==KErrNone);
sl@0
  1622
//	r=TheFs.CheckDisk(fileName);
sl@0
  1623
//	if (r!=KErrNone && r!=KErrNotSupported)
sl@0
  1624
//		{
sl@0
  1625
//		test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r);
sl@0
  1626
//		test(r==KErrNone);
sl@0
  1627
//		}
sl@0
  1628
	test.Printf(_L("Deleted File %d\n"),aX);
sl@0
  1629
	return(KErrNone);
sl@0
  1630
	}
sl@0
  1631
sl@0
  1632
LOCAL_C void MakeAndDeleteFiles()
sl@0
  1633
//
sl@0
  1634
// Create and delete large files in a randomish order
sl@0
  1635
//
sl@0
  1636
	{
sl@0
  1637
sl@0
  1638
	test.Start(_L("Create and delete large files"));
sl@0
  1639
	TInt r=TheFs.MkDirAll(_L("\\F32-TST\\SMALLDIRECTORY\\"));
sl@0
  1640
	test(r==KErrNone || r==KErrAlreadyExists);
sl@0
  1641
	TBuf<128> fileName=_L("\\F32-TST\\SMALLDIRECTORY\\FILE");
sl@0
  1642
	r=CreateFileX(fileName,0);
sl@0
  1643
	test(r==KErrNone);
sl@0
  1644
	r=CreateFileX(fileName,1);
sl@0
  1645
	test(r==KErrNone);
sl@0
  1646
	r=DeleteFileX(fileName,0);	
sl@0
  1647
	test(r==KErrNone);
sl@0
  1648
	r=CreateFileX(fileName,2);
sl@0
  1649
	test(r==KErrNone);
sl@0
  1650
	r=CreateFileX(fileName,1);
sl@0
  1651
	test(r==KErrNone);
sl@0
  1652
	r=CreateFileX(fileName,3);
sl@0
  1653
	test(r==KErrNone);
sl@0
  1654
	r=DeleteFileX(fileName,1);	
sl@0
  1655
	test(r==KErrNone);
sl@0
  1656
	r=CreateFileX(fileName,4);
sl@0
  1657
	test(r==KErrNone);
sl@0
  1658
	r=DeleteFileX(fileName,2);	
sl@0
  1659
	test(r==KErrNone);
sl@0
  1660
	r=DeleteFileX(fileName,3);	
sl@0
  1661
	test(r==KErrNone);
sl@0
  1662
	r=DeleteFileX(fileName,4);	
sl@0
  1663
	test(r==KErrNone);
sl@0
  1664
	r=CreateFileX(fileName,1);
sl@0
  1665
	test(r==KErrNone);
sl@0
  1666
	r=DeleteFileX(fileName,1);	
sl@0
  1667
	test(r==KErrNone);
sl@0
  1668
sl@0
  1669
	r=TheFs.CheckDisk(fileName);
sl@0
  1670
	if (r!=KErrNone && r!=KErrNotSupported)
sl@0
  1671
		{
sl@0
  1672
		test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r);
sl@0
  1673
		test(0);
sl@0
  1674
		//test.Getch();
sl@0
  1675
		}
sl@0
  1676
	
sl@0
  1677
	test.End();
sl@0
  1678
	}
sl@0
  1679
sl@0
  1680
LOCAL_C void FillUpDisk()
sl@0
  1681
//
sl@0
  1682
// Test that a full disk is ok
sl@0
  1683
//
sl@0
  1684
	{
sl@0
  1685
sl@0
  1686
	test.Start(_L("Fill disk to capacity"));
sl@0
  1687
	TInt r=TheFs.MkDirAll(_L("\\F32-TST\\BIGDIRECTORY\\"));
sl@0
  1688
	test(r==KErrNone || r==KErrAlreadyExists);
sl@0
  1689
	TInt count=0;
sl@0
  1690
	TFileName sessionPath;
sl@0
  1691
	r=TheFs.SessionPath(sessionPath);
sl@0
  1692
	test(r==KErrNone);
sl@0
  1693
	TBuf<128> fileName=_L("\\F32-TST\\BIGDIRECTORY\\FILE");
sl@0
  1694
	FOREVER
sl@0
  1695
		{
sl@0
  1696
		TInt r=CreateFileX(fileName,count);
sl@0
  1697
		if (r==KErrDiskFull)
sl@0
  1698
			break;
sl@0
  1699
		test(r==KErrNone);
sl@0
  1700
		count++;
sl@0
  1701
#if defined(__WINS__)
sl@0
  1702
		if (count==32 && sessionPath[0]=='C')
sl@0
  1703
			break;
sl@0
  1704
#endif
sl@0
  1705
		}
sl@0
  1706
sl@0
  1707
	r=TheFs.CheckDisk(fileName);
sl@0
  1708
	if (r!=KErrNone && r!=KErrNotSupported)
sl@0
  1709
		{
sl@0
  1710
		test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r);
sl@0
  1711
		test(0);
sl@0
  1712
		//test.Getch();
sl@0
  1713
		}
sl@0
  1714
sl@0
  1715
	while(count--)
sl@0
  1716
		DeleteFileX(fileName,count);
sl@0
  1717
sl@0
  1718
	r=TheFs.CheckDisk(fileName);
sl@0
  1719
	if (r!=KErrNone && r!=KErrNotSupported)
sl@0
  1720
		{
sl@0
  1721
		test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r);
sl@0
  1722
		test(0);
sl@0
  1723
		//test.Getch();
sl@0
  1724
		}
sl@0
  1725
sl@0
  1726
	test.End();
sl@0
  1727
	}
sl@0
  1728
sl@0
  1729
LOCAL_C void CopyFileToTestDirectory()
sl@0
  1730
//
sl@0
  1731
// Make a copy of the file in ram
sl@0
  1732
//
sl@0
  1733
	{
sl@0
  1734
sl@0
  1735
	TFileName fn = _L("Z:\\TEST\\T_FSRV.CPP");
sl@0
  1736
	fn[0] = gExeFileName[0];
sl@0
  1737
	TParse f;
sl@0
  1738
	TInt r=TheFs.Parse(fn,f);
sl@0
  1739
	test(r==KErrNone);
sl@0
  1740
	test.Next(_L("Copying file to test directory"));
sl@0
  1741
	TParse fCopy;
sl@0
  1742
	r=TheFs.Parse(f.NameAndExt(),fCopy);
sl@0
  1743
	test(r==KErrNone);
sl@0
  1744
sl@0
  1745
	RFile f1;
sl@0
  1746
	r=f1.Open(TheFs,f.FullName(),EFileStreamText|EFileShareReadersOnly);
sl@0
  1747
	test(r==KErrNone);
sl@0
  1748
	RFile f2;
sl@0
  1749
	r=f2.Replace(TheFs,fCopy.FullName(),EFileWrite);
sl@0
  1750
	test(r==KErrNone);
sl@0
  1751
	TBuf8<512> copyBuf;
sl@0
  1752
	TInt rem;
sl@0
  1753
	r=f1.Size(rem);
sl@0
  1754
	test(r==KErrNone);
sl@0
  1755
	TInt pos=0;
sl@0
  1756
	while (rem)
sl@0
  1757
		{
sl@0
  1758
		TInt s=Min(rem,copyBuf.MaxSize());
sl@0
  1759
		r=f1.Read(pos,copyBuf,s);
sl@0
  1760
		test(r==KErrNone);
sl@0
  1761
		test(copyBuf.Length()==s);
sl@0
  1762
		r=f2.Write(pos,copyBuf,s);
sl@0
  1763
		test(r==KErrNone);
sl@0
  1764
		pos+=s;
sl@0
  1765
		rem-=s;
sl@0
  1766
		}
sl@0
  1767
	f1.Close();
sl@0
  1768
	f2.Close();
sl@0
  1769
	}
sl@0
  1770
sl@0
  1771
sl@0
  1772
//---------------------------------------------------------------------------
sl@0
  1773
sl@0
  1774
/**
sl@0
  1775
    test RFs::SetErrorCondition() aspects
sl@0
  1776
*/
sl@0
  1777
void TestSetErrorCondition()
sl@0
  1778
{
sl@0
  1779
#ifdef _DEBUG
sl@0
  1780
sl@0
  1781
    test.Next(_L("TestSetErrorCondition\n"));
sl@0
  1782
sl@0
  1783
    _LIT(KFileName, "\\A.swf");
sl@0
  1784
sl@0
  1785
    TInt        nRes;
sl@0
  1786
    RFile       file;    
sl@0
  1787
    RFile       file1;
sl@0
  1788
    
sl@0
  1789
    const TInt KMyError = -756; //-- specific error code we will simulate
sl@0
  1790
    
sl@0
  1791
    //==========  just create a file
sl@0
  1792
    nRes = TheFs.SetErrorCondition(KMyError,0); //-- set up FS error simulation
sl@0
  1793
    test(nRes == KErrNone);
sl@0
  1794
sl@0
  1795
    //-- this shall fail immediately 
sl@0
  1796
    nRes = file.Replace(TheFs, KFileName, EFileWrite);
sl@0
  1797
    test(nRes == KMyError);
sl@0
  1798
sl@0
  1799
    nRes = TheFs.SetErrorCondition(KErrNone); //-- disable FS error simulation
sl@0
  1800
    file.Close();
sl@0
  1801
sl@0
  1802
    //========== create file & duplicate a handle #1
sl@0
  1803
    nRes = TheFs.SetErrorCondition(KMyError,1); //-- set up FS error simulation
sl@0
  1804
    test(nRes == KErrNone);
sl@0
  1805
sl@0
  1806
    //-- this shall succeed
sl@0
  1807
    nRes = file.Replace(TheFs, KFileName, EFileWrite); //-- err cnt -> 0
sl@0
  1808
    test(nRes == KErrNone);
sl@0
  1809
sl@0
  1810
    //-- this shall fail inside RFile::Duplicate() half way through in the RFile::DuplicateHandle()
sl@0
  1811
    nRes = file1.Duplicate(file);
sl@0
  1812
    test(nRes == KMyError);
sl@0
  1813
    file1.Close();
sl@0
  1814
    
sl@0
  1815
    nRes = TheFs.SetErrorCondition(KErrNone); //-- disable FS error simulation
sl@0
  1816
    file.Close();
sl@0
  1817
sl@0
  1818
    //-- check that the file isn't locked
sl@0
  1819
    nRes = TheFs.Delete(KFileName);
sl@0
  1820
    test(nRes == KErrNone);
sl@0
  1821
sl@0
  1822
    //========== create file & duplicate a handle #2
sl@0
  1823
    nRes = TheFs.SetErrorCondition(KMyError,2); //-- set up FS error simulation
sl@0
  1824
    test(nRes == KErrNone);
sl@0
  1825
sl@0
  1826
    //-- this shall succeed
sl@0
  1827
    nRes = file.Replace(TheFs, KFileName, EFileWrite); //-- err cnt -> 1
sl@0
  1828
    test(nRes == KErrNone);
sl@0
  1829
sl@0
  1830
    //-- this must not fail, because EFsFileAdopt is excluded from the erros simulation
sl@0
  1831
    nRes = file1.Duplicate(file);
sl@0
  1832
    test(nRes == KErrNone);
sl@0
  1833
    file1.Close();
sl@0
  1834
    
sl@0
  1835
    nRes = TheFs.SetErrorCondition(KErrNone); //-- disable FS error simulation
sl@0
  1836
    file.Close();
sl@0
  1837
sl@0
  1838
    //-- check that the file isn't locked
sl@0
  1839
    nRes = TheFs.Delete(KFileName);
sl@0
  1840
    test(nRes == KErrNone);
sl@0
  1841
sl@0
  1842
    //========== crazy loop, for DEF103757
sl@0
  1843
sl@0
  1844
    for(TInt i=0; i<6; ++i)
sl@0
  1845
    {
sl@0
  1846
        nRes = TheFs.SetErrorCondition(KMyError,i); //-- set up FS error simulation
sl@0
  1847
        
sl@0
  1848
        nRes = file.Replace(TheFs, KFileName, EFileWrite); //-- err cnt -> 1
sl@0
  1849
        if(nRes != KErrNone)
sl@0
  1850
            continue;
sl@0
  1851
sl@0
  1852
        nRes = file1.Duplicate(file);
sl@0
  1853
sl@0
  1854
        file1.Close();
sl@0
  1855
        file.Close();
sl@0
  1856
        
sl@0
  1857
        nRes = TheFs.SetErrorCondition(KErrNone); //-- disable FS error simulation
sl@0
  1858
    }
sl@0
  1859
sl@0
  1860
    //-- check that the file isn't locked
sl@0
  1861
    nRes = TheFs.Delete(KFileName);
sl@0
  1862
    test(nRes == KErrNone);
sl@0
  1863
sl@0
  1864
sl@0
  1865
#endif
sl@0
  1866
}
sl@0
  1867
sl@0
  1868
//---------------------------------------------------------------------------
sl@0
  1869
sl@0
  1870
GLDEF_C void CallTestsL()
sl@0
  1871
//
sl@0
  1872
// Test the file server.
sl@0
  1873
//
sl@0
  1874
    {
sl@0
  1875
sl@0
  1876
    //-- set up console output 
sl@0
  1877
    F32_Test_Utils::SetConsole(test.Console()); 
sl@0
  1878
    
sl@0
  1879
    TInt nRes=TheFs.CharToDrive(gDriveToTest, gDrive);
sl@0
  1880
    test(nRes==KErrNone);
sl@0
  1881
    
sl@0
  1882
    PrintDrvInfo(TheFs, gDrive);
sl@0
  1883
sl@0
  1884
sl@0
  1885
	TVolumeInfo v;
sl@0
  1886
	TInt r=TheFs.Volume(v, CurrentDrive());
sl@0
  1887
	test(r==KErrNone);
sl@0
  1888
	LargeFileSize=Max((TUint32)I64LOW(v.iFree >> 7), (TUint32)65536u);
sl@0
  1889
sl@0
  1890
    if (gFirstTime)
sl@0
  1891
		{
sl@0
  1892
		MountRemoteFilesystem();
sl@0
  1893
		CreateSubstDrive();
sl@0
  1894
		
sl@0
  1895
		testDriveList();
sl@0
  1896
		
sl@0
  1897
		DisMountRemoteFilesystem();
sl@0
  1898
		RemoveSubstDrive();
sl@0
  1899
		
sl@0
  1900
		testDriveInfo();
sl@0
  1901
		testVolumeInfo();
sl@0
  1902
		testClientParse();
sl@0
  1903
		testPath();
sl@0
  1904
		testServerParse();
sl@0
  1905
		gFirstTime=EFalse;
sl@0
  1906
		}
sl@0
  1907
sl@0
  1908
	CreateTestDirectory(_L("\\F32-TST\\TFSRV\\"));
sl@0
  1909
	testSubst();
sl@0
  1910
	testSetVolume();
sl@0
  1911
	CopyFileToTestDirectory();
sl@0
  1912
	testModified();
sl@0
  1913
	testName();
sl@0
  1914
	MakeAndDeleteFiles();
sl@0
  1915
	FillUpDisk();
sl@0
  1916
	DeleteTestDirectory();
sl@0
  1917
sl@0
  1918
    TestSetErrorCondition();
sl@0
  1919
sl@0
  1920
    }
sl@0
  1921