os/kernelhwsrv/kerneltest/f32test/rofs/src/t_rofsfile.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) 2002-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
// Tests reading from files
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <e32std.h>
sl@0
    19
#include <e32std_private.h>
sl@0
    20
#include <e32test.h>
sl@0
    21
#include <f32file.h>
sl@0
    22
#include "utl.h"
sl@0
    23
#include "randgen.h"
sl@0
    24
sl@0
    25
GLREF_D RFs TheFs;
sl@0
    26
sl@0
    27
RTest	test( _L("T_ROFSFILE") );
sl@0
    28
sl@0
    29
sl@0
    30
_LIT( KSpotFile1, "root.txt" );
sl@0
    31
_LIT( KSpotFile2, "Dir1\\level1.txt" );
sl@0
    32
_LIT( KSpotFile3, "Dir1\\Dir2\\level2.txt" );
sl@0
    33
_LIT( KSpotFile4, "Dir1\\Dir2\\Dir3\\level3.txt" );
sl@0
    34
_LIT( KSpotFile5, "Dir1\\Dir2\\Dir3\\Dir4\\level4.txt" );
sl@0
    35
_LIT( KSpotFile6, "Dir1\\Dir2\\Dir3\\Dir4\\Dir5\\level5.txt" );
sl@0
    36
_LIT( KSpotFile7, "Dir1\\Dir2\\Dir3\\Dir4\\Dir5\\Dir6\\level6.txt" );
sl@0
    37
_LIT( KSpotFile8, "Dir1\\Dir2\\Dir3\\Dir4\\Dir5\\Dir6\\Dir7\\level7.txt" );
sl@0
    38
_LIT( KSpotFile9, "DeepDir1\\DeepDir2\\DeepDir3\\DeepDir4\\DeepDir5\\DeepDir6\\DeepDir7\\DeepDir8\\DeepDir9\\DeepDir10\\DeepDir11\\DeepDir12\\DeepDir13\\DeepDir14\\file.txt" );
sl@0
    39
_LIT( KSpotFile10, "Parent\\parfile.txt" );
sl@0
    40
_LIT( KSpotFile11, "Parent\\SubDir1A\\subfileA.txt" );
sl@0
    41
_LIT( KSpotFile12, "Mixed\\par1.txt" );
sl@0
    42
_LIT( KSpotFile13, "Mixed\\SubDir1\\sub1.txt" );
sl@0
    43
_LIT( KSpotFile14, "Mixed\\SubDir2\\sub2.txt" );
sl@0
    44
_LIT( KSpotFile15, "Dir1\\level1_ext.txt" );
sl@0
    45
sl@0
    46
sl@0
    47
_LIT( KSameDirFile1, "ReadTest\\A\\file1" );
sl@0
    48
_LIT( KSameDirFile2, "ReadTest\\A\\file2" );
sl@0
    49
_LIT( KSameDirFile3, "ReadTest\\A\\file3" );
sl@0
    50
_LIT( KSameDirFile4, "ReadTest\\A\\file4" );
sl@0
    51
const TInt KSameDirFileLength = 256;
sl@0
    52
const TUint KSameDirFile1Seed = 0xEF1113BC;
sl@0
    53
const TUint KSameDirFile2Seed = 0x04082195;
sl@0
    54
const TUint KSameDirFile3Seed = 0xEC36D359;
sl@0
    55
const TUint KSameDirFile4Seed = 0x07D4DAC2;
sl@0
    56
sl@0
    57
_LIT( KSameNameFile1, "ReadTest\\B\\B1\\testfile" );
sl@0
    58
_LIT( KSameNameFile2, "ReadTest\\B\\B2\\testfile" );
sl@0
    59
_LIT( KSameNameFile3, "ReadTest\\B\\B3\\testfile" );
sl@0
    60
_LIT( KSameNameFile4, "ReadTest\\B\\B4\\testfile" );
sl@0
    61
const TInt KSameNameFileLength = 256;	// we will read this much of the file
sl@0
    62
const TUint KSameNameFile1Seed = 0x8DA9AA5A;
sl@0
    63
const TUint KSameNameFile2Seed = 0x735AA240;
sl@0
    64
const TUint KSameNameFile3Seed = 0x42D4BF02;
sl@0
    65
const TUint KSameNameFile4Seed = 0x47C728FB;
sl@0
    66
sl@0
    67
_LIT( KRandomReadFile, "ReadTest\\C\\seektest" );
sl@0
    68
const TInt KRandomReadFileSize = 17466;
sl@0
    69
const TUint KRandomReadFileSeed = 0x8DA9AA5A;
sl@0
    70
sl@0
    71
_LIT( KEofFile1, "ReadTest\\D\\eoftest1" );
sl@0
    72
_LIT( KEofFile2, "ReadTest\\D\\eoftest2" );
sl@0
    73
_LIT( KEofFile3, "ReadTest\\D\\eoftest3" );
sl@0
    74
_LIT( KEofFile4, "ReadTest\\D\\eoftest4" );
sl@0
    75
_LIT( KEofFile5, "ReadTest\\D\\eoftest5" );
sl@0
    76
_LIT( KEofFile6, "ReadTest\\D\\eoftest6" );
sl@0
    77
sl@0
    78
sl@0
    79
_LIT( KStreamFile1, "ReadTest\\E\\stream1" );
sl@0
    80
_LIT( KStreamFile2, "ReadTest\\E\\stream2" );
sl@0
    81
_LIT( KStreamFile3, "ReadTest\\E\\stream3" );
sl@0
    82
_LIT( KStreamFile4, "ReadTest\\E\\stream4" );
sl@0
    83
sl@0
    84
_LIT( KTestFileExt, "ext.txt" );
sl@0
    85
sl@0
    86
const TUint KStreamReadSeed = 0x8DA9AA5A;
sl@0
    87
sl@0
    88
_LIT( KDriveBase, " :\\" );
sl@0
    89
sl@0
    90
sl@0
    91
const TInt KHello8FileSize = 5;
sl@0
    92
_LIT8( KHello8FileContent, "hello" );
sl@0
    93
sl@0
    94
sl@0
    95
// A large buffer for file reads
sl@0
    96
LOCAL_D TBuf8<18000> gFileBuffer;
sl@0
    97
sl@0
    98
sl@0
    99
LOCAL_C void SpotCheckFilesL(TInt aDriveToTest, TBool aExtension)
sl@0
   100
//
sl@0
   101
// Tests a few files for size & content. These are all the hello8.txt test file
sl@0
   102
//
sl@0
   103
	{
sl@0
   104
	const TDesC* const fileArray[15] =
sl@0
   105
		{
sl@0
   106
		&KSpotFile1, &KSpotFile2, &KSpotFile3, &KSpotFile4, &KSpotFile5,
sl@0
   107
		&KSpotFile6, &KSpotFile7, &KSpotFile8, &KSpotFile9, &KSpotFile10,
sl@0
   108
		&KSpotFile11, &KSpotFile12, &KSpotFile13, &KSpotFile14, &KSpotFile15
sl@0
   109
		};
sl@0
   110
sl@0
   111
	test.Next( _L("Spot-check some files") );
sl@0
   112
	TFileName name(KDriveBase);
sl@0
   113
	name[0] = TText('A' + aDriveToTest);
sl@0
   114
sl@0
   115
	TInt index =0;
sl@0
   116
	if(aExtension) index =1;
sl@0
   117
	for( TInt i = index; i < 14; i++ )
sl@0
   118
		{
sl@0
   119
		name.SetLength( 3 );	// trim back to drive specifier
sl@0
   120
		if(aExtension &&(i==1))
sl@0
   121
			name.Append( *fileArray[i+13] );
sl@0
   122
		else
sl@0
   123
			name.Append( *fileArray[i] );
sl@0
   124
sl@0
   125
		test.Printf( _L("Opening file %S"), &name );
sl@0
   126
		RFile file;
sl@0
   127
		TInt r = file.Open( TheFs, name, EFileRead );
sl@0
   128
		TEST_FOR_ERROR( r );
sl@0
   129
sl@0
   130
		TInt fileSize;
sl@0
   131
		r = file.Size( fileSize );
sl@0
   132
		TEST_FOR_ERROR( r );
sl@0
   133
		TEST_FOR_MATCH( fileSize, KHello8FileSize );
sl@0
   134
sl@0
   135
		TBuf8<5> buf;
sl@0
   136
		r = file.Read( buf );
sl@0
   137
		TEST_FOR_ERROR( r );
sl@0
   138
		TEST_FOR_MATCH( buf.Length(), KHello8FileSize );
sl@0
   139
		test(buf == KHello8FileContent);
sl@0
   140
		file.Close();
sl@0
   141
		}
sl@0
   142
	}
sl@0
   143
sl@0
   144
sl@0
   145
LOCAL_C void FillRandomBuffer( TDes8& aDes, TRandomGenerator& aRand, TInt aLength )
sl@0
   146
	{
sl@0
   147
	aDes.SetLength( aLength );
sl@0
   148
	TUint* ptr = (TUint*)aDes.Ptr();
sl@0
   149
	while( aLength >= 4 )
sl@0
   150
		{
sl@0
   151
		TUint v = aRand.Next();
sl@0
   152
		*ptr++ = v;
sl@0
   153
		aLength -= 4;
sl@0
   154
		}
sl@0
   155
	if( aLength )
sl@0
   156
		{
sl@0
   157
		TUint v = aRand.Next();
sl@0
   158
		TUint8* p8 = (TUint8*)ptr;
sl@0
   159
		while( aLength )
sl@0
   160
			{
sl@0
   161
			*p8++ = (TUint8)(v & 0xFF);
sl@0
   162
			v >>= 8;
sl@0
   163
			--aLength;
sl@0
   164
			}
sl@0
   165
		}
sl@0
   166
	}
sl@0
   167
sl@0
   168
LOCAL_C TBool ValidateRandomBuffer( const TDes8& aDes, TUint aSeed )
sl@0
   169
	{
sl@0
   170
	const TUint* ptr = (const TUint*)aDes.Ptr();
sl@0
   171
	TInt length = aDes.Length();
sl@0
   172
	
sl@0
   173
	TRandomGenerator rand;
sl@0
   174
	rand.SetSeed( aSeed );
sl@0
   175
	while( length >= 4 )
sl@0
   176
		{
sl@0
   177
		TUint v = rand.Next();
sl@0
   178
		if( *ptr++ != v )
sl@0
   179
			{
sl@0
   180
			return EFalse;
sl@0
   181
			}
sl@0
   182
		length -= 4;
sl@0
   183
		}
sl@0
   184
	if( length )
sl@0
   185
		{
sl@0
   186
		TUint v = rand.Next();
sl@0
   187
		TUint8* p8 = (TUint8*)ptr;
sl@0
   188
		while( length )
sl@0
   189
			{
sl@0
   190
			if( *p8++ != (TUint8)(v & 0xFF) )
sl@0
   191
				{
sl@0
   192
				return EFalse;
sl@0
   193
				}
sl@0
   194
			v >>= 8;
sl@0
   195
			--length;
sl@0
   196
			}
sl@0
   197
		}
sl@0
   198
	return ETrue;
sl@0
   199
	}
sl@0
   200
sl@0
   201
sl@0
   202
sl@0
   203
LOCAL_C void TestFilesInSameDirectoryL(TInt aDriveToTest)
sl@0
   204
	//
sl@0
   205
	// Tests opening different files in the same directory
sl@0
   206
	//
sl@0
   207
	{
sl@0
   208
	test.Next( _L("Testing files in same directory") );
sl@0
   209
	
sl@0
   210
	struct TTheFiles
sl@0
   211
		{
sl@0
   212
		RFile	iFile;
sl@0
   213
		TRandomGenerator	iRand;
sl@0
   214
		};
sl@0
   215
	TTheFiles files[4];
sl@0
   216
sl@0
   217
	TFileName name(KDriveBase);
sl@0
   218
	name[0] = TText('A' + aDriveToTest);
sl@0
   219
	
sl@0
   220
	name.Append( KSameDirFile1 );
sl@0
   221
	TInt r = files[0].iFile.Open( TheFs, name, EFileRead );
sl@0
   222
	TEST_FOR_ERROR( r );
sl@0
   223
sl@0
   224
	name.SetLength( 3 );
sl@0
   225
	name.Append( KSameDirFile2 );
sl@0
   226
	r = files[1].iFile.Open( TheFs, name, EFileRead );
sl@0
   227
	TEST_FOR_ERROR( r );
sl@0
   228
sl@0
   229
	name.SetLength( 3 );
sl@0
   230
	name.Append( KSameDirFile3 );
sl@0
   231
	r = files[2].iFile.Open( TheFs, name, EFileRead );
sl@0
   232
	TEST_FOR_ERROR( r );
sl@0
   233
sl@0
   234
	name.SetLength( 3 );
sl@0
   235
	name.Append( KSameDirFile4 );
sl@0
   236
	r = files[3].iFile.Open( TheFs, name, EFileRead );
sl@0
   237
	TEST_FOR_ERROR( r );
sl@0
   238
sl@0
   239
	const TInt KReadLen = KSameDirFileLength / 16;
sl@0
   240
	TBuf8<KReadLen> readBuf;
sl@0
   241
	TBuf8<KReadLen> randomBuf;
sl@0
   242
sl@0
   243
	files[0].iRand.SetSeed( KSameDirFile1Seed );
sl@0
   244
	files[1].iRand.SetSeed( KSameDirFile2Seed );
sl@0
   245
	files[2].iRand.SetSeed( KSameDirFile3Seed );
sl@0
   246
	files[3].iRand.SetSeed( KSameDirFile4Seed );
sl@0
   247
sl@0
   248
	for( TInt fragment = 0; fragment < (KSameDirFileLength / KReadLen); ++fragment )
sl@0
   249
		{
sl@0
   250
		// read next fragment from each file and compare
sl@0
   251
		for( TInt j = 0; j < 4; ++j )
sl@0
   252
			{
sl@0
   253
			FillRandomBuffer( randomBuf, files[j].iRand, KReadLen );
sl@0
   254
			r = files[j].iFile.Read( readBuf );
sl@0
   255
			TEST_FOR_ERROR( r );
sl@0
   256
			TEST_FOR_MATCH( readBuf.Length(), KReadLen );
sl@0
   257
			test( readBuf == randomBuf );
sl@0
   258
			}
sl@0
   259
		}
sl@0
   260
	files[0].iFile.Close();
sl@0
   261
	files[1].iFile.Close();
sl@0
   262
	files[2].iFile.Close();
sl@0
   263
	files[3].iFile.Close();
sl@0
   264
	}
sl@0
   265
sl@0
   266
sl@0
   267
LOCAL_C void TestFilesSameNameDifferentDirectoryL(TInt aDriveToTest)
sl@0
   268
	//
sl@0
   269
	// Tests opening files with the same name but in different directories
sl@0
   270
	//
sl@0
   271
	{
sl@0
   272
	test.Next( _L("Testing files with same name in different directories") );
sl@0
   273
	
sl@0
   274
	struct TTheFiles
sl@0
   275
		{
sl@0
   276
		RFile	iFile;
sl@0
   277
		TRandomGenerator	iRand;
sl@0
   278
		};
sl@0
   279
	TTheFiles files[4];
sl@0
   280
sl@0
   281
	TFileName name(KDriveBase);
sl@0
   282
	name[0] = TText('A' + aDriveToTest);
sl@0
   283
	
sl@0
   284
	name.Append( KSameNameFile1 );
sl@0
   285
	TInt r = files[0].iFile.Open( TheFs, name, EFileRead );
sl@0
   286
	TEST_FOR_ERROR( r );
sl@0
   287
sl@0
   288
	name.SetLength( 3 );
sl@0
   289
	name.Append( KSameNameFile2 );
sl@0
   290
	r = files[1].iFile.Open( TheFs, name, EFileRead );
sl@0
   291
	TEST_FOR_ERROR( r );
sl@0
   292
sl@0
   293
	name.SetLength( 3 );
sl@0
   294
	name.Append( KSameNameFile3 );
sl@0
   295
	r = files[2].iFile.Open( TheFs, name, EFileRead );
sl@0
   296
	TEST_FOR_ERROR( r );
sl@0
   297
sl@0
   298
	name.SetLength( 3 );
sl@0
   299
	name.Append( KSameNameFile4 );
sl@0
   300
	r = files[3].iFile.Open( TheFs, name, EFileRead );
sl@0
   301
	TEST_FOR_ERROR( r );
sl@0
   302
sl@0
   303
	const TInt KReadLen = KSameNameFileLength / 16;
sl@0
   304
	TBuf8<KReadLen> readBuf;
sl@0
   305
	TBuf8<KReadLen> randomBuf;
sl@0
   306
sl@0
   307
	files[0].iRand.SetSeed( KSameNameFile1Seed );
sl@0
   308
	files[1].iRand.SetSeed( KSameNameFile2Seed );
sl@0
   309
	files[2].iRand.SetSeed( KSameNameFile3Seed );
sl@0
   310
	files[3].iRand.SetSeed( KSameNameFile4Seed );
sl@0
   311
sl@0
   312
	for( TInt fragment = 0; fragment < (KSameDirFileLength / KReadLen); ++fragment )
sl@0
   313
		{
sl@0
   314
		// read next fragment from each file and compare
sl@0
   315
		for( TInt j = 0; j < 4; ++j )
sl@0
   316
			{
sl@0
   317
			FillRandomBuffer( randomBuf, files[j].iRand, KReadLen );
sl@0
   318
			r = files[j].iFile.Read( readBuf );
sl@0
   319
			TEST_FOR_ERROR( r );
sl@0
   320
			TEST_FOR_MATCH( readBuf.Length(), KReadLen );
sl@0
   321
			test( readBuf == randomBuf );
sl@0
   322
			}
sl@0
   323
		}
sl@0
   324
	files[0].iFile.Close();
sl@0
   325
	files[1].iFile.Close();
sl@0
   326
	files[2].iFile.Close();
sl@0
   327
	files[3].iFile.Close();
sl@0
   328
	}
sl@0
   329
sl@0
   330
sl@0
   331
sl@0
   332
sl@0
   333
LOCAL_C void TestRandomSeekL(TInt aDriveToTest)
sl@0
   334
	//
sl@0
   335
	// Tests reading from random positions in a file
sl@0
   336
	//
sl@0
   337
	{
sl@0
   338
	test.Next( _L("Testing random read position") );
sl@0
   339
	
sl@0
   340
	TFileName name(KDriveBase);
sl@0
   341
	name[0] = TText('A' + aDriveToTest);
sl@0
   342
	
sl@0
   343
	name.Append( KRandomReadFile );
sl@0
   344
	RFile file;
sl@0
   345
	TInt r = file.Open( TheFs, name, EFileRead );
sl@0
   346
	TEST_FOR_ERROR( r );
sl@0
   347
sl@0
   348
	// Check file size
sl@0
   349
	TInt fileSize;
sl@0
   350
	r = file.Size( fileSize ), 
sl@0
   351
	TEST_FOR_ERROR( r );
sl@0
   352
	TEST_FOR_MATCH( fileSize, KRandomReadFileSize );
sl@0
   353
sl@0
   354
	// Fill buffer with expected file contents
sl@0
   355
	TRandomGenerator rand;
sl@0
   356
	rand.SetSeed( KRandomReadFileSeed );
sl@0
   357
	FillRandomBuffer( gFileBuffer, rand, KRandomReadFileSize );
sl@0
   358
sl@0
   359
sl@0
   360
	// Read from random positions within the file
sl@0
   361
	rand.SetSeed( 0xA6E320F1 );
sl@0
   362
	const TInt KMaxRead = 256;
sl@0
   363
	TBuf8<KMaxRead> buf;
sl@0
   364
	const TInt maxRead = Min( fileSize, buf.MaxLength() );
sl@0
   365
	for( TInt readCount = 0; readCount < 100; ++readCount )
sl@0
   366
		{
sl@0
   367
		TInt readLen = rand.Next() % (maxRead+1);
sl@0
   368
		if( readLen > buf.MaxLength() )
sl@0
   369
			{
sl@0
   370
			readLen = buf.MaxLength();
sl@0
   371
			}
sl@0
   372
		TInt readPos = rand.Next() % (fileSize - readLen);
sl@0
   373
sl@0
   374
		_LIT( KMessage, "Reading %d bytes from 0x%x" );
sl@0
   375
		test.Printf( KMessage, readLen, readPos );
sl@0
   376
		
sl@0
   377
		const TUint8* pExpected = gFileBuffer.Ptr() + readPos;
sl@0
   378
		r = file.Seek( ESeekStart, readPos );
sl@0
   379
		TEST_FOR_ERROR( r );
sl@0
   380
sl@0
   381
		r = file.Read( buf, readLen );
sl@0
   382
		TEST_FOR_ERROR( r );
sl@0
   383
		TEST_FOR_MATCH( buf.Length(), readLen );
sl@0
   384
sl@0
   385
		const TUint8* pRead = buf.Ptr();
sl@0
   386
		test( 0 == Mem::Compare( pExpected, readLen, pRead, readLen ) );
sl@0
   387
		}
sl@0
   388
	}
sl@0
   389
sl@0
   390
sl@0
   391
LOCAL_C void TestEofReadL(TInt aDriveToTest)
sl@0
   392
	//
sl@0
   393
	// Test reading off the end of a file
sl@0
   394
	//
sl@0
   395
	{
sl@0
   396
	test.Next( _L("Testing reading past EOF") );
sl@0
   397
sl@0
   398
	
sl@0
   399
	const TDesC* const fileArray[6] =
sl@0
   400
		{
sl@0
   401
		&KEofFile1, &KEofFile2, &KEofFile3, &KEofFile4, &KEofFile5, &KEofFile6
sl@0
   402
		};
sl@0
   403
sl@0
   404
	TFileName name(KDriveBase);
sl@0
   405
	name[0] = TText('A' + aDriveToTest);
sl@0
   406
sl@0
   407
	TRandomGenerator rand;
sl@0
   408
	rand.SetSeed( 0x1001A005 );
sl@0
   409
	for( TInt i = 0; i < 6; i++ )
sl@0
   410
		{
sl@0
   411
		name.SetLength( 3 );	// trim back to drive specifier
sl@0
   412
		name.Append( *fileArray[i] );
sl@0
   413
		test.Printf( _L("Opening file %S"), &name );
sl@0
   414
		RFile file;
sl@0
   415
		TInt r = file.Open( TheFs, name, EFileRead );
sl@0
   416
		TEST_FOR_ERROR( r );
sl@0
   417
		
sl@0
   418
		TInt fileSize;
sl@0
   419
		r = file.Size( fileSize ), 
sl@0
   420
		TEST_FOR_ERROR( r );
sl@0
   421
		test( fileSize > 0 );
sl@0
   422
		
sl@0
   423
		TInt readPos = fileSize - ( rand.Next() % 12);
sl@0
   424
		if( readPos < 0 )
sl@0
   425
			{
sl@0
   426
			readPos = 0;
sl@0
   427
			}
sl@0
   428
		r = file.Seek( ESeekStart, readPos );
sl@0
   429
		TEST_FOR_ERROR( r );
sl@0
   430
		
sl@0
   431
		TBuf8<32> buf;
sl@0
   432
		r = file.Read( buf );
sl@0
   433
		TEST_FOR_ERROR( r );
sl@0
   434
		TEST_FOR_MATCH( buf.Length(), fileSize - readPos );
sl@0
   435
		file.Close();
sl@0
   436
		}
sl@0
   437
	
sl@0
   438
	}
sl@0
   439
sl@0
   440
sl@0
   441
sl@0
   442
LOCAL_C void TestStreamReadL(TInt aDriveToTest)
sl@0
   443
	//
sl@0
   444
	// Reads the whole file into a buffer in a single read
sl@0
   445
	// and validates the data
sl@0
   446
	//
sl@0
   447
	{
sl@0
   448
	test.Next( _L("Testing whole file read") );
sl@0
   449
sl@0
   450
	const TDesC* const fileArray[4] =
sl@0
   451
		{
sl@0
   452
		&KStreamFile1, &KStreamFile2, &KStreamFile3, &KStreamFile4
sl@0
   453
		};
sl@0
   454
	
sl@0
   455
	TFileName name(KDriveBase);
sl@0
   456
	name[0] = TText('A' + aDriveToTest);
sl@0
   457
sl@0
   458
	for( TInt i = 0; i < 4; ++i )
sl@0
   459
		{
sl@0
   460
		name.SetLength(3);
sl@0
   461
		name.Append( *fileArray[i] );
sl@0
   462
sl@0
   463
		test.Printf( _L("... file %S"), &name );
sl@0
   464
		
sl@0
   465
		RFile file;
sl@0
   466
		TInt r = file.Open( TheFs, name, EFileRead );
sl@0
   467
		TEST_FOR_ERROR( r );
sl@0
   468
sl@0
   469
		TInt fileSize;
sl@0
   470
		r = file.Size( fileSize ), 
sl@0
   471
		TEST_FOR_ERROR( r );
sl@0
   472
		test( fileSize > 0 );
sl@0
   473
sl@0
   474
		r = file.Read( gFileBuffer );
sl@0
   475
		TEST_FOR_ERROR( r );
sl@0
   476
		TEST_FOR_MATCH( fileSize, gFileBuffer.Length() );
sl@0
   477
sl@0
   478
		test( ValidateRandomBuffer( gFileBuffer, KStreamReadSeed ) );
sl@0
   479
sl@0
   480
		file.Close();
sl@0
   481
		}
sl@0
   482
	}
sl@0
   483
sl@0
   484
//************************
sl@0
   485
// Entry point
sl@0
   486
sl@0
   487
void DoTestL(TInt aDriveToTest)
sl@0
   488
	{
sl@0
   489
	test.Title();
sl@0
   490
	test.Start( _L("Testing ROFS file reading") );
sl@0
   491
	
sl@0
   492
	test.Printf( _L("Looking for ROFS extension\n"));
sl@0
   493
	TBool extension = EFalse;
sl@0
   494
	TFileName name(KDriveBase);
sl@0
   495
	name[0] = TText('A' + aDriveToTest);
sl@0
   496
sl@0
   497
	name.SetLength( 3 );	// trim back to drive specifier
sl@0
   498
	name.Append( KTestFileExt );
sl@0
   499
sl@0
   500
	RFile file;
sl@0
   501
	test.Printf( _L("Opening file %S"), &name );
sl@0
   502
	TInt r = file.Open( TheFs, name, EFileRead );
sl@0
   503
	if(r==KErrNone)
sl@0
   504
		{
sl@0
   505
		extension=ETrue;
sl@0
   506
		file.Close();
sl@0
   507
		test.Printf( _L("ROFS extension found\n"));
sl@0
   508
		}
sl@0
   509
	else if(r==KErrNotFound)
sl@0
   510
		{
sl@0
   511
		test.Printf( _L("Not found, ROFS extension not present\n"));
sl@0
   512
		}
sl@0
   513
sl@0
   514
	SpotCheckFilesL(aDriveToTest, extension);
sl@0
   515
	TestFilesInSameDirectoryL(aDriveToTest);
sl@0
   516
	TestFilesSameNameDifferentDirectoryL(aDriveToTest);
sl@0
   517
	TestRandomSeekL(aDriveToTest);
sl@0
   518
	TestEofReadL(aDriveToTest);
sl@0
   519
	TestStreamReadL(aDriveToTest);
sl@0
   520
sl@0
   521
	test.End();
sl@0
   522
	}