os/kernelhwsrv/kerneltest/e32test/property/t_property_main.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) 2002-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
// Overview:
sl@0
    15
// Test the RProperty and RPropertyRef classes
sl@0
    16
// API Information:
sl@0
    17
// RProperty, RPropertyRef
sl@0
    18
// Details:
sl@0
    19
// - Test and verify the RProperty methods: Delete, Define, Attach and 
sl@0
    20
// Subscribe work as expected.
sl@0
    21
// - Test the RPropery::Define() method. 
sl@0
    22
// Define the attributes and access control for a property. Verify results 
sl@0
    23
// are as expected. Verify property redefinition does not change security 
sl@0
    24
// settings. Perform various additional tests associated with the Define 
sl@0
    25
// method. Verify results are as expected.
sl@0
    26
// - Test the RPropery::Delete() method. 
sl@0
    27
// Verify that if the property has not been defined, Delete fails with 
sl@0
    28
// KErrNotFound. Verify pending subscriptions will be completed with 
sl@0
    29
// KErrNotFound if the property is deleted. Verify new requests will not 
sl@0
    30
// complete until the property is defined and published again.
sl@0
    31
// - Test the RPropery::Get() and Set() methods. 
sl@0
    32
// Verify failure if the property has not been defined, can set property
sl@0
    33
// to zero length, failure if the property is larger than KMaxPropertySize.
sl@0
    34
// Verify operation mismatch with property type fails as expected. Verify
sl@0
    35
// various get/set operations work as expected.
sl@0
    36
// - Test the RPropery::Subscribe() and Cancel() methods. 
sl@0
    37
// Verify failure if the property has not been defined, request will not 
sl@0
    38
// complete. Cancel outstanding subscription request, verify results are as
sl@0
    39
// expected.
sl@0
    40
// - Test the platform security settings, verify results are as expected. 
sl@0
    41
// Verify that RProperty::Delete() can only succeed when called by the 
sl@0
    42
// property owner. Verify Define, Subscribe, Get caller must have read 
sl@0
    43
// capabilities or error as expected. Verify Set caller must have write 
sl@0
    44
// capabilities or error as expected.
sl@0
    45
// - Perform multiple Set, Get, Subscribe and Cancel operations between 
sl@0
    46
// multiple threads, verify results are as expected.
sl@0
    47
// - Create multiple slave threads, verify Set, Get, Subscribe and Cancel 
sl@0
    48
// operations work as expected.
sl@0
    49
// - Using a loadable device driver, test the basic functionality of an 
sl@0
    50
// RPropertyRef object. Perform many of the same tests as above except 
sl@0
    51
// on a RPropertyRef object. Verify results are as expected.
sl@0
    52
// - Perform all the above multithreaded tests in parallel. Verify results
sl@0
    53
// are as expected.
sl@0
    54
// Platforms/Drives/Compatibility:
sl@0
    55
// All.
sl@0
    56
// Assumptions/Requirement/Pre-requisites:
sl@0
    57
// Failures and causes:
sl@0
    58
// Base Port information:
sl@0
    59
// 
sl@0
    60
//
sl@0
    61
sl@0
    62
#include <e32test.h>
sl@0
    63
#include "t_property.h"
sl@0
    64
sl@0
    65
static const TInt32 KUidPropTestCategoryValue = 0x101f75b7;
sl@0
    66
static const TUid KPropTestCategory = { KUidPropTestCategoryValue };
sl@0
    67
sl@0
    68
GLDEF_C TInt E32Main()
sl@0
    69
	{
sl@0
    70
	TInt iter = 10000;
sl@0
    71
sl@0
    72
	TInt len = User::CommandLineLength();
sl@0
    73
	if (len)
sl@0
    74
		{
sl@0
    75
		//
sl@0
    76
		// Copy the command line in a buffer
sl@0
    77
		//
sl@0
    78
		HBufC* hb = HBufC::NewMax(len);
sl@0
    79
		__ASSERT_ALWAYS(hb, User::Panic(_L("t_property: no memory"), 0));
sl@0
    80
		TPtr cmd((TUint16*) hb->Ptr(), len);
sl@0
    81
		User::CommandLine(cmd);
sl@0
    82
sl@0
    83
		TLex l(cmd);
sl@0
    84
		TInt r = l.Val(iter);
sl@0
    85
		__ASSERT_ALWAYS((r == KErrNone), User::Panic(_L("Usage: t_property <iteration number>\n"), 0));
sl@0
    86
		delete hb;
sl@0
    87
		}
sl@0
    88
	
sl@0
    89
	CTestProgram::Start();
sl@0
    90
sl@0
    91
	CTestProgram* panic = new CPropPanic(KPropTestCategory, 01);
sl@0
    92
	panic->Launch(1);
sl@0
    93
	delete panic;
sl@0
    94
sl@0
    95
		{
sl@0
    96
		// Tests to be executed in order
sl@0
    97
		CTestProgram* progs[] = 
sl@0
    98
			{
sl@0
    99
			new CPropDefine(KPropTestCategory, 11, RProperty::EInt),
sl@0
   100
			new CPropDefine(KPropTestCategory, 22, RProperty::EByteArray),
sl@0
   101
			new CPropDefine(KPropTestCategory, 28, RProperty::ELargeByteArray),
sl@0
   102
			new CPropDelete(KPropTestCategory, 33, RProperty::EInt),
sl@0
   103
			new CPropDelete(KPropTestCategory, 44, RProperty::EByteArray),
sl@0
   104
			new CPropDelete(KPropTestCategory, 50, RProperty::ELargeByteArray),
sl@0
   105
			new CPropSetGet(KPropTestCategory, 55, RProperty::EInt),
sl@0
   106
			new CPropSetGet(KPropTestCategory, 66, RProperty::EByteArray),
sl@0
   107
			new CPropSetGet(KPropTestCategory, 78, RProperty::ELargeByteArray),
sl@0
   108
			new CPropSubsCancel(KPropTestCategory, 73, RProperty::ELargeByteArray),
sl@0
   109
			new CPropSubsCancel(KPropTestCategory, 77, RProperty::EByteArray),
sl@0
   110
			new CPropSubsCancel(KPropTestCategory, 88, RProperty::EInt),
sl@0
   111
			new CPropSecurity(KPropTestCategory, 99, RProperty::EInt, 1000),
sl@0
   112
			new CPropSetGetRace(KPropTestCategory, 111),
sl@0
   113
			new CPropCancelRace(KPropTestCategory, 122),
sl@0
   114
			new CPropBroadcast(KPropTestCategory, 133, 2000, 8, 0),
sl@0
   115
			new CPropBroadcast(KPropTestCategory, 144, 3000, 8, 4),
sl@0
   116
			new CPropBroadcast(KPropTestCategory, 155, 4000, 8, 8),
sl@0
   117
			new CPropLddClient(KPropTestCategory, 166, RProperty::EInt),
sl@0
   118
			new CPropLddClient(KPropTestCategory, 177, RProperty::EByteArray),
sl@0
   119
			new CPropLddClient(KPropTestCategory, 188, RProperty::ELargeByteArray),
sl@0
   120
sl@0
   121
			NULL 
sl@0
   122
		};
sl@0
   123
sl@0
   124
		TInt i;
sl@0
   125
		TInt n = (sizeof(progs)/sizeof(*progs)) - 1;
sl@0
   126
sl@0
   127
		for (i = 0; i < n; ++i)
sl@0
   128
			{
sl@0
   129
			__ASSERT_ALWAYS(progs[i], User::Panic(_L("t_property: no memory"), 0));
sl@0
   130
			}
sl@0
   131
sl@0
   132
		// 2 - just to be sure that we can execute the program twice
sl@0
   133
		CTestProgram::LaunchGroup(progs, 2);
sl@0
   134
sl@0
   135
		for (i = 0; i < n; ++i)
sl@0
   136
			{
sl@0
   137
			delete progs[i];
sl@0
   138
			}
sl@0
   139
		}
sl@0
   140
sl@0
   141
		{
sl@0
   142
		// Tests to be executed in parallel
sl@0
   143
		CTestProgram* progs[] = 
sl@0
   144
			{
sl@0
   145
			new CPropSetGetRace(KPropTestCategory, 111),
sl@0
   146
			new CPropCancelRace(KPropTestCategory, 122),
sl@0
   147
			new CPropBroadcast(KPropTestCategory, 133, 2000, 8, 0),
sl@0
   148
			new CPropBroadcast(KPropTestCategory, 144, 3000, 8, 4),
sl@0
   149
			new CPropBroadcast(KPropTestCategory, 155, 4000, 8, 8),
sl@0
   150
sl@0
   151
			NULL 
sl@0
   152
			};
sl@0
   153
sl@0
   154
		TInt i;
sl@0
   155
		TInt n = (sizeof(progs)/sizeof(*progs)) - 1;
sl@0
   156
		for (i = 0; i < n; ++i)
sl@0
   157
			{
sl@0
   158
			__ASSERT_ALWAYS(progs[i], User::Panic(_L("t_property: no memory"), 0));
sl@0
   159
			}
sl@0
   160
		
sl@0
   161
		CTestProgram::SpawnGroup(progs, iter);
sl@0
   162
sl@0
   163
		for (i = 0; i < n; ++i)
sl@0
   164
			{
sl@0
   165
			delete progs[i];
sl@0
   166
			}
sl@0
   167
		}
sl@0
   168
sl@0
   169
	CTestProgram::End();
sl@0
   170
sl@0
   171
	return KErrNone;
sl@0
   172
	}