diff -r 000000000000 -r a41df078684a baseintegtests/baseintegrationtest/testsuites/fat32/src/basetestfat32writeraw.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/baseintegtests/baseintegrationtest/testsuites/fat32/src/basetestfat32writeraw.cpp Mon Oct 19 15:55:17 2009 +0100 @@ -0,0 +1,212 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Performs various operations to write to the raw disk. +// +// + +#include "basetestfat32writeraw.h" + +static RRawDisk TheDisk; + +/** +Class Constructor +*/ +CBaseTestFat32WriteRaw::CBaseTestFat32WriteRaw() + { + SetTestStepName(KTestStepWriteRaw); + } + +/** +Class Destructor +*/ +CBaseTestFat32WriteRaw::~CBaseTestFat32WriteRaw() + { + } + +/** +This function performs the following actions: +1. Get the position at which to write on the raw disk from the ini file + -> if a cluster is specified, get the position from the GetCluster function +2. Get the number of bytes to write from the ini file +3. Obtain the values to be written to the disk from the ini file. +4. Write the values to the disk byte by byte. + +@return EPass if test passes and EFail if test fails +*/ +TVerdict CBaseTestFat32WriteRaw::doTestStepL() + { + SetTestStepResult(EFail); + _LIT(KPosition,"WritePosition"); + _LIT(KNumOfBytes,"NumberOfBytes"); + _LIT(KCluster,"ClusterNumber"); + TInt writevalues[12]; + TInt position; + TInt64 clusterPosition; + TInt cluster; + TInt numbyte; + TInt r; + TBool alright = GetHexFromConfig(ConfigSection(), KPosition, position); + if(alright) + { + if (iMedia == 1 && position >= 16384) + { + INFO_PRINTF2(_L("Position = %d"), position); + INFO_PRINTF2(_L("iBPB_ResvdSecCnt = %d"), iBPB_ResvdSecCnt); + position = (iBPB_ResvdSecCnt * 512) + (position - 0x4000); + INFO_PRINTF2(_L("New Position = %d"), position); + } + TBool alright2 = GetHexFromConfig(ConfigSection(), KNumOfBytes, numbyte); + if (alright2) + { + TBool alright2 = GetIntFromConfig(ConfigSection(), KCluster, cluster); + if (alright2) + { + r = GetCluster(cluster, clusterPosition); + position = clusterPosition; + } + else + { + position = position; + } + _LIT(KWritePosition, "The position on the disk being written to is %d"); + INFO_PRINTF2(KWritePosition,position); + r = GetWriteValue(numbyte,writevalues); + TInt i; + r = TheDisk.Open(iTheFs, CurrentDrive()); + if (r!=KErrNone) + { + _LIT(KErrorOpen, "Cannot open the raw disk - r=%d"); + INFO_PRINTF2(KErrorOpen, r); + } + for (i=0;i writeValue; + writeValue.Format(KWriteValues, i); + TBool alright3 = GetHexFromConfig(ConfigSection(), writeValue, value); + if (alright3) + { + aValueArray[i-1] = value; + } + else + { + INFO_PRINTF1(_L("Cannot read WriteValue from ini file")); + return KErrGeneral; + } + } + return KErrNone; + } + +/** +Get the position by calulating from the entry and position in the entry +specified in the ini file + +@param aClusterNumber The cluster on the disk to write to +@param aPosition the position within an entry + +@return KErrNone if successfull +*/ +TInt CBaseTestFat32WriteRaw::GetCluster(TInt aClusterNumber,TInt64 &aPosition) + { + TInt entry; + _LIT(KEntry,"Entry"); + TInt entryposition; + _LIT(KPositionInEntry,"PositionInEntry"); + TBool alright = GetIntFromConfig(ConfigSection(), KEntry, entry); + if (alright) + { + TBool alright2 = GetIntFromConfig(ConfigSection(), KPositionInEntry, entryposition); + if (alright2) + { + aPosition = (iBPB_ResvdSecCnt + (iBPB_FATSz32*2) + (iBPB_SecPerClus * (aClusterNumber - 2))) * 512; + aPosition = aPosition + ((entry - 1)*96)+ entryposition;//(32 * (entry - 1)); + } + } + return KErrNone; + } +