baseport/syborg/ethernet/test/ethernet_test.cpp
author William Roberts <williamr@symbian.org>
Fri, 07 Aug 2009 16:55:42 +0100
changeset 8 3c796bbf0db3
parent 2 d55eb581a87c
permissions -rw-r--r--
Updated the README.txt - includes instructions on downloading ready-to-use QEMU binaries
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
     1
/*
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
     3
* All rights reserved.
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
     4
* This component and the accompanying materials are made available
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
     6
* which accompanies this distribution, and is available
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
     8
*
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
     9
* Initial Contributors:
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    11
*
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    12
* Contributors:
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    13
*
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    14
* Description:
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    15
*
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    16
*/
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    17
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    18
#include <e32test.h>
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    19
#include <e32debug.h>
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    20
#include <d32ethernet.h>
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    21
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    22
LOCAL_D RTest test(_L("DRIVER1_TEST"));
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    23
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    24
_LIT(KDriver1LddFileName,"enet");
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    25
_LIT(KDriver1PddFileName,"ethernet");
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    26
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    27
_LIT8(KTestSendData,"abcdefghijklmnopqrstuvwxyz");
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    28
_LIT8(KTestLargeSendData,"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    29
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    30
GLDEF_C TInt E32Main()
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    31
    {
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    32
	test.Title();
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    33
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    34
	TInt r;
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    35
	RDebug::Printf(">>>>>>E32Main()");
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    36
	
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    37
	test.Start(_L("Load Physical Device"));
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    38
	r=User::LoadPhysicalDevice(KDriver1PddFileName);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    39
	if (r != KErrNone)
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    40
		RDebug::Printf("LoadPhysicalDevice: value of error =%d", r);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    41
		test(r==KErrNone || r==KErrAlreadyExists);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    42
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    43
	test.Next(_L("Load Logical Device"));
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    44
	r=User::LoadLogicalDevice(KDriver1LddFileName);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    45
	if (r != KErrNone)
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    46
			RDebug::Printf("LoadLogicalDevice: value of error =%d", r);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    47
			test(r==KErrNone || r==KErrAlreadyExists);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    48
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    49
	__KHEAP_MARK;
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    50
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    51
	test.Next(_L("Open Logical Channel"));
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    52
	RBusDevEthernet ldd;
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    53
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    54
	r=ldd.Open(0);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    55
	RDebug::Printf("Value returned from ldd.Open()=%d", r);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    56
	test(r==KErrNone);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    57
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    58
	test.Next(_L("SendData"));
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    59
	TRequestStatus status;
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    60
	ldd.Write(status,KTestSendData);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    61
	
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    62
	test.Next(_L("SendDataCancel"));
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    63
	ldd.WriteCancel();
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    64
	User::WaitForRequest(status);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    65
	r=status.Int();
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    66
	//test(r==KErrCancel);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    67
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    68
	test.Next(_L("SendData"));
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    69
	ldd.Write(status,KTestSendData);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    70
	User::WaitForRequest(status);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    71
	r=status.Int();
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    72
	//test(r==KErrNone);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    73
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    74
	test.Next(_L("ReceiveData"));
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    75
	TBuf8<256> buffer;
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    76
	ldd.Read(status,buffer);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    77
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    78
	test.Next(_L("ReceiveDataCancel"));
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    79
	ldd.ReadCancel();
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    80
	User::WaitForRequest(status);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    81
	r=status.Int();
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    82
	test(r==KErrCancel);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    83
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    84
	test.Next(_L("Close Logical Channel"));
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    85
	ldd.Close();
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    86
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    87
	__KHEAP_MARKEND;
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    88
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    89
	test.End();
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    90
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    91
	return(0);
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    92
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    93
  }
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    94
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    95