os/kernelhwsrv/kerneltest/e32test/dll/t_staticdata.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/dll/t_staticdata.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,86 @@
     1.4 +// Copyright (c) 2008-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_staticdata.cpp
    1.18 +// Overview:
    1.19 +// Test static data is initialised correctly
    1.20 +// API Information:
    1.21 +// n/a
    1.22 +// Details:
    1.23 +// Platforms/Drives/Compatibility:
    1.24 +// All.
    1.25 +// Assumptions/Requirement/Pre-requisites:
    1.26 +// Failures and causes:
    1.27 +// Base Port information:
    1.28 +// 
    1.29 +//
    1.30 +
    1.31 +#define __E32TEST_EXTENSION__
    1.32 +
    1.33 +#include <e32test.h>
    1.34 +#include <e32svr.h>
    1.35 +
    1.36 +
    1.37 +const TUint32 KTestValue = 0x12345678;
    1.38 +TInt E32Main();
    1.39 +
    1.40 +// initialised static data...
    1.41 +TUint32  Data[4]		= {0,KTestValue,~KTestValue,0xffffffffu};
    1.42 +TInt   (*CodePointer)()	= &E32Main;
    1.43 +TUint32* DataPointer	= Data;
    1.44 +TUint32  Bss[4]			= {0};
    1.45 +
    1.46 +
    1.47 +TInt E32Main()
    1.48 +	{
    1.49 +	RTest test(_L("T_STATICDATA"));
    1.50 +	test.Title();
    1.51 +
    1.52 +	// Turn off evil lazy dll unloading
    1.53 +	RLoader l;
    1.54 +	test(l.Connect()==KErrNone);
    1.55 +	test(l.CancelLazyDllUnload()==KErrNone);
    1.56 +	l.Close();
    1.57 +
    1.58 +	test.Start(_L("Test static data in EXEs"));
    1.59 +
    1.60 +	test_Equal(0,Data[0]);
    1.61 +	test_Equal(KTestValue,Data[1]);
    1.62 +	test_Equal(~KTestValue,Data[2]);
    1.63 +	test_Equal(0xffffffffu,Data[3]);
    1.64 +
    1.65 +	test_Equal(&E32Main,CodePointer);
    1.66 +
    1.67 +	test_Equal(Data,DataPointer);
    1.68 +
    1.69 +	TInt i;
    1.70 +	for(i=0; i<TInt(sizeof(Bss)/sizeof(Bss[0])); ++i)
    1.71 +		test_Equal(0,Bss[i]);
    1.72 +
    1.73 +	// check a second concurrent process also works...
    1.74 +	if(User::CommandLineLength()==0)
    1.75 +		{
    1.76 +		test.Next(_L("Test static data in second EXE instance"));
    1.77 +		RProcess p;
    1.78 +		test_KErrNone(p.Create(p.FileName(),_L("2")));
    1.79 +		TRequestStatus s;
    1.80 +		p.Logon(s);
    1.81 +		p.Resume();
    1.82 +		User::WaitForRequest(s);
    1.83 +		test_Equal(0,p.ExitReason());
    1.84 +		test_Equal(EExitKill,p.ExitType());
    1.85 +		}
    1.86 +	test.End();
    1.87 +	return(KErrNone);
    1.88 +	}
    1.89 +