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