os/kernelhwsrv/kerneltest/e32test/system/t_reg.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) 1996-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\system\t_reg.cpp
sl@0
    15
// Overview:
sl@0
    16
// Test the machine configuration functions
sl@0
    17
// API Information:
sl@0
    18
// User::MachineConfiguration, User::SetMachineConfiguration
sl@0
    19
// Details:
sl@0
    20
// - Save machine configuration to different size descriptors and verify
sl@0
    21
// the results are as expected.
sl@0
    22
// - Set the machine configuration back to previous configurations, verify
sl@0
    23
// the results are as expected.
sl@0
    24
// Platforms/Drives/Compatibility:
sl@0
    25
// All.
sl@0
    26
// Assumptions/Requirement/Pre-requisites:
sl@0
    27
// Failures and causes:
sl@0
    28
// Base Port information:
sl@0
    29
// 
sl@0
    30
//
sl@0
    31
sl@0
    32
#include <e32test.h>
sl@0
    33
#include <e32hal.h>
sl@0
    34
sl@0
    35
LOCAL_D RTest test(_L("T_REG"));
sl@0
    36
sl@0
    37
sl@0
    38
LOCAL_C void testMachineConfiguration()
sl@0
    39
//
sl@0
    40
// Test the machine configuration functions
sl@0
    41
//
sl@0
    42
	{
sl@0
    43
sl@0
    44
	test.Start(_L("Create test environment"));
sl@0
    45
//	
sl@0
    46
	test.Next(_L("Save machine configuration to tiny descriptor"));
sl@0
    47
	TInt x=0;
sl@0
    48
    TPtr8 mc11((TUint8*)&x,sizeof(x));
sl@0
    49
	test(User::MachineConfiguration(mc11,x)==KErrArgument);
sl@0
    50
	test(x!=0);
sl@0
    51
	test(x<10000);
sl@0
    52
//
sl@0
    53
	test.Next(_L("Save machine configuration to just too small descriptor"));
sl@0
    54
	TUint8* pMC1=(TUint8*)User::Alloc(x);
sl@0
    55
	test(pMC1!=NULL);
sl@0
    56
	TInt y;
sl@0
    57
    TPtr8 mc12(pMC1,x-1);
sl@0
    58
	test(User::MachineConfiguration(mc12,y)==KErrArgument);
sl@0
    59
	test(y==x);
sl@0
    60
//
sl@0
    61
	test.Next(_L("Save machine configuration properly"));
sl@0
    62
    TPtr8 mc13(pMC1,x);
sl@0
    63
	test(User::MachineConfiguration(mc13,y)==KErrNone);
sl@0
    64
	test(y==x);
sl@0
    65
//
sl@0
    66
	test.Next(_L("Save machine configuration to tiny descriptor"));
sl@0
    67
	TInt z=0;
sl@0
    68
    TPtr8 mc21((TUint8*)&z,sizeof(z));
sl@0
    69
	test(User::MachineConfiguration(mc21,z)==KErrArgument);
sl@0
    70
	test(z!=0);
sl@0
    71
	test(z<10000);
sl@0
    72
//
sl@0
    73
	test.Next(_L("Save machine configuration to just too small descriptor"));
sl@0
    74
	TUint8* pMC2=(TUint8*)User::Alloc(z);
sl@0
    75
	test(pMC2!=NULL);
sl@0
    76
    TPtr8 mc22(pMC2,z-1);
sl@0
    77
	test(User::MachineConfiguration(mc22,y)==KErrArgument);
sl@0
    78
	test(y==z);
sl@0
    79
//
sl@0
    80
	test.Next(_L("Save machine configuration properly"));
sl@0
    81
    TPtr8 mc23(pMC2,z);
sl@0
    82
	test(User::MachineConfiguration(mc23,y)==KErrNone);
sl@0
    83
	test(y==z);
sl@0
    84
//
sl@0
    85
//	__KHEAP_MARK;	// GLD 3/2/97 I don't know why the KHEAP checking is no longer working
sl@0
    86
	test.Next(_L("Restore first configuration"));
sl@0
    87
	test(User::SetMachineConfiguration(TPtrC8(pMC1,x))==KErrNone);
sl@0
    88
//	__KHEAP_CHECK(0);
sl@0
    89
//
sl@0
    90
	test.Next(_L("Restore second configuration"));
sl@0
    91
	test(User::SetMachineConfiguration(TPtrC8(pMC2,z))==KErrNone);
sl@0
    92
//	__KHEAP_MARKEND;
sl@0
    93
//
sl@0
    94
	test.Next(_L("Tidy up"));
sl@0
    95
	delete pMC1;
sl@0
    96
	delete pMC2;
sl@0
    97
	test.End();
sl@0
    98
	}
sl@0
    99
sl@0
   100
sl@0
   101
GLDEF_C TInt E32Main()
sl@0
   102
//
sl@0
   103
// Test the registry functions.
sl@0
   104
//
sl@0
   105
    {
sl@0
   106
sl@0
   107
	test.Title();
sl@0
   108
//
sl@0
   109
	test.Start(_L("Test Machine Configuration"));
sl@0
   110
	testMachineConfiguration();
sl@0
   111
//
sl@0
   112
	test.End();
sl@0
   113
	return(KErrNone);
sl@0
   114
    }
sl@0
   115