os/kernelhwsrv/kerneltest/f32test/manager/t_locdrv.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200 (2012-06-15)
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1996-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
// f32test\manager\t_locdrv.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <e32test.h>
sl@0
    19
#include <e32svr.h>
sl@0
    20
const TUint KMaxDriveFileLen=0x00020000;
sl@0
    21
sl@0
    22
LOCAL_D RTest test(_L("T_LOCDRV"));
sl@0
    23
sl@0
    24
GLDEF_C TInt E32Main()
sl@0
    25
    {
sl@0
    26
	TBusLocalDrive TheLocalDrives[KMaxLocalDrives];
sl@0
    27
	TBool isBoolean;
sl@0
    28
sl@0
    29
	test.Title();
sl@0
    30
	test.Start(_L("Test Local Drive Sw"));
sl@0
    31
    
sl@0
    32
	test.Next(_L("Connect - all drives"));
sl@0
    33
    TInt i=0;
sl@0
    34
	for (; i<KMaxLocalDrives; i++)
sl@0
    35
		TheLocalDrives[i].Connect(i,isBoolean);
sl@0
    36
sl@0
    37
	test.Next(_L("Caps - all drives"));
sl@0
    38
	TLocalDriveCaps info;
sl@0
    39
	for (i=0;i<KMaxLocalDrives;i++)
sl@0
    40
		{
sl@0
    41
		TInt r=TheLocalDrives[i].Caps(info);
sl@0
    42
		if (r==KErrNotSupported)
sl@0
    43
			test.Printf(_L("Drive %c: Not Supported\r\n"),(i+'A'));
sl@0
    44
		else if (r==KErrNone)
sl@0
    45
			test.Printf(_L("Drive %c size: %d\r\n"),(i+'A'),info.iSize );
sl@0
    46
		else
sl@0
    47
			{
sl@0
    48
			test.Printf(_L("Drive %c: Error %d\r\n"),(i+'A'),r);
sl@0
    49
			test.Getch();
sl@0
    50
			}
sl@0
    51
		}
sl@0
    52
sl@0
    53
	TBuf8<256> wrBuf(0x100);
sl@0
    54
	TBuf8<256> rdBuf(0X100);
sl@0
    55
sl@0
    56
	for (TInt j=0 ; j<0x100 ; j++)
sl@0
    57
		wrBuf[j]=(TUint8)j;
sl@0
    58
	for (i=0;i<KMaxLocalDrives;i++)	
sl@0
    59
		{
sl@0
    60
		rdBuf.Fill(0,0x100);
sl@0
    61
		TInt r=TheLocalDrives[i].Write((KMaxDriveFileLen-0x100),wrBuf);
sl@0
    62
		test((r==KErrNone)||(r==KErrNotSupported));
sl@0
    63
 		r=TheLocalDrives[i].Read((KMaxDriveFileLen-0x100),0x100,rdBuf);
sl@0
    64
  		test((r==KErrNone)||(r==KErrNotSupported));
sl@0
    65
		r=rdBuf.Compare(wrBuf);
sl@0
    66
		test((r==KErrNone)||(r==KErrNotFound));
sl@0
    67
		test.Printf( _L("Drive %c Rd/Wr\r\n"),(i+'A'));
sl@0
    68
		}
sl@0
    69
sl@0
    70
	test.Next(_L("Drive A: Format"));
sl@0
    71
	for (i=0 ; i<0x100 ; i++)
sl@0
    72
		wrBuf[i]=0;
sl@0
    73
	
sl@0
    74
	TFormatInfo formatInfo;
sl@0
    75
sl@0
    76
	TInt r=TheLocalDrives[0].Format(formatInfo);
sl@0
    77
	test((r==KErrNone)||(r==KErrNotSupported));
sl@0
    78
 	r=TheLocalDrives[0].Read((KMaxDriveFileLen-0x100),0x100,rdBuf);
sl@0
    79
	test((r==KErrNone)||(r==KErrNotSupported));
sl@0
    80
  	r=rdBuf.Compare(wrBuf);
sl@0
    81
	test((r==KErrNone)||(r==KErrNotFound));
sl@0
    82
sl@0
    83
    test.End();
sl@0
    84
sl@0
    85
	return(0);
sl@0
    86
	}
sl@0
    87