os/kernelhwsrv/kerneltest/e32test/pccd/t_pccdsk.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32test\pccd\t_pccdsk.cpp
sl@0
    15
// Soak test the Compact Flash card (ATA).
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
sl@0
    20
// One of these
sl@0
    21
#define USE_MEDIA_CHANGE
sl@0
    22
//#define USE_POWER_OFF_ON
sl@0
    23
sl@0
    24
#include <e32test.h>
sl@0
    25
#include <e32svr.h>
sl@0
    26
#include <e32hal.h>
sl@0
    27
#include <e32uid.h>
sl@0
    28
#include <hal.h>
sl@0
    29
sl@0
    30
#define ATA_PDD_NAME _L("MEDATA")
sl@0
    31
sl@0
    32
const TInt KAtaSectorSize=512;
sl@0
    33
const TInt KMaxSectors=16;
sl@0
    34
const TInt KMaxRdWrBufLen=(KAtaSectorSize*KMaxSectors); // 8K
sl@0
    35
const TInt KMaxErrPos=5;
sl@0
    36
sl@0
    37
LOCAL_D	TBusLocalDrive TheDrive;
sl@0
    38
LOCAL_D TBool ChangedFlag;
sl@0
    39
RTest test(_L("Local Drive Soak Test"));
sl@0
    40
LOCAL_D TBuf8<KMaxRdWrBufLen> wrBuf1,wrBuf2,rdBuf;
sl@0
    41
sl@0
    42
class TResult
sl@0
    43
	{
sl@0
    44
public:
sl@0
    45
	enum TResTest {EWrite,ERead,ECompare,EFormat,EReMount};
sl@0
    46
	TResult();
sl@0
    47
	void Display(CConsoleBase *aConsole, TInt aCycles);
sl@0
    48
	void Add(TResTest aTst,TInt anErr,TInt anErrPos);
sl@0
    49
	inline void SetMemStillFree(TInt aVal)
sl@0
    50
		{iFreeMem=aVal;}
sl@0
    51
	inline void WriteAborted()
sl@0
    52
		{iAbortedWrites++;}
sl@0
    53
	inline TInt WriteFails()
sl@0
    54
		{return(iWriteTimeoutFails+iWriteWriteFails+iWriteGeneralFails+iWriteCorruptFails+iWriteBatLowFails+iWriteOtherFails);}
sl@0
    55
	inline TInt ReadFails()
sl@0
    56
		{return(iReadTimeoutFails+iReadCorruptFails+iReadOtherFails);}
sl@0
    57
	inline TInt CompareFails()
sl@0
    58
		{return(iCompareFails);}
sl@0
    59
	inline TInt FormatFails()
sl@0
    60
		{return(iFormatTimeoutFails+iFormatEmergencyFails+iFormatBatLowFails+iFormatOtherFails);}
sl@0
    61
	inline TInt ReMountFails()
sl@0
    62
		{return(iReMountFails);}
sl@0
    63
public:
sl@0
    64
	TInt iWriteTimeoutFails;
sl@0
    65
	TInt iWriteWriteFails;
sl@0
    66
	TInt iWriteGeneralFails;
sl@0
    67
	TInt iWriteCorruptFails;
sl@0
    68
	TInt iWriteBatLowFails;
sl@0
    69
	TInt iWriteOtherFails;
sl@0
    70
	TInt iReadTimeoutFails;
sl@0
    71
	TInt iReadCorruptFails;
sl@0
    72
	TInt iReadOtherFails;
sl@0
    73
	TInt iCompareFails;
sl@0
    74
	TInt iFormatTimeoutFails;
sl@0
    75
	TInt iFormatEmergencyFails;
sl@0
    76
	TInt iFormatBatLowFails;
sl@0
    77
	TInt iFormatOtherFails;
sl@0
    78
	TInt iReMountFails;
sl@0
    79
	TInt iLastErrorPos[KMaxErrPos];
sl@0
    80
	TInt iLastErrorPtr;
sl@0
    81
	TInt iFreeMem;
sl@0
    82
	TInt iAbortedWrites;
sl@0
    83
	};
sl@0
    84
sl@0
    85
sl@0
    86
LOCAL_C void StatusBar(TInt aPos,TInt anEndPos,TInt aYPos,const TPtrC &aTitle)
sl@0
    87
//
sl@0
    88
// Display progress of local drive operation on screen (1-16 dots)
sl@0
    89
//
sl@0
    90
	{
sl@0
    91
	static TInt prev;
sl@0
    92
	TInt curr;
sl@0
    93
	if ((curr=(aPos-1)/(anEndPos>>4))>prev)
sl@0
    94
		{ // Update progress bar
sl@0
    95
		test.Console()->SetPos(0,aYPos);
sl@0
    96
		test.Printf(_L("                              "));
sl@0
    97
		test.Console()->SetPos(2);
sl@0
    98
		test.Printf(_L("%S "),&aTitle);
sl@0
    99
		for (TInt i=curr;i>=0;i--)
sl@0
   100
			test.Printf(_L("."));
sl@0
   101
		}
sl@0
   102
	prev=curr;
sl@0
   103
	}
sl@0
   104
sl@0
   105
TResult::TResult()
sl@0
   106
//
sl@0
   107
// Constructor
sl@0
   108
//
sl@0
   109
	{
sl@0
   110
sl@0
   111
	iWriteTimeoutFails=0;
sl@0
   112
	iWriteWriteFails=0;
sl@0
   113
	iWriteGeneralFails=0;
sl@0
   114
	iWriteCorruptFails=0;
sl@0
   115
	iWriteBatLowFails=0;
sl@0
   116
	iWriteOtherFails=0;
sl@0
   117
	iReadTimeoutFails=0;
sl@0
   118
	iReadCorruptFails=0;
sl@0
   119
	iReadOtherFails=0;
sl@0
   120
	iCompareFails=0;
sl@0
   121
	iFormatTimeoutFails=0;
sl@0
   122
	iFormatEmergencyFails=0;
sl@0
   123
	iFormatBatLowFails=0;
sl@0
   124
	iFormatOtherFails=0;
sl@0
   125
	iReMountFails=0;
sl@0
   126
	for (TInt i=0;i<KMaxErrPos;i++)
sl@0
   127
		iLastErrorPos[i]=0;
sl@0
   128
	iLastErrorPtr=0;
sl@0
   129
	iFreeMem=0;
sl@0
   130
	iAbortedWrites=0;
sl@0
   131
	}
sl@0
   132
sl@0
   133
void TResult::Display(CConsoleBase *aConsole, TInt aCycles)
sl@0
   134
//
sl@0
   135
// Display test results
sl@0
   136
//
sl@0
   137
	{
sl@0
   138
sl@0
   139
	TInt xStartPos=3;
sl@0
   140
	TInt yStartPos=8;
sl@0
   141
sl@0
   142
	aConsole->SetPos(xStartPos,yStartPos);
sl@0
   143
	test.Printf(_L("Cycles(%08xH) : %d"),iFreeMem,aCycles);
sl@0
   144
sl@0
   145
	aConsole->SetPos(xStartPos,yStartPos+1);
sl@0
   146
	if (WriteFails())
sl@0
   147
		test.Printf(_L("Write Fails       : %d (TO:%d BT:%d WR:%d GE:%d CU:%d OT:%d)"),WriteFails(),iWriteTimeoutFails,\
sl@0
   148
					   iWriteBatLowFails,iWriteWriteFails,iWriteGeneralFails,iWriteCorruptFails,iWriteOtherFails);
sl@0
   149
	else
sl@0
   150
		test.Printf(_L("Write Fails       : 0"));
sl@0
   151
sl@0
   152
	aConsole->SetPos(xStartPos,yStartPos+2);
sl@0
   153
	if (ReadFails())
sl@0
   154
		test.Printf(_L("Read Fails        : %d (TO:%d CU:%d OT:%d)"),ReadFails(),iReadTimeoutFails,iReadCorruptFails,iReadOtherFails);
sl@0
   155
	else
sl@0
   156
		test.Printf(_L("Read Fails        : 0"));
sl@0
   157
sl@0
   158
	aConsole->SetPos(xStartPos,yStartPos+3);
sl@0
   159
	test.Printf(_L("Compare Fails     : %d"),CompareFails());
sl@0
   160
sl@0
   161
	aConsole->SetPos(xStartPos,yStartPos+4);
sl@0
   162
	if (FormatFails())
sl@0
   163
		test.Printf(_L("Format Fails      : %d (TO:%d EM:%d BT:%d OT:%d)"),FormatFails(),iFormatTimeoutFails,iFormatEmergencyFails,iFormatBatLowFails,iFormatOtherFails);
sl@0
   164
	else
sl@0
   165
		test.Printf(_L("Format Fails      : 0"));
sl@0
   166
sl@0
   167
	aConsole->SetPos(xStartPos,yStartPos+5);
sl@0
   168
#if defined (USE_MEDIA_CHANGE)
sl@0
   169
	test.Printf(_L("MediaChange Fails : %d"),ReMountFails());
sl@0
   170
#else
sl@0
   171
	test.Printf(_L("Pwr off/on Fails  : %d"),ReMountFails());
sl@0
   172
#endif
sl@0
   173
sl@0
   174
	aConsole->SetPos(xStartPos,yStartPos+6);
sl@0
   175
	test.Printf(_L("Last failures at  : "));
sl@0
   176
	for (TInt i=iLastErrorPtr;i>0;i--)
sl@0
   177
		test.Printf(_L("%xH "),iLastErrorPos[i-1]);
sl@0
   178
	aConsole->SetPos(xStartPos,yStartPos+7);
sl@0
   179
	test.Printf(_L("Writes aborted    : %d"),iAbortedWrites);
sl@0
   180
	test.Printf(_L("\r\n"));
sl@0
   181
	}
sl@0
   182
sl@0
   183
void TResult::Add(TResTest aTst,TInt anErr,TInt anErrPos)
sl@0
   184
//
sl@0
   185
// Add a test result
sl@0
   186
//
sl@0
   187
	{
sl@0
   188
sl@0
   189
	if (anErr!=KErrNone)
sl@0
   190
		{
sl@0
   191
		RDebug::Print(_L("%d) %d(%x)"),aTst,anErr,anErrPos);
sl@0
   192
		// Save start sector involved in operation which failed
sl@0
   193
		if (anErrPos>=0)
sl@0
   194
			{
sl@0
   195
			if (iLastErrorPtr>=KMaxErrPos)
sl@0
   196
				{
sl@0
   197
				TInt i;
sl@0
   198
				for (i=0;i<(KMaxErrPos-1);i++)
sl@0
   199
					iLastErrorPos[i]=iLastErrorPos[i+1];
sl@0
   200
				iLastErrorPos[i]=anErrPos;
sl@0
   201
				}
sl@0
   202
			else
sl@0
   203
				{
sl@0
   204
				iLastErrorPtr++;
sl@0
   205
				iLastErrorPos[iLastErrorPtr-1]=anErrPos;
sl@0
   206
				}
sl@0
   207
			}
sl@0
   208
sl@0
   209
		// Save error type
sl@0
   210
		switch (aTst)
sl@0
   211
			{
sl@0
   212
			case EWrite:
sl@0
   213
				if (anErr==KErrTimedOut)
sl@0
   214
					iWriteTimeoutFails++;
sl@0
   215
				else if (anErr==KErrWrite)
sl@0
   216
					iWriteWriteFails++;
sl@0
   217
				else if (anErr==KErrGeneral)
sl@0
   218
					iWriteGeneralFails++;
sl@0
   219
				else if (anErr==KErrCorrupt)
sl@0
   220
					iWriteCorruptFails++;
sl@0
   221
				else if (anErr==KErrBadPower)
sl@0
   222
					iWriteBatLowFails++;
sl@0
   223
				else
sl@0
   224
					iWriteOtherFails++;
sl@0
   225
				break;
sl@0
   226
			case ERead:
sl@0
   227
				if (anErr==KErrTimedOut)
sl@0
   228
					iReadTimeoutFails++;
sl@0
   229
				else if (anErr==KErrCorrupt)
sl@0
   230
					iReadCorruptFails++;
sl@0
   231
				else
sl@0
   232
					iReadOtherFails++;
sl@0
   233
				break;
sl@0
   234
			case ECompare:
sl@0
   235
				iCompareFails++;
sl@0
   236
				break;
sl@0
   237
			case EFormat:
sl@0
   238
				if (anErr==KErrTimedOut)
sl@0
   239
					iFormatTimeoutFails++;
sl@0
   240
				else if (anErr==KErrAbort)
sl@0
   241
					iFormatEmergencyFails++;
sl@0
   242
				else if (anErr==KErrBadPower)
sl@0
   243
					iFormatBatLowFails++;
sl@0
   244
				else
sl@0
   245
					iFormatOtherFails++;
sl@0
   246
				break;
sl@0
   247
			case EReMount:
sl@0
   248
				iReMountFails++;
sl@0
   249
				break;
sl@0
   250
			}
sl@0
   251
		}
sl@0
   252
	}
sl@0
   253
sl@0
   254
LOCAL_C TUint GetTUintFromConsole(const TDesC &aText)
sl@0
   255
//
sl@0
   256
// Get a TUint value from the console
sl@0
   257
//
sl@0
   258
    {
sl@0
   259
sl@0
   260
    TBuf<10> buf(0);
sl@0
   261
    TKeyCode kc;
sl@0
   262
    TUint pos=0;
sl@0
   263
	test.Printf(aText);
sl@0
   264
    TUint linePos=(aText.Length()+2);
sl@0
   265
	test.Console()->SetPos(linePos);
sl@0
   266
    FOREVER
sl@0
   267
        {
sl@0
   268
		switch((kc=test.Getch()))
sl@0
   269
			{
sl@0
   270
            case EKeyEscape: case EKeyEnter:
sl@0
   271
				{
sl@0
   272
                TLex lex(buf);
sl@0
   273
	            TUint v;
sl@0
   274
                if (lex.Val(v,EDecimal)==KErrNone)
sl@0
   275
                    return(v);
sl@0
   276
                return(0);
sl@0
   277
				}
sl@0
   278
            case EKeyBackspace: case EKeyDelete:
sl@0
   279
                pos--;
sl@0
   280
				buf.Delete(pos,1);
sl@0
   281
                linePos--;
sl@0
   282
	            test.Console()->SetPos(linePos);
sl@0
   283
	            test.Printf(_L(" "));
sl@0
   284
	            test.Console()->SetPos(linePos);
sl@0
   285
				break;
sl@0
   286
            default:
sl@0
   287
				TChar ch=(TUint)kc;
sl@0
   288
                if (ch.IsDigit() && pos<9)
sl@0
   289
                    {
sl@0
   290
                    buf.Append(ch);
sl@0
   291
					pos++;
sl@0
   292
	                test.Printf(_L("%c"),(TUint)ch);
sl@0
   293
					linePos++;
sl@0
   294
                    }
sl@0
   295
                break;
sl@0
   296
			}
sl@0
   297
        }
sl@0
   298
    }
sl@0
   299
sl@0
   300
GLDEF_C TInt E32Main()
sl@0
   301
    {
sl@0
   302
	TBuf<64> b;
sl@0
   303
sl@0
   304
	test.Title();
sl@0
   305
	TDriveInfoV1Buf diBuf;
sl@0
   306
	UserHal::DriveInfo(diBuf);
sl@0
   307
	TDriveInfoV1 &di=diBuf();
sl@0
   308
	test.Printf(_L("Select Local Drive (C-%c): "),'C'+(di.iTotalSupportedDrives-1));
sl@0
   309
	TChar c;
sl@0
   310
	TInt drv;
sl@0
   311
	FOREVER
sl@0
   312
		{
sl@0
   313
		c=(TUint)test.Getch();
sl@0
   314
		c.UpperCase();
sl@0
   315
		drv=((TUint)c)-'C';
sl@0
   316
		if (drv>=0&&drv<di.iTotalSupportedDrives)
sl@0
   317
			break;
sl@0
   318
		}
sl@0
   319
	test.Printf(_L("%c:\r\n"),'C'+drv);
sl@0
   320
sl@0
   321
	test.Printf(_L("Select Test Sequence (Sector 1-R,2-WR,3-WRF)/(SubSector 4-R,5-WR,6-WRF): "));
sl@0
   322
	TInt testSeq;
sl@0
   323
	FOREVER
sl@0
   324
		{
sl@0
   325
		c=(TUint)test.Getch();
sl@0
   326
		testSeq=((TUint)c)-'0';
sl@0
   327
		if (testSeq>=0&&testSeq<=6)
sl@0
   328
			break;
sl@0
   329
		}
sl@0
   330
	test.Printf(_L("%d\r\n"),testSeq);
sl@0
   331
sl@0
   332
	TInt RdWrLen=(TInt)GetTUintFromConsole(_L("Select Buffer Size In Sectors: "));
sl@0
   333
	RdWrLen*=KAtaSectorSize;
sl@0
   334
sl@0
   335
	test.Start(_L("Load Ata Media Driver"));
sl@0
   336
	TInt r;
sl@0
   337
	r=User::LoadPhysicalDevice(ATA_PDD_NAME);
sl@0
   338
	test(r==KErrNone || r==KErrAlreadyExists);
sl@0
   339
#if defined (USE_POWER_OFF_ON)
sl@0
   340
	RTimer timer;
sl@0
   341
	test(timer.CreateLocal()==KErrNone);
sl@0
   342
	TRequestStatus prs;
sl@0
   343
	TTime tim;
sl@0
   344
#endif
sl@0
   345
	TInt muid=0;
sl@0
   346
	r=HAL::Get(HAL::EMachineUid, muid);
sl@0
   347
	test(r==KErrNone);
sl@0
   348
	TBool reMountTestSupported=ETrue;
sl@0
   349
//	if (machineName.MatchF(_L("SNOWBALL*"))>=0)	// snowball is ancient history
sl@0
   350
//		reMountTestSupported=EFalse;
sl@0
   351
sl@0
   352
	b.Format(_L("Connect to drive %c:"),'C'+drv);
sl@0
   353
	test.Next(b);
sl@0
   354
	ChangedFlag=EFalse;
sl@0
   355
	TheDrive.Connect(drv,ChangedFlag);
sl@0
   356
sl@0
   357
	test.Next(_L("ATA drive: Capabilities"));
sl@0
   358
	TLocalDriveCapsV2Buf info;
sl@0
   359
	test(TheDrive.Caps(info)==KErrNone);
sl@0
   360
	test(info().iType==EMediaHardDisk);
sl@0
   361
	TInt diskSize=I64LOW(info().iSize);
sl@0
   362
sl@0
   363
	wrBuf1.SetLength(RdWrLen);
sl@0
   364
	TInt j;
sl@0
   365
	for (j=0;j<RdWrLen;j++)
sl@0
   366
		wrBuf1[j]=(TUint8)j;
sl@0
   367
	wrBuf2.SetLength(RdWrLen);
sl@0
   368
	for (j=0;j<RdWrLen;j++)
sl@0
   369
		wrBuf2[j]=(TUint8)((RdWrLen-1)-j);
sl@0
   370
sl@0
   371
	TUint *p;
sl@0
   372
	TDes8* wrBuf;
sl@0
   373
	TInt cycles=0;
sl@0
   374
	TResult results;
sl@0
   375
	TBool decendPat=EFalse;
sl@0
   376
sl@0
   377
	TRequestStatus kStat;
sl@0
   378
	test.Console()->Read(kStat);
sl@0
   379
	FOREVER
sl@0
   380
		{
sl@0
   381
		wrBuf=(decendPat)?&wrBuf2:&wrBuf1;
sl@0
   382
		p=(decendPat)?(TUint*)&wrBuf2[0]:(TUint*)&wrBuf1[0];
sl@0
   383
		TInt i,j,len,res;
sl@0
   384
sl@0
   385
		// Recalculate amount of free memory
sl@0
   386
    	TMemoryInfoV1Buf membuf;
sl@0
   387
    	UserHal::MemoryInfo(membuf);
sl@0
   388
    	TMemoryInfoV1 &memoryInfo=membuf();
sl@0
   389
		results.SetMemStillFree(memoryInfo.iFreeRamInBytes);
sl@0
   390
		results.Display(test.Console(),cycles);
sl@0
   391
sl@0
   392
		// Write test
sl@0
   393
		RDebug::Print(_L("0"));
sl@0
   394
		if (testSeq==2||testSeq==3||testSeq==5||testSeq==6)
sl@0
   395
			{
sl@0
   396
			for (i=0,j=0;i<diskSize;i+=len,j++)
sl@0
   397
				{
sl@0
   398
				StatusBar(i,diskSize,16,_L("WRITING   "));
sl@0
   399
				if (testSeq>3)
sl@0
   400
					len=Min(RdWrLen-3,(diskSize-i)); // Not on sector boundary
sl@0
   401
				else
sl@0
   402
					len=Min(RdWrLen,(diskSize-i));
sl@0
   403
				(*p)=j;
sl@0
   404
				wrBuf->SetLength(len);
sl@0
   405
				do
sl@0
   406
					{
sl@0
   407
					res=TheDrive.Write(i,*wrBuf);
sl@0
   408
					if (res==KErrAbort)
sl@0
   409
						{
sl@0
   410
						results.WriteAborted();
sl@0
   411
						results.Display(test.Console(),cycles);
sl@0
   412
						}
sl@0
   413
					} while (res==KErrNotReady||res==KErrAbort);
sl@0
   414
				results.Add(TResult::EWrite,res,i);
sl@0
   415
				if (res!=KErrNone)
sl@0
   416
					break;
sl@0
   417
				}
sl@0
   418
			results.Display(test.Console(),cycles);
sl@0
   419
			}
sl@0
   420
sl@0
   421
		// Read test
sl@0
   422
		RDebug::Print(_L("1"));
sl@0
   423
		if (testSeq>=1)
sl@0
   424
			{
sl@0
   425
			for (i=0,j=0;i<diskSize;i+=len,j++)
sl@0
   426
				{
sl@0
   427
				StatusBar(i,diskSize,16,_L("READING   "));
sl@0
   428
				if (testSeq>3)
sl@0
   429
					len=Min(RdWrLen-3,(diskSize-i)); // Not on sector boundary
sl@0
   430
				else
sl@0
   431
					len=Min(RdWrLen,(diskSize-i));
sl@0
   432
				rdBuf.Fill(0,len);
sl@0
   433
				do
sl@0
   434
					{
sl@0
   435
					res=TheDrive.Read(i,len,rdBuf);
sl@0
   436
					} while (res==KErrNotReady);
sl@0
   437
sl@0
   438
				results.Add(TResult::ERead,res,i);
sl@0
   439
				if (res!=KErrNone)
sl@0
   440
					break;
sl@0
   441
				if (testSeq==2||testSeq==3||testSeq==5||testSeq==6)
sl@0
   442
					{
sl@0
   443
					(*p)=j;
sl@0
   444
					wrBuf->SetLength(len);
sl@0
   445
					if (rdBuf.Compare(*wrBuf)!=0)
sl@0
   446
						{
sl@0
   447
						results.Add(TResult::ECompare,KErrGeneral,-1);
sl@0
   448
						break;
sl@0
   449
						}
sl@0
   450
					}
sl@0
   451
				}
sl@0
   452
			results.Display(test.Console(),cycles);
sl@0
   453
			}
sl@0
   454
sl@0
   455
		// Format test
sl@0
   456
		RDebug::Print(_L("3"));
sl@0
   457
		if (testSeq==3||testSeq==6)
sl@0
   458
			{ 
sl@0
   459
			TFormatInfo fi;
sl@0
   460
			FOREVER
sl@0
   461
				{
sl@0
   462
				StatusBar((fi.i512ByteSectorsFormatted<<9),diskSize,16,_L("FORMATTING"));
sl@0
   463
				do
sl@0
   464
					{
sl@0
   465
					res=TheDrive.Format(fi);
sl@0
   466
					} while (res==KErrNotReady);
sl@0
   467
				if (res==KErrEof)
sl@0
   468
					break;
sl@0
   469
				results.Add(TResult::EFormat,res,(fi.i512ByteSectorsFormatted<<9));
sl@0
   470
				if (res!=KErrNone)
sl@0
   471
					break;
sl@0
   472
				}
sl@0
   473
			results.Display(test.Console(),cycles);
sl@0
   474
			}
sl@0
   475
sl@0
   476
		RDebug::Print(_L("4"));
sl@0
   477
		if (reMountTestSupported)
sl@0
   478
			{
sl@0
   479
			// Media change test / power off-on test
sl@0
   480
#if defined (USE_MEDIA_CHANGE)
sl@0
   481
			TheDrive.ForceMediaChange();
sl@0
   482
			if (ChangedFlag==EFalse)
sl@0
   483
				results.Add(TResult::EReMount,KErrGeneral,-1);
sl@0
   484
#else
sl@0
   485
			tim.HomeTime();
sl@0
   486
			tim+=TTimeIntervalSeconds(8);
sl@0
   487
			timer.At(prs,tim);
sl@0
   488
			UserHal::SwitchOff();		// Switch off
sl@0
   489
			User::WaitForRequest(prs);	// Switch back on
sl@0
   490
			if (prs.Int()!=KErrNone)
sl@0
   491
				results.Add(TResult::EReMount,KErrGeneral,-1);
sl@0
   492
#endif
sl@0
   493
			else
sl@0
   494
				{
sl@0
   495
				do
sl@0
   496
					{
sl@0
   497
					res=TheDrive.Caps(info);
sl@0
   498
					} while (res==KErrNotReady);
sl@0
   499
				if (res==KErrNone)
sl@0
   500
					{
sl@0
   501
					if (info().iType!=EMediaHardDisk)
sl@0
   502
						results.Add(TResult::EReMount,KErrGeneral,-1);
sl@0
   503
					}
sl@0
   504
				else
sl@0
   505
					results.Add(TResult::EReMount,res,-1);
sl@0
   506
				}
sl@0
   507
			ChangedFlag=EFalse;
sl@0
   508
			}
sl@0
   509
sl@0
   510
		cycles++;
sl@0
   511
		decendPat^=0x01;
sl@0
   512
sl@0
   513
		if (kStat!=KRequestPending)
sl@0
   514
			{
sl@0
   515
			TKeyCode c=test.Console()->KeyCode();
sl@0
   516
			if (c==EKeySpace)
sl@0
   517
				break;
sl@0
   518
			test.Console()->Read(kStat);
sl@0
   519
			}
sl@0
   520
		RDebug::Print(_L("<<"));
sl@0
   521
		}
sl@0
   522
sl@0
   523
	b.Format(_L("Disconnect from local drive (%c:)"),'C'+drv);
sl@0
   524
	test.Next(b);
sl@0
   525
	TheDrive.Disconnect();
sl@0
   526
sl@0
   527
	test.End();
sl@0
   528
	return(0);
sl@0
   529
	}
sl@0
   530