1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/dll/oe/t_oeexport_wins.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,101 @@
1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32test\dll\t_oeexport_wins.cpp
1.18 +// Overview:
1.19 +// Emulator version that tests it is possible to retrieve the 0th
1.20 +// ordinal from exes and dlls that are marked as having named
1.21 +// symbol export data.
1.22 +// API Information:
1.23 +// RProcess, RLibrary
1.24 +// Details:
1.25 +// - Test reading 0th ordinal from a dll which has a E32EmulExpSymInfoHdr
1.26 +// struct at the 0th ordinal and verify the contents of the header
1.27 +// - Test NULL is returned on attempts to get the 0th ordinal from a
1.28 +// dll without the named symbol data
1.29 +// - Test reading the named symbol data from an exe that contains a
1.30 +// E32EmulExpSymInfoHdr struct at the 0th ordinal and verify the contents
1.31 +// - Test NULL is returned when attempting to read the 0th ordinal of
1.32 +// an exe that doesn't contain a E32EmulExpSymInfoHdr
1.33 +// Platforms/Drives/Compatibility:
1.34 +// All
1.35 +// Assumptions/Requirement/Pre-requisites:
1.36 +// Failures and causes:
1.37 +// Base Port information:
1.38 +//
1.39 +//
1.40 +
1.41 +#include <t_oedll.h>
1.42 +#include <e32test.h>
1.43 +#include <e32panic.h>
1.44 +#include <f32image.h>
1.45 +
1.46 +RTest test(_L("T_OEEXPORT"));
1.47 +
1.48 +LOCAL_D void VerifyHdr(E32EmulExpSymInfoHdr& aExpectedHdr, E32EmulExpSymInfoHdr &aReadHdr)
1.49 + {
1.50 + test(aExpectedHdr.iSymCount == aReadHdr.iSymCount);
1.51 + test(aExpectedHdr.iDllCount == aReadHdr.iDllCount);
1.52 + }
1.53 +
1.54 +TInt E32Main()
1.55 + {
1.56 + test.Title();
1.57 +
1.58 + test.Start(_L("Test retrieving 0th ordinal and therefore named symbol export data"));
1.59 +
1.60 + E32EmulExpSymInfoHdr tmpHdr;
1.61 + E32EmulExpSymInfoHdr *readHdr;
1.62 + RLibrary library;
1.63 +
1.64 + // The values for the header of the dll with a 0th ordinal
1.65 + tmpHdr.iSymCount = 0x0;
1.66 + tmpHdr.iDllCount = 0x3;
1.67 + test(library.Load(_L("t_oedll.dll")) == KErrNone);
1.68 + test.Next(_L("Attempt to retrieve named symbol data from t_oedll.dll"));
1.69 + readHdr = (E32EmulExpSymInfoHdr*)library.Lookup(0);
1.70 + test(readHdr!=NULL);
1.71 +//#define PRINT_ZEROTH
1.72 +#ifdef PRINT_ZEROTH
1.73 + test.Printf(_L("iSymCount=%08x;iDllCounts=%08x\n"),readHdr->iSymCount,readHdr->iDllCount);
1.74 +#endif
1.75 + test.Next(_L("Verify export data of t_oedll.dll is that expected"));
1.76 + VerifyHdr(tmpHdr, *readHdr);
1.77 + library.Close();
1.78 +
1.79 + test.Next(_L("Verify lookup on dll without oe export data returns NULL"));
1.80 + test(library.Load(_L("t_dll1.dll")) == KErrNone);
1.81 + readHdr = (E32EmulExpSymInfoHdr*)library.Lookup(0);
1.82 + test(readHdr == NULL);
1.83 + library.Close();
1.84 +
1.85 + // The values for the header of the exe of the current process with a 0th ordinal
1.86 + tmpHdr.iSymCount = 0x3;
1.87 + tmpHdr.iDllCount = 0x5;
1.88 + test.Next(_L("Attempt to retrieve named symbol data from current process"));
1.89 + readHdr = (E32EmulExpSymInfoHdr*)(RProcess::ExeExportData());
1.90 + test(readHdr!=NULL);
1.91 + test.Next(_L("Verify export data 0th ordinal data of this exe is that expected"));
1.92 +#ifdef PRINT_ZEROTH
1.93 + test.Printf(_L("iSymCount=%08x;iDllCounts=%08x;\n"),readHdr->iSymCount,readHdr->iDllCount);
1.94 +#endif
1.95 + VerifyHdr(tmpHdr, *readHdr);
1.96 +
1.97 +/*
1.98 +On Emulator can't examine fixups & depdencies via export data as data not included
1.99 +in E32EmulExpSymInfoHdr. This is all handled by the MS loader.
1.100 +
1.101 +*/
1.102 + test.End();
1.103 + return KErrNone;
1.104 + }