os/kernelhwsrv/kerneltest/e32test/property/t_property_main.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/property/t_property_main.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,172 @@
     1.4 +// Copyright (c) 2002-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 +// Overview:
    1.18 +// Test the RProperty and RPropertyRef classes
    1.19 +// API Information:
    1.20 +// RProperty, RPropertyRef
    1.21 +// Details:
    1.22 +// - Test and verify the RProperty methods: Delete, Define, Attach and 
    1.23 +// Subscribe work as expected.
    1.24 +// - Test the RPropery::Define() method. 
    1.25 +// Define the attributes and access control for a property. Verify results 
    1.26 +// are as expected. Verify property redefinition does not change security 
    1.27 +// settings. Perform various additional tests associated with the Define 
    1.28 +// method. Verify results are as expected.
    1.29 +// - Test the RPropery::Delete() method. 
    1.30 +// Verify that if the property has not been defined, Delete fails with 
    1.31 +// KErrNotFound. Verify pending subscriptions will be completed with 
    1.32 +// KErrNotFound if the property is deleted. Verify new requests will not 
    1.33 +// complete until the property is defined and published again.
    1.34 +// - Test the RPropery::Get() and Set() methods. 
    1.35 +// Verify failure if the property has not been defined, can set property
    1.36 +// to zero length, failure if the property is larger than KMaxPropertySize.
    1.37 +// Verify operation mismatch with property type fails as expected. Verify
    1.38 +// various get/set operations work as expected.
    1.39 +// - Test the RPropery::Subscribe() and Cancel() methods. 
    1.40 +// Verify failure if the property has not been defined, request will not 
    1.41 +// complete. Cancel outstanding subscription request, verify results are as
    1.42 +// expected.
    1.43 +// - Test the platform security settings, verify results are as expected. 
    1.44 +// Verify that RProperty::Delete() can only succeed when called by the 
    1.45 +// property owner. Verify Define, Subscribe, Get caller must have read 
    1.46 +// capabilities or error as expected. Verify Set caller must have write 
    1.47 +// capabilities or error as expected.
    1.48 +// - Perform multiple Set, Get, Subscribe and Cancel operations between 
    1.49 +// multiple threads, verify results are as expected.
    1.50 +// - Create multiple slave threads, verify Set, Get, Subscribe and Cancel 
    1.51 +// operations work as expected.
    1.52 +// - Using a loadable device driver, test the basic functionality of an 
    1.53 +// RPropertyRef object. Perform many of the same tests as above except 
    1.54 +// on a RPropertyRef object. Verify results are as expected.
    1.55 +// - Perform all the above multithreaded tests in parallel. Verify results
    1.56 +// are as expected.
    1.57 +// Platforms/Drives/Compatibility:
    1.58 +// All.
    1.59 +// Assumptions/Requirement/Pre-requisites:
    1.60 +// Failures and causes:
    1.61 +// Base Port information:
    1.62 +// 
    1.63 +//
    1.64 +
    1.65 +#include <e32test.h>
    1.66 +#include "t_property.h"
    1.67 +
    1.68 +static const TInt32 KUidPropTestCategoryValue = 0x101f75b7;
    1.69 +static const TUid KPropTestCategory = { KUidPropTestCategoryValue };
    1.70 +
    1.71 +GLDEF_C TInt E32Main()
    1.72 +	{
    1.73 +	TInt iter = 10000;
    1.74 +
    1.75 +	TInt len = User::CommandLineLength();
    1.76 +	if (len)
    1.77 +		{
    1.78 +		//
    1.79 +		// Copy the command line in a buffer
    1.80 +		//
    1.81 +		HBufC* hb = HBufC::NewMax(len);
    1.82 +		__ASSERT_ALWAYS(hb, User::Panic(_L("t_property: no memory"), 0));
    1.83 +		TPtr cmd((TUint16*) hb->Ptr(), len);
    1.84 +		User::CommandLine(cmd);
    1.85 +
    1.86 +		TLex l(cmd);
    1.87 +		TInt r = l.Val(iter);
    1.88 +		__ASSERT_ALWAYS((r == KErrNone), User::Panic(_L("Usage: t_property <iteration number>\n"), 0));
    1.89 +		delete hb;
    1.90 +		}
    1.91 +	
    1.92 +	CTestProgram::Start();
    1.93 +
    1.94 +	CTestProgram* panic = new CPropPanic(KPropTestCategory, 01);
    1.95 +	panic->Launch(1);
    1.96 +	delete panic;
    1.97 +
    1.98 +		{
    1.99 +		// Tests to be executed in order
   1.100 +		CTestProgram* progs[] = 
   1.101 +			{
   1.102 +			new CPropDefine(KPropTestCategory, 11, RProperty::EInt),
   1.103 +			new CPropDefine(KPropTestCategory, 22, RProperty::EByteArray),
   1.104 +			new CPropDefine(KPropTestCategory, 28, RProperty::ELargeByteArray),
   1.105 +			new CPropDelete(KPropTestCategory, 33, RProperty::EInt),
   1.106 +			new CPropDelete(KPropTestCategory, 44, RProperty::EByteArray),
   1.107 +			new CPropDelete(KPropTestCategory, 50, RProperty::ELargeByteArray),
   1.108 +			new CPropSetGet(KPropTestCategory, 55, RProperty::EInt),
   1.109 +			new CPropSetGet(KPropTestCategory, 66, RProperty::EByteArray),
   1.110 +			new CPropSetGet(KPropTestCategory, 78, RProperty::ELargeByteArray),
   1.111 +			new CPropSubsCancel(KPropTestCategory, 73, RProperty::ELargeByteArray),
   1.112 +			new CPropSubsCancel(KPropTestCategory, 77, RProperty::EByteArray),
   1.113 +			new CPropSubsCancel(KPropTestCategory, 88, RProperty::EInt),
   1.114 +			new CPropSecurity(KPropTestCategory, 99, RProperty::EInt, 1000),
   1.115 +			new CPropSetGetRace(KPropTestCategory, 111),
   1.116 +			new CPropCancelRace(KPropTestCategory, 122),
   1.117 +			new CPropBroadcast(KPropTestCategory, 133, 2000, 8, 0),
   1.118 +			new CPropBroadcast(KPropTestCategory, 144, 3000, 8, 4),
   1.119 +			new CPropBroadcast(KPropTestCategory, 155, 4000, 8, 8),
   1.120 +			new CPropLddClient(KPropTestCategory, 166, RProperty::EInt),
   1.121 +			new CPropLddClient(KPropTestCategory, 177, RProperty::EByteArray),
   1.122 +			new CPropLddClient(KPropTestCategory, 188, RProperty::ELargeByteArray),
   1.123 +
   1.124 +			NULL 
   1.125 +		};
   1.126 +
   1.127 +		TInt i;
   1.128 +		TInt n = (sizeof(progs)/sizeof(*progs)) - 1;
   1.129 +
   1.130 +		for (i = 0; i < n; ++i)
   1.131 +			{
   1.132 +			__ASSERT_ALWAYS(progs[i], User::Panic(_L("t_property: no memory"), 0));
   1.133 +			}
   1.134 +
   1.135 +		// 2 - just to be sure that we can execute the program twice
   1.136 +		CTestProgram::LaunchGroup(progs, 2);
   1.137 +
   1.138 +		for (i = 0; i < n; ++i)
   1.139 +			{
   1.140 +			delete progs[i];
   1.141 +			}
   1.142 +		}
   1.143 +
   1.144 +		{
   1.145 +		// Tests to be executed in parallel
   1.146 +		CTestProgram* progs[] = 
   1.147 +			{
   1.148 +			new CPropSetGetRace(KPropTestCategory, 111),
   1.149 +			new CPropCancelRace(KPropTestCategory, 122),
   1.150 +			new CPropBroadcast(KPropTestCategory, 133, 2000, 8, 0),
   1.151 +			new CPropBroadcast(KPropTestCategory, 144, 3000, 8, 4),
   1.152 +			new CPropBroadcast(KPropTestCategory, 155, 4000, 8, 8),
   1.153 +
   1.154 +			NULL 
   1.155 +			};
   1.156 +
   1.157 +		TInt i;
   1.158 +		TInt n = (sizeof(progs)/sizeof(*progs)) - 1;
   1.159 +		for (i = 0; i < n; ++i)
   1.160 +			{
   1.161 +			__ASSERT_ALWAYS(progs[i], User::Panic(_L("t_property: no memory"), 0));
   1.162 +			}
   1.163 +		
   1.164 +		CTestProgram::SpawnGroup(progs, iter);
   1.165 +
   1.166 +		for (i = 0; i < n; ++i)
   1.167 +			{
   1.168 +			delete progs[i];
   1.169 +			}
   1.170 +		}
   1.171 +
   1.172 +	CTestProgram::End();
   1.173 +
   1.174 +	return KErrNone;
   1.175 +	}