os/kernelhwsrv/kerneltest/f32test/server/t_blockmap.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/server/t_blockmap.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1405 @@
     1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Tests for the blockmap API. The blockmap API enumerates the resources
    1.18 +// used by a file depending upon the type of media on which the file
    1.19 +// resides.
    1.20 +// 002 Test Initialise error checking
    1.21 +// 003 Test processing of user-side block map into extent list
    1.22 +// 004 Test processing of user-side block map into extent list, block size > read unit size
    1.23 +// 005 Test Read error checking
    1.24 +// 006 Test Read
    1.25 +// Test BlockMap API functionality.
    1.26 +// 
    1.27 +//
    1.28 +
    1.29 +//! @SYMTestCaseID			KBASE-T_BLOCKMAP-0337
    1.30 +//! @SYMTestType			UT
    1.31 +//! @SYMPREQ				PREQ1110
    1.32 +//! @SYMTestCaseDesc		Demand Paging Blockmap tests
    1.33 +//! @SYMTestActions			001 Unit tests the TKernBlockMap class
    1.34 +//! @SYMTestExpectedResults All tests should pass.
    1.35 +//! @SYMTestPriority        High
    1.36 +//! @SYMTestStatus          Implemented
    1.37 +
    1.38 +
    1.39 +#include <e32test.h>
    1.40 +#include <e32svr.h>
    1.41 +#include <f32file.h>
    1.42 +#include <e32math.h>
    1.43 +#include <hal.h>
    1.44 +#include "t_server.h"
    1.45 +
    1.46 +RTest test( _L("T_BLOCKMAP") );
    1.47 +
    1.48 +const TInt KReadBufferSize = 1024;
    1.49 +const TInt KMaxFragmentSize = 400;
    1.50 +const TInt KMaxFileSize = 10000;
    1.51 +
    1.52 +TInt RamFatDrive = -1;
    1.53 +TInt RemovableFatDrive = -1;
    1.54 +TInt InternalRemovableFatDrive = -1;
    1.55 +TInt NandDrive = -1;
    1.56 +TBool Pageable = EFalse;
    1.57 +TBool Finished = EFalse;
    1.58 +
    1.59 +enum DriveType
    1.60 +	{
    1.61 +	EDriveNand,
    1.62 +	EDriveRam,
    1.63 +	EDriveRemovable,
    1.64 +	EDriveInternalRemovable
    1.65 +	};
    1.66 +
    1.67 +_LIT( KTestFile, "Z:\\TEST\\T_FILE.CPP");
    1.68 +_LIT( KTestFileFAT, "Z:\\Multiple\\T_file.cpp");
    1.69 +_LIT( KTestFileName, "T_FILE.CPP");
    1.70 +_LIT( KFragmentedFileName1, "FRAG1.TXT");
    1.71 +_LIT( KFragmentedFileName2, "FRAG2.TXT");
    1.72 +_LIT( KDriveBase, " :\\" );
    1.73 +
    1.74 +LOCAL_C TInt TestBlockMapNandFATUserData(TInt64 aStartPos, TInt64 aEndPos)
    1.75 +	{
    1.76 +	CFileMan* fMan=CFileMan::NewL(TheFs);
    1.77 +	test(fMan!=NULL);
    1.78 +	TFileName name(KDriveBase);
    1.79 +	name[0] = TText('A' + NandDrive);
    1.80 +	name.Append( KTestFileName );
    1.81 +
    1.82 +	TInt r = fMan->Attribs(name, 0, KEntryAttReadOnly, 0);
    1.83 +	r = fMan->Delete(name);
    1.84 +
    1.85 +	r = fMan->Copy(KTestFile, name);
    1.86 +	test( r == KErrNone );
    1.87 +
    1.88 +	TInt localDriveNum = 0;
    1.89 +	RFile testFile;
    1.90 +	r = testFile.Open( TheFs, name, EFileRead );
    1.91 +	test( r == KErrNone );
    1.92 +	
    1.93 +	RArray<SBlockMapInfo> map;	// From RArray<TBlockMapEntry> map; to RArray<SBlockMapInfo> map;
    1.94 +	SBlockMapInfo info;
    1.95 +	TInt counter = 0;
    1.96 +	TInt startPos = aStartPos;
    1.97 +	TInt bmErr;
    1.98 +
    1.99 +	// Store SBlockMapInfo objects in map:RArray until KErrCompletion is returned.
   1.100 +	do
   1.101 +		{
   1.102 +		bmErr = testFile.BlockMap(info, aStartPos, aEndPos, ETestDebug);
   1.103 +		if (bmErr != 0 && bmErr != KErrCompletion)
   1.104 +			{
   1.105 +			map.Close();
   1.106 +			testFile.Close();
   1.107 +			r = fMan->Attribs(name, 0, KEntryAttReadOnly, 0);
   1.108 +			test( r == KErrNone );
   1.109 +			r = fMan->Delete(name);
   1.110 +			test( r == KErrNone );
   1.111 +			delete fMan;
   1.112 +			return bmErr;
   1.113 +			}
   1.114 +		map.Append(info); 
   1.115 +		if (counter++ == 0)
   1.116 +			localDriveNum = info.iLocalDriveNumber;
   1.117 +		} while ( bmErr == 0 && bmErr != KErrCompletion );
   1.118 +	test( bmErr == KErrCompletion );
   1.119 +	TInt granularity;
   1.120 +
   1.121 +	TInt size;
   1.122 +	r = testFile.Size(size);
   1.123 +	test( r == KErrNone );
   1.124 +
   1.125 +	TBuf8<KReadBufferSize> buf1;
   1.126 +	TBuf8<KReadBufferSize> buf2;
   1.127 +	
   1.128 +	TBool changed;	
   1.129 +	TBusLocalDrive localDrive;
   1.130 +
   1.131 +	UserSvr::UnlockRamDrive();
   1.132 +
   1.133 +	TBlockMapEntry* myBlockMapEntry;
   1.134 +	TInt myCounter = 0;
   1.135 +	TInt totalSegments = 0;
   1.136 +	TInt remainder = 0;
   1.137 +	TInt miniLength = 0;
   1.138 +	TInt amountRead = 0;
   1.139 +
   1.140 +	TInt c;
   1.141 +	for ( c = 0; c < map.Count(); c++ )
   1.142 +		{
   1.143 +		myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr();
   1.144 +		granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry);
   1.145 +		totalSegments += granularity;
   1.146 +		}
   1.147 +
   1.148 +	const TInt KTotalSegments = totalSegments;
   1.149 +	r = localDrive.Connect( localDriveNum, changed );
   1.150 +	test( r == KErrNone );
   1.151 +
   1.152 +//	For each SBlockMapInfo object in RArray map
   1.153 +	for ( c = 0; c < map.Count(); c++ )
   1.154 +		{
   1.155 +		myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr();
   1.156 +		granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry);
   1.157 +		TInt length;
   1.158 +		if ( aEndPos == -1 )
   1.159 +			{
   1.160 +			length = size - startPos;
   1.161 +			aEndPos = size;
   1.162 +			}
   1.163 +		else
   1.164 +			length = aEndPos - startPos;
   1.165 +		
   1.166 +		for ( TInt c2 = 1; c2 <= granularity; c2++)
   1.167 +			{
   1.168 +			myCounter = 0;
   1.169 +			if ( c2 == KTotalSegments && aEndPos%map[c].iBlockGranularity != 0 )
   1.170 +				remainder = map[c].iBlockGranularity - aEndPos%map[c].iBlockGranularity;
   1.171 +			else
   1.172 +				remainder = 0;
   1.173 +			miniLength = map[c].iBlockGranularity*myBlockMapEntry->iNumberOfBlocks - remainder - (c2 == 1?map[c].iBlockStartOffset:0);
   1.174 +			do
   1.175 +				{
   1.176 +				if ( miniLength >= KReadBufferSize )
   1.177 +					{
   1.178 +					testFile.Read( startPos + amountRead, buf1, KReadBufferSize );
   1.179 +					localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, KReadBufferSize, buf2);
   1.180 +					r = buf1.Compare( buf2 );
   1.181 +					test( r == 0 );
   1.182 +					buf1.Zero();
   1.183 +					buf2.Zero();
   1.184 +					myCounter++;
   1.185 +					miniLength -= KReadBufferSize;
   1.186 +					length -= KReadBufferSize;
   1.187 +					amountRead += KReadBufferSize;
   1.188 +					}
   1.189 +				else
   1.190 +					{
   1.191 +					testFile.Read(startPos + amountRead, buf1, miniLength);
   1.192 +					localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, miniLength, buf2);
   1.193 +					r = buf1.Compare( buf2 );
   1.194 +					test( r == 0 );
   1.195 +					amountRead += miniLength;
   1.196 +					length -= miniLength;
   1.197 +					miniLength = 0;
   1.198 +					}
   1.199 +				} while ( miniLength != 0 && length != 0);
   1.200 +			myBlockMapEntry++;
   1.201 +			}
   1.202 +		}
   1.203 +	map.Close();
   1.204 +
   1.205 +	testFile.Close();
   1.206 +	r=fMan->Attribs(name, 0, KEntryAttReadOnly, 0);
   1.207 +	test( r == KErrNone );
   1.208 +	r = fMan->Delete(name);
   1.209 +	test( r == KErrNone );
   1.210 +	delete fMan;
   1.211 +	return bmErr;
   1.212 +	}
   1.213 +
   1.214 +LOCAL_C TInt TestBlockMapNandFAT(TInt64 aStartPos, TInt64 aEndPos)
   1.215 +//
   1.216 +// Test BlockMap retrieval on NAND FAT.
   1.217 +//
   1.218 +	{
   1.219 +	TInt localDriveNum = 0;
   1.220 +	RFile testFile;
   1.221 +	TInt r = testFile.Open( TheFs, KTestFileFAT, EFileRead );
   1.222 +	test( r == KErrNone );
   1.223 +	
   1.224 +	RArray<SBlockMapInfo> map;	// From RArray<TBlockMapEntry> map; to RArray<SBlockMapInfo> map;
   1.225 +	SBlockMapInfo info;
   1.226 +	TInt counter = 0;
   1.227 +	TInt startPos = aStartPos;
   1.228 +	TInt bmErr;
   1.229 +
   1.230 +	// Store SBlockMapInfo objects in map:RArray until KErrCompletion is returned.
   1.231 +	do
   1.232 +		{
   1.233 +		bmErr = testFile.BlockMap(info, aStartPos, aEndPos, Pageable?EBlockMapUsagePaging:ETestDebug);
   1.234 +		if (bmErr != 0 && bmErr != KErrCompletion)
   1.235 +			{
   1.236 +			map.Close();
   1.237 +			testFile.Close();
   1.238 +			return bmErr;
   1.239 +			}
   1.240 +		map.Append(info); 
   1.241 +		if (counter++ == 0)
   1.242 +			localDriveNum = info.iLocalDriveNumber;
   1.243 +		} while ( bmErr == 0 && bmErr != KErrCompletion );
   1.244 +	test( bmErr == KErrCompletion );
   1.245 +	TInt granularity;
   1.246 +
   1.247 +	TInt size;
   1.248 +	r = testFile.Size(size);
   1.249 +	test( r == KErrNone );
   1.250 +
   1.251 +	TBuf8<KReadBufferSize> buf1;
   1.252 +	TBuf8<KReadBufferSize> buf2;
   1.253 +	
   1.254 +	TBool changed;	
   1.255 +	TBusLocalDrive localDrive;
   1.256 +
   1.257 +	TBlockMapEntry* myBlockMapEntry;
   1.258 +	TInt myCounter = 0;
   1.259 +	TInt totalSegments = 0;
   1.260 +	TInt remainder = 0;
   1.261 +	TInt miniLength = 0;
   1.262 +	TInt amountRead = 0;
   1.263 +
   1.264 +	TInt c;
   1.265 +	for ( c = 0; c < map.Count(); c++ )
   1.266 +		{
   1.267 +		myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr();
   1.268 +		granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry);
   1.269 +		totalSegments += granularity;
   1.270 +		}
   1.271 +
   1.272 +	const TInt KTotalSegments = totalSegments;
   1.273 +	r = localDrive.Connect( localDriveNum, changed );
   1.274 +	test( r == KErrNone );
   1.275 +
   1.276 +//	For each SBlockMapInfo object in RArray map
   1.277 +	for ( c = 0; c < map.Count(); c++ )
   1.278 +		{
   1.279 +		myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr();
   1.280 +		granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry);
   1.281 +
   1.282 +		TInt length;
   1.283 +		if ( aEndPos == -1 )
   1.284 +			{
   1.285 +			length = size - startPos;
   1.286 +			aEndPos = size;
   1.287 +			}
   1.288 +		else
   1.289 +			length = aEndPos - startPos;
   1.290 +
   1.291 +		for ( TInt c2 = 1; c2 <= granularity; c2++)
   1.292 +			{
   1.293 +			myCounter = 0;
   1.294 +			if ( c2 == KTotalSegments && aEndPos%map[c].iBlockGranularity != 0 )
   1.295 +				remainder = map[c].iBlockGranularity - aEndPos%map[c].iBlockGranularity;
   1.296 +			else
   1.297 +				remainder = 0;
   1.298 +			miniLength = map[c].iBlockGranularity*myBlockMapEntry->iNumberOfBlocks - remainder - (c2 == 1?map[c].iBlockStartOffset:0);
   1.299 +			do
   1.300 +				{
   1.301 +				if ( miniLength >= KReadBufferSize )
   1.302 +					{
   1.303 +					testFile.Read( startPos + amountRead, buf1, KReadBufferSize );
   1.304 +					localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, KReadBufferSize, buf2);
   1.305 +					r = buf1.Compare( buf2 );
   1.306 +					test( r == 0 );
   1.307 +					buf1.Zero();
   1.308 +					buf2.Zero();
   1.309 +					myCounter++;
   1.310 +					miniLength -= KReadBufferSize;
   1.311 +					length -= KReadBufferSize;
   1.312 +					amountRead += KReadBufferSize;
   1.313 +					}
   1.314 +				else
   1.315 +					{
   1.316 +					testFile.Read(startPos + amountRead, buf1, miniLength);
   1.317 +					localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, miniLength, buf2);
   1.318 +					r = buf1.Compare( buf2 );
   1.319 +					test( r == 0 );
   1.320 +					amountRead += miniLength;
   1.321 +					length -= miniLength;
   1.322 +					miniLength = 0;
   1.323 +					}
   1.324 +				} while ( miniLength != 0 && length != 0);
   1.325 +			myBlockMapEntry++;
   1.326 +			}
   1.327 +		}
   1.328 +	map.Close();
   1.329 +	testFile.Close();
   1.330 +	return bmErr;
   1.331 +	}
   1.332 +
   1.333 +LOCAL_C TInt TestBlockMapNandROFS(TInt64 aStartPos, TInt64 aEndPos)
   1.334 +//
   1.335 +// Test BlockMap retrieval on NAND ROFS.
   1.336 +//
   1.337 +	{
   1.338 +	TInt localDriveNum = 0;
   1.339 +	RFile testFile;
   1.340 +	TInt r = testFile.Open( TheFs, KTestFile, EFileRead );
   1.341 +	test( r == KErrNone );
   1.342 +	
   1.343 +	RArray<SBlockMapInfo> map;	// From RArray<TBlockMapEntry> map; to RArray<SBlockMapInfo> map;
   1.344 +	SBlockMapInfo info;
   1.345 +	TInt counter = 0;
   1.346 +	TInt startPos = aStartPos;
   1.347 +	TInt bmErr;
   1.348 +
   1.349 +	// Store SBlockMapInfo objects in map:RArray until KErrCompletion is returned.
   1.350 +	do
   1.351 +		{
   1.352 +		bmErr = testFile.BlockMap(info, aStartPos, aEndPos, Pageable?EBlockMapUsagePaging:ETestDebug);
   1.353 +		if (bmErr != 0 && bmErr != KErrCompletion)
   1.354 +			{
   1.355 +			map.Close();
   1.356 +			testFile.Close();
   1.357 +			return bmErr;
   1.358 +			}
   1.359 +		map.Append(info); 
   1.360 +		if (counter++ == 0)
   1.361 +			localDriveNum = info.iLocalDriveNumber;
   1.362 +		} while ( bmErr == 0 && bmErr != KErrCompletion );
   1.363 +	test( bmErr == KErrCompletion );
   1.364 +	TInt granularity;
   1.365 +
   1.366 +	TInt size;
   1.367 +	r = testFile.Size(size);
   1.368 +	test( r == KErrNone );
   1.369 +
   1.370 +	TBuf8<KReadBufferSize> buf1;
   1.371 +	TBuf8<KReadBufferSize> buf2;
   1.372 +	
   1.373 +	TBool changed;	
   1.374 +	TBusLocalDrive localDrive;
   1.375 +
   1.376 +	TBlockMapEntry* myBlockMapEntry;
   1.377 +	TInt myCounter = 0;
   1.378 +	TInt totalSegments = 0;
   1.379 +	TInt miniLength = 0;
   1.380 +	TInt amountRead = 0;
   1.381 +
   1.382 +	TInt c;
   1.383 +	for ( c = 0; c < map.Count(); c++ )
   1.384 +		{
   1.385 +		myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr();
   1.386 +		granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry);
   1.387 +		totalSegments += granularity;
   1.388 +		}
   1.389 +	r = localDrive.Connect( localDriveNum, changed );
   1.390 +	test( r == KErrNone );
   1.391 +
   1.392 +//	For each SBlockMapInfo object in RArray map
   1.393 +	for ( c = 0; c < map.Count(); c++ )
   1.394 +		{
   1.395 +		myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr();
   1.396 +		granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry);
   1.397 +
   1.398 +		TInt length;
   1.399 +		if ( aEndPos == -1 )
   1.400 +			{
   1.401 +			length = size - startPos;
   1.402 +			aEndPos = size;
   1.403 +			}
   1.404 +		else
   1.405 +			length = aEndPos - startPos;
   1.406 +		
   1.407 +		for ( TInt c2 = 1; c2 <= granularity; c2++)
   1.408 +			{
   1.409 +			myCounter = 0;
   1.410 +			miniLength = length;
   1.411 +			do
   1.412 +				{
   1.413 +				if ( miniLength >= KReadBufferSize )
   1.414 +					{
   1.415 +					testFile.Read( startPos + amountRead, buf1, KReadBufferSize );
   1.416 +					localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, KReadBufferSize, buf2);
   1.417 +					r = buf1.Compare( buf2 );
   1.418 +					test( r == 0 );
   1.419 +					buf1.Zero();
   1.420 +					buf2.Zero();
   1.421 +					myCounter++;
   1.422 +					miniLength -= KReadBufferSize;
   1.423 +					length -= KReadBufferSize;
   1.424 +					amountRead += KReadBufferSize;
   1.425 +					}
   1.426 +				else
   1.427 +					{
   1.428 +					testFile.Read(startPos + amountRead, buf1, miniLength);
   1.429 +					localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, miniLength, buf2);
   1.430 +					r = buf1.Compare( buf2 );
   1.431 +					test( r == 0 );
   1.432 +					amountRead += miniLength;
   1.433 +					length -= miniLength;
   1.434 +					miniLength = 0;
   1.435 +					}
   1.436 +				} while ( miniLength != 0 && length != 0);
   1.437 +			myBlockMapEntry++;
   1.438 +			}
   1.439 +		}
   1.440 +	map.Close();
   1.441 +
   1.442 +	testFile.Close();
   1.443 +	return bmErr;
   1.444 +	}
   1.445 +
   1.446 +LOCAL_C TInt TestBlockMapRamFAT(TInt64 aStartPos, TInt64 aEndPos)
   1.447 +//
   1.448 +// Test BlockMap retrieval on RAM FAT.
   1.449 +//
   1.450 +	{
   1.451 +	CFileMan* fMan=CFileMan::NewL(TheFs);
   1.452 +	test(fMan!=NULL);
   1.453 +	TFileName name(KDriveBase);
   1.454 +	name[0] = TText('A' + RamFatDrive);
   1.455 +	name.Append( KTestFileName );
   1.456 +
   1.457 +	TInt r = fMan->Attribs(name, 0, KEntryAttReadOnly, 0);
   1.458 +	r = fMan->Delete(name);
   1.459 +
   1.460 +	r = fMan->Copy(KTestFile, name);
   1.461 +	test( r == KErrNone  || r == KErrAlreadyExists);
   1.462 +
   1.463 +	TInt localDriveNum = 0;
   1.464 +	RFile testFile;
   1.465 +	r = testFile.Open( TheFs, name, EFileRead );
   1.466 +	test( r == KErrNone );
   1.467 +	
   1.468 +	RArray<SBlockMapInfo> map;	// From RArray<TBlockMapEntry> map; to RArray<SBlockMapInfo> map;
   1.469 +	SBlockMapInfo info;
   1.470 +	TInt counter = 0;
   1.471 +	TInt startPos = aStartPos;
   1.472 +	TInt bmErr;
   1.473 +
   1.474 +	// Store SBlockMapInfo objects in map:RArray until KErrCompletion is returned.
   1.475 +	do
   1.476 +		{
   1.477 +		bmErr = testFile.BlockMap(info, aStartPos, aEndPos, ETestDebug);
   1.478 +		if (bmErr != 0 && bmErr != KErrCompletion)
   1.479 +			{
   1.480 +			map.Close();
   1.481 +			testFile.Close();
   1.482 +			r = fMan->Attribs(name, 0, KEntryAttReadOnly, 0);
   1.483 +			test( r == KErrNone );
   1.484 +			r = fMan->Delete(name);
   1.485 +			test( r == KErrNone );
   1.486 +			delete fMan;
   1.487 +			return bmErr;
   1.488 +			}
   1.489 +		map.Append(info); 
   1.490 +		if (counter++ == 0)
   1.491 +			localDriveNum = info.iLocalDriveNumber;
   1.492 +		} while ( bmErr == 0 && bmErr != KErrCompletion );
   1.493 +	test( bmErr == KErrCompletion );
   1.494 +	TInt granularity;
   1.495 +
   1.496 +	TInt size;
   1.497 +	r = testFile.Size(size);
   1.498 +	test( r == KErrNone );
   1.499 +
   1.500 +	TBuf8<KReadBufferSize> buf1;
   1.501 +	TBuf8<KReadBufferSize> buf2;
   1.502 +	
   1.503 +	TBool changed;	
   1.504 +	TBusLocalDrive localDrive;
   1.505 +
   1.506 +	UserSvr::UnlockRamDrive();
   1.507 +
   1.508 +	TBlockMapEntry* myBlockMapEntry;
   1.509 +	TInt myCounter = 0;
   1.510 +	TInt totalSegments = 0;
   1.511 +	TInt remainder = 0;
   1.512 +	TInt miniLength = 0;
   1.513 +	TInt amountRead = 0;
   1.514 +
   1.515 +	TInt c;
   1.516 +	for ( c = 0; c < map.Count(); c++ )
   1.517 +		{
   1.518 +		myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr();
   1.519 +		granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry);
   1.520 +		totalSegments += granularity;
   1.521 +		}
   1.522 +
   1.523 +	const TInt KTotalSegments = totalSegments;
   1.524 +
   1.525 +	r = localDrive.Connect( localDriveNum, changed );
   1.526 +	test( r == KErrNone );
   1.527 +
   1.528 +//	For each SBlockMapInfo object in RArray map
   1.529 +	for ( c = 0; c < map.Count(); c++ )
   1.530 +		{
   1.531 +		myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr();
   1.532 +		granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry);
   1.533 +
   1.534 +		TInt length;
   1.535 +		if ( aEndPos == -1 )
   1.536 +			{
   1.537 +			length = size - startPos;
   1.538 +			aEndPos = size;
   1.539 +			}
   1.540 +		else
   1.541 +			length = aEndPos - startPos;
   1.542 +	
   1.543 +		for ( TInt c2 = 1; c2 <= granularity; c2++)
   1.544 +			{
   1.545 +			myCounter = 0;
   1.546 +			if ( c2 == KTotalSegments && aEndPos%map[c].iBlockGranularity != 0 )
   1.547 +				remainder = map[c].iBlockGranularity - aEndPos%map[c].iBlockGranularity;
   1.548 +			else
   1.549 +				remainder = 0;
   1.550 +			miniLength = map[c].iBlockGranularity*myBlockMapEntry->iNumberOfBlocks - remainder - (c2 == 1?map[c].iBlockStartOffset:0);
   1.551 +			do
   1.552 +				{
   1.553 +				if ( miniLength >= KReadBufferSize )
   1.554 +					{
   1.555 +					testFile.Read( startPos + amountRead, buf1, KReadBufferSize );
   1.556 +					localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, KReadBufferSize, buf2);
   1.557 +					r = buf1.Compare( buf2 );
   1.558 +					test( r == 0 );
   1.559 +					buf1.Zero();
   1.560 +					buf2.Zero();
   1.561 +					myCounter++;
   1.562 +					miniLength -= KReadBufferSize;
   1.563 +					length -= KReadBufferSize;
   1.564 +					amountRead += KReadBufferSize;
   1.565 +					}
   1.566 +				else
   1.567 +					{
   1.568 +					testFile.Read(startPos + amountRead, buf1, miniLength);
   1.569 +					localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, miniLength, buf2);
   1.570 +					r = buf1.Compare( buf2 );
   1.571 +					test( r == 0 );
   1.572 +					amountRead += miniLength;
   1.573 +					length -= miniLength;
   1.574 +					miniLength = 0;
   1.575 +					}
   1.576 +				} while ( miniLength != 0 && length != 0);
   1.577 +			myBlockMapEntry++;
   1.578 +			}
   1.579 +		}
   1.580 +	map.Close();
   1.581 +
   1.582 +	testFile.Close();
   1.583 +	r=fMan->Attribs(name, 0, KEntryAttReadOnly, 0);
   1.584 +	test( r == KErrNone );
   1.585 +	r = fMan->Delete(name);
   1.586 +	test( r == KErrNone );
   1.587 +	delete fMan;
   1.588 +	return bmErr;
   1.589 +	}
   1.590 +
   1.591 +LOCAL_C TInt TestBlockMapRamFAT2(TInt64 aStartPos, TInt64 aEndPos)
   1.592 +//
   1.593 +// Test BlockMap retrieval on Ram FAT.
   1.594 +//
   1.595 +	{
   1.596 +	CFileMan* fMan=CFileMan::NewL(TheFs);
   1.597 +	test(fMan!=NULL);
   1.598 +	TFileName name(KDriveBase);
   1.599 +	name[0] = TText('A' + RamFatDrive);
   1.600 +	name.Append( KTestFileName );
   1.601 +
   1.602 +	TInt r = fMan->Attribs(name, 0, KEntryAttReadOnly, 0);
   1.603 +	r = fMan->Delete(name);
   1.604 +
   1.605 +	r = fMan->Copy(KTestFile, name);
   1.606 +	test( r == KErrNone  || r == KErrAlreadyExists);
   1.607 +
   1.608 +	RFile testFile;
   1.609 +	r = testFile.Open( TheFs, name, EFileRead );
   1.610 +	test( r == KErrNone );
   1.611 +	
   1.612 +	RArray<SBlockMapInfo> map;	// From RArray<TBlockMapEntry> map; to RArray<SBlockMapInfo> map;
   1.613 +	SBlockMapInfo info;
   1.614 +
   1.615 +	TInt bmErr;
   1.616 +	bmErr = testFile.BlockMap(info, aStartPos, aEndPos, EBlockMapUsagePaging);
   1.617 +
   1.618 +	map.Close();
   1.619 +
   1.620 +	testFile.Close();
   1.621 +	r = fMan->Attribs(name, 0, KEntryAttReadOnly, 0);
   1.622 +	test( r == KErrNone );
   1.623 +	r = fMan->Delete(name);
   1.624 +	test( r == KErrNone );
   1.625 +	delete fMan;
   1.626 +	return bmErr;
   1.627 +	}
   1.628 +
   1.629 +LOCAL_C TInt TestBlockMapRemovableFAT(TInt64 aStartPos, TInt64 aEndPos)
   1.630 +//
   1.631 +// Test BlockMap retrieval on Removable FAT.
   1.632 +//
   1.633 +	{
   1.634 +	CFileMan* fMan=CFileMan::NewL(TheFs);
   1.635 +	test(fMan!=NULL);
   1.636 +	TFileName name(KDriveBase);
   1.637 +	name[0] = TText('A' + RemovableFatDrive);
   1.638 +	name.Append( KTestFileName );
   1.639 +
   1.640 +	TInt r=fMan->Copy(KTestFile, name);
   1.641 +	test( r == KErrNone  || r == KErrAlreadyExists);
   1.642 +
   1.643 +	RFile testFile;
   1.644 +	r = testFile.Open( TheFs, name, EFileRead );
   1.645 +	test( r == KErrNone );
   1.646 +	
   1.647 +	RArray<SBlockMapInfo> map;	// From RArray<TBlockMapEntry> map; to RArray<SBlockMapInfo> map;
   1.648 +	SBlockMapInfo info;
   1.649 +	TInt bmErr = testFile.BlockMap(info, aStartPos, aEndPos, Pageable?EBlockMapUsagePaging:ETestDebug);
   1.650 +	map.Close();
   1.651 +
   1.652 +	testFile.Close();
   1.653 +	r=fMan->Attribs(name, 0, KEntryAttReadOnly, 0);
   1.654 +	test( r == KErrNone );
   1.655 +	r = fMan->Delete(name);
   1.656 +	test( r == KErrNone );
   1.657 +	delete fMan;
   1.658 +	return bmErr;
   1.659 +	}
   1.660 +
   1.661 +LOCAL_C TInt TestBlockMapInternalRemovableFAT(TInt64 aStartPos, TInt64 aEndPos)
   1.662 +//
   1.663 +// Test BlockMap retrieval on internal removable FAT.
   1.664 +//
   1.665 +	{
   1.666 +	CFileMan* fMan=CFileMan::NewL(TheFs);
   1.667 +	test(fMan!=NULL);
   1.668 +	TFileName name(KDriveBase);
   1.669 +	name[0] = TText('A' + RamFatDrive);
   1.670 +	name.Append( KTestFileName );
   1.671 +
   1.672 +	TInt r=fMan->Copy(KTestFile, name);
   1.673 +	test( r == KErrNone  || r == KErrAlreadyExists);
   1.674 +
   1.675 +	TInt localDriveNum = 0;
   1.676 +	RFile testFile;
   1.677 +	r = testFile.Open( TheFs, name, EFileRead );
   1.678 +	test( r == KErrNone );
   1.679 +	
   1.680 +	RArray<SBlockMapInfo> map;	// From RArray<TBlockMapEntry> map; to RArray<SBlockMapInfo> map;
   1.681 +	SBlockMapInfo info;
   1.682 +	TInt counter = 0;
   1.683 +	TInt startPos = aStartPos;
   1.684 +	TInt bmErr;
   1.685 +
   1.686 +	// Store SBlockMapInfo objects in map:RArray until KErrCompletion is returned.
   1.687 +	do
   1.688 +		{
   1.689 +		bmErr = testFile.BlockMap(info, aStartPos, aEndPos, ETestDebug);
   1.690 +		if (bmErr != 0 && bmErr != KErrCompletion)
   1.691 +			{
   1.692 +			map.Close();
   1.693 +			testFile.Close();
   1.694 +			r = fMan->Attribs(name, 0, KEntryAttReadOnly, 0);
   1.695 +			test( r == KErrNone );
   1.696 +			r = fMan->Delete(name);
   1.697 +			test( r == KErrNone );
   1.698 +			delete fMan;
   1.699 +			return bmErr;
   1.700 +			}
   1.701 +		map.Append(info); 
   1.702 +		if (counter++ == 0)
   1.703 +			localDriveNum = info.iLocalDriveNumber;
   1.704 +		} while ( bmErr == 0 && bmErr != KErrCompletion );
   1.705 +	test( bmErr == KErrCompletion );
   1.706 +	TInt granularity;
   1.707 +
   1.708 +	TInt size;
   1.709 +	r = testFile.Size(size);
   1.710 +	test( r == KErrNone );
   1.711 +
   1.712 +	TBuf8<KReadBufferSize> buf1;
   1.713 +	TBuf8<KReadBufferSize> buf2;
   1.714 +	
   1.715 +	TBool changed;	
   1.716 +	TBusLocalDrive localDrive;
   1.717 +
   1.718 +	UserSvr::UnlockRamDrive();
   1.719 +
   1.720 +	TBlockMapEntry* myBlockMapEntry;
   1.721 +	TInt myCounter = 0;
   1.722 +	TInt totalSegments = 0;
   1.723 +	TInt remainder = 0;
   1.724 +	TInt miniLength = 0;
   1.725 +	TInt amountRead = 0;
   1.726 +
   1.727 +	TInt c;
   1.728 +	for ( c = 0; c < map.Count(); c++ )
   1.729 +		{
   1.730 +		myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr();
   1.731 +		granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry);
   1.732 +		totalSegments += granularity;
   1.733 +		}
   1.734 +
   1.735 +	const TInt KTotalSegments = totalSegments;
   1.736 +
   1.737 +	r = localDrive.Connect( localDriveNum, changed );
   1.738 +	test( r == KErrNone );
   1.739 +
   1.740 +//	For each SBlockMapInfo object in RArray map
   1.741 +	for ( c = 0; c < map.Count(); c++ )
   1.742 +		{
   1.743 +		myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr();
   1.744 +		granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry);
   1.745 +
   1.746 +		TInt length;
   1.747 +		if ( aEndPos == -1 )
   1.748 +			{
   1.749 +			length = size - startPos;
   1.750 +			aEndPos = size;
   1.751 +			}
   1.752 +		else
   1.753 +			length = aEndPos - startPos;
   1.754 +		
   1.755 +		for ( TInt c2 = 1; c2 <= granularity; c2++)
   1.756 +			{
   1.757 +			myCounter = 0;
   1.758 +			if ( c2 == KTotalSegments && aEndPos%map[c].iBlockGranularity != 0 )
   1.759 +				remainder = map[c].iBlockGranularity - aEndPos%map[c].iBlockGranularity;
   1.760 +			else
   1.761 +				remainder = 0;
   1.762 +			miniLength = map[c].iBlockGranularity*myBlockMapEntry->iNumberOfBlocks - remainder - (c2 == 1?map[c].iBlockStartOffset:0);
   1.763 +			do
   1.764 +				{
   1.765 +				if ( miniLength >= KReadBufferSize )
   1.766 +					{
   1.767 +					testFile.Read( startPos + amountRead, buf1, KReadBufferSize );
   1.768 +					localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, KReadBufferSize, buf2);
   1.769 +					r = buf1.Compare( buf2 );
   1.770 +					test( r == 0 );
   1.771 +					buf1.Zero();
   1.772 +					buf2.Zero();
   1.773 +					myCounter++;
   1.774 +					miniLength -= KReadBufferSize;
   1.775 +					length -= KReadBufferSize;
   1.776 +					amountRead += KReadBufferSize;
   1.777 +					}
   1.778 +				else
   1.779 +					{
   1.780 +					testFile.Read(startPos + amountRead, buf1, miniLength);
   1.781 +					localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, miniLength, buf2);
   1.782 +					r = buf1.Compare( buf2 );
   1.783 +					test( r == 0 );
   1.784 +					amountRead += miniLength;
   1.785 +					length -= miniLength;
   1.786 +					miniLength = 0;
   1.787 +					}
   1.788 +				} while ( miniLength != 0 && length != 0);
   1.789 +			myBlockMapEntry++;
   1.790 +			}
   1.791 +		}
   1.792 +	map.Close();
   1.793 +
   1.794 +	testFile.Close();
   1.795 +	r=fMan->Attribs(name, 0, KEntryAttReadOnly, 0);
   1.796 +	test( r == KErrNone );
   1.797 +	r = fMan->Delete(name);
   1.798 +	test( r == KErrNone );
   1.799 +	delete fMan;
   1.800 +	return bmErr;
   1.801 +	}
   1.802 +
   1.803 +LOCAL_C TInt TestBlockMapFragmented(DriveType aDriveType, TInt64 aStartPos, TInt64 aEndPos)
   1.804 +	{
   1.805 +	CFileMan* fMan=CFileMan::NewL(TheFs);
   1.806 +	test(fMan!=NULL);
   1.807 +	TFileName name(KDriveBase);
   1.808 +	if (aDriveType==EDriveRam)
   1.809 +		name[0] = TText('A' + RamFatDrive);
   1.810 +	else if (aDriveType==EDriveRemovable)
   1.811 +		name[0] = TText('A' + RemovableFatDrive);
   1.812 +	else if (aDriveType==EDriveNand)
   1.813 +		name[0] = TText('A' + NandDrive);
   1.814 +	else 
   1.815 +		name[0] = TText('A' + InternalRemovableFatDrive);
   1.816 +	name.Append( KFragmentedFileName1 );
   1.817 +	TInt localDriveNum = 0;
   1.818 +	RFile testFile;
   1.819 +	TInt r = testFile.Open( TheFs, name, EFileRead );
   1.820 +	test( r == KErrNone );
   1.821 +	RArray<SBlockMapInfo> map;	// From RArray<TBlockMapEntry> map; to RArray<SBlockMapInfo> map;
   1.822 +	SBlockMapInfo info;
   1.823 +	TInt counter = 0;
   1.824 +	TInt startPos = aStartPos;
   1.825 +	TInt bmErr;
   1.826 +
   1.827 +	// Store SBlockMapInfo objects in map:RArray until KErrCompletion is returned.
   1.828 +	do
   1.829 +		{
   1.830 +		bmErr = testFile.BlockMap(info, aStartPos, aEndPos, ETestDebug);
   1.831 +		if (bmErr != 0 && bmErr != KErrCompletion)
   1.832 +			{
   1.833 +			map.Close();
   1.834 +			testFile.Close();
   1.835 +			if ( Finished )
   1.836 +				{
   1.837 +				r = fMan->Attribs(name, 0, KEntryAttReadOnly, 0);
   1.838 +				test( r == KErrNone );
   1.839 +				r = fMan->Delete(name);
   1.840 +				test( r == KErrNone );
   1.841 +				}
   1.842 +			delete fMan;
   1.843 +			return bmErr;
   1.844 +			}
   1.845 +		map.Append(info); 
   1.846 +		if (counter++ == 0)
   1.847 +			localDriveNum = info.iLocalDriveNumber;
   1.848 +		} while ( bmErr == 0 && bmErr != KErrCompletion );
   1.849 +	test( bmErr == KErrCompletion );
   1.850 +	TInt granularity;
   1.851 +	TInt size;
   1.852 +	r = testFile.Size(size);
   1.853 +	test( r == KErrNone );
   1.854 +
   1.855 +	TBuf8<KReadBufferSize> buf1;
   1.856 +	TBuf8<KReadBufferSize> buf2;
   1.857 +	
   1.858 +	TBool changed;	
   1.859 +	TBusLocalDrive localDrive;
   1.860 +
   1.861 +	UserSvr::UnlockRamDrive();
   1.862 +
   1.863 +	TBlockMapEntry* myBlockMapEntry;
   1.864 +	TInt myCounter = 0;
   1.865 +	TInt totalSegments = 0;
   1.866 +	TInt remainder = 0;
   1.867 +	TInt miniLength = 0;
   1.868 +	TInt amountRead = 0;
   1.869 +
   1.870 +	TInt c;
   1.871 +	for ( c = 0; c < map.Count(); c++ )
   1.872 +		{
   1.873 +		myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr();
   1.874 +		granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry);
   1.875 +		totalSegments += granularity;
   1.876 +		}
   1.877 +
   1.878 +	const TInt KTotalSegments = totalSegments;
   1.879 +	r = localDrive.Connect( localDriveNum, changed );
   1.880 +	test( r == KErrNone );
   1.881 +
   1.882 +//	For each SBlockMapInfo object in RArray map
   1.883 +	for ( c = 0; c < map.Count(); c++ )
   1.884 +		{
   1.885 +		myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr();
   1.886 +		granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry);
   1.887 +
   1.888 +		TInt length;
   1.889 +		if ( aEndPos == -1 )
   1.890 +			{
   1.891 +			length = size - startPos;
   1.892 +			aEndPos = size;
   1.893 +			}
   1.894 +		else
   1.895 +			length = aEndPos - startPos;
   1.896 +		
   1.897 +		for ( TInt c2 = 1; c2 <= granularity; c2++)
   1.898 +			{
   1.899 +			myCounter = 0;
   1.900 +			if ( c2 == KTotalSegments && aEndPos%map[c].iBlockGranularity != 0 )
   1.901 +				remainder = map[c].iBlockGranularity - aEndPos%map[c].iBlockGranularity;
   1.902 +			else
   1.903 +				remainder = 0;
   1.904 +			miniLength = map[c].iBlockGranularity*myBlockMapEntry->iNumberOfBlocks - remainder - (c2 == 1?map[c].iBlockStartOffset:0);
   1.905 +			do
   1.906 +				{
   1.907 +				if ( miniLength >= KReadBufferSize )
   1.908 +					{
   1.909 +					testFile.Read( startPos + amountRead, buf1, KReadBufferSize );
   1.910 +					localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, KReadBufferSize, buf2);
   1.911 +					r = buf1.Compare( buf2 );
   1.912 +					test( r == 0 );
   1.913 +					buf1.Zero();
   1.914 +					buf2.Zero();
   1.915 +					myCounter++;
   1.916 +					miniLength -= KReadBufferSize;
   1.917 +					length -= KReadBufferSize;
   1.918 +					amountRead += KReadBufferSize;
   1.919 +					}
   1.920 +				else
   1.921 +					{
   1.922 +					testFile.Read(startPos + amountRead, buf1, miniLength );
   1.923 +					localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, miniLength, buf2);
   1.924 +					r = buf1.Compare( buf2 );
   1.925 +					test( r == 0 );
   1.926 +					amountRead += miniLength;
   1.927 +					length -= miniLength;
   1.928 +					miniLength = 0;
   1.929 +					}
   1.930 +				} while ( miniLength != 0 && length != 0);
   1.931 +			myBlockMapEntry++;
   1.932 +			}
   1.933 +		}
   1.934 +	map.Close();
   1.935 +
   1.936 +	testFile.Close();
   1.937 +	if ( Finished )
   1.938 +		{
   1.939 +		r=fMan->Attribs(name, 0, KEntryAttReadOnly, 0);
   1.940 +		test( r == KErrNone );
   1.941 +		r = fMan->Delete(name);
   1.942 +		test( r == KErrNone );
   1.943 +		}
   1.944 +	delete fMan;
   1.945 +	return bmErr;	
   1.946 +	}
   1.947 +
   1.948 +LOCAL_C void GenerateFragmentedFiles(DriveType aDriveType)
   1.949 +	{
   1.950 +	TInt r;
   1.951 +	TFileName name1(KDriveBase);
   1.952 +	if (aDriveType==EDriveRam)
   1.953 +		name1[0] = TText('A' + RamFatDrive);
   1.954 +	else if (aDriveType==EDriveRemovable)
   1.955 +		name1[0] = TText('A' + RemovableFatDrive);
   1.956 +	else if (aDriveType==EDriveNand)
   1.957 +		name1[0] = TText('A' + NandDrive);
   1.958 +	else 
   1.959 +		name1[0] = TText('A' + InternalRemovableFatDrive);
   1.960 +	name1.Append( KFragmentedFileName1 );
   1.961 +	RFile file1;
   1.962 +	r = file1.Create(TheFs, name1, EFileWrite);
   1.963 +	test( r == KErrNone );
   1.964 +	file1.Close();
   1.965 +
   1.966 +	TFileName name2(KDriveBase);
   1.967 +	if (aDriveType==EDriveRam)
   1.968 +		name2[0] = TText('A' + RamFatDrive);
   1.969 +	else if (aDriveType==EDriveRemovable)
   1.970 +		name2[0] = TText('A' + RemovableFatDrive);
   1.971 +	else if (aDriveType==EDriveNand)
   1.972 +		name2[0] = TText('A' + NandDrive);
   1.973 +	else 
   1.974 +		name2[0] = TText('A' + InternalRemovableFatDrive);
   1.975 +	name2.Append( KFragmentedFileName2 );
   1.976 +	RFile file2;
   1.977 +	r = file2.Create(TheFs, name2, EFileWrite);
   1.978 +	test( r == KErrNone );
   1.979 +	file2.Close();
   1.980 +	TInt64 randomSeed;
   1.981 +	TBuf8<KMaxFragmentSize> tempBuf;	
   1.982 +	TUint8 *buf;
   1.983 +	TInt fileSize = 0;
   1.984 +	TInt fragmentSize;
   1.985 +	TInt randomLength;
   1.986 +	TInt pos1;
   1.987 +	TInt pos2;
   1.988 +	TInt mycount = 0;
   1.989 +	do	
   1.990 +		{
   1.991 +		fragmentSize = 0;
   1.992 +		pos1 = 0;
   1.993 +		pos2 = 0;
   1.994 +		buf = (TUint8*) tempBuf.Ptr();
   1.995 +		tempBuf.Zero();
   1.996 +		randomLength = Math::Random() % KMaxFragmentSize;
   1.997 +		randomSeed = Math::Random();
   1.998 +		tempBuf.SetLength(randomLength);
   1.999 +
  1.1000 +		while (randomLength-- && fragmentSize++ < KMaxFragmentSize && fileSize++ < KMaxFileSize)
  1.1001 +			{
  1.1002 +			*buf++ = (TUint8)('A' + (Math::Rand(randomSeed) % ('Z' - 'A')));
  1.1003 +			}
  1.1004 +		r = file1.Open( TheFs, name1, EFileWrite );
  1.1005 +		test( r == KErrNone );
  1.1006 +		r = file1.Seek( ESeekEnd, pos1 );
  1.1007 +		test( r == KErrNone );
  1.1008 +		r = file1.Write( pos1, tempBuf );
  1.1009 +		test( r == KErrNone );
  1.1010 +		r = file1.Flush();
  1.1011 +		test( r == KErrNone );		
  1.1012 +		file1.Close();
  1.1013 +		if ( mycount++ < 6 )
  1.1014 +			{
  1.1015 +			r = file2.Open( TheFs, name2, EFileWrite );
  1.1016 +			test( r == KErrNone );
  1.1017 +			r = file2.Seek( ESeekEnd, pos2 );
  1.1018 +			test( r == KErrNone );
  1.1019 +			r = file2.Write( pos2, tempBuf );
  1.1020 +			test( r == KErrNone );
  1.1021 +			r = file2.Flush();
  1.1022 +			test( r == KErrNone );
  1.1023 +			file2.Close();
  1.1024 +			}
  1.1025 +		} while ( fileSize < KMaxFileSize );
  1.1026 +	CFileMan* fMan=CFileMan::NewL(TheFs);
  1.1027 +	test(fMan!=NULL);
  1.1028 +	r = fMan->Delete(name2);
  1.1029 +	test( r == KErrNone );
  1.1030 +	delete fMan;
  1.1031 +	}
  1.1032 +
  1.1033 +LOCAL_C void FindDrive(DriveType aDriveType)
  1.1034 +	{
  1.1035 +	TInt i;
  1.1036 +	TInt c = 0;
  1.1037 +	for( i = EDriveA; i < EDriveZ; i++ )
  1.1038 +		{
  1.1039 +		TDriveInfo info;
  1.1040 +		TInt r = TheFs.Drive(info, i);
  1.1041 +		if ( r != KErrNone )
  1.1042 +			continue;
  1.1043 +		test( r == KErrNone );
  1.1044 +		if ( aDriveType == EDriveNand )	
  1.1045 +			{
  1.1046 +			c++ == 0 ? test.Printf( _L("Searching for NAND drive.")) : test.Printf( _L("."));
  1.1047 +			if ( info.iType == EMediaNANDFlash && ((info.iMediaAtt & KMediaAttWriteProtected) == 0) )
  1.1048 +				{
  1.1049 +				if ( info.iDriveAtt & KDriveAttPageable )
  1.1050 +					Pageable = ETrue;
  1.1051 +				NandDrive = i;
  1.1052 +				test.Printf( _L("Found NAND drive: %d\n"), NandDrive );
  1.1053 +				break;
  1.1054 +				}
  1.1055 +			}
  1.1056 +		else if ( aDriveType == EDriveRam )
  1.1057 +			{
  1.1058 +			c++ == 0 ? test.Printf( _L("Searching for RAM FAT drive.")) : test.Printf( _L("."));
  1.1059 +			if ( (info.iType == EMediaRam) && ( info.iDriveAtt == (KDriveAttLocal|KDriveAttInternal) ) && ( info.iMediaAtt == (KMediaAttVariableSize|KMediaAttFormattable) ) )
  1.1060 +				{
  1.1061 +				if ( info.iDriveAtt & KDriveAttPageable )
  1.1062 +					Pageable = ETrue;
  1.1063 +				RamFatDrive = i;
  1.1064 +				test.Printf( _L("Found RAM FAT drive: %d\n"), RamFatDrive );
  1.1065 +				break;
  1.1066 +				}
  1.1067 +			}
  1.1068 +		else if ( aDriveType == EDriveRemovable )
  1.1069 +			{
  1.1070 +			c++ == 0 ? test.Printf( _L("Searching for removable FAT drive.")) : test.Printf( _L("."));
  1.1071 +			if ( info.iType == EMediaHardDisk && ( info.iDriveAtt == (KDriveAttLocal|KDriveAttRemovable) ) )
  1.1072 +				{
  1.1073 +				if ( info.iDriveAtt & KDriveAttPageable )
  1.1074 +					Pageable = ETrue;
  1.1075 +				RemovableFatDrive = i;
  1.1076 +				test.Printf( _L("Found removable FAT drive: %d\n"), RemovableFatDrive );
  1.1077 +				break;
  1.1078 +				}
  1.1079 +			}
  1.1080 +		else if ( aDriveType == EDriveInternalRemovable )
  1.1081 +			{
  1.1082 +			c++ == 0 ? test.Printf( _L("Searching for internal removable FAT drive.")) : test.Printf( _L("."));
  1.1083 +			if ( info.iType == EMediaHardDisk && ( info.iDriveAtt == (KDriveAttLocal|KDriveAttInternal) ) )
  1.1084 +				{
  1.1085 +				if ( info.iDriveAtt & KDriveAttPageable )
  1.1086 +					Pageable = ETrue;
  1.1087 +				InternalRemovableFatDrive = i;
  1.1088 +				test.Printf( _L("Found internal removable FAT drive: %d\n"), InternalRemovableFatDrive );
  1.1089 +				break;
  1.1090 +				}
  1.1091 +			}
  1.1092 +		}
  1.1093 +		if ( i == EDriveZ )
  1.1094 +			{
  1.1095 +			switch(aDriveType)
  1.1096 +				{
  1.1097 +				case EDriveNand:
  1.1098 +					test.Printf( _L("NAND drive not found.\n") );
  1.1099 +					break;
  1.1100 +				case EDriveRam:
  1.1101 +					test.Printf( _L("RAM FAT drive not found.\n") );
  1.1102 +					break;
  1.1103 +				case EDriveRemovable:
  1.1104 +					test.Printf( _L("Removable FAT drive not found.\n") );
  1.1105 +					break;
  1.1106 +				case EDriveInternalRemovable:
  1.1107 +					test.Printf( _L("Internal removable FAT drive not found.\n") );
  1.1108 +					break;
  1.1109 +				default:
  1.1110 +					test.Printf( _L("Drive not found.\n") );
  1.1111 +				}			
  1.1112 +			}
  1.1113 +	}
  1.1114 +
  1.1115 +//************************
  1.1116 +// Entry point
  1.1117 +
  1.1118 +GLDEF_C void CallTestsL(void)
  1.1119 +	{
  1.1120 +	test.Title(); 
  1.1121 +	test.Start( _L("BlockMap Test\n") );
  1.1122 +
  1.1123 +	TInt testFileSize = 0;
  1.1124 +	RFile testFile;
  1.1125 +	TInt r = testFile.Open(TheFs, KTestFile, EFileRead);
  1.1126 +	test(r==KErrNone);
  1.1127 +	r = testFile.Size(testFileSize);
  1.1128 +	test(r==KErrNone);
  1.1129 +	test(testFileSize>16384);
  1.1130 +	testFile.Close();
  1.1131 +
  1.1132 +	if ( gDriveToTest == 'C' )
  1.1133 +		{
  1.1134 +		TInt value;
  1.1135 +		r = HAL::Get( HAL::EMachineUid, value );
  1.1136 +		test( r == KErrNone );
  1.1137 +		if ( value != HAL::EMachineUid_Lubbock )	// Lubbock cannot run FindDrive as it doesn't support the NAND API
  1.1138 +			{
  1.1139 +			test.Next(_L("Test BlockMap retrieval on NAND FAT."));
  1.1140 +			FindDrive(EDriveNand);
  1.1141 +			if ( NandDrive > -1 )	// not finding a NAND drive isn't an error as only NAND builds have one
  1.1142 +				{
  1.1143 +				r = TestBlockMapNandFATUserData(0, -1);
  1.1144 +				test( r == KErrCompletion );
  1.1145 +				r = TestBlockMapNandFATUserData(1024, 4096);
  1.1146 +				test( r == KErrCompletion );
  1.1147 +				r = TestBlockMapNandFATUserData(1020, 4100);
  1.1148 +				test( r == KErrCompletion );
  1.1149 +				r = TestBlockMapNandFATUserData(1024, 4100);
  1.1150 +				test( r == KErrCompletion );
  1.1151 +				r = TestBlockMapNandFATUserData(1020, 4096);
  1.1152 +				test( r == KErrCompletion );
  1.1153 +				r = TestBlockMapNandFATUserData(1025, 1200);
  1.1154 +				test( r == KErrCompletion );
  1.1155 +				r = TestBlockMapNandFATUserData(0, testFileSize+100);
  1.1156 +				test( r == KErrArgument );
  1.1157 +				r = TestBlockMapNandFATUserData(-5, -1);
  1.1158 +				test( r == KErrArgument );
  1.1159 +				r = TestBlockMapNandFATUserData(-5, testFileSize+100);
  1.1160 +				test( r == KErrArgument );
  1.1161 +				r = TestBlockMapNandFATUserData(0, 0);
  1.1162 +				test( r == KErrArgument );
  1.1163 +				r = TestBlockMapNandFATUserData(testFileSize, -1);
  1.1164 +				test( r == KErrArgument );
  1.1165 +				r = TestBlockMapNandFATUserData(0, -1);
  1.1166 +				test( r == KErrCompletion );
  1.1167 +				r = TestBlockMapNandFATUserData(2000, 2001);
  1.1168 +				test( r == KErrCompletion );
  1.1169 +				r = TestBlockMapNandFATUserData(0, 0);
  1.1170 +				test( r == KErrArgument );
  1.1171 +				r = TestBlockMapNandFATUserData(2000, 2000);
  1.1172 +				test( r == KErrArgument );
  1.1173 +				r = TestBlockMapNandFATUserData(2048, 2048);
  1.1174 +				test( r == KErrArgument );
  1.1175 +				test.Printf(_L("Generating Fragmented File..."));
  1.1176 +				GenerateFragmentedFiles(EDriveNand);
  1.1177 +				test.Printf(_L("Done!\n"));
  1.1178 +				test.Next(_L("Test BlockMap retrieval on NAND FAT (User area) (fragmented)."));	
  1.1179 +				r = TestBlockMapFragmented(EDriveNand, 0, -1);
  1.1180 +				test( r == KErrCompletion );
  1.1181 +				r = TestBlockMapFragmented(EDriveNand, 1024, 4096);
  1.1182 +				test( r == KErrCompletion );
  1.1183 +				r = TestBlockMapFragmented(EDriveNand, 1020, 4100);
  1.1184 +				test( r == KErrCompletion );
  1.1185 +				r = TestBlockMapFragmented(EDriveNand, 1024, 4100);
  1.1186 +				test( r == KErrCompletion );
  1.1187 +				r = TestBlockMapFragmented(EDriveNand, 1020, 4096);
  1.1188 +				test( r == KErrCompletion );
  1.1189 +				r = TestBlockMapFragmented(EDriveNand, 1025, 1200);
  1.1190 +				test( r == KErrCompletion );
  1.1191 +				r = TestBlockMapFragmented(EDriveNand, 0, testFileSize+100);
  1.1192 +				test( r == KErrArgument );
  1.1193 +				r = TestBlockMapFragmented(EDriveNand, -5, -1);
  1.1194 +				test( r == KErrArgument );
  1.1195 +				r = TestBlockMapFragmented(EDriveNand, -5, testFileSize+100);
  1.1196 +				test( r == KErrArgument );
  1.1197 +				r = TestBlockMapFragmented(EDriveNand, 0, 0);
  1.1198 +				test( r == KErrArgument );
  1.1199 +				r = TestBlockMapFragmented(EDriveNand, testFileSize, -1);
  1.1200 +				test( r == KErrArgument );
  1.1201 +				r = TestBlockMapFragmented(EDriveNand, 0, -1);
  1.1202 +				test( r == KErrCompletion );
  1.1203 +				r = TestBlockMapFragmented(EDriveNand, 2000, 2001);
  1.1204 +				test( r == KErrCompletion );
  1.1205 +				r = TestBlockMapFragmented(EDriveNand, 0, 0);
  1.1206 +				test( r == KErrArgument );
  1.1207 +				r = TestBlockMapFragmented(EDriveNand, 2000, 2000);
  1.1208 +				test( r == KErrArgument );
  1.1209 +				Finished = ETrue;
  1.1210 +				r = TestBlockMapFragmented(EDriveNand, 2048, 2048);
  1.1211 +				test( r == KErrArgument );
  1.1212 +				test.Next(_L("Test BlockMap retrieval on NAND FAT."));	
  1.1213 +				r = TestBlockMapNandFAT(0, -1);
  1.1214 +				test( r == KErrCompletion );
  1.1215 +				r = TestBlockMapNandFAT(1024, 4096);
  1.1216 +				test( r == KErrCompletion );
  1.1217 +				r = TestBlockMapNandFAT(1020, 4100);
  1.1218 +				test( r == KErrCompletion );
  1.1219 +				r = TestBlockMapNandFAT(1024, 4100);
  1.1220 +				test( r == KErrCompletion );
  1.1221 +				r = TestBlockMapNandFAT(1020, 4096);
  1.1222 +				test( r == KErrCompletion );
  1.1223 +				r = TestBlockMapNandFAT(1025, 1200);
  1.1224 +				test( r == KErrCompletion );
  1.1225 +				r = TestBlockMapNandFAT(0, testFileSize+100);
  1.1226 +				test( r == KErrArgument );
  1.1227 +				r = TestBlockMapNandFAT(-5, -1);
  1.1228 +				test( r == KErrArgument );
  1.1229 +				r = TestBlockMapNandFAT(-5, testFileSize+100);
  1.1230 +				test( r == KErrArgument );
  1.1231 +				r = TestBlockMapNandFAT(0, 0);
  1.1232 +				test( r == KErrArgument );
  1.1233 +				r = TestBlockMapNandFAT(testFileSize, -1);
  1.1234 +				test( r == KErrArgument );
  1.1235 +				r = TestBlockMapNandFAT(0, -1);
  1.1236 +				test( r == KErrCompletion );
  1.1237 +				r = TestBlockMapNandFAT(2000, 2001);
  1.1238 +				test( r == KErrCompletion );
  1.1239 +				r = TestBlockMapNandFAT(0, 0);
  1.1240 +				test( r == KErrArgument );
  1.1241 +				r = TestBlockMapNandFAT(2000, 2000);
  1.1242 +				test( r == KErrArgument );
  1.1243 +				r = TestBlockMapNandFAT(2048, 2048);
  1.1244 +				test( r == KErrArgument );
  1.1245 +				test.Next(_L("Test BlockMap retrieval on NAND ROFS."));
  1.1246 +				r = TestBlockMapNandROFS(0, -1);
  1.1247 +				test( r == KErrCompletion );
  1.1248 +				r = TestBlockMapNandROFS(1024, 4096);
  1.1249 +				test( r == KErrCompletion );
  1.1250 +				r = TestBlockMapNandROFS(1020, 4100);
  1.1251 +				test( r == KErrCompletion );
  1.1252 +				r = TestBlockMapNandROFS(1024, 4100);
  1.1253 +				test( r == KErrCompletion );
  1.1254 +				r = TestBlockMapNandROFS(1020, 4096);
  1.1255 +				test( r == KErrCompletion );
  1.1256 +				r = TestBlockMapNandROFS(1025, 1200);
  1.1257 +				test( r == KErrCompletion );
  1.1258 +				r = TestBlockMapNandROFS(0, testFileSize+100);
  1.1259 +				test( r == KErrArgument );
  1.1260 +				r = TestBlockMapNandROFS(-5, -1);
  1.1261 +				test( r == KErrArgument );
  1.1262 +				r = TestBlockMapNandROFS(-5, testFileSize+100);
  1.1263 +				test( r == KErrArgument );
  1.1264 +				r = TestBlockMapNandROFS(0, 0);
  1.1265 +				test( r == KErrArgument );
  1.1266 +				r = TestBlockMapNandROFS(testFileSize, -1);
  1.1267 +				test( r == KErrArgument );
  1.1268 +				r = TestBlockMapNandROFS(0, -1);
  1.1269 +				test( r == KErrCompletion );
  1.1270 +				r = TestBlockMapNandROFS(2000, 2001);
  1.1271 +				test( r == KErrCompletion );
  1.1272 +				r = TestBlockMapNandROFS(0, 0);
  1.1273 +				test( r == KErrArgument );
  1.1274 +				r = TestBlockMapNandROFS(2000, 2000);
  1.1275 +				test( r == KErrArgument );
  1.1276 +				r = TestBlockMapNandROFS(2048, 2048);
  1.1277 +				test( r == KErrArgument );
  1.1278 +				test.Next(_L("Test BlockMap retrieval on RAM FAT."));
  1.1279 +				FindDrive(EDriveRam);
  1.1280 +				test( RamFatDrive > -1 );
  1.1281 +				r = TestBlockMapRamFAT(0, -1);
  1.1282 +				test( r == KErrCompletion );
  1.1283 +				r = TestBlockMapRamFAT(1024, 4096);
  1.1284 +				test( r == KErrCompletion );
  1.1285 +				r = TestBlockMapRamFAT(1020, 4100);
  1.1286 +				test( r == KErrCompletion );
  1.1287 +				r = TestBlockMapRamFAT(1024, 4100);
  1.1288 +				test( r == KErrCompletion );
  1.1289 +				r = TestBlockMapRamFAT(1020, 4096);
  1.1290 +				test( r == KErrCompletion );
  1.1291 +				r = TestBlockMapRamFAT(1025, 1200);
  1.1292 +				test( r == KErrCompletion );
  1.1293 +				r = TestBlockMapRamFAT(0, testFileSize+100);
  1.1294 +				test( r == KErrArgument );
  1.1295 +				r = TestBlockMapRamFAT(-5, -1);
  1.1296 +				test( r == KErrArgument );
  1.1297 +				r = TestBlockMapRamFAT(-5, testFileSize+100);
  1.1298 +				test( r == KErrArgument );
  1.1299 +				r = TestBlockMapRamFAT(0, 0);
  1.1300 +				test( r == KErrArgument );
  1.1301 +				r = TestBlockMapRamFAT(testFileSize, -1);
  1.1302 +				test( r == KErrArgument );
  1.1303 +				r = TestBlockMapRamFAT(0, -1);
  1.1304 +				test( r == KErrCompletion );
  1.1305 +				r = TestBlockMapRamFAT(2000, 2001);
  1.1306 +				test( r == KErrCompletion );
  1.1307 +				r = TestBlockMapRamFAT(0, 0);
  1.1308 +				test( r == KErrArgument );
  1.1309 +				r = TestBlockMapRamFAT(2000, 2000);
  1.1310 +				test( r == KErrArgument );
  1.1311 +				r = TestBlockMapRamFAT(2048, 2048);
  1.1312 +				test( r == KErrArgument ); 
  1.1313 +				test.Next(_L("Test BlockMap retrieval on Ram FAT (2)."));
  1.1314 +				r = TestBlockMapRamFAT2(0, -1);
  1.1315 +				test( r == KErrNotSupported );
  1.1316 +				FindDrive(EDriveRemovable);
  1.1317 +				if ( RemovableFatDrive > -1)
  1.1318 +					{
  1.1319 +					test.Next(_L("Test BlockMap retrieval on removable FAT."));
  1.1320 +					r = TestBlockMapRemovableFAT(0, -1);
  1.1321 +					Pageable?test( r == KErrNotSupported ):test( r == KErrCompletion );
  1.1322 +					}
  1.1323 +				else
  1.1324 +					{
  1.1325 +					test.Next(_L("Test BlockMap retrieval on internal removable FAT."));
  1.1326 +					FindDrive(EDriveInternalRemovable);
  1.1327 +					test( InternalRemovableFatDrive > -1);
  1.1328 +					r = TestBlockMapInternalRemovableFAT(0, -1);
  1.1329 +					test( r == KErrCompletion );
  1.1330 +					r = TestBlockMapInternalRemovableFAT(1024, 4096);
  1.1331 +					test( r == KErrCompletion );
  1.1332 +					r = TestBlockMapInternalRemovableFAT(1020, 4100);
  1.1333 +					test( r == KErrCompletion );
  1.1334 +					r = TestBlockMapInternalRemovableFAT(1024, 4100);
  1.1335 +					test( r == KErrCompletion );
  1.1336 +					r = TestBlockMapInternalRemovableFAT(1020, 4096);
  1.1337 +					test( r == KErrCompletion );
  1.1338 +					r = TestBlockMapInternalRemovableFAT(1025, 1200);
  1.1339 +					test( r == KErrCompletion );
  1.1340 +					r = TestBlockMapInternalRemovableFAT(0, testFileSize+100);
  1.1341 +					test( r == KErrArgument );
  1.1342 +					r = TestBlockMapInternalRemovableFAT(-5, -1);
  1.1343 +					test( r == KErrArgument );
  1.1344 +					r = TestBlockMapInternalRemovableFAT(-5, testFileSize+100);
  1.1345 +					test( r == KErrArgument );
  1.1346 +					r = TestBlockMapInternalRemovableFAT(0, 0);
  1.1347 +					test( r == KErrArgument );
  1.1348 +					r = TestBlockMapInternalRemovableFAT(testFileSize, -1);
  1.1349 +					test( r == KErrArgument );
  1.1350 +					r = TestBlockMapInternalRemovableFAT(0, -1);
  1.1351 +					test( r == KErrCompletion );
  1.1352 +					r = TestBlockMapInternalRemovableFAT(2000, 2001);
  1.1353 +					test( r == KErrCompletion );
  1.1354 +					r = TestBlockMapInternalRemovableFAT(0, 0);
  1.1355 +					test( r == KErrArgument );
  1.1356 +					r = TestBlockMapInternalRemovableFAT(2000, 2000);
  1.1357 +					test( r == KErrArgument );
  1.1358 +					r = TestBlockMapInternalRemovableFAT(2048, 2048);
  1.1359 +					test( r == KErrArgument );
  1.1360 +					}
  1.1361 +				test.Next(_L("Test BlockMap retrieval on Ram FAT (fragmented)."));	
  1.1362 +				test.Printf(_L("Generating Fragmented File..."));
  1.1363 +				GenerateFragmentedFiles(EDriveRam);
  1.1364 +				test.Printf(_L("Done!\n"));
  1.1365 +				Finished = EFalse;
  1.1366 +				r = TestBlockMapFragmented(EDriveRam, 0, -1);
  1.1367 +				test( r == KErrCompletion );
  1.1368 +				r = TestBlockMapFragmented(EDriveRam, 1020, 4100);
  1.1369 +				test( r == KErrCompletion );
  1.1370 +				r = TestBlockMapFragmented(EDriveRam, 2049, 4096);
  1.1371 +				test( r == KErrCompletion );
  1.1372 +				r = TestBlockMapFragmented(EDriveRam, 1024, 4100);
  1.1373 +				test( r == KErrCompletion );
  1.1374 +				r = TestBlockMapFragmented(EDriveRam, 1020, 4096);
  1.1375 +				test( r == KErrCompletion );
  1.1376 +				r = TestBlockMapFragmented(EDriveRam, 1025, 1200);
  1.1377 +				test( r == KErrCompletion );
  1.1378 +				r = TestBlockMapFragmented(EDriveRam, 0, testFileSize+100);
  1.1379 +				test( r == KErrArgument );
  1.1380 +				r = TestBlockMapFragmented(EDriveRam, -5, -1);
  1.1381 +				test( r == KErrArgument );
  1.1382 +				r = TestBlockMapFragmented(EDriveRam, -5, testFileSize+100);
  1.1383 +				test( r == KErrArgument );
  1.1384 +				r = TestBlockMapFragmented(EDriveRam, 0, 0);
  1.1385 +				test( r == KErrArgument );
  1.1386 +				r = TestBlockMapFragmented(EDriveRam, testFileSize, -1);
  1.1387 +				test( r == KErrArgument );
  1.1388 +				r = TestBlockMapFragmented(EDriveRam, 0, -1);
  1.1389 +				test( r == KErrCompletion );
  1.1390 +				r = TestBlockMapFragmented(EDriveRam, 2000, 2001);
  1.1391 +				test( r == KErrCompletion );
  1.1392 +				r = TestBlockMapFragmented(EDriveRam, 0, 0);
  1.1393 +				test( r == KErrArgument );
  1.1394 +				r = TestBlockMapFragmented(EDriveRam, 2000, 2000);
  1.1395 +				test( r == KErrArgument );
  1.1396 +				Finished = ETrue;
  1.1397 +				r = TestBlockMapFragmented(EDriveRam, 2048, 2048);
  1.1398 +				test( r == KErrArgument );
  1.1399 +				}
  1.1400 +			else
  1.1401 +				{
  1.1402 +				test.Printf( _L("NAND drive not found, skipping test.\n") );
  1.1403 +				}
  1.1404 +			}
  1.1405 +		}
  1.1406 +	test.End();
  1.1407 +	test.Close();
  1.1408 +	}