1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/system/t_reg.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,115 @@
1.4 +// Copyright (c) 1996-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\system\t_reg.cpp
1.18 +// Overview:
1.19 +// Test the machine configuration functions
1.20 +// API Information:
1.21 +// User::MachineConfiguration, User::SetMachineConfiguration
1.22 +// Details:
1.23 +// - Save machine configuration to different size descriptors and verify
1.24 +// the results are as expected.
1.25 +// - Set the machine configuration back to previous configurations, verify
1.26 +// the results are as expected.
1.27 +// Platforms/Drives/Compatibility:
1.28 +// All.
1.29 +// Assumptions/Requirement/Pre-requisites:
1.30 +// Failures and causes:
1.31 +// Base Port information:
1.32 +//
1.33 +//
1.34 +
1.35 +#include <e32test.h>
1.36 +#include <e32hal.h>
1.37 +
1.38 +LOCAL_D RTest test(_L("T_REG"));
1.39 +
1.40 +
1.41 +LOCAL_C void testMachineConfiguration()
1.42 +//
1.43 +// Test the machine configuration functions
1.44 +//
1.45 + {
1.46 +
1.47 + test.Start(_L("Create test environment"));
1.48 +//
1.49 + test.Next(_L("Save machine configuration to tiny descriptor"));
1.50 + TInt x=0;
1.51 + TPtr8 mc11((TUint8*)&x,sizeof(x));
1.52 + test(User::MachineConfiguration(mc11,x)==KErrArgument);
1.53 + test(x!=0);
1.54 + test(x<10000);
1.55 +//
1.56 + test.Next(_L("Save machine configuration to just too small descriptor"));
1.57 + TUint8* pMC1=(TUint8*)User::Alloc(x);
1.58 + test(pMC1!=NULL);
1.59 + TInt y;
1.60 + TPtr8 mc12(pMC1,x-1);
1.61 + test(User::MachineConfiguration(mc12,y)==KErrArgument);
1.62 + test(y==x);
1.63 +//
1.64 + test.Next(_L("Save machine configuration properly"));
1.65 + TPtr8 mc13(pMC1,x);
1.66 + test(User::MachineConfiguration(mc13,y)==KErrNone);
1.67 + test(y==x);
1.68 +//
1.69 + test.Next(_L("Save machine configuration to tiny descriptor"));
1.70 + TInt z=0;
1.71 + TPtr8 mc21((TUint8*)&z,sizeof(z));
1.72 + test(User::MachineConfiguration(mc21,z)==KErrArgument);
1.73 + test(z!=0);
1.74 + test(z<10000);
1.75 +//
1.76 + test.Next(_L("Save machine configuration to just too small descriptor"));
1.77 + TUint8* pMC2=(TUint8*)User::Alloc(z);
1.78 + test(pMC2!=NULL);
1.79 + TPtr8 mc22(pMC2,z-1);
1.80 + test(User::MachineConfiguration(mc22,y)==KErrArgument);
1.81 + test(y==z);
1.82 +//
1.83 + test.Next(_L("Save machine configuration properly"));
1.84 + TPtr8 mc23(pMC2,z);
1.85 + test(User::MachineConfiguration(mc23,y)==KErrNone);
1.86 + test(y==z);
1.87 +//
1.88 +// __KHEAP_MARK; // GLD 3/2/97 I don't know why the KHEAP checking is no longer working
1.89 + test.Next(_L("Restore first configuration"));
1.90 + test(User::SetMachineConfiguration(TPtrC8(pMC1,x))==KErrNone);
1.91 +// __KHEAP_CHECK(0);
1.92 +//
1.93 + test.Next(_L("Restore second configuration"));
1.94 + test(User::SetMachineConfiguration(TPtrC8(pMC2,z))==KErrNone);
1.95 +// __KHEAP_MARKEND;
1.96 +//
1.97 + test.Next(_L("Tidy up"));
1.98 + delete pMC1;
1.99 + delete pMC2;
1.100 + test.End();
1.101 + }
1.102 +
1.103 +
1.104 +GLDEF_C TInt E32Main()
1.105 +//
1.106 +// Test the registry functions.
1.107 +//
1.108 + {
1.109 +
1.110 + test.Title();
1.111 +//
1.112 + test.Start(_L("Test Machine Configuration"));
1.113 + testMachineConfiguration();
1.114 +//
1.115 + test.End();
1.116 + return(KErrNone);
1.117 + }
1.118 +