os/kernelhwsrv/kerneltest/e32test/pccd/t_lfsdrv.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) 1998-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_lfsdrv.cpp
sl@0
    15
// Test the LFS media driver
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
#include <e32base.h>
sl@0
    20
#include <e32base_private.h>
sl@0
    21
#include <e32test.h>
sl@0
    22
#include <e32svr.h>
sl@0
    23
#include <e32hal.h>
sl@0
    24
#include <e32uid.h>
sl@0
    25
#include <hal.h>
sl@0
    26
sl@0
    27
const TInt KDriveNumber=8;	
sl@0
    28
sl@0
    29
#define PDD_NAME _L("MEDLFS")
sl@0
    30
sl@0
    31
LOCAL_D RTest test(_L("T_LFSDRV"));
sl@0
    32
sl@0
    33
sl@0
    34
GLDEF_C TInt E32Main()
sl@0
    35
    {
sl@0
    36
	TBuf<64> b;
sl@0
    37
	TInt r;
sl@0
    38
sl@0
    39
	test.Title();
sl@0
    40
	test.Start(_L("Check loader running"));
sl@0
    41
sl@0
    42
#if !defined (__WINS__)
sl@0
    43
    test.Next(_L("Read machine information"));
sl@0
    44
	TInt muid;
sl@0
    45
	r=HAL::Get(HAL::EMachineUid, muid);
sl@0
    46
	test(r==KErrNone);
sl@0
    47
	if (muid != HAL::EMachineUid_Brutus)
sl@0
    48
		{
sl@0
    49
		test.Printf(_L("Test not supported on this platform"));
sl@0
    50
		test.End();
sl@0
    51
		return(0);
sl@0
    52
		}
sl@0
    53
#endif
sl@0
    54
sl@0
    55
	test.Next(_L("Load ATA Media Driver"));
sl@0
    56
	r=User::LoadPhysicalDevice(PDD_NAME);
sl@0
    57
	test(r==KErrNone||r==KErrAlreadyExists);
sl@0
    58
sl@0
    59
#if defined (__WINS__)
sl@0
    60
	b.Format(_L("Connect to local drive %d (W)"),KDriveNumber);
sl@0
    61
#else
sl@0
    62
	b.Format(_L("Connect to local drive %d (K)"),KDriveNumber);
sl@0
    63
#endif
sl@0
    64
	test.Next(b);
sl@0
    65
	TBusLocalDrive theDrive;
sl@0
    66
	TBool changeFlag=EFalse;
sl@0
    67
	test(theDrive.Connect(KDriveNumber,changeFlag)==KErrNone);
sl@0
    68
sl@0
    69
	test.Next(_L("LFS drive: Capabilities"));
sl@0
    70
	TLocalDriveCapsV2Buf info;
sl@0
    71
	test(theDrive.Caps(info)==KErrNone);
sl@0
    72
	TInt diskSize=I64LOW(info().iSize);
sl@0
    73
	test.Printf( _L("Check drive size: %d\r\n"),diskSize);
sl@0
    74
//	test.Getch();
sl@0
    75
	test(info().iType==EMediaFlash);
sl@0
    76
	test(info().iConnectionBusType==EConnectionBusInternal);
sl@0
    77
	test(info().iDriveAtt==(TUint)(KDriveAttLocal|KDriveAttInternal));
sl@0
    78
	test(info().iMediaAtt==KMediaAttFormattable);
sl@0
    79
	test(info().iFileSystemId==KDriveFileSysLFFS);
sl@0
    80
sl@0
    81
	test.Next(_L("LFS drive: Read"));
sl@0
    82
	TBuf8<0x10> rdBuf;
sl@0
    83
 	test(theDrive.Read(0,4,rdBuf)==KErrNone);
sl@0
    84
	test.Printf( _L("%x %x %x %x\r\n"),rdBuf[0],rdBuf[1],rdBuf[2],rdBuf[3]);
sl@0
    85
//	test.Getch();
sl@0
    86
sl@0
    87
	test.Next(_L("Free device"));
sl@0
    88
	r=User::FreePhysicalDevice(_L("Media.Lfs"));
sl@0
    89
	test(r==KErrNone);
sl@0
    90
sl@0
    91
	test.End();
sl@0
    92
	return(0);
sl@0
    93
	}
sl@0
    94