kerneltest/e32test/dll/oe/t_oeexport_wins.cpp
changeset 9 96e5fb8b040d
equal deleted inserted replaced
-1:000000000000 9:96e5fb8b040d
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32test\dll\t_oeexport_wins.cpp
       
    15 // Overview:
       
    16 // Emulator version that tests it is possible to retrieve the 0th 
       
    17 // ordinal from exes and dlls that are marked as having named 
       
    18 // symbol export data.
       
    19 // API Information:
       
    20 // RProcess, RLibrary
       
    21 // Details:
       
    22 // - 	Test reading 0th ordinal from a dll which has a E32EmulExpSymInfoHdr 
       
    23 // struct at the 0th ordinal and verify the contents of the header
       
    24 // -	Test NULL is returned on attempts to get the 0th ordinal from a 
       
    25 // dll without the named symbol data
       
    26 // -	Test reading the named symbol data from an exe that contains a
       
    27 // E32EmulExpSymInfoHdr struct at the 0th ordinal and verify the contents
       
    28 // -	Test NULL is returned when attempting to read the 0th ordinal of
       
    29 // an exe that doesn't contain a E32EmulExpSymInfoHdr
       
    30 // Platforms/Drives/Compatibility:
       
    31 // All
       
    32 // Assumptions/Requirement/Pre-requisites:
       
    33 // Failures and causes:
       
    34 // Base Port information:
       
    35 // 
       
    36 //
       
    37 
       
    38 #include <t_oedll.h>
       
    39 #include <e32test.h>
       
    40 #include <e32panic.h>
       
    41 #include <f32image.h>
       
    42 
       
    43 RTest test(_L("T_OEEXPORT"));
       
    44 
       
    45 LOCAL_D void VerifyHdr(E32EmulExpSymInfoHdr& aExpectedHdr, E32EmulExpSymInfoHdr &aReadHdr)
       
    46 	{
       
    47 	test(aExpectedHdr.iSymCount == aReadHdr.iSymCount);
       
    48 	test(aExpectedHdr.iDllCount == aReadHdr.iDllCount);
       
    49 	}
       
    50 
       
    51 TInt E32Main()
       
    52 	{
       
    53 	test.Title();
       
    54 
       
    55 	test.Start(_L("Test retrieving 0th ordinal and therefore named symbol export data"));
       
    56 	
       
    57 	E32EmulExpSymInfoHdr tmpHdr;
       
    58 	E32EmulExpSymInfoHdr *readHdr;
       
    59 	RLibrary library;
       
    60 
       
    61 	// The values for the header of the dll with a 0th ordinal
       
    62 	tmpHdr.iSymCount = 0x0;
       
    63 	tmpHdr.iDllCount = 0x3;
       
    64 	test(library.Load(_L("t_oedll.dll")) == KErrNone);
       
    65 	test.Next(_L("Attempt to retrieve named symbol data from t_oedll.dll"));
       
    66 	readHdr = (E32EmulExpSymInfoHdr*)library.Lookup(0);
       
    67 	test(readHdr!=NULL);
       
    68 //#define PRINT_ZEROTH
       
    69 #ifdef PRINT_ZEROTH
       
    70 	test.Printf(_L("iSymCount=%08x;iDllCounts=%08x\n"),readHdr->iSymCount,readHdr->iDllCount);
       
    71 #endif
       
    72 	test.Next(_L("Verify export data of t_oedll.dll is that expected"));
       
    73 	VerifyHdr(tmpHdr, *readHdr);
       
    74 	library.Close();
       
    75 
       
    76 	test.Next(_L("Verify lookup on dll without oe export data returns NULL"));
       
    77 	test(library.Load(_L("t_dll1.dll")) == KErrNone);
       
    78 	readHdr = (E32EmulExpSymInfoHdr*)library.Lookup(0);
       
    79 	test(readHdr == NULL);
       
    80 	library.Close();
       
    81 
       
    82 	// The values for the header of the exe of the current process with a 0th ordinal
       
    83 	tmpHdr.iSymCount = 0x3;
       
    84 	tmpHdr.iDllCount = 0x5;
       
    85 	test.Next(_L("Attempt to retrieve named symbol data from current process"));
       
    86 	readHdr = (E32EmulExpSymInfoHdr*)(RProcess::ExeExportData());
       
    87 	test(readHdr!=NULL);
       
    88 	test.Next(_L("Verify export data 0th ordinal data of this exe is that expected"));
       
    89 #ifdef PRINT_ZEROTH
       
    90 	test.Printf(_L("iSymCount=%08x;iDllCounts=%08x;\n"),readHdr->iSymCount,readHdr->iDllCount);
       
    91 #endif
       
    92 	VerifyHdr(tmpHdr, *readHdr);
       
    93 
       
    94 /*
       
    95 On Emulator can't examine fixups & depdencies via export data as data not included
       
    96 in E32EmulExpSymInfoHdr.  This is all handled by the MS loader.
       
    97 
       
    98 */
       
    99 	test.End();
       
   100 	return KErrNone;
       
   101 	}