os/kernelhwsrv/kerneltest/e32test/dll/oe/t_oeexport_wins.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2006-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\dll\t_oeexport_wins.cpp
sl@0
    15
// Overview:
sl@0
    16
// Emulator version that tests it is possible to retrieve the 0th 
sl@0
    17
// ordinal from exes and dlls that are marked as having named 
sl@0
    18
// symbol export data.
sl@0
    19
// API Information:
sl@0
    20
// RProcess, RLibrary
sl@0
    21
// Details:
sl@0
    22
// - 	Test reading 0th ordinal from a dll which has a E32EmulExpSymInfoHdr 
sl@0
    23
// struct at the 0th ordinal and verify the contents of the header
sl@0
    24
// -	Test NULL is returned on attempts to get the 0th ordinal from a 
sl@0
    25
// dll without the named symbol data
sl@0
    26
// -	Test reading the named symbol data from an exe that contains a
sl@0
    27
// E32EmulExpSymInfoHdr struct at the 0th ordinal and verify the contents
sl@0
    28
// -	Test NULL is returned when attempting to read the 0th ordinal of
sl@0
    29
// an exe that doesn't contain a E32EmulExpSymInfoHdr
sl@0
    30
// Platforms/Drives/Compatibility:
sl@0
    31
// All
sl@0
    32
// Assumptions/Requirement/Pre-requisites:
sl@0
    33
// Failures and causes:
sl@0
    34
// Base Port information:
sl@0
    35
// 
sl@0
    36
//
sl@0
    37
sl@0
    38
#include <t_oedll.h>
sl@0
    39
#include <e32test.h>
sl@0
    40
#include <e32panic.h>
sl@0
    41
#include <f32image.h>
sl@0
    42
sl@0
    43
RTest test(_L("T_OEEXPORT"));
sl@0
    44
sl@0
    45
LOCAL_D void VerifyHdr(E32EmulExpSymInfoHdr& aExpectedHdr, E32EmulExpSymInfoHdr &aReadHdr)
sl@0
    46
	{
sl@0
    47
	test(aExpectedHdr.iSymCount == aReadHdr.iSymCount);
sl@0
    48
	test(aExpectedHdr.iDllCount == aReadHdr.iDllCount);
sl@0
    49
	}
sl@0
    50
sl@0
    51
TInt E32Main()
sl@0
    52
	{
sl@0
    53
	test.Title();
sl@0
    54
sl@0
    55
	test.Start(_L("Test retrieving 0th ordinal and therefore named symbol export data"));
sl@0
    56
	
sl@0
    57
	E32EmulExpSymInfoHdr tmpHdr;
sl@0
    58
	E32EmulExpSymInfoHdr *readHdr;
sl@0
    59
	RLibrary library;
sl@0
    60
sl@0
    61
	// The values for the header of the dll with a 0th ordinal
sl@0
    62
	tmpHdr.iSymCount = 0x0;
sl@0
    63
	tmpHdr.iDllCount = 0x3;
sl@0
    64
	test(library.Load(_L("t_oedll.dll")) == KErrNone);
sl@0
    65
	test.Next(_L("Attempt to retrieve named symbol data from t_oedll.dll"));
sl@0
    66
	readHdr = (E32EmulExpSymInfoHdr*)library.Lookup(0);
sl@0
    67
	test(readHdr!=NULL);
sl@0
    68
//#define PRINT_ZEROTH
sl@0
    69
#ifdef PRINT_ZEROTH
sl@0
    70
	test.Printf(_L("iSymCount=%08x;iDllCounts=%08x\n"),readHdr->iSymCount,readHdr->iDllCount);
sl@0
    71
#endif
sl@0
    72
	test.Next(_L("Verify export data of t_oedll.dll is that expected"));
sl@0
    73
	VerifyHdr(tmpHdr, *readHdr);
sl@0
    74
	library.Close();
sl@0
    75
sl@0
    76
	test.Next(_L("Verify lookup on dll without oe export data returns NULL"));
sl@0
    77
	test(library.Load(_L("t_dll1.dll")) == KErrNone);
sl@0
    78
	readHdr = (E32EmulExpSymInfoHdr*)library.Lookup(0);
sl@0
    79
	test(readHdr == NULL);
sl@0
    80
	library.Close();
sl@0
    81
sl@0
    82
	// The values for the header of the exe of the current process with a 0th ordinal
sl@0
    83
	tmpHdr.iSymCount = 0x3;
sl@0
    84
	tmpHdr.iDllCount = 0x5;
sl@0
    85
	test.Next(_L("Attempt to retrieve named symbol data from current process"));
sl@0
    86
	readHdr = (E32EmulExpSymInfoHdr*)(RProcess::ExeExportData());
sl@0
    87
	test(readHdr!=NULL);
sl@0
    88
	test.Next(_L("Verify export data 0th ordinal data of this exe is that expected"));
sl@0
    89
#ifdef PRINT_ZEROTH
sl@0
    90
	test.Printf(_L("iSymCount=%08x;iDllCounts=%08x;\n"),readHdr->iSymCount,readHdr->iDllCount);
sl@0
    91
#endif
sl@0
    92
	VerifyHdr(tmpHdr, *readHdr);
sl@0
    93
sl@0
    94
/*
sl@0
    95
On Emulator can't examine fixups & depdencies via export data as data not included
sl@0
    96
in E32EmulExpSymInfoHdr.  This is all handled by the MS loader.
sl@0
    97
sl@0
    98
*/
sl@0
    99
	test.End();
sl@0
   100
	return KErrNone;
sl@0
   101
	}