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