os/kernelhwsrv/kerneltest/e32test/pccd/t_lfsdrv.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/pccd/t_lfsdrv.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,94 @@
     1.4 +// Copyright (c) 1998-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 +// e32test\pccd\t_lfsdrv.cpp
    1.18 +// Test the LFS media driver
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#include <e32base.h>
    1.23 +#include <e32base_private.h>
    1.24 +#include <e32test.h>
    1.25 +#include <e32svr.h>
    1.26 +#include <e32hal.h>
    1.27 +#include <e32uid.h>
    1.28 +#include <hal.h>
    1.29 +
    1.30 +const TInt KDriveNumber=8;	
    1.31 +
    1.32 +#define PDD_NAME _L("MEDLFS")
    1.33 +
    1.34 +LOCAL_D RTest test(_L("T_LFSDRV"));
    1.35 +
    1.36 +
    1.37 +GLDEF_C TInt E32Main()
    1.38 +    {
    1.39 +	TBuf<64> b;
    1.40 +	TInt r;
    1.41 +
    1.42 +	test.Title();
    1.43 +	test.Start(_L("Check loader running"));
    1.44 +
    1.45 +#if !defined (__WINS__)
    1.46 +    test.Next(_L("Read machine information"));
    1.47 +	TInt muid;
    1.48 +	r=HAL::Get(HAL::EMachineUid, muid);
    1.49 +	test(r==KErrNone);
    1.50 +	if (muid != HAL::EMachineUid_Brutus)
    1.51 +		{
    1.52 +		test.Printf(_L("Test not supported on this platform"));
    1.53 +		test.End();
    1.54 +		return(0);
    1.55 +		}
    1.56 +#endif
    1.57 +
    1.58 +	test.Next(_L("Load ATA Media Driver"));
    1.59 +	r=User::LoadPhysicalDevice(PDD_NAME);
    1.60 +	test(r==KErrNone||r==KErrAlreadyExists);
    1.61 +
    1.62 +#if defined (__WINS__)
    1.63 +	b.Format(_L("Connect to local drive %d (W)"),KDriveNumber);
    1.64 +#else
    1.65 +	b.Format(_L("Connect to local drive %d (K)"),KDriveNumber);
    1.66 +#endif
    1.67 +	test.Next(b);
    1.68 +	TBusLocalDrive theDrive;
    1.69 +	TBool changeFlag=EFalse;
    1.70 +	test(theDrive.Connect(KDriveNumber,changeFlag)==KErrNone);
    1.71 +
    1.72 +	test.Next(_L("LFS drive: Capabilities"));
    1.73 +	TLocalDriveCapsV2Buf info;
    1.74 +	test(theDrive.Caps(info)==KErrNone);
    1.75 +	TInt diskSize=I64LOW(info().iSize);
    1.76 +	test.Printf( _L("Check drive size: %d\r\n"),diskSize);
    1.77 +//	test.Getch();
    1.78 +	test(info().iType==EMediaFlash);
    1.79 +	test(info().iConnectionBusType==EConnectionBusInternal);
    1.80 +	test(info().iDriveAtt==(TUint)(KDriveAttLocal|KDriveAttInternal));
    1.81 +	test(info().iMediaAtt==KMediaAttFormattable);
    1.82 +	test(info().iFileSystemId==KDriveFileSysLFFS);
    1.83 +
    1.84 +	test.Next(_L("LFS drive: Read"));
    1.85 +	TBuf8<0x10> rdBuf;
    1.86 + 	test(theDrive.Read(0,4,rdBuf)==KErrNone);
    1.87 +	test.Printf( _L("%x %x %x %x\r\n"),rdBuf[0],rdBuf[1],rdBuf[2],rdBuf[3]);
    1.88 +//	test.Getch();
    1.89 +
    1.90 +	test.Next(_L("Free device"));
    1.91 +	r=User::FreePhysicalDevice(_L("Media.Lfs"));
    1.92 +	test(r==KErrNone);
    1.93 +
    1.94 +	test.End();
    1.95 +	return(0);
    1.96 +	}
    1.97 +