sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Tests for the blockmap API. The blockmap API enumerates the resources sl@0: // used by a file depending upon the type of media on which the file sl@0: // resides. sl@0: // 002 Test Initialise error checking sl@0: // 003 Test processing of user-side block map into extent list sl@0: // 004 Test processing of user-side block map into extent list, block size > read unit size sl@0: // 005 Test Read error checking sl@0: // 006 Test Read sl@0: // Test BlockMap API functionality. sl@0: // sl@0: // sl@0: sl@0: //! @SYMTestCaseID KBASE-T_BLOCKMAP-0337 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1110 sl@0: //! @SYMTestCaseDesc Demand Paging Blockmap tests sl@0: //! @SYMTestActions 001 Unit tests the TKernBlockMap class sl@0: //! @SYMTestExpectedResults All tests should pass. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "t_server.h" sl@0: sl@0: RTest test( _L("T_BLOCKMAP") ); sl@0: sl@0: const TInt KReadBufferSize = 1024; sl@0: const TInt KMaxFragmentSize = 400; sl@0: const TInt KMaxFileSize = 10000; sl@0: sl@0: TInt RamFatDrive = -1; sl@0: TInt RemovableFatDrive = -1; sl@0: TInt InternalRemovableFatDrive = -1; sl@0: TInt NandDrive = -1; sl@0: TBool Pageable = EFalse; sl@0: TBool Finished = EFalse; sl@0: sl@0: enum DriveType sl@0: { sl@0: EDriveNand, sl@0: EDriveRam, sl@0: EDriveRemovable, sl@0: EDriveInternalRemovable sl@0: }; sl@0: sl@0: _LIT( KTestFile, "Z:\\TEST\\T_FILE.CPP"); sl@0: _LIT( KTestFileFAT, "Z:\\Multiple\\T_file.cpp"); sl@0: _LIT( KTestFileName, "T_FILE.CPP"); sl@0: _LIT( KFragmentedFileName1, "FRAG1.TXT"); sl@0: _LIT( KFragmentedFileName2, "FRAG2.TXT"); sl@0: _LIT( KDriveBase, " :\\" ); sl@0: sl@0: LOCAL_C TInt TestBlockMapNandFATUserData(TInt64 aStartPos, TInt64 aEndPos) sl@0: { sl@0: CFileMan* fMan=CFileMan::NewL(TheFs); sl@0: test(fMan!=NULL); sl@0: TFileName name(KDriveBase); sl@0: name[0] = TText('A' + NandDrive); sl@0: name.Append( KTestFileName ); sl@0: sl@0: TInt r = fMan->Attribs(name, 0, KEntryAttReadOnly, 0); sl@0: r = fMan->Delete(name); sl@0: sl@0: r = fMan->Copy(KTestFile, name); sl@0: test( r == KErrNone ); sl@0: sl@0: TInt localDriveNum = 0; sl@0: RFile testFile; sl@0: r = testFile.Open( TheFs, name, EFileRead ); sl@0: test( r == KErrNone ); sl@0: sl@0: RArray map; // From RArray map; to RArray map; sl@0: SBlockMapInfo info; sl@0: TInt counter = 0; sl@0: TInt startPos = aStartPos; sl@0: TInt bmErr; sl@0: sl@0: // Store SBlockMapInfo objects in map:RArray until KErrCompletion is returned. sl@0: do sl@0: { sl@0: bmErr = testFile.BlockMap(info, aStartPos, aEndPos, ETestDebug); sl@0: if (bmErr != 0 && bmErr != KErrCompletion) sl@0: { sl@0: map.Close(); sl@0: testFile.Close(); sl@0: r = fMan->Attribs(name, 0, KEntryAttReadOnly, 0); sl@0: test( r == KErrNone ); sl@0: r = fMan->Delete(name); sl@0: test( r == KErrNone ); sl@0: delete fMan; sl@0: return bmErr; sl@0: } sl@0: map.Append(info); sl@0: if (counter++ == 0) sl@0: localDriveNum = info.iLocalDriveNumber; sl@0: } while ( bmErr == 0 && bmErr != KErrCompletion ); sl@0: test( bmErr == KErrCompletion ); sl@0: TInt granularity; sl@0: sl@0: TInt size; sl@0: r = testFile.Size(size); sl@0: test( r == KErrNone ); sl@0: sl@0: TBuf8 buf1; sl@0: TBuf8 buf2; sl@0: sl@0: TBool changed; sl@0: TBusLocalDrive localDrive; sl@0: sl@0: UserSvr::UnlockRamDrive(); sl@0: sl@0: TBlockMapEntry* myBlockMapEntry; sl@0: TInt myCounter = 0; sl@0: TInt totalSegments = 0; sl@0: TInt remainder = 0; sl@0: TInt miniLength = 0; sl@0: TInt amountRead = 0; sl@0: sl@0: TInt c; sl@0: for ( c = 0; c < map.Count(); c++ ) sl@0: { sl@0: myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr(); sl@0: granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry); sl@0: totalSegments += granularity; sl@0: } sl@0: sl@0: const TInt KTotalSegments = totalSegments; sl@0: r = localDrive.Connect( localDriveNum, changed ); sl@0: test( r == KErrNone ); sl@0: sl@0: // For each SBlockMapInfo object in RArray map sl@0: for ( c = 0; c < map.Count(); c++ ) sl@0: { sl@0: myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr(); sl@0: granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry); sl@0: TInt length; sl@0: if ( aEndPos == -1 ) sl@0: { sl@0: length = size - startPos; sl@0: aEndPos = size; sl@0: } sl@0: else sl@0: length = aEndPos - startPos; sl@0: sl@0: for ( TInt c2 = 1; c2 <= granularity; c2++) sl@0: { sl@0: myCounter = 0; sl@0: if ( c2 == KTotalSegments && aEndPos%map[c].iBlockGranularity != 0 ) sl@0: remainder = map[c].iBlockGranularity - aEndPos%map[c].iBlockGranularity; sl@0: else sl@0: remainder = 0; sl@0: miniLength = map[c].iBlockGranularity*myBlockMapEntry->iNumberOfBlocks - remainder - (c2 == 1?map[c].iBlockStartOffset:0); sl@0: do sl@0: { sl@0: if ( miniLength >= KReadBufferSize ) sl@0: { sl@0: testFile.Read( startPos + amountRead, buf1, KReadBufferSize ); sl@0: localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, KReadBufferSize, buf2); sl@0: r = buf1.Compare( buf2 ); sl@0: test( r == 0 ); sl@0: buf1.Zero(); sl@0: buf2.Zero(); sl@0: myCounter++; sl@0: miniLength -= KReadBufferSize; sl@0: length -= KReadBufferSize; sl@0: amountRead += KReadBufferSize; sl@0: } sl@0: else sl@0: { sl@0: testFile.Read(startPos + amountRead, buf1, miniLength); sl@0: localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, miniLength, buf2); sl@0: r = buf1.Compare( buf2 ); sl@0: test( r == 0 ); sl@0: amountRead += miniLength; sl@0: length -= miniLength; sl@0: miniLength = 0; sl@0: } sl@0: } while ( miniLength != 0 && length != 0); sl@0: myBlockMapEntry++; sl@0: } sl@0: } sl@0: map.Close(); sl@0: sl@0: testFile.Close(); sl@0: r=fMan->Attribs(name, 0, KEntryAttReadOnly, 0); sl@0: test( r == KErrNone ); sl@0: r = fMan->Delete(name); sl@0: test( r == KErrNone ); sl@0: delete fMan; sl@0: return bmErr; sl@0: } sl@0: sl@0: LOCAL_C TInt TestBlockMapNandFAT(TInt64 aStartPos, TInt64 aEndPos) sl@0: // sl@0: // Test BlockMap retrieval on NAND FAT. sl@0: // sl@0: { sl@0: TInt localDriveNum = 0; sl@0: RFile testFile; sl@0: TInt r = testFile.Open( TheFs, KTestFileFAT, EFileRead ); sl@0: test( r == KErrNone ); sl@0: sl@0: RArray map; // From RArray map; to RArray map; sl@0: SBlockMapInfo info; sl@0: TInt counter = 0; sl@0: TInt startPos = aStartPos; sl@0: TInt bmErr; sl@0: sl@0: // Store SBlockMapInfo objects in map:RArray until KErrCompletion is returned. sl@0: do sl@0: { sl@0: bmErr = testFile.BlockMap(info, aStartPos, aEndPos, Pageable?EBlockMapUsagePaging:ETestDebug); sl@0: if (bmErr != 0 && bmErr != KErrCompletion) sl@0: { sl@0: map.Close(); sl@0: testFile.Close(); sl@0: return bmErr; sl@0: } sl@0: map.Append(info); sl@0: if (counter++ == 0) sl@0: localDriveNum = info.iLocalDriveNumber; sl@0: } while ( bmErr == 0 && bmErr != KErrCompletion ); sl@0: test( bmErr == KErrCompletion ); sl@0: TInt granularity; sl@0: sl@0: TInt size; sl@0: r = testFile.Size(size); sl@0: test( r == KErrNone ); sl@0: sl@0: TBuf8 buf1; sl@0: TBuf8 buf2; sl@0: sl@0: TBool changed; sl@0: TBusLocalDrive localDrive; sl@0: sl@0: TBlockMapEntry* myBlockMapEntry; sl@0: TInt myCounter = 0; sl@0: TInt totalSegments = 0; sl@0: TInt remainder = 0; sl@0: TInt miniLength = 0; sl@0: TInt amountRead = 0; sl@0: sl@0: TInt c; sl@0: for ( c = 0; c < map.Count(); c++ ) sl@0: { sl@0: myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr(); sl@0: granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry); sl@0: totalSegments += granularity; sl@0: } sl@0: sl@0: const TInt KTotalSegments = totalSegments; sl@0: r = localDrive.Connect( localDriveNum, changed ); sl@0: test( r == KErrNone ); sl@0: sl@0: // For each SBlockMapInfo object in RArray map sl@0: for ( c = 0; c < map.Count(); c++ ) sl@0: { sl@0: myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr(); sl@0: granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry); sl@0: sl@0: TInt length; sl@0: if ( aEndPos == -1 ) sl@0: { sl@0: length = size - startPos; sl@0: aEndPos = size; sl@0: } sl@0: else sl@0: length = aEndPos - startPos; sl@0: sl@0: for ( TInt c2 = 1; c2 <= granularity; c2++) sl@0: { sl@0: myCounter = 0; sl@0: if ( c2 == KTotalSegments && aEndPos%map[c].iBlockGranularity != 0 ) sl@0: remainder = map[c].iBlockGranularity - aEndPos%map[c].iBlockGranularity; sl@0: else sl@0: remainder = 0; sl@0: miniLength = map[c].iBlockGranularity*myBlockMapEntry->iNumberOfBlocks - remainder - (c2 == 1?map[c].iBlockStartOffset:0); sl@0: do sl@0: { sl@0: if ( miniLength >= KReadBufferSize ) sl@0: { sl@0: testFile.Read( startPos + amountRead, buf1, KReadBufferSize ); sl@0: localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, KReadBufferSize, buf2); sl@0: r = buf1.Compare( buf2 ); sl@0: test( r == 0 ); sl@0: buf1.Zero(); sl@0: buf2.Zero(); sl@0: myCounter++; sl@0: miniLength -= KReadBufferSize; sl@0: length -= KReadBufferSize; sl@0: amountRead += KReadBufferSize; sl@0: } sl@0: else sl@0: { sl@0: testFile.Read(startPos + amountRead, buf1, miniLength); sl@0: localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, miniLength, buf2); sl@0: r = buf1.Compare( buf2 ); sl@0: test( r == 0 ); sl@0: amountRead += miniLength; sl@0: length -= miniLength; sl@0: miniLength = 0; sl@0: } sl@0: } while ( miniLength != 0 && length != 0); sl@0: myBlockMapEntry++; sl@0: } sl@0: } sl@0: map.Close(); sl@0: testFile.Close(); sl@0: return bmErr; sl@0: } sl@0: sl@0: LOCAL_C TInt TestBlockMapNandROFS(TInt64 aStartPos, TInt64 aEndPos) sl@0: // sl@0: // Test BlockMap retrieval on NAND ROFS. sl@0: // sl@0: { sl@0: TInt localDriveNum = 0; sl@0: RFile testFile; sl@0: TInt r = testFile.Open( TheFs, KTestFile, EFileRead ); sl@0: test( r == KErrNone ); sl@0: sl@0: RArray map; // From RArray map; to RArray map; sl@0: SBlockMapInfo info; sl@0: TInt counter = 0; sl@0: TInt startPos = aStartPos; sl@0: TInt bmErr; sl@0: sl@0: // Store SBlockMapInfo objects in map:RArray until KErrCompletion is returned. sl@0: do sl@0: { sl@0: bmErr = testFile.BlockMap(info, aStartPos, aEndPos, Pageable?EBlockMapUsagePaging:ETestDebug); sl@0: if (bmErr != 0 && bmErr != KErrCompletion) sl@0: { sl@0: map.Close(); sl@0: testFile.Close(); sl@0: return bmErr; sl@0: } sl@0: map.Append(info); sl@0: if (counter++ == 0) sl@0: localDriveNum = info.iLocalDriveNumber; sl@0: } while ( bmErr == 0 && bmErr != KErrCompletion ); sl@0: test( bmErr == KErrCompletion ); sl@0: TInt granularity; sl@0: sl@0: TInt size; sl@0: r = testFile.Size(size); sl@0: test( r == KErrNone ); sl@0: sl@0: TBuf8 buf1; sl@0: TBuf8 buf2; sl@0: sl@0: TBool changed; sl@0: TBusLocalDrive localDrive; sl@0: sl@0: TBlockMapEntry* myBlockMapEntry; sl@0: TInt myCounter = 0; sl@0: TInt totalSegments = 0; sl@0: TInt miniLength = 0; sl@0: TInt amountRead = 0; sl@0: sl@0: TInt c; sl@0: for ( c = 0; c < map.Count(); c++ ) sl@0: { sl@0: myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr(); sl@0: granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry); sl@0: totalSegments += granularity; sl@0: } sl@0: r = localDrive.Connect( localDriveNum, changed ); sl@0: test( r == KErrNone ); sl@0: sl@0: // For each SBlockMapInfo object in RArray map sl@0: for ( c = 0; c < map.Count(); c++ ) sl@0: { sl@0: myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr(); sl@0: granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry); sl@0: sl@0: TInt length; sl@0: if ( aEndPos == -1 ) sl@0: { sl@0: length = size - startPos; sl@0: aEndPos = size; sl@0: } sl@0: else sl@0: length = aEndPos - startPos; sl@0: sl@0: for ( TInt c2 = 1; c2 <= granularity; c2++) sl@0: { sl@0: myCounter = 0; sl@0: miniLength = length; sl@0: do sl@0: { sl@0: if ( miniLength >= KReadBufferSize ) sl@0: { sl@0: testFile.Read( startPos + amountRead, buf1, KReadBufferSize ); sl@0: localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, KReadBufferSize, buf2); sl@0: r = buf1.Compare( buf2 ); sl@0: test( r == 0 ); sl@0: buf1.Zero(); sl@0: buf2.Zero(); sl@0: myCounter++; sl@0: miniLength -= KReadBufferSize; sl@0: length -= KReadBufferSize; sl@0: amountRead += KReadBufferSize; sl@0: } sl@0: else sl@0: { sl@0: testFile.Read(startPos + amountRead, buf1, miniLength); sl@0: localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, miniLength, buf2); sl@0: r = buf1.Compare( buf2 ); sl@0: test( r == 0 ); sl@0: amountRead += miniLength; sl@0: length -= miniLength; sl@0: miniLength = 0; sl@0: } sl@0: } while ( miniLength != 0 && length != 0); sl@0: myBlockMapEntry++; sl@0: } sl@0: } sl@0: map.Close(); sl@0: sl@0: testFile.Close(); sl@0: return bmErr; sl@0: } sl@0: sl@0: LOCAL_C TInt TestBlockMapRamFAT(TInt64 aStartPos, TInt64 aEndPos) sl@0: // sl@0: // Test BlockMap retrieval on RAM FAT. sl@0: // sl@0: { sl@0: CFileMan* fMan=CFileMan::NewL(TheFs); sl@0: test(fMan!=NULL); sl@0: TFileName name(KDriveBase); sl@0: name[0] = TText('A' + RamFatDrive); sl@0: name.Append( KTestFileName ); sl@0: sl@0: TInt r = fMan->Attribs(name, 0, KEntryAttReadOnly, 0); sl@0: r = fMan->Delete(name); sl@0: sl@0: r = fMan->Copy(KTestFile, name); sl@0: test( r == KErrNone || r == KErrAlreadyExists); sl@0: sl@0: TInt localDriveNum = 0; sl@0: RFile testFile; sl@0: r = testFile.Open( TheFs, name, EFileRead ); sl@0: test( r == KErrNone ); sl@0: sl@0: RArray map; // From RArray map; to RArray map; sl@0: SBlockMapInfo info; sl@0: TInt counter = 0; sl@0: TInt startPos = aStartPos; sl@0: TInt bmErr; sl@0: sl@0: // Store SBlockMapInfo objects in map:RArray until KErrCompletion is returned. sl@0: do sl@0: { sl@0: bmErr = testFile.BlockMap(info, aStartPos, aEndPos, ETestDebug); sl@0: if (bmErr != 0 && bmErr != KErrCompletion) sl@0: { sl@0: map.Close(); sl@0: testFile.Close(); sl@0: r = fMan->Attribs(name, 0, KEntryAttReadOnly, 0); sl@0: test( r == KErrNone ); sl@0: r = fMan->Delete(name); sl@0: test( r == KErrNone ); sl@0: delete fMan; sl@0: return bmErr; sl@0: } sl@0: map.Append(info); sl@0: if (counter++ == 0) sl@0: localDriveNum = info.iLocalDriveNumber; sl@0: } while ( bmErr == 0 && bmErr != KErrCompletion ); sl@0: test( bmErr == KErrCompletion ); sl@0: TInt granularity; sl@0: sl@0: TInt size; sl@0: r = testFile.Size(size); sl@0: test( r == KErrNone ); sl@0: sl@0: TBuf8 buf1; sl@0: TBuf8 buf2; sl@0: sl@0: TBool changed; sl@0: TBusLocalDrive localDrive; sl@0: sl@0: UserSvr::UnlockRamDrive(); sl@0: sl@0: TBlockMapEntry* myBlockMapEntry; sl@0: TInt myCounter = 0; sl@0: TInt totalSegments = 0; sl@0: TInt remainder = 0; sl@0: TInt miniLength = 0; sl@0: TInt amountRead = 0; sl@0: sl@0: TInt c; sl@0: for ( c = 0; c < map.Count(); c++ ) sl@0: { sl@0: myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr(); sl@0: granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry); sl@0: totalSegments += granularity; sl@0: } sl@0: sl@0: const TInt KTotalSegments = totalSegments; sl@0: sl@0: r = localDrive.Connect( localDriveNum, changed ); sl@0: test( r == KErrNone ); sl@0: sl@0: // For each SBlockMapInfo object in RArray map sl@0: for ( c = 0; c < map.Count(); c++ ) sl@0: { sl@0: myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr(); sl@0: granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry); sl@0: sl@0: TInt length; sl@0: if ( aEndPos == -1 ) sl@0: { sl@0: length = size - startPos; sl@0: aEndPos = size; sl@0: } sl@0: else sl@0: length = aEndPos - startPos; sl@0: sl@0: for ( TInt c2 = 1; c2 <= granularity; c2++) sl@0: { sl@0: myCounter = 0; sl@0: if ( c2 == KTotalSegments && aEndPos%map[c].iBlockGranularity != 0 ) sl@0: remainder = map[c].iBlockGranularity - aEndPos%map[c].iBlockGranularity; sl@0: else sl@0: remainder = 0; sl@0: miniLength = map[c].iBlockGranularity*myBlockMapEntry->iNumberOfBlocks - remainder - (c2 == 1?map[c].iBlockStartOffset:0); sl@0: do sl@0: { sl@0: if ( miniLength >= KReadBufferSize ) sl@0: { sl@0: testFile.Read( startPos + amountRead, buf1, KReadBufferSize ); sl@0: localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, KReadBufferSize, buf2); sl@0: r = buf1.Compare( buf2 ); sl@0: test( r == 0 ); sl@0: buf1.Zero(); sl@0: buf2.Zero(); sl@0: myCounter++; sl@0: miniLength -= KReadBufferSize; sl@0: length -= KReadBufferSize; sl@0: amountRead += KReadBufferSize; sl@0: } sl@0: else sl@0: { sl@0: testFile.Read(startPos + amountRead, buf1, miniLength); sl@0: localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, miniLength, buf2); sl@0: r = buf1.Compare( buf2 ); sl@0: test( r == 0 ); sl@0: amountRead += miniLength; sl@0: length -= miniLength; sl@0: miniLength = 0; sl@0: } sl@0: } while ( miniLength != 0 && length != 0); sl@0: myBlockMapEntry++; sl@0: } sl@0: } sl@0: map.Close(); sl@0: sl@0: testFile.Close(); sl@0: r=fMan->Attribs(name, 0, KEntryAttReadOnly, 0); sl@0: test( r == KErrNone ); sl@0: r = fMan->Delete(name); sl@0: test( r == KErrNone ); sl@0: delete fMan; sl@0: return bmErr; sl@0: } sl@0: sl@0: LOCAL_C TInt TestBlockMapRamFAT2(TInt64 aStartPos, TInt64 aEndPos) sl@0: // sl@0: // Test BlockMap retrieval on Ram FAT. sl@0: // sl@0: { sl@0: CFileMan* fMan=CFileMan::NewL(TheFs); sl@0: test(fMan!=NULL); sl@0: TFileName name(KDriveBase); sl@0: name[0] = TText('A' + RamFatDrive); sl@0: name.Append( KTestFileName ); sl@0: sl@0: TInt r = fMan->Attribs(name, 0, KEntryAttReadOnly, 0); sl@0: r = fMan->Delete(name); sl@0: sl@0: r = fMan->Copy(KTestFile, name); sl@0: test( r == KErrNone || r == KErrAlreadyExists); sl@0: sl@0: RFile testFile; sl@0: r = testFile.Open( TheFs, name, EFileRead ); sl@0: test( r == KErrNone ); sl@0: sl@0: RArray map; // From RArray map; to RArray map; sl@0: SBlockMapInfo info; sl@0: sl@0: TInt bmErr; sl@0: bmErr = testFile.BlockMap(info, aStartPos, aEndPos, EBlockMapUsagePaging); sl@0: sl@0: map.Close(); sl@0: sl@0: testFile.Close(); sl@0: r = fMan->Attribs(name, 0, KEntryAttReadOnly, 0); sl@0: test( r == KErrNone ); sl@0: r = fMan->Delete(name); sl@0: test( r == KErrNone ); sl@0: delete fMan; sl@0: return bmErr; sl@0: } sl@0: sl@0: LOCAL_C TInt TestBlockMapRemovableFAT(TInt64 aStartPos, TInt64 aEndPos) sl@0: // sl@0: // Test BlockMap retrieval on Removable FAT. sl@0: // sl@0: { sl@0: CFileMan* fMan=CFileMan::NewL(TheFs); sl@0: test(fMan!=NULL); sl@0: TFileName name(KDriveBase); sl@0: name[0] = TText('A' + RemovableFatDrive); sl@0: name.Append( KTestFileName ); sl@0: sl@0: TInt r=fMan->Copy(KTestFile, name); sl@0: test( r == KErrNone || r == KErrAlreadyExists); sl@0: sl@0: RFile testFile; sl@0: r = testFile.Open( TheFs, name, EFileRead ); sl@0: test( r == KErrNone ); sl@0: sl@0: RArray map; // From RArray map; to RArray map; sl@0: SBlockMapInfo info; sl@0: TInt bmErr = testFile.BlockMap(info, aStartPos, aEndPos, Pageable?EBlockMapUsagePaging:ETestDebug); sl@0: map.Close(); sl@0: sl@0: testFile.Close(); sl@0: r=fMan->Attribs(name, 0, KEntryAttReadOnly, 0); sl@0: test( r == KErrNone ); sl@0: r = fMan->Delete(name); sl@0: test( r == KErrNone ); sl@0: delete fMan; sl@0: return bmErr; sl@0: } sl@0: sl@0: LOCAL_C TInt TestBlockMapInternalRemovableFAT(TInt64 aStartPos, TInt64 aEndPos) sl@0: // sl@0: // Test BlockMap retrieval on internal removable FAT. sl@0: // sl@0: { sl@0: CFileMan* fMan=CFileMan::NewL(TheFs); sl@0: test(fMan!=NULL); sl@0: TFileName name(KDriveBase); sl@0: name[0] = TText('A' + RamFatDrive); sl@0: name.Append( KTestFileName ); sl@0: sl@0: TInt r=fMan->Copy(KTestFile, name); sl@0: test( r == KErrNone || r == KErrAlreadyExists); sl@0: sl@0: TInt localDriveNum = 0; sl@0: RFile testFile; sl@0: r = testFile.Open( TheFs, name, EFileRead ); sl@0: test( r == KErrNone ); sl@0: sl@0: RArray map; // From RArray map; to RArray map; sl@0: SBlockMapInfo info; sl@0: TInt counter = 0; sl@0: TInt startPos = aStartPos; sl@0: TInt bmErr; sl@0: sl@0: // Store SBlockMapInfo objects in map:RArray until KErrCompletion is returned. sl@0: do sl@0: { sl@0: bmErr = testFile.BlockMap(info, aStartPos, aEndPos, ETestDebug); sl@0: if (bmErr != 0 && bmErr != KErrCompletion) sl@0: { sl@0: map.Close(); sl@0: testFile.Close(); sl@0: r = fMan->Attribs(name, 0, KEntryAttReadOnly, 0); sl@0: test( r == KErrNone ); sl@0: r = fMan->Delete(name); sl@0: test( r == KErrNone ); sl@0: delete fMan; sl@0: return bmErr; sl@0: } sl@0: map.Append(info); sl@0: if (counter++ == 0) sl@0: localDriveNum = info.iLocalDriveNumber; sl@0: } while ( bmErr == 0 && bmErr != KErrCompletion ); sl@0: test( bmErr == KErrCompletion ); sl@0: TInt granularity; sl@0: sl@0: TInt size; sl@0: r = testFile.Size(size); sl@0: test( r == KErrNone ); sl@0: sl@0: TBuf8 buf1; sl@0: TBuf8 buf2; sl@0: sl@0: TBool changed; sl@0: TBusLocalDrive localDrive; sl@0: sl@0: UserSvr::UnlockRamDrive(); sl@0: sl@0: TBlockMapEntry* myBlockMapEntry; sl@0: TInt myCounter = 0; sl@0: TInt totalSegments = 0; sl@0: TInt remainder = 0; sl@0: TInt miniLength = 0; sl@0: TInt amountRead = 0; sl@0: sl@0: TInt c; sl@0: for ( c = 0; c < map.Count(); c++ ) sl@0: { sl@0: myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr(); sl@0: granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry); sl@0: totalSegments += granularity; sl@0: } sl@0: sl@0: const TInt KTotalSegments = totalSegments; sl@0: sl@0: r = localDrive.Connect( localDriveNum, changed ); sl@0: test( r == KErrNone ); sl@0: sl@0: // For each SBlockMapInfo object in RArray map sl@0: for ( c = 0; c < map.Count(); c++ ) sl@0: { sl@0: myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr(); sl@0: granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry); sl@0: sl@0: TInt length; sl@0: if ( aEndPos == -1 ) sl@0: { sl@0: length = size - startPos; sl@0: aEndPos = size; sl@0: } sl@0: else sl@0: length = aEndPos - startPos; sl@0: sl@0: for ( TInt c2 = 1; c2 <= granularity; c2++) sl@0: { sl@0: myCounter = 0; sl@0: if ( c2 == KTotalSegments && aEndPos%map[c].iBlockGranularity != 0 ) sl@0: remainder = map[c].iBlockGranularity - aEndPos%map[c].iBlockGranularity; sl@0: else sl@0: remainder = 0; sl@0: miniLength = map[c].iBlockGranularity*myBlockMapEntry->iNumberOfBlocks - remainder - (c2 == 1?map[c].iBlockStartOffset:0); sl@0: do sl@0: { sl@0: if ( miniLength >= KReadBufferSize ) sl@0: { sl@0: testFile.Read( startPos + amountRead, buf1, KReadBufferSize ); sl@0: localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, KReadBufferSize, buf2); sl@0: r = buf1.Compare( buf2 ); sl@0: test( r == 0 ); sl@0: buf1.Zero(); sl@0: buf2.Zero(); sl@0: myCounter++; sl@0: miniLength -= KReadBufferSize; sl@0: length -= KReadBufferSize; sl@0: amountRead += KReadBufferSize; sl@0: } sl@0: else sl@0: { sl@0: testFile.Read(startPos + amountRead, buf1, miniLength); sl@0: localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, miniLength, buf2); sl@0: r = buf1.Compare( buf2 ); sl@0: test( r == 0 ); sl@0: amountRead += miniLength; sl@0: length -= miniLength; sl@0: miniLength = 0; sl@0: } sl@0: } while ( miniLength != 0 && length != 0); sl@0: myBlockMapEntry++; sl@0: } sl@0: } sl@0: map.Close(); sl@0: sl@0: testFile.Close(); sl@0: r=fMan->Attribs(name, 0, KEntryAttReadOnly, 0); sl@0: test( r == KErrNone ); sl@0: r = fMan->Delete(name); sl@0: test( r == KErrNone ); sl@0: delete fMan; sl@0: return bmErr; sl@0: } sl@0: sl@0: LOCAL_C TInt TestBlockMapFragmented(DriveType aDriveType, TInt64 aStartPos, TInt64 aEndPos) sl@0: { sl@0: CFileMan* fMan=CFileMan::NewL(TheFs); sl@0: test(fMan!=NULL); sl@0: TFileName name(KDriveBase); sl@0: if (aDriveType==EDriveRam) sl@0: name[0] = TText('A' + RamFatDrive); sl@0: else if (aDriveType==EDriveRemovable) sl@0: name[0] = TText('A' + RemovableFatDrive); sl@0: else if (aDriveType==EDriveNand) sl@0: name[0] = TText('A' + NandDrive); sl@0: else sl@0: name[0] = TText('A' + InternalRemovableFatDrive); sl@0: name.Append( KFragmentedFileName1 ); sl@0: TInt localDriveNum = 0; sl@0: RFile testFile; sl@0: TInt r = testFile.Open( TheFs, name, EFileRead ); sl@0: test( r == KErrNone ); sl@0: RArray map; // From RArray map; to RArray map; sl@0: SBlockMapInfo info; sl@0: TInt counter = 0; sl@0: TInt startPos = aStartPos; sl@0: TInt bmErr; sl@0: sl@0: // Store SBlockMapInfo objects in map:RArray until KErrCompletion is returned. sl@0: do sl@0: { sl@0: bmErr = testFile.BlockMap(info, aStartPos, aEndPos, ETestDebug); sl@0: if (bmErr != 0 && bmErr != KErrCompletion) sl@0: { sl@0: map.Close(); sl@0: testFile.Close(); sl@0: if ( Finished ) sl@0: { sl@0: r = fMan->Attribs(name, 0, KEntryAttReadOnly, 0); sl@0: test( r == KErrNone ); sl@0: r = fMan->Delete(name); sl@0: test( r == KErrNone ); sl@0: } sl@0: delete fMan; sl@0: return bmErr; sl@0: } sl@0: map.Append(info); sl@0: if (counter++ == 0) sl@0: localDriveNum = info.iLocalDriveNumber; sl@0: } while ( bmErr == 0 && bmErr != KErrCompletion ); sl@0: test( bmErr == KErrCompletion ); sl@0: TInt granularity; sl@0: TInt size; sl@0: r = testFile.Size(size); sl@0: test( r == KErrNone ); sl@0: sl@0: TBuf8 buf1; sl@0: TBuf8 buf2; sl@0: sl@0: TBool changed; sl@0: TBusLocalDrive localDrive; sl@0: sl@0: UserSvr::UnlockRamDrive(); sl@0: sl@0: TBlockMapEntry* myBlockMapEntry; sl@0: TInt myCounter = 0; sl@0: TInt totalSegments = 0; sl@0: TInt remainder = 0; sl@0: TInt miniLength = 0; sl@0: TInt amountRead = 0; sl@0: sl@0: TInt c; sl@0: for ( c = 0; c < map.Count(); c++ ) sl@0: { sl@0: myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr(); sl@0: granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry); sl@0: totalSegments += granularity; sl@0: } sl@0: sl@0: const TInt KTotalSegments = totalSegments; sl@0: r = localDrive.Connect( localDriveNum, changed ); sl@0: test( r == KErrNone ); sl@0: sl@0: // For each SBlockMapInfo object in RArray map sl@0: for ( c = 0; c < map.Count(); c++ ) sl@0: { sl@0: myBlockMapEntry = (TBlockMapEntry*) map[c].iMap.Ptr(); sl@0: granularity = map[c].iMap.Size()/sizeof(TBlockMapEntry); sl@0: sl@0: TInt length; sl@0: if ( aEndPos == -1 ) sl@0: { sl@0: length = size - startPos; sl@0: aEndPos = size; sl@0: } sl@0: else sl@0: length = aEndPos - startPos; sl@0: sl@0: for ( TInt c2 = 1; c2 <= granularity; c2++) sl@0: { sl@0: myCounter = 0; sl@0: if ( c2 == KTotalSegments && aEndPos%map[c].iBlockGranularity != 0 ) sl@0: remainder = map[c].iBlockGranularity - aEndPos%map[c].iBlockGranularity; sl@0: else sl@0: remainder = 0; sl@0: miniLength = map[c].iBlockGranularity*myBlockMapEntry->iNumberOfBlocks - remainder - (c2 == 1?map[c].iBlockStartOffset:0); sl@0: do sl@0: { sl@0: if ( miniLength >= KReadBufferSize ) sl@0: { sl@0: testFile.Read( startPos + amountRead, buf1, KReadBufferSize ); sl@0: localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, KReadBufferSize, buf2); sl@0: r = buf1.Compare( buf2 ); sl@0: test( r == 0 ); sl@0: buf1.Zero(); sl@0: buf2.Zero(); sl@0: myCounter++; sl@0: miniLength -= KReadBufferSize; sl@0: length -= KReadBufferSize; sl@0: amountRead += KReadBufferSize; sl@0: } sl@0: else sl@0: { sl@0: testFile.Read(startPos + amountRead, buf1, miniLength ); sl@0: localDrive.Read( map[c].iStartBlockAddress + myBlockMapEntry->iStartBlock * map[c].iBlockGranularity + (c2 == 1?map[c].iBlockStartOffset:0) + myCounter*KReadBufferSize, miniLength, buf2); sl@0: r = buf1.Compare( buf2 ); sl@0: test( r == 0 ); sl@0: amountRead += miniLength; sl@0: length -= miniLength; sl@0: miniLength = 0; sl@0: } sl@0: } while ( miniLength != 0 && length != 0); sl@0: myBlockMapEntry++; sl@0: } sl@0: } sl@0: map.Close(); sl@0: sl@0: testFile.Close(); sl@0: if ( Finished ) sl@0: { sl@0: r=fMan->Attribs(name, 0, KEntryAttReadOnly, 0); sl@0: test( r == KErrNone ); sl@0: r = fMan->Delete(name); sl@0: test( r == KErrNone ); sl@0: } sl@0: delete fMan; sl@0: return bmErr; sl@0: } sl@0: sl@0: LOCAL_C void GenerateFragmentedFiles(DriveType aDriveType) sl@0: { sl@0: TInt r; sl@0: TFileName name1(KDriveBase); sl@0: if (aDriveType==EDriveRam) sl@0: name1[0] = TText('A' + RamFatDrive); sl@0: else if (aDriveType==EDriveRemovable) sl@0: name1[0] = TText('A' + RemovableFatDrive); sl@0: else if (aDriveType==EDriveNand) sl@0: name1[0] = TText('A' + NandDrive); sl@0: else sl@0: name1[0] = TText('A' + InternalRemovableFatDrive); sl@0: name1.Append( KFragmentedFileName1 ); sl@0: RFile file1; sl@0: r = file1.Create(TheFs, name1, EFileWrite); sl@0: test( r == KErrNone ); sl@0: file1.Close(); sl@0: sl@0: TFileName name2(KDriveBase); sl@0: if (aDriveType==EDriveRam) sl@0: name2[0] = TText('A' + RamFatDrive); sl@0: else if (aDriveType==EDriveRemovable) sl@0: name2[0] = TText('A' + RemovableFatDrive); sl@0: else if (aDriveType==EDriveNand) sl@0: name2[0] = TText('A' + NandDrive); sl@0: else sl@0: name2[0] = TText('A' + InternalRemovableFatDrive); sl@0: name2.Append( KFragmentedFileName2 ); sl@0: RFile file2; sl@0: r = file2.Create(TheFs, name2, EFileWrite); sl@0: test( r == KErrNone ); sl@0: file2.Close(); sl@0: TInt64 randomSeed; sl@0: TBuf8 tempBuf; sl@0: TUint8 *buf; sl@0: TInt fileSize = 0; sl@0: TInt fragmentSize; sl@0: TInt randomLength; sl@0: TInt pos1; sl@0: TInt pos2; sl@0: TInt mycount = 0; sl@0: do sl@0: { sl@0: fragmentSize = 0; sl@0: pos1 = 0; sl@0: pos2 = 0; sl@0: buf = (TUint8*) tempBuf.Ptr(); sl@0: tempBuf.Zero(); sl@0: randomLength = Math::Random() % KMaxFragmentSize; sl@0: randomSeed = Math::Random(); sl@0: tempBuf.SetLength(randomLength); sl@0: sl@0: while (randomLength-- && fragmentSize++ < KMaxFragmentSize && fileSize++ < KMaxFileSize) sl@0: { sl@0: *buf++ = (TUint8)('A' + (Math::Rand(randomSeed) % ('Z' - 'A'))); sl@0: } sl@0: r = file1.Open( TheFs, name1, EFileWrite ); sl@0: test( r == KErrNone ); sl@0: r = file1.Seek( ESeekEnd, pos1 ); sl@0: test( r == KErrNone ); sl@0: r = file1.Write( pos1, tempBuf ); sl@0: test( r == KErrNone ); sl@0: r = file1.Flush(); sl@0: test( r == KErrNone ); sl@0: file1.Close(); sl@0: if ( mycount++ < 6 ) sl@0: { sl@0: r = file2.Open( TheFs, name2, EFileWrite ); sl@0: test( r == KErrNone ); sl@0: r = file2.Seek( ESeekEnd, pos2 ); sl@0: test( r == KErrNone ); sl@0: r = file2.Write( pos2, tempBuf ); sl@0: test( r == KErrNone ); sl@0: r = file2.Flush(); sl@0: test( r == KErrNone ); sl@0: file2.Close(); sl@0: } sl@0: } while ( fileSize < KMaxFileSize ); sl@0: CFileMan* fMan=CFileMan::NewL(TheFs); sl@0: test(fMan!=NULL); sl@0: r = fMan->Delete(name2); sl@0: test( r == KErrNone ); sl@0: delete fMan; sl@0: } sl@0: sl@0: LOCAL_C void FindDrive(DriveType aDriveType) sl@0: { sl@0: TInt i; sl@0: TInt c = 0; sl@0: for( i = EDriveA; i < EDriveZ; i++ ) sl@0: { sl@0: TDriveInfo info; sl@0: TInt r = TheFs.Drive(info, i); sl@0: if ( r != KErrNone ) sl@0: continue; sl@0: test( r == KErrNone ); sl@0: if ( aDriveType == EDriveNand ) sl@0: { sl@0: c++ == 0 ? test.Printf( _L("Searching for NAND drive.")) : test.Printf( _L(".")); sl@0: if ( info.iType == EMediaNANDFlash && ((info.iMediaAtt & KMediaAttWriteProtected) == 0) ) sl@0: { sl@0: if ( info.iDriveAtt & KDriveAttPageable ) sl@0: Pageable = ETrue; sl@0: NandDrive = i; sl@0: test.Printf( _L("Found NAND drive: %d\n"), NandDrive ); sl@0: break; sl@0: } sl@0: } sl@0: else if ( aDriveType == EDriveRam ) sl@0: { sl@0: c++ == 0 ? test.Printf( _L("Searching for RAM FAT drive.")) : test.Printf( _L(".")); sl@0: if ( (info.iType == EMediaRam) && ( info.iDriveAtt == (KDriveAttLocal|KDriveAttInternal) ) && ( info.iMediaAtt == (KMediaAttVariableSize|KMediaAttFormattable) ) ) sl@0: { sl@0: if ( info.iDriveAtt & KDriveAttPageable ) sl@0: Pageable = ETrue; sl@0: RamFatDrive = i; sl@0: test.Printf( _L("Found RAM FAT drive: %d\n"), RamFatDrive ); sl@0: break; sl@0: } sl@0: } sl@0: else if ( aDriveType == EDriveRemovable ) sl@0: { sl@0: c++ == 0 ? test.Printf( _L("Searching for removable FAT drive.")) : test.Printf( _L(".")); sl@0: if ( info.iType == EMediaHardDisk && ( info.iDriveAtt == (KDriveAttLocal|KDriveAttRemovable) ) ) sl@0: { sl@0: if ( info.iDriveAtt & KDriveAttPageable ) sl@0: Pageable = ETrue; sl@0: RemovableFatDrive = i; sl@0: test.Printf( _L("Found removable FAT drive: %d\n"), RemovableFatDrive ); sl@0: break; sl@0: } sl@0: } sl@0: else if ( aDriveType == EDriveInternalRemovable ) sl@0: { sl@0: c++ == 0 ? test.Printf( _L("Searching for internal removable FAT drive.")) : test.Printf( _L(".")); sl@0: if ( info.iType == EMediaHardDisk && ( info.iDriveAtt == (KDriveAttLocal|KDriveAttInternal) ) ) sl@0: { sl@0: if ( info.iDriveAtt & KDriveAttPageable ) sl@0: Pageable = ETrue; sl@0: InternalRemovableFatDrive = i; sl@0: test.Printf( _L("Found internal removable FAT drive: %d\n"), InternalRemovableFatDrive ); sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: if ( i == EDriveZ ) sl@0: { sl@0: switch(aDriveType) sl@0: { sl@0: case EDriveNand: sl@0: test.Printf( _L("NAND drive not found.\n") ); sl@0: break; sl@0: case EDriveRam: sl@0: test.Printf( _L("RAM FAT drive not found.\n") ); sl@0: break; sl@0: case EDriveRemovable: sl@0: test.Printf( _L("Removable FAT drive not found.\n") ); sl@0: break; sl@0: case EDriveInternalRemovable: sl@0: test.Printf( _L("Internal removable FAT drive not found.\n") ); sl@0: break; sl@0: default: sl@0: test.Printf( _L("Drive not found.\n") ); sl@0: } sl@0: } sl@0: } sl@0: sl@0: //************************ sl@0: // Entry point sl@0: sl@0: GLDEF_C void CallTestsL(void) sl@0: { sl@0: test.Title(); sl@0: test.Start( _L("BlockMap Test\n") ); sl@0: sl@0: TInt testFileSize = 0; sl@0: RFile testFile; sl@0: TInt r = testFile.Open(TheFs, KTestFile, EFileRead); sl@0: test(r==KErrNone); sl@0: r = testFile.Size(testFileSize); sl@0: test(r==KErrNone); sl@0: test(testFileSize>16384); sl@0: testFile.Close(); sl@0: sl@0: if ( gDriveToTest == 'C' ) sl@0: { sl@0: TInt value; sl@0: r = HAL::Get( HAL::EMachineUid, value ); sl@0: test( r == KErrNone ); sl@0: if ( value != HAL::EMachineUid_Lubbock ) // Lubbock cannot run FindDrive as it doesn't support the NAND API sl@0: { sl@0: test.Next(_L("Test BlockMap retrieval on NAND FAT.")); sl@0: FindDrive(EDriveNand); sl@0: if ( NandDrive > -1 ) // not finding a NAND drive isn't an error as only NAND builds have one sl@0: { sl@0: r = TestBlockMapNandFATUserData(0, -1); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandFATUserData(1024, 4096); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandFATUserData(1020, 4100); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandFATUserData(1024, 4100); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandFATUserData(1020, 4096); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandFATUserData(1025, 1200); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandFATUserData(0, testFileSize+100); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandFATUserData(-5, -1); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandFATUserData(-5, testFileSize+100); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandFATUserData(0, 0); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandFATUserData(testFileSize, -1); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandFATUserData(0, -1); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandFATUserData(2000, 2001); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandFATUserData(0, 0); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandFATUserData(2000, 2000); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandFATUserData(2048, 2048); sl@0: test( r == KErrArgument ); sl@0: test.Printf(_L("Generating Fragmented File...")); sl@0: GenerateFragmentedFiles(EDriveNand); sl@0: test.Printf(_L("Done!\n")); sl@0: test.Next(_L("Test BlockMap retrieval on NAND FAT (User area) (fragmented).")); sl@0: r = TestBlockMapFragmented(EDriveNand, 0, -1); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapFragmented(EDriveNand, 1024, 4096); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapFragmented(EDriveNand, 1020, 4100); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapFragmented(EDriveNand, 1024, 4100); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapFragmented(EDriveNand, 1020, 4096); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapFragmented(EDriveNand, 1025, 1200); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapFragmented(EDriveNand, 0, testFileSize+100); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapFragmented(EDriveNand, -5, -1); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapFragmented(EDriveNand, -5, testFileSize+100); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapFragmented(EDriveNand, 0, 0); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapFragmented(EDriveNand, testFileSize, -1); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapFragmented(EDriveNand, 0, -1); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapFragmented(EDriveNand, 2000, 2001); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapFragmented(EDriveNand, 0, 0); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapFragmented(EDriveNand, 2000, 2000); sl@0: test( r == KErrArgument ); sl@0: Finished = ETrue; sl@0: r = TestBlockMapFragmented(EDriveNand, 2048, 2048); sl@0: test( r == KErrArgument ); sl@0: test.Next(_L("Test BlockMap retrieval on NAND FAT.")); sl@0: r = TestBlockMapNandFAT(0, -1); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandFAT(1024, 4096); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandFAT(1020, 4100); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandFAT(1024, 4100); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandFAT(1020, 4096); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandFAT(1025, 1200); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandFAT(0, testFileSize+100); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandFAT(-5, -1); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandFAT(-5, testFileSize+100); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandFAT(0, 0); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandFAT(testFileSize, -1); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandFAT(0, -1); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandFAT(2000, 2001); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandFAT(0, 0); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandFAT(2000, 2000); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandFAT(2048, 2048); sl@0: test( r == KErrArgument ); sl@0: test.Next(_L("Test BlockMap retrieval on NAND ROFS.")); sl@0: r = TestBlockMapNandROFS(0, -1); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandROFS(1024, 4096); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandROFS(1020, 4100); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandROFS(1024, 4100); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandROFS(1020, 4096); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandROFS(1025, 1200); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandROFS(0, testFileSize+100); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandROFS(-5, -1); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandROFS(-5, testFileSize+100); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandROFS(0, 0); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandROFS(testFileSize, -1); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandROFS(0, -1); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandROFS(2000, 2001); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapNandROFS(0, 0); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandROFS(2000, 2000); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapNandROFS(2048, 2048); sl@0: test( r == KErrArgument ); sl@0: test.Next(_L("Test BlockMap retrieval on RAM FAT.")); sl@0: FindDrive(EDriveRam); sl@0: test( RamFatDrive > -1 ); sl@0: r = TestBlockMapRamFAT(0, -1); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapRamFAT(1024, 4096); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapRamFAT(1020, 4100); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapRamFAT(1024, 4100); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapRamFAT(1020, 4096); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapRamFAT(1025, 1200); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapRamFAT(0, testFileSize+100); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapRamFAT(-5, -1); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapRamFAT(-5, testFileSize+100); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapRamFAT(0, 0); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapRamFAT(testFileSize, -1); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapRamFAT(0, -1); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapRamFAT(2000, 2001); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapRamFAT(0, 0); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapRamFAT(2000, 2000); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapRamFAT(2048, 2048); sl@0: test( r == KErrArgument ); sl@0: test.Next(_L("Test BlockMap retrieval on Ram FAT (2).")); sl@0: r = TestBlockMapRamFAT2(0, -1); sl@0: test( r == KErrNotSupported ); sl@0: FindDrive(EDriveRemovable); sl@0: if ( RemovableFatDrive > -1) sl@0: { sl@0: test.Next(_L("Test BlockMap retrieval on removable FAT.")); sl@0: r = TestBlockMapRemovableFAT(0, -1); sl@0: Pageable?test( r == KErrNotSupported ):test( r == KErrCompletion ); sl@0: } sl@0: else sl@0: { sl@0: test.Next(_L("Test BlockMap retrieval on internal removable FAT.")); sl@0: FindDrive(EDriveInternalRemovable); sl@0: test( InternalRemovableFatDrive > -1); sl@0: r = TestBlockMapInternalRemovableFAT(0, -1); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapInternalRemovableFAT(1024, 4096); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapInternalRemovableFAT(1020, 4100); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapInternalRemovableFAT(1024, 4100); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapInternalRemovableFAT(1020, 4096); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapInternalRemovableFAT(1025, 1200); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapInternalRemovableFAT(0, testFileSize+100); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapInternalRemovableFAT(-5, -1); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapInternalRemovableFAT(-5, testFileSize+100); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapInternalRemovableFAT(0, 0); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapInternalRemovableFAT(testFileSize, -1); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapInternalRemovableFAT(0, -1); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapInternalRemovableFAT(2000, 2001); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapInternalRemovableFAT(0, 0); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapInternalRemovableFAT(2000, 2000); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapInternalRemovableFAT(2048, 2048); sl@0: test( r == KErrArgument ); sl@0: } sl@0: test.Next(_L("Test BlockMap retrieval on Ram FAT (fragmented).")); sl@0: test.Printf(_L("Generating Fragmented File...")); sl@0: GenerateFragmentedFiles(EDriveRam); sl@0: test.Printf(_L("Done!\n")); sl@0: Finished = EFalse; sl@0: r = TestBlockMapFragmented(EDriveRam, 0, -1); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapFragmented(EDriveRam, 1020, 4100); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapFragmented(EDriveRam, 2049, 4096); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapFragmented(EDriveRam, 1024, 4100); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapFragmented(EDriveRam, 1020, 4096); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapFragmented(EDriveRam, 1025, 1200); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapFragmented(EDriveRam, 0, testFileSize+100); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapFragmented(EDriveRam, -5, -1); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapFragmented(EDriveRam, -5, testFileSize+100); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapFragmented(EDriveRam, 0, 0); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapFragmented(EDriveRam, testFileSize, -1); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapFragmented(EDriveRam, 0, -1); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapFragmented(EDriveRam, 2000, 2001); sl@0: test( r == KErrCompletion ); sl@0: r = TestBlockMapFragmented(EDriveRam, 0, 0); sl@0: test( r == KErrArgument ); sl@0: r = TestBlockMapFragmented(EDriveRam, 2000, 2000); sl@0: test( r == KErrArgument ); sl@0: Finished = ETrue; sl@0: r = TestBlockMapFragmented(EDriveRam, 2048, 2048); sl@0: test( r == KErrArgument ); sl@0: } sl@0: else sl@0: { sl@0: test.Printf( _L("NAND drive not found, skipping test.\n") ); sl@0: } sl@0: } sl@0: } sl@0: test.End(); sl@0: test.Close(); sl@0: }