os/kernelhwsrv/kerneltest/e32test/dll/t_staticdata.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) 2008-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_staticdata.cpp
sl@0
    15
// Overview:
sl@0
    16
// Test static data is initialised correctly
sl@0
    17
// API Information:
sl@0
    18
// n/a
sl@0
    19
// Details:
sl@0
    20
// Platforms/Drives/Compatibility:
sl@0
    21
// All.
sl@0
    22
// Assumptions/Requirement/Pre-requisites:
sl@0
    23
// Failures and causes:
sl@0
    24
// Base Port information:
sl@0
    25
// 
sl@0
    26
//
sl@0
    27
sl@0
    28
#define __E32TEST_EXTENSION__
sl@0
    29
sl@0
    30
#include <e32test.h>
sl@0
    31
#include <e32svr.h>
sl@0
    32
sl@0
    33
sl@0
    34
const TUint32 KTestValue = 0x12345678;
sl@0
    35
TInt E32Main();
sl@0
    36
sl@0
    37
// initialised static data...
sl@0
    38
TUint32  Data[4]		= {0,KTestValue,~KTestValue,0xffffffffu};
sl@0
    39
TInt   (*CodePointer)()	= &E32Main;
sl@0
    40
TUint32* DataPointer	= Data;
sl@0
    41
TUint32  Bss[4]			= {0};
sl@0
    42
sl@0
    43
sl@0
    44
TInt E32Main()
sl@0
    45
	{
sl@0
    46
	RTest test(_L("T_STATICDATA"));
sl@0
    47
	test.Title();
sl@0
    48
sl@0
    49
	// Turn off evil lazy dll unloading
sl@0
    50
	RLoader l;
sl@0
    51
	test(l.Connect()==KErrNone);
sl@0
    52
	test(l.CancelLazyDllUnload()==KErrNone);
sl@0
    53
	l.Close();
sl@0
    54
sl@0
    55
	test.Start(_L("Test static data in EXEs"));
sl@0
    56
sl@0
    57
	test_Equal(0,Data[0]);
sl@0
    58
	test_Equal(KTestValue,Data[1]);
sl@0
    59
	test_Equal(~KTestValue,Data[2]);
sl@0
    60
	test_Equal(0xffffffffu,Data[3]);
sl@0
    61
sl@0
    62
	test_Equal(&E32Main,CodePointer);
sl@0
    63
sl@0
    64
	test_Equal(Data,DataPointer);
sl@0
    65
sl@0
    66
	TInt i;
sl@0
    67
	for(i=0; i<TInt(sizeof(Bss)/sizeof(Bss[0])); ++i)
sl@0
    68
		test_Equal(0,Bss[i]);
sl@0
    69
sl@0
    70
	// check a second concurrent process also works...
sl@0
    71
	if(User::CommandLineLength()==0)
sl@0
    72
		{
sl@0
    73
		test.Next(_L("Test static data in second EXE instance"));
sl@0
    74
		RProcess p;
sl@0
    75
		test_KErrNone(p.Create(p.FileName(),_L("2")));
sl@0
    76
		TRequestStatus s;
sl@0
    77
		p.Logon(s);
sl@0
    78
		p.Resume();
sl@0
    79
		User::WaitForRequest(s);
sl@0
    80
		test_Equal(0,p.ExitReason());
sl@0
    81
		test_Equal(EExitKill,p.ExitType());
sl@0
    82
		}
sl@0
    83
	test.End();
sl@0
    84
	return(KErrNone);
sl@0
    85
	}
sl@0
    86