diff -r 000000000000 -r a41df078684a kerneltest/e32test/pccd/t_meddrv.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kerneltest/e32test/pccd/t_meddrv.cpp Mon Oct 19 15:55:17 2009 +0100 @@ -0,0 +1,246 @@ +// Copyright (c) 1998-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: +// e32test\pccd\t_meddrv.cpp +// General media driver tests +// +// + +#include +#include +#include +#include +#include +#include +const TInt KHeapSize=0x4000; +const TInt KTestDriverMediaSize=0x1000; // 4K +const TInt KShortBufferSize=0x100; + +#define MEDDRV_ATA_NAME _L("MEDATA") +#define MEDDRV_SINGLE_REQ_NAME _L("MEDT1") +#define MEDDRV_SIMULTANEOUS_REQ_NAME _L("MEDT2") + +LOCAL_D RTest test(_L("T_MEDDRV")); +LOCAL_D TInt TheDriveNumber=3; + + +LOCAL_C TInt formatThread(TAny*) + { + + TBusLocalDrive anotherDrive; + RTest ftest(_L("Formatting thread")); + ftest.Title(); + + ftest.Start(_L("Connect to local drive")); + TBool changeFlag=EFalse; + ftest(anotherDrive.Connect(TheDriveNumber,changeFlag)==KErrNone); + + ftest.Next(_L("Format disk")); + ftest(anotherDrive.Format(0,KTestDriverMediaSize)==KErrNone); + anotherDrive.Disconnect(); + + ftest.End(); + return(KErrNone); + } + +GLDEF_C TInt E32Main() + { + TBuf<64> b; + TInt r; + TInt i; + + test.Title(); + test.Start(_L("Check loader running")); + +#if !defined (__WINS__) + test.Next(_L("Read drive information")); + TDriveInfoV1Buf dinfo; + r=UserHal::DriveInfo(dinfo); + test(r==KErrNone); + if (dinfo().iTotalSockets==2) + TheDriveNumber=3; + else if (dinfo().iTotalSockets==1) + TheDriveNumber=2; + else + { + test.Printf(_L("Test not supported on this platform")); + test.End(); + return(0); + } +#else + TheDriveNumber=3; +#endif + + test.Next(_L("Load 1st Media Driver")); + r=User::LoadPhysicalDevice(MEDDRV_ATA_NAME); + test(r==KErrNone||r==KErrAlreadyExists); + r=User::LoadPhysicalDevice(MEDDRV_SINGLE_REQ_NAME); + test(r==KErrNone||r==KErrAlreadyExists); + test.Printf(_L("Media drivers installed:\n\r")); + TFindPhysicalDevice findMediaDrv(_L("Media.*")); + TFullName findResult; + r=findMediaDrv.Next(findResult); + while (r==KErrNone) + { + test.Printf(_L(" %S\n\r"),&findResult); + r=findMediaDrv.Next(findResult); + } + + b.Format(_L("Connect to local drive %d"),TheDriveNumber); + test.Next(b); + TBusLocalDrive theDrive; + TBool changeFlag=EFalse; + test(theDrive.Connect(TheDriveNumber,changeFlag)==KErrNone); + + test.Next(_L("Local drive: Capabilities")); + // Generate a media change to open the profiler media driver rather than the standard one +// UserSvr::ForceRemountMedia(ERemovableMedia0); + User::After(300000); // Wait 0.3Sec + TLocalDriveCapsV2Buf info; + test(theDrive.Caps(info)==KErrNone); + test(I64LOW(info().iSize)==(TUint)KTestDriverMediaSize); + test(info().iType==EMediaRam); + + test.Next(_L("Local drive: Write/Read")); + TInt len; + TBuf8 rdBuf,wrBuf; + wrBuf.SetLength(KShortBufferSize); + for (i=0;i