authorisation/userpromptservice/server/test/upstest/upstest.cpp
changeset 8 35751d3474b7
child 15 da2ae96f639b
equal deleted inserted replaced
2:675a964f4eb5 8:35751d3474b7
       
     1 /*
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * Test program exercises the skeleton UPS server API.
       
    16 * See individual test functions for more information.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 /**
       
    22  @file
       
    23 */
       
    24 
       
    25 #include <e32ldr.h>
       
    26 #include <scs/rtestwrapper.h>
       
    27 
       
    28 #include <ups/upsclient.h>
       
    29 #include <ups/upserr.h>
       
    30 #include "f32file.h"
       
    31 
       
    32 using namespace UserPromptService;
       
    33 
       
    34 /** Top-level test object renders stages and confirms conditions. */
       
    35 static RTestWrapper test(_L("UPSTEST"));
       
    36 
       
    37 /**
       
    38 	This session handle is defined at the file level so each individual test
       
    39 	does not have to connect to the server.
       
    40  */
       
    41 static RUpsSession sTestSession;
       
    42 /**
       
    43 	This subsession handle is defined at the file level so each individual test
       
    44 	does not have to connect to the server and create a subssesion.
       
    45  */
       
    46 static RUpsSubsession sTestSubsession;
       
    47 
       
    48 // -------- open / close session --------
       
    49 
       
    50 static void TestOpenCloseSession()
       
    51 /**
       
    52 	Open and close a connection to the UPS server.
       
    53  */
       
    54 	{
       
    55 	test.Start(_L("TestOpenCloseSession"));
       
    56 	
       
    57 	RUpsSession s;
       
    58 	TInt r = s.Connect();
       
    59 	test(r == KErrNone);
       
    60 
       
    61 	r = s.ShareAuto();
       
    62 	test(r == KErrNone);
       
    63 	
       
    64 	s.Close();
       
    65 	
       
    66 	test.End();
       
    67 	}
       
    68 
       
    69 // -------- open / close subsession --------
       
    70 
       
    71 static void TestOpenCloseSubsession()
       
    72 /**
       
    73 	Open and close a subsession on the UPS server.
       
    74  */
       
    75 	{
       
    76 	test.Start(_L("TestOpenCloseSubsession"));
       
    77 	
       
    78 	RUpsSubsession ss;
       
    79 	RThread thd;
       
    80 	TInt r = ss.Initialise(sTestSession, thd);
       
    81 	test(r == KErrNone);
       
    82 	ss.Close();
       
    83 	
       
    84 	test.End();
       
    85 	}
       
    86 
       
    87 // -------- Authorise succeed, cancel --------
       
    88 _LIT8(KOpaqueData, "<ce>fred</ce>");
       
    89 static void TestAuthoriseL()
       
    90 /**
       
    91 	Launch an asynchronous Authorise request on a UPS subsession.
       
    92 	Let it complete normally, and also cancel it.
       
    93  */
       
    94 	{
       
    95 	test.Start(_L("TestAuthorise"));
       
    96 	
       
    97 	TServiceId serviceId = {43};
       
    98 	TRequestStatus rs;
       
    99 
       
   100 	
       
   101 	test.Next(_L("complete normally - no opaque data\n"));
       
   102 	TUpsDecision dec = EUpsDecYes;
       
   103 	sTestSubsession.Authorise(EFalse, serviceId, KNullDesC, dec, rs);
       
   104 	test(dec == EUpsDecYes);	// not changed yet
       
   105 	User::WaitForRequest(rs);
       
   106 	test(rs == KErrNone);
       
   107 	test(dec == EUpsDecNo);
       
   108 	
       
   109 	test.Next(_L("cancel - empty opaque data\n"));
       
   110 	dec = EUpsDecYes;	// ensure changed
       
   111 	sTestSubsession.Authorise(EFalse, serviceId, KNullDesC, KNullDesC8, dec, rs);
       
   112 	test(dec == EUpsDecYes);	// not changed yet
       
   113 	test.Printf(_L("About to cancel - current status is %d"), rs.Int());
       
   114 	sTestSubsession.CancelPrompt();
       
   115 	User::WaitForRequest(rs);
       
   116 	test(rs == KErrCancel);
       
   117 	test(dec == EUpsDecYes);	// not changed
       
   118 
       
   119 	test.Next(_L("Opaque data\n"));
       
   120 	dec = EUpsDecYes;	// ensure changed
       
   121 	sTestSubsession.Authorise(EFalse, serviceId, _L("opaque data test"), KOpaqueData, dec, rs);
       
   122 	test(dec == EUpsDecYes);	// not changed yet
       
   123 	User::WaitForRequest(rs);
       
   124 	test(rs == KErrNone);
       
   125 	test(dec == EUpsDecNo);
       
   126 
       
   127 	
       
   128 	test.Next(_L("cancel when no outstanding - harmless\n"));
       
   129 	sTestSubsession.CancelPrompt();
       
   130 
       
   131 	test.Next(_L("cancel/close when sub session never created - harmless\n"));
       
   132 	RUpsSubsession uninitialisedCancel;
       
   133 	uninitialisedCancel.CancelPrompt();
       
   134 	uninitialisedCancel.Close();
       
   135 	
       
   136 	test.End();
       
   137 	}
       
   138 
       
   139 static void TestFlurryL()
       
   140 /**
       
   141 	Launch multiple requests
       
   142  */
       
   143 	{
       
   144 	test.Start(_L("TestFlurry"));
       
   145 
       
   146 	RThread thd;
       
   147 	RUpsSubsession testSubsession1;
       
   148 	testSubsession1.Initialise(sTestSession, thd);
       
   149 	RUpsSubsession testSubsession2;
       
   150 	testSubsession2.Initialise(sTestSession, thd);
       
   151 	RUpsSubsession testSubsession3;
       
   152 	testSubsession3.Initialise(sTestSession, thd);
       
   153 	RUpsSubsession testSubsession4;
       
   154 	testSubsession4.Initialise(sTestSession, thd);
       
   155 	RUpsSubsession testSubsession5;
       
   156 	testSubsession5.Initialise(sTestSession, thd);
       
   157 	RUpsSubsession testSubsession6;
       
   158 	testSubsession6.Initialise(sTestSession, thd);
       
   159 	
       
   160 	TServiceId serviceId = {43};
       
   161 	TRequestStatus rs1;
       
   162 	TRequestStatus rs2;
       
   163 	TRequestStatus rs3;
       
   164 	TRequestStatus rs4;
       
   165 	TRequestStatus rs5;
       
   166 	TRequestStatus rs6;
       
   167 	
       
   168 	// complete normally - no opaque data
       
   169 	TUpsDecision dec1 = EUpsDecYes;
       
   170 	TUpsDecision dec2 = EUpsDecYes;
       
   171 	TUpsDecision dec3 = EUpsDecYes;
       
   172 	TUpsDecision dec4 = EUpsDecYes;
       
   173 	TUpsDecision dec5 = EUpsDecYes;
       
   174 	TUpsDecision dec6 = EUpsDecYes;
       
   175 	testSubsession1.Authorise(EFalse, serviceId, _L("req1"), dec1, rs1);
       
   176 	testSubsession2.Authorise(EFalse, serviceId, _L("reqX"), dec2, rs2);
       
   177 	testSubsession3.Authorise(EFalse, serviceId, _L("req2"), dec3, rs3);
       
   178 	testSubsession4.Authorise(EFalse, serviceId, _L("reqX"), dec4, rs4);
       
   179 	testSubsession5.Authorise(EFalse, serviceId, _L("req3"), dec5, rs5);
       
   180 	testSubsession6.Authorise(EFalse, serviceId, _L("req4"), dec6, rs6);
       
   181 #if 0
       
   182 	// Will change immediately in non-interactive testing
       
   183 	test(dec1 == EUpsDecYes);	// not changed yet
       
   184 	test(dec2 == EUpsDecYes);	// not changed yet
       
   185 	test(dec3 == EUpsDecYes);	// not changed yet
       
   186 	test(dec4 == EUpsDecYes);	// not changed yet
       
   187 	test(dec5 == EUpsDecYes);	// not changed yet
       
   188 	test(dec6 == EUpsDecYes);	// not changed yet
       
   189 #endif
       
   190 	User::After(1000);
       
   191 
       
   192 	User::WaitForRequest(rs1);
       
   193 
       
   194 	User::WaitForRequest(rs2);
       
   195 	User::WaitForRequest(rs4);
       
   196 
       
   197 	User::WaitForRequest(rs3);
       
   198 	User::WaitForRequest(rs5);
       
   199 	User::WaitForRequest(rs6);
       
   200 	test(rs1 == KErrNone);
       
   201 	test(rs2 == KErrNone);
       
   202 	test(rs3 == KErrNone);
       
   203 	test(rs4 == KErrNone);
       
   204 	test(rs5 == KErrNone);
       
   205 	test(rs6 == KErrNone);
       
   206 	test(dec1 == EUpsDecNo);
       
   207 	test(dec2 == EUpsDecNo);
       
   208 	test(dec3 == EUpsDecNo);
       
   209 	test(dec4 == EUpsDecNo);
       
   210 	test(dec5 == EUpsDecNo);
       
   211 	test(dec6 == EUpsDecNo);
       
   212 	
       
   213 	test.End();
       
   214 	}
       
   215 
       
   216 // -------- RUpsSubsession --------
       
   217 _LIT(KSayYes,"SayYes");
       
   218 static void TestRUpsSubsession()
       
   219 /**
       
   220 	Attempt query with server checks passed and without
       
   221  */
       
   222 	{
       
   223 	//
       
   224 	// Tests for RUpsSubsession
       
   225 	//
       
   226 	RThread thd;
       
   227 
       
   228 	test.Start(_L("Testing RUpsSubsession"));
       
   229 	RUpsSubsession clientSubsession;
       
   230 	TInt r = clientSubsession.Initialise(sTestSession, thd);
       
   231 	test(r == KErrNone);
       
   232 
       
   233 	test.Next(_L("Query with server checks passed"));
       
   234 	TServiceId serviceId = {42};
       
   235 	TUpsDecision dec = EUpsDecNo;
       
   236 	TRequestStatus rs;
       
   237 	// Query saying our checks were ok, expect to get decision set to EUpsDecYes
       
   238 	clientSubsession.Authorise(ETrue, serviceId, _L("Destination"), _L8("Opaque data"), dec, rs);
       
   239 	User::WaitForRequest(rs);
       
   240 	test(rs == KErrNone);
       
   241 	test(dec == EUpsDecYes);
       
   242 
       
   243 
       
   244 
       
   245 	test.Next(_L("Try closing client subsession before it is really created"));
       
   246 	clientSubsession.Close();
       
   247 
       
   248 	test.Next(_L("Re-\"create\" client subsession"));
       
   249 	r = clientSubsession.Initialise(sTestSession, thd);
       
   250 	test(r == KErrNone);
       
   251 
       
   252 	test.Next(_L("Query with server checks failed, ie query UPS, expect fail"));
       
   253 	// Query saying our checks failed, should talk to UPS and change decision to EUpsDecNo
       
   254 	dec = EUpsDecYes;
       
   255 	clientSubsession.Authorise(EFalse, serviceId, KNullDesC, dec, rs);
       
   256 	User::WaitForRequest(rs);
       
   257 	test(rs == KErrNone);
       
   258 	test(dec == EUpsDecNo);
       
   259 
       
   260 
       
   261 	test.Next(_L("Query with server checks failed, ie query UPS, special destination, expect yes"));
       
   262 	// Query saying our checks failed, should talk to UPS and change decision to EUpsDecNo
       
   263 	dec = EUpsDecYes;
       
   264 	clientSubsession.Authorise(EFalse, serviceId, KSayYes(), dec, rs);
       
   265 	User::WaitForRequest(rs);
       
   266 	test(rs == KErrNone);
       
   267 	test(dec == EUpsDecYes);
       
   268 
       
   269 
       
   270 	clientSubsession.Close();
       
   271 	test.End();
       
   272 	}
       
   273 
       
   274 TInt ThreadFunction(TAny *)
       
   275 	{
       
   276 	return KErrNone;
       
   277 	}
       
   278 
       
   279 static void TestRUpsSubsessionDeathL()
       
   280 	{
       
   281 	RThread thd;
       
   282 	TRequestStatus thdStatus;
       
   283 	User::LeaveIfError(thd.Create(_L("MyThread"), ThreadFunction, 4096, 4096, 4096, 0, EOwnerThread));
       
   284 //	thd.SetHandle(666);
       
   285 	thd.Rendezvous(thdStatus);
       
   286 	thd.Kill(KErrAbort);
       
   287 	User::WaitForRequest(thdStatus);
       
   288 
       
   289 	test.Start(_L("Testing RUpsSubsession"));
       
   290 	RUpsSubsession clientSubsession;
       
   291 	TInt r = clientSubsession.Initialise(sTestSession, thd);
       
   292 	test(r == KErrNone);
       
   293 
       
   294 	test.Next(_L("Query with dead thread id"));
       
   295 	TServiceId serviceId = {43};
       
   296 	TUpsDecision dec = EUpsDecYes;
       
   297 	TRequestStatus rs;
       
   298 	thd.Close();
       
   299 	clientSubsession.Authorise(EFalse, serviceId, _L("req1"), dec, rs);
       
   300 	User::WaitForRequest(rs);
       
   301 	test(rs == KErrNone);
       
   302 	test(dec == EUpsDecNo);
       
   303 
       
   304 	
       
   305 	clientSubsession.Close();
       
   306 	test.End();
       
   307 	}
       
   308 
       
   309 static void TestRUpsManagementL()
       
   310 /**
       
   311 	Attempt to delete database
       
   312  */
       
   313 	{
       
   314 	test.Start(_L("Testing RUpsManagement"));
       
   315 	RThread thd;
       
   316 	TRequestStatus rs;
       
   317 
       
   318 	// Create filter
       
   319 	TServiceId serviceId = {43};
       
   320 	CDecisionFilter *filter = CDecisionFilter::NewLC();
       
   321 	filter->SetClientSid(thd.SecureId(), EEqual);
       
   322 	filter->SetServerSid(thd.SecureId(), EEqual);
       
   323 	filter->SetServiceId(serviceId, EEqual);
       
   324 
       
   325 	RUpsSubsession clientSubsession;
       
   326 	TInt r = clientSubsession.Initialise(sTestSession, thd);
       
   327 	test(r == KErrNone);
       
   328 
       
   329 	test.Next(_L("Open management session"));
       
   330 	RUpsManagement mngmnt;
       
   331 	r = mngmnt.Connect();
       
   332 	test(r == KErrNone);
       
   333 	User::LeaveIfError(r);
       
   334 
       
   335 	test.Next(_L("View create - then delete DB"));
       
   336 	mngmnt.CreateView(*filter, rs);
       
   337 
       
   338 	test.Next(_L("Delete database"));
       
   339 	TRAP(r, mngmnt.DeleteDatabaseL());
       
   340 	test(r == KErrNone);
       
   341 
       
   342 	test.Next(_L("Now see what view create completed with...."));
       
   343 	User::WaitForRequest(rs);
       
   344 	test(rs.Int() == KErrAbort);
       
   345 
       
   346 	test.Next(_L("Add entry to new database"));
       
   347 	TUpsDecision dec = EUpsDecYes;
       
   348 	clientSubsession.Authorise(EFalse, serviceId, _L("DB delete 1"), _L8("Opaque data"), dec, rs);
       
   349 	User::WaitForRequest(rs);
       
   350 	test(rs == KErrNone);
       
   351 	test(dec == EUpsDecNo);
       
   352 
       
   353 	dec = EUpsDecYes;
       
   354 	clientSubsession.Authorise(EFalse, serviceId, _L("DB delete 2"), _L8("Opaque data"), dec, rs);
       
   355 	User::WaitForRequest(rs);
       
   356 	test(rs == KErrNone);
       
   357 	test(dec == EUpsDecNo);
       
   358 
       
   359 
       
   360 	test.Next(_L("View create - immediate cancel"));
       
   361 	mngmnt.CreateView(*filter, rs);
       
   362 	mngmnt.CancelAndCloseView();
       
   363 	User::WaitForRequest(rs);
       
   364 	test(rs.Int() == KErrCancel);
       
   365 
       
   366 	mngmnt.UpdateDecision(TUint32(-23), ETrue, rs);
       
   367 	mngmnt.CancelUpdateDecision();
       
   368 	User::WaitForRequest(rs);
       
   369 	test(rs.Int() == KErrCancel);
       
   370 
       
   371 	mngmnt.UpdateDecision(TUint32(-23), ETrue, rs);
       
   372 	User::WaitForRequest(rs);
       
   373 	test(rs.Int() == KErrNotFound);
       
   374 
       
   375 	test.Next(_L("View create - when busy"));
       
   376 	TRequestStatus rs2;
       
   377 	mngmnt.CreateView(*filter, rs);
       
   378 	mngmnt.CreateView(*filter, rs2);
       
   379 	User::WaitForRequest(rs2);
       
   380 	test(rs2.Int() == KErrServerBusy);
       
   381 	User::WaitForRequest(rs);
       
   382 	test(rs.Int() == KErrNone);
       
   383 	mngmnt.CancelAndCloseView();
       
   384 
       
   385 	test.Next(_L("View create - iterate through it"));
       
   386 	mngmnt.CreateView(*filter, rs);
       
   387 
       
   388 	User::WaitForRequest(rs);
       
   389 	test(rs.Int() == KErrNone);
       
   390 	
       
   391 	CleanupStack::PopAndDestroy(filter);
       
   392 
       
   393 	CDecisionRecord *record = 0;
       
   394 	r = KErrNone;
       
   395 	TInt recordCount = 0;
       
   396 	while(r == KErrNone)
       
   397 		{
       
   398 		TRAP(r, record = mngmnt.NextMatchL());
       
   399 		if(record == 0)
       
   400 			{
       
   401 			break;
       
   402 			}
       
   403 		test(r == KErrNone);
       
   404 		if(r == KErrNone)
       
   405 			{
       
   406 			++recordCount;
       
   407 			CleanupStack::PushL(record);
       
   408 			CDecisionFilter *exactFilter = CDecisionFilter::NewLC(record->iClientSid,
       
   409 																  record->iEvaluatorId,
       
   410 																  record->iServiceId,
       
   411 																  record->iServerSid,
       
   412 																  record->iFingerprint,
       
   413 																  record->iClientEntity,
       
   414 																  record->iMajorPolicyVersion);
       
   415 				
       
   416 			
       
   417 			mngmnt.UpdateDecision(record->iRecordId, ETrue, rs);
       
   418 			User::WaitForRequest(rs);
       
   419 			test(rs.Int() == KErrNone);
       
   420 			TRAP(r, mngmnt.RemoveDecisionsL(*exactFilter));
       
   421 			test(r == KErrNone);
       
   422 
       
   423 			CleanupStack::PopAndDestroy(exactFilter);
       
   424 			CleanupStack::PopAndDestroy(record);
       
   425 			}
       
   426 		
       
   427 		};
       
   428 	test(recordCount == 2);
       
   429 	
       
   430 	TRAP(r, record = mngmnt.NextMatchL());
       
   431 	test((r == KErrNone) && (record == 0));
       
   432 
       
   433 	mngmnt.CancelAndCloseView();
       
   434 
       
   435 	test.Next(_L("Close management session and clientSubsession"));
       
   436 	mngmnt.Close();
       
   437 	clientSubsession.Close();
       
   438 
       
   439 	test.End();
       
   440 	}
       
   441 
       
   442 void TestSwiObserverSecurityL()
       
   443 {
       
   444 	test.Start(_L("Testing swi observer functions do not work from here..."));
       
   445 
       
   446 	TInt r;
       
   447 
       
   448 	RUpsManagement session;
       
   449 	User::LeaveIfError(session.Connect());
       
   450 	CleanupClosePushL(session);
       
   451 
       
   452 	TUid ourSid;
       
   453 	ourSid.iUid = 0x10283559;
       
   454 	TRAP(r, session.DeleteDecisionsForExeL(ourSid));
       
   455 	test(r == KErrPermissionDenied);
       
   456 
       
   457 	TRAP(r, session.NotifyPluginsMayHaveChangedL());
       
   458 	test(r == KErrPermissionDenied);
       
   459 
       
   460 	TRequestStatus rs;
       
   461 	session.NotifyPolicyFilesChanged(rs);
       
   462 	User::WaitForRequest(rs);
       
   463 
       
   464 	test(rs.Int() == KErrPermissionDenied);
       
   465 
       
   466 	session.CancelNotifyPolicyFilesChanged();
       
   467 
       
   468 	CleanupStack::PopAndDestroy(&session);
       
   469 	
       
   470 	test.End();
       
   471 }
       
   472 
       
   473 // -------- entrypoint --------
       
   474 
       
   475 
       
   476 void MainL()
       
   477 	{
       
   478 	test.Title(_L("c:\\upstest.log"));
       
   479 	test.Start(_L(" @SYMTestCaseID:SEC-UPS-0001 Testing RUpsSubsession "));
       
   480 
       
   481 	RFs fs;
       
   482 	User::LeaveIfError(fs.Connect());
       
   483 	CleanupClosePushL(fs);
       
   484 	
       
   485 	TBuf<21> notifierConfig(_L("!:\\upsrefnotifier.txt"));
       
   486 	notifierConfig[0] = fs.GetSystemDriveChar();
       
   487 
       
   488 	TBuf<35> database(_L("!:\\Private\\10283558\\database\\ups.db"));
       
   489 	database[0] = fs.GetSystemDriveChar();
       
   490 
       
   491 	TInt lineLength = User::CommandLineLength();
       
   492 	switch(lineLength)
       
   493 		{
       
   494 	default:
       
   495 		case 2:
       
   496 			(void) fs.Delete(database);
       
   497 			// Fall through to also delete notifier config file
       
   498 		case 1:
       
   499 			(void) fs.Delete(notifierConfig);
       
   500 			break;
       
   501 		case 0:
       
   502 			{
       
   503 			// No args so run in silent mode
       
   504 			(void) fs.Delete(database);
       
   505 			(void) fs.Delete(notifierConfig);
       
   506 			RFile file;
       
   507 			User::LeaveIfError(file.Create(fs, notifierConfig, EFileShareExclusive | EFileWrite));
       
   508 			User::LeaveIfError(file.Write(_L8("Never")));
       
   509 			file.Close();
       
   510 			break;
       
   511 			}
       
   512 		}
       
   513 
       
   514 	//RThread ourThread;
       
   515 	//ourThread.SetPriority(EPriorityMore);
       
   516 	//ourThread.Close();
       
   517 //	User::SetProcessCritical(User::ESystemCritical);
       
   518 //	User::SetCritical(User::ESystemCritical);
       
   519 	TestOpenCloseSession();
       
   520 
       
   521 
       
   522 	TInt r = sTestSession.Connect();
       
   523 	test(r == KErrNone);
       
   524 	User::LeaveIfError(r);
       
   525 
       
   526 	TestRUpsSubsessionDeathL();
       
   527 
       
   528 	TestOpenCloseSubsession();
       
   529 
       
   530 	TestSwiObserverSecurityL();
       
   531 	
       
   532 	RThread thd;
       
   533 	r = sTestSubsession.Initialise(sTestSession, thd);
       
   534 	test(r == KErrNone);
       
   535 	User::LeaveIfError(r);
       
   536 	
       
   537 	TestFlurryL();
       
   538 
       
   539 	TestAuthoriseL();
       
   540 	
       
   541 	sTestSubsession.Close();
       
   542 
       
   543 	TestRUpsSubsession();
       
   544 
       
   545 	TestRUpsManagementL();
       
   546 
       
   547 	sTestSession.ShutdownServer();
       
   548 
       
   549 	// Close top level session (low level session was closed by
       
   550 	// ShutdownServer, but we still need to do the RUpsSession
       
   551 	// cleanup).
       
   552 	sTestSession.Close();
       
   553 
       
   554 	(void) fs.Delete(notifierConfig);
       
   555 	CleanupStack::PopAndDestroy(&fs);
       
   556 	
       
   557 	test.End();
       
   558 	test.Close();
       
   559 }
       
   560 
       
   561 void PanicIfError(TInt r)
       
   562 	{
       
   563 	if(r != KErrNone)
       
   564 		{
       
   565 		User::Panic(_L("upstest failed: "), r);
       
   566 		}
       
   567 	}
       
   568 
       
   569 
       
   570 TInt E32Main()
       
   571 /**
       
   572 	Executable entrypoint establishes connection with UPS server
       
   573 	and then invokes tests for each functional area.
       
   574 	
       
   575 	@return					Symbian OS error code where KErrNone indicates
       
   576 							success and any other value indicates failure.
       
   577  */
       
   578 	{
       
   579 	// disable lazy DLL unloading so kernel heap balances at end
       
   580 	RLoader l;
       
   581 	PanicIfError(l.Connect());
       
   582 	PanicIfError(l.CancelLazyDllUnload());
       
   583 	l.Close();
       
   584 	
       
   585 	__UHEAP_MARK;
       
   586 	//__KHEAP_MARK;
       
   587 	
       
   588 	// allocating a cleanup stack also installs it
       
   589 	CTrapCleanup* tc = CTrapCleanup::New();
       
   590 	if (tc == 0)
       
   591 		return KErrNoMemory;
       
   592 
       
   593 	TRAPD(err, MainL());
       
   594 	if(err != KErrNone)
       
   595 		{
       
   596 		User::Panic(_L("upstest failed: "), err);
       
   597 		}
       
   598 	delete tc;
       
   599 	
       
   600 	//__KHEAP_MARKEND;
       
   601 	__UHEAP_MARKEND;
       
   602 	
       
   603 	
       
   604 	return KErrNone;
       
   605 	}
       
   606