os/ossrv/lowlevellibsandfws/apputils/bsul/test/t_clientmessage/t_clientmessage.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2008-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 "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 //
    15 
    16 #include <f32file.h>
    17 #include <e32test.h>
    18 #include <bautils.h>
    19 #include <hal.h>
    20 #include <e32std.h>
    21 #include <bsul/bsul.h>
    22 #include "t_clientmessagetestserver.h"
    23 
    24 using namespace BSUL;
    25 
    26 
    27 LOCAL_D RTest				Test (_L("T_ClientMessage"));
    28 LOCAL_D RFs					TheFs;
    29 
    30 _LIT(KServerName,"ClientMessageTestServer");
    31 _LIT(KServer2Name,"SecondTestServer");
    32 _LIT(KServerFileName,"T_ClientMessageTestServer.exe");
    33 
    34 struct TExitDetails
    35 	{
    36 	TExitCategoryName iCategory;
    37 	TExitType iExitType;
    38 	TInt iReason;
    39 	};
    40 
    41 typedef void (*TestFunction)();
    42 
    43 
    44 /*RClientMessageTestSession client side interface to
    45  * CClientMessageTestServer server.  This is used to pass
    46  * messages to the server to testthe Client Message Framework.
    47  */
    48 class RClientMessageTestSession : public RSessionBase
    49 	{
    50 public:
    51 	TInt Connect();
    52 
    53 	TInt TestFunction0(TInt aArg0);
    54 	TInt TestFunction0(TInt aArg0, TInt aArg1);
    55 	TInt TestFunction0(TInt aArg0, TInt aArg1, TInt aArg2);
    56 	TInt TestFunction0(const TDesC8& aData0, const TDesC& aData1);
    57 	TInt TestFunction1(TInt aArg0, TInt aArg1);
    58 	TInt TestFunction2(TInt aArg0, TInt aArg1);
    59 	TInt TestFunction3(TInt aArg0, TInt aArg1);
    60 
    61 	TInt TestFunction4(const TDesC8& aData0, const TDesC& aData1);
    62 	TInt TestFunction4(const TDesC& aData0, const TDesC8& aData1);
    63 	TInt TestFunction4(const TDesC8& aData0);
    64 	TInt TestFunction5(const TDesC8& aData0, const TDesC& aData1);
    65 	TInt TestFunction6(const TDesC8& aData0, const TDesC& aData1);
    66 	TInt TestFunction7(const TDesC8& aData0, const TDesC& aData1);
    67 	TInt TestFunction8(const TDesC8& aData0, const TDesC& aData1);
    68 
    69 	TInt TestFunction9(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1);
    70 	TInt TestFunction9(TDes& aData0,TInt aOffset0, TDes8& aData1,TInt aOffset1);
    71 	TInt TestFunction10(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1);
    72 	TInt TestFunction11(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1);
    73 	TInt TestFunction12(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1);
    74 	TInt TestFunction13(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1);
    75 	TInt TestFunction14(const TDesC8& aData0,TInt aOffset0, TDes8& aData1);
    76 	TInt TestFunction15(const TDesC& aData0,TInt aOffset0, TDes& aData1);
    77 
    78 	TInt TestFunction16(TAny* aData);
    79 	TInt TestFunction17(TAny* aData);
    80 
    81 	TInt TestFunction18(TDes8& aData);
    82 	TInt TestFunction18(TDes16& aData);
    83 	TInt TestFunction19(TDes8& aData);
    84 
    85 	TInt TestFunction20(TInt aArg0, TInt aArg1);
    86 	TInt TestFunction21(TInt aArg0, TInt aArg1);
    87 	TInt TestFunction22(TInt aArg0, TInt aArg1);
    88 	TInt TestFunction23(TInt aArg0, TInt aArg1);
    89 	TInt TestFunction24(TInt aArg0, TInt aArg1);
    90 
    91 	TInt TestFunction25();
    92 	TInt TestFunction26();
    93 	TInt TestFunction27();
    94 	TInt TestFunction28(TInt aArg0);
    95 	TInt TestFunction29(TDes& aData);
    96 	TInt TestFunction30(TDes8& aData);
    97 	TInt TestFunction31(TInt aArg0);
    98 	TInt TestFunction32(TDes8& aData);
    99 
   100 	TInt TestInvalidFunction(TInt aFn);
   101 
   102 
   103 	};
   104 
   105 /*RClientMessageTestSession2 client side interface to
   106  * CClientMessageTestServer2 server.  This is used to pass
   107  * messages to the server to testthe Client Message Framework.
   108  */
   109 class RClientMessageTestSession2 : public RSessionBase
   110 	{
   111 public:
   112 	TInt Connect();
   113 
   114 	TInt TestFunction0(TInt aArg0, TInt aArg1);
   115 	
   116 	TInt TestFunction1(const TDesC& aData0);
   117 
   118 	};
   119 
   120 //Global process that is accessible in test code to determine the
   121 //exit reason and category on termination
   122 RProcess serverProcess;
   123 
   124 //Launch the server process
   125 static TInt LaunchServer()
   126 	{
   127 	TInt err = serverProcess.Create(KServerFileName,_L(""));
   128 
   129 	if(err == KErrNone)
   130 		{
   131 		 TRequestStatus serverStat;
   132 
   133 		 serverProcess.SetJustInTime(EFalse);
   134 		 serverProcess.Rendezvous(serverStat);
   135 		 serverProcess.Resume();
   136 		 User::WaitForRequest(serverStat);
   137 		}
   138 
   139 	return err;
   140 	}
   141 
   142 
   143 /* Connect to the CClientMessageTestServer, launching
   144  * the sevrer process if necessary
   145  */
   146 TInt RClientMessageTestSession::Connect()
   147 	{
   148 	TInt retry = 2;
   149 	for(;;)
   150 		{
   151 		TInt r = CreateSession(KServerName,TVersion(1,0,0));
   152 
   153 		if((r != KErrNotFound)&&(r != KErrServerTerminated))
   154 			{
   155 			return r;
   156 			}
   157 
   158 		if(--retry == 0)
   159 			{
   160 			return r;
   161 			}
   162 
   163 		r = LaunchServer();
   164 		if((r != KErrNone)&&(r != KErrAlreadyExists))
   165 			{
   166 			return r;
   167 			}
   168 		}
   169 	}
   170 
   171 /* These functions are used to send IPC messages to the server.
   172  * The messages are sent with different parameters to test the
   173  * ClientMessage framework handling of bad messages
   174  */
   175 TInt RClientMessageTestSession::TestFunction0(TInt aArg0, TInt aArg1)
   176 	{
   177 	return SendReceive(ETestMessage0,TIpcArgs(aArg0,aArg1));
   178 	}
   179 
   180 TInt RClientMessageTestSession::TestFunction0(TInt aArg0)
   181 	{
   182 	return SendReceive(ETestMessage0,TIpcArgs(aArg0));
   183 	}
   184 
   185 TInt RClientMessageTestSession::TestFunction0(TInt aArg0, TInt aArg1, TInt aArg2)
   186 	{
   187 	return SendReceive(ETestMessage0,TIpcArgs(aArg0,aArg1,aArg2));
   188 	}
   189 
   190 TInt RClientMessageTestSession::TestFunction0(const TDesC8& aData0, const TDesC& aData1)
   191 	{
   192 	//Call the function passing invalid arguments
   193 	return SendReceive(ETestMessage0,TIpcArgs(&aData0,&aData1));
   194 	}
   195 
   196 TInt RClientMessageTestSession::TestFunction1(TInt aArg0, TInt aArg1)
   197 	{
   198 	return SendReceive(ETestMessage1,TIpcArgs(aArg0,aArg1));
   199 	}
   200 
   201 TInt RClientMessageTestSession::TestFunction2(TInt aArg0, TInt aArg1)
   202 	{
   203 	return SendReceive(ETestMessage2,TIpcArgs(aArg0,aArg1));
   204 	}
   205 
   206 TInt RClientMessageTestSession::TestFunction3(TInt aArg0, TInt aArg1)
   207 	{
   208 	return SendReceive(ETestMessage3,TIpcArgs(aArg0,aArg1));
   209 	}
   210 
   211 TInt RClientMessageTestSession::TestFunction4(const TDesC8& aData0, const TDesC& aData1)
   212 	{
   213 	return SendReceive(ETestMessage4,TIpcArgs(&aData0,&aData1));
   214 	}
   215 
   216 TInt RClientMessageTestSession::TestFunction4(const TDesC& aData0, const TDesC8& aData1)
   217 	{
   218 	return SendReceive(ETestMessage4,TIpcArgs(&aData0,&aData1));
   219 	}
   220 
   221 TInt RClientMessageTestSession::TestFunction4(const TDesC8& aData0)
   222 	{
   223 	return SendReceive(ETestMessage4,TIpcArgs(&aData0));
   224 	}
   225 
   226 TInt RClientMessageTestSession::TestFunction5(const TDesC8& aData0, const TDesC& aData1)
   227 	{
   228 	return SendReceive(ETestMessage5,TIpcArgs(&aData0,&aData1));
   229 	}
   230 
   231 TInt RClientMessageTestSession::TestFunction6(const TDesC8& aData0, const TDesC& aData1)
   232 	{
   233 	return SendReceive(ETestMessage6,TIpcArgs(&aData0,&aData1));
   234 	}
   235 
   236 TInt RClientMessageTestSession::TestFunction7(const TDesC8& aData0, const TDesC& aData1)
   237 	{
   238 	return SendReceive(ETestMessage7,TIpcArgs(&aData0,&aData1));
   239 	}
   240 
   241 TInt RClientMessageTestSession::TestFunction8(const TDesC8& aData0, const TDesC& aData1)
   242 	{
   243 	return SendReceive(ETestMessage8,TIpcArgs(&aData0,&aData1));
   244 	}
   245 
   246 TInt RClientMessageTestSession::TestFunction9(TDes& aData0,TInt aOffset0, TDes8& aData1,TInt aOffset1)
   247 	{
   248 	return SendReceive(ETestMessage9,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1));
   249 	}
   250 
   251 TInt RClientMessageTestSession::TestFunction9(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1)
   252 	{
   253 	return SendReceive(ETestMessage9,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1));
   254 	}
   255 
   256 TInt RClientMessageTestSession::TestFunction10(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1)
   257 	{
   258 	return SendReceive(ETestMessage10,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1));
   259 	}
   260 
   261 TInt RClientMessageTestSession::TestFunction11(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1)
   262 	{
   263 	return SendReceive(ETestMessage11,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1));
   264 	}
   265 
   266 TInt RClientMessageTestSession::TestFunction12(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1)
   267 	{
   268 	return SendReceive(ETestMessage12,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1));
   269 	}
   270 
   271 TInt RClientMessageTestSession::TestFunction13(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1)
   272 	{
   273 	return SendReceive(ETestMessage13,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1));
   274 	}
   275 
   276 TInt RClientMessageTestSession::TestFunction14(const TDesC8& aData0,TInt aOffset0, TDes8& aData1)
   277 	{
   278 	return SendReceive(ETestMessage14,TIpcArgs(&aData0,aOffset0,&aData1));
   279 	}
   280 
   281 TInt RClientMessageTestSession::TestFunction15(const TDesC& aData0,TInt aOffset0, TDes& aData1)
   282 	{
   283 	return SendReceive(ETestMessage15,TIpcArgs(&aData0,aOffset0,&aData1));
   284 	}
   285 
   286 TInt RClientMessageTestSession::TestFunction16(TAny* aData)
   287 	{
   288 	return SendReceive(ETestMessage16,TIpcArgs(aData));
   289 	}
   290 
   291 TInt RClientMessageTestSession::TestFunction17(TAny* aData)
   292 	{
   293 	return SendReceive(ETestMessage17,TIpcArgs(aData));
   294 	}
   295 
   296 TInt RClientMessageTestSession::TestFunction18(TDes8& aData)
   297 	{
   298 	return SendReceive(ETestMessage18,TIpcArgs(&aData));
   299 	}
   300 
   301 TInt RClientMessageTestSession::TestFunction18(TDes& aData)
   302 	{
   303 	return SendReceive(ETestMessage18,TIpcArgs(&aData));
   304 	}
   305 
   306 TInt RClientMessageTestSession::TestFunction19(TDes8& aData)
   307 	{
   308 	return SendReceive(ETestMessage19,TIpcArgs(&aData));
   309 	}
   310 
   311 TInt RClientMessageTestSession::TestFunction20(TInt aArg0, TInt aArg1)
   312 	{
   313 	return SendReceive(ETestMessage20,TIpcArgs(aArg0,aArg1));
   314 	}
   315 
   316 TInt RClientMessageTestSession::TestFunction21(TInt aArg0, TInt aArg1)
   317 	{
   318 	return SendReceive(ETestMessage21,TIpcArgs(aArg0,aArg1));
   319 	}
   320 
   321 TInt RClientMessageTestSession::TestFunction22(TInt aArg0, TInt aArg1)
   322 	{
   323 	return SendReceive(ETestMessage22,TIpcArgs(aArg0,aArg1));
   324 	}
   325 
   326 TInt RClientMessageTestSession::TestFunction23(TInt aArg0, TInt aArg1)
   327 	{
   328 	return SendReceive(ETestMessage23,TIpcArgs(aArg0,aArg1));
   329 	}
   330 
   331 TInt RClientMessageTestSession::TestFunction24(TInt aArg0, TInt aArg1)
   332 	{
   333 	return SendReceive(ETestMessage24,TIpcArgs(aArg0,aArg1));
   334 	}
   335 
   336 TInt RClientMessageTestSession::TestFunction25()
   337 	{
   338 	return SendReceive(ETestMessage25,TIpcArgs());
   339 	}
   340 
   341 TInt RClientMessageTestSession::TestFunction26()
   342 	{
   343 	return SendReceive(ETestMessage26,TIpcArgs());
   344 	}
   345 
   346 TInt RClientMessageTestSession::TestFunction27()
   347 	{
   348 	return SendReceive(ETestMessage27,TIpcArgs());
   349 	}
   350 
   351 TInt RClientMessageTestSession::TestFunction28(TInt aArg0)
   352 	{
   353 	return SendReceive(ETestMessage28,TIpcArgs(aArg0));
   354 	}
   355 
   356 TInt RClientMessageTestSession::TestFunction29(TDes& aData)
   357 	{
   358 	return SendReceive(ETestMessage29,TIpcArgs(&aData));
   359 	}
   360 
   361 TInt RClientMessageTestSession::TestFunction30(TDes8& aData)
   362 	{
   363 	return SendReceive(ETestMessage30,TIpcArgs(&aData));
   364 	}
   365 
   366 TInt RClientMessageTestSession::TestFunction31(TInt aArg0)
   367 	{
   368 	return SendReceive(ETestMessage31,TIpcArgs(aArg0));
   369 	}
   370 
   371 TInt RClientMessageTestSession::TestFunction32(TDes8& aData)
   372 	{
   373 	return SendReceive(ETestMessage32,TIpcArgs(&aData));
   374 	}
   375 
   376 TInt RClientMessageTestSession::TestInvalidFunction(TInt aFn)
   377 	{
   378 	return SendReceive(aFn,TIpcArgs());
   379 	}
   380 
   381 /* This function is the entry point for a new thread.  It calls the
   382  * function passed to it as a TAny*.
   383  */
   384 TInt TestFunctionLauncherL(TAny* aTestFunction)
   385 	{
   386    	CTrapCleanup* cleanup=CTrapCleanup::New();
   387    	TInt r=KErrNoMemory;
   388    	if (cleanup)
   389    		{
   390    		TestFunction function = (TestFunction)aTestFunction;
   391 
   392 __UHEAP_MARK;
   393  		TRAP(r,function());
   394 __UHEAP_MARKEND;
   395 
   396    		delete cleanup;
   397    		}
   398    	return r;
   399 	}
   400 
   401 /* This function creates a new thread and passes through the test function
   402  * to be called.  It also monitors and returns the exit reason for the launched
   403  * thread.
   404  */
   405 TExitDetails LaunchTestThreadL(const TDesC& aThreadName, TestFunction aFunction)
   406 	{
   407 	RThread thread;
   408 	TInt err = thread.Create(aThreadName, &TestFunctionLauncherL, KDefaultStackSize, NULL, (TAny*)aFunction);
   409 
   410 	if(err != KErrAlreadyExists)
   411 		{
   412 		User::LeaveIfError(err);
   413 		}
   414 
   415 	TRequestStatus threadStat;
   416 	thread.Logon(threadStat);
   417 
   418 	TBool jit = User::JustInTime();
   419 	User::SetJustInTime(EFalse);
   420 
   421 	thread.Resume();
   422 	User::WaitForRequest(threadStat);
   423 
   424 	User::SetJustInTime(jit);
   425 
   426 	TExitDetails exitDetails;
   427 	exitDetails.iCategory = thread.ExitCategory();
   428 	exitDetails.iReason = thread.ExitReason();
   429 	exitDetails.iExitType = thread.ExitType();
   430 
   431 	return exitDetails;
   432 	}
   433 
   434 
   435 /*
   436  This test function accepts 2 integer parameters as defined below
   437 {EParamInt,-10,100},{EParamInt,0,200}
   438 Any calls to this function with parameters outside the ranges
   439 defined above should fail with KErrBadParameter
   440 */
   441 void TestFunction0AL()
   442 	{
   443 	RClientMessageTestSession session;
   444 
   445 	TInt err = session.Connect();
   446 	Test(err == KErrNone);
   447 
   448 	CleanupClosePushL(session);
   449 
   450 	err = session.TestFunction0( 0, 100);
   451 	Test(err == KErrNone);
   452 
   453 	err = session.TestFunction0( 100, 0);
   454 	Test(err == KErrNone);
   455 
   456 	err = session.TestFunction0( -5, 10);
   457 	Test(err == KErrNone);
   458 
   459 	err = session.TestFunction0( -5, -10);
   460 	Test(err == KErrBadParameter);
   461 
   462 	err = session.TestFunction0( -15, 10);
   463 	Test(err == KErrBadParameter);
   464 
   465 	err = session.TestFunction0( -10, 200);
   466 	Test(err == KErrNone);
   467 
   468 	err = session.TestFunction0( 101, 102);
   469 	Test(err == KErrBadParameter);
   470 
   471 	err = session.TestFunction0(11, 56, 43);
   472 	Test(err == KErrNone);
   473 
   474 	err = session.TestFunction0( _L8("Des8"), _L("Des"));
   475 	Test(err == KErrBadParameter);
   476 
   477 	CleanupStack::PopAndDestroy(&session);
   478 	}
   479 
   480 
   481 /*
   482  This test function accepts 2 integer parameters as defined below
   483 {EParamInt,-10,100},{EParamInt,0,200}
   484 In the server, this function tries to access a ptr type from
   485 an int argument. This is a programming error and should result
   486 in the server panicking with ECMPanicWrongParameterType in UDEB
   487 or returning KErrWrongParameterType in UREL
   488 */
   489 void TestFunction1L()
   490 	{
   491 	RClientMessageTestSession session;
   492 
   493 	TInt err = session.Connect();
   494 	Test(err == KErrNone);
   495 
   496 	CleanupClosePushL(session);
   497 
   498 	err = session.TestFunction1(10,100);
   499 
   500 #ifdef _DEBUG
   501 	Test(err == KErrServerTerminated);
   502 
   503 	TInt type = serverProcess.ExitType();
   504 	Test(type == EExitPanic);
   505 
   506 	TInt reason = serverProcess.ExitReason();
   507 	Test(reason == ECMPanicWrongParameterType);
   508 #else
   509 	Test(err == KErrWrongParameterType);
   510 #endif
   511 	CleanupStack::PopAndDestroy(&session);
   512 	}
   513 
   514 /*
   515  This test function accepts 1 integer parameter as defined below
   516 {EParamInt,100,10}
   517 As can be seen above, the schema is incorrectly defined as iMin is
   518 greater than iMax. This is a programming error and should result
   519 in the server panicking with ECMPanicBadMessageSchema in UDEB
   520 or returning KErrBadParameter in UREL
   521 */
   522 void TestFunction2L()
   523 	{
   524 	RClientMessageTestSession session;
   525 
   526 	TInt err = session.Connect();
   527 	Test(err == KErrNone);
   528 
   529 	CleanupClosePushL(session);
   530 
   531 	//this function is incorrectly defined in the
   532 	//message schema. This should result in the
   533 	//server panicking
   534 	err = session.TestFunction2(10,100);
   535 
   536 	//In debug builds the server should panic.
   537 	//In release builds KErrBadParameter should be returned
   538 #ifdef _DEBUG
   539 	Test(err == KErrServerTerminated);
   540 
   541 	TInt type = serverProcess.ExitType();
   542 	Test(type == EExitPanic);
   543 
   544 	TInt reason = serverProcess.ExitReason();
   545 	Test(reason == ECMPanicBadMessageSchema);
   546 #else
   547 	Test(err == KErrBadParameter);
   548 #endif
   549 
   550 	CleanupStack::PopAndDestroy(&session);
   551 	}
   552 
   553 /*
   554  This test function accepts 1 integer parameter as defined below
   555 {EParamInt,-10,-20}
   556 As can be seen above, the schema is incorrectly defined as iMin is
   557 greater than iMax. This is a programming error and should result
   558 in the server panicking with ECMPanicBadMessageSchema in UDEB
   559 or returning KErrBadParameter in UREL
   560 */
   561 void TestFunction3L()
   562 	{
   563 	RClientMessageTestSession session;
   564 
   565 	TInt err = session.Connect();
   566 	Test(err == KErrNone);
   567 
   568 	CleanupClosePushL(session);
   569 
   570 	//this function is incorrectly defined in the
   571 	//message schema. This should result in the
   572 	//server panicking
   573 	err = session.TestFunction3(10,100);
   574 
   575 	//In debug builds the server should panic.
   576 	//In release builds KErrBadParameter should be returned
   577 #ifdef _DEBUG
   578 	Test(err == KErrServerTerminated);
   579 
   580 	TInt type = serverProcess.ExitType();
   581 	Test(type == EExitPanic);
   582 
   583 	TInt reason = serverProcess.ExitReason();
   584 	Test(reason == ECMPanicBadMessageSchema);
   585 #else
   586 	Test(err == KErrBadParameter);
   587 #endif
   588 
   589 	CleanupStack::PopAndDestroy(&session);
   590 	}
   591 
   592 /*
   593  This test function accepts 2 descriptor parameters as defined below
   594 {EParamDes8Read,2,16},{EParamDes16Read,0,32}
   595 Any calls to this function with parameters outside the constraints
   596 defined above should result in the client being panicked with
   597 KErrBadDescriptor
   598 */
   599 void TestFunction4AL()
   600 	{
   601 	RClientMessageTestSession session;
   602 	_LIT8(KDes8, "Des8");
   603 	_LIT8(KShortDes8, "De");
   604 	_LIT(KDes16, "Des16");
   605 	_LIT(KLongDes16, "Des16 - A longer version");
   606 
   607 	TInt err = session.Connect();
   608 	Test(err == KErrNone);
   609 
   610 	CleanupClosePushL(session);
   611 
   612 	err = session.TestFunction4(KDes8,KDes16);
   613 	Test(err == KErrNone);
   614 
   615 	err = session.TestFunction4(KShortDes8,KLongDes16);
   616 	Test(err == KErrNone);
   617 
   618 	CleanupStack::PopAndDestroy(&session);
   619 	}
   620 
   621 /*
   622  This test function accepts 2 descriptor parameters as defined below
   623 {EParamDes8Read,2,16},{EParamDes16Read,0,32}
   624 Any calls to this function with parameters outside the constraints
   625 defined above should result in the client being panicked with
   626 KErrBadDescriptor
   627 */
   628 void TestFunction4BL()
   629 	{
   630 	RClientMessageTestSession session;
   631 	_LIT8(KDes8, "Des8");
   632 	_LIT(KDes16, "Des16");
   633 
   634 	TInt err = session.Connect();
   635 	Test(err == KErrNone);
   636 
   637 	CleanupClosePushL(session);
   638 
   639 	//This should result in the server panicking the client
   640 	err = session.TestFunction4(KDes16,KDes8);
   641 
   642 	CleanupStack::PopAndDestroy(&session);
   643 	}
   644 
   645 /*
   646  This test function accepts 2 descriptor parameters as defined below
   647 {EParamDes8Read,2,16},{EParamDes16Read,0,32}
   648 Any calls to this function with parameters outside the constraints
   649 defined above should result in the client being panicked with
   650 KErrBadDescriptor
   651 */
   652 void TestFunction4CL()
   653 	{
   654 	RClientMessageTestSession session;
   655 	_LIT(KDes16, "Des16");
   656 	_LIT8(KLongDes8, "This is a long Des8");
   657 
   658 	TInt err = session.Connect();
   659 	Test(err == KErrNone);
   660 
   661 	CleanupClosePushL(session);
   662 
   663 	//This should result in the server panicing the client
   664 	err = session.TestFunction4(KLongDes8,KDes16);
   665 
   666 	CleanupStack::PopAndDestroy(&session);
   667 	}
   668 
   669 /*
   670 This test function accepts 2 descriptor parameters as defined below
   671 {EParamDes8Read,2,16},{EParamDes16Read,0,32}
   672 Any calls to this function with parameters outside the constraints
   673 defined above should result in the client being panicked with
   674 KErrBadDescriptor
   675 */
   676 void TestFunction4DL()
   677 	{
   678 	RClientMessageTestSession session;
   679 	_LIT8(KDes8, "Des8");
   680 	_LIT(KLongDes16, "This is a long Des16 that should cause an issue");
   681 
   682 	TInt err = session.Connect();
   683 	Test(err == KErrNone);
   684 
   685 	CleanupClosePushL(session);
   686 
   687 	//This should result in the server panicing the client
   688 	err = session.TestFunction4(KDes8,KLongDes16);
   689 
   690 	CleanupStack::PopAndDestroy(&session);
   691 	}
   692 
   693 /*
   694 This test function accepts 2 descriptor parameters as defined below
   695 {EParamDes8Read,2,16},{EParamDes16Read,0,32}
   696 Any calls to this function with parameters outside the constraints
   697 defined above should result in the client being panicked with
   698 KErrBadDescriptor
   699 */
   700 void TestFunction4EL()
   701 	{
   702 	RClientMessageTestSession session;
   703 	_LIT(KDes16, "Des16");
   704 	_LIT8(KEmptyDes8, "");
   705 	TInt err = session.Connect();
   706 	Test(err == KErrNone);
   707 
   708 	CleanupClosePushL(session);
   709 
   710 	//This should result in the server panicing the client
   711 	//as the function expects a descriptor of minimum length 2
   712 	err = session.TestFunction4(KEmptyDes8,KDes16);
   713 
   714 	CleanupStack::PopAndDestroy(&session);
   715 	}
   716 
   717 /*
   718 This test function accepts 2 descriptor parameters as defined below
   719 {EParamDes8Read,2,16},{EParamDes16Read,0,32}
   720 Any calls to this function with parameters outside the constraints
   721 defined above should result in the client being panicked with
   722 KErrBadDescriptor
   723 */
   724 void TestFunction4FL()
   725 	{
   726 	RClientMessageTestSession session;
   727 	_LIT8(KDes8, "Des8");
   728 	TInt err = session.Connect();
   729 	Test(err == KErrNone);
   730 
   731 	CleanupClosePushL(session);
   732 
   733 	//This should result in the server panicing the client
   734 	//as the function expects 2 descriptor arguments
   735 	err = session.TestFunction4(KDes8);
   736 
   737 	CleanupStack::PopAndDestroy(&session);
   738 	}
   739 
   740 
   741 /*
   742 This test function accepts 2 descriptor parameters as defined below
   743 {EParamDes8Read,2,16},{EParamDes16Read,0,32}
   744 The server attempts to read from the first descriptor but passes
   745 in a buffer that is too small.  This is a programming error and
   746 should result in the server panicking with ECMPanicBadDescriptor in UDEB
   747 and returning KErrNone in UREL
   748 KErrBadDescriptor
   749 */
   750 void TestFunction5L()
   751 	{
   752 	RClientMessageTestSession session;
   753 	_LIT8(KDes8, "Des8");
   754 	_LIT(KDes16, "Des16");
   755 
   756 	TInt err = session.Connect();
   757 	Test(err == KErrNone);
   758 
   759 	CleanupClosePushL(session);
   760 
   761 	err = session.TestFunction5(KDes8,KDes16);
   762 #ifdef _DEBUG
   763 	Test(err == KErrServerTerminated);
   764 
   765 	TInt type = serverProcess.ExitType();
   766 	Test(type == EExitPanic);
   767 
   768 	TInt reason = serverProcess.ExitReason();
   769 	Test(reason == ECMPanicBadDescriptor);
   770 #else
   771 	Test(err == KErrNone);
   772 #endif
   773 
   774 	CleanupStack::PopAndDestroy(&session);
   775 	}
   776 
   777 /*
   778 This test function accepts 2 descriptor parameters as defined below
   779 {EParamDes8Read,2,16},{EParamDes16Read,0,32}
   780 Any calls to this function with parameters outside the constraints
   781 defined above should result in the client being panicked with
   782 KErrBadDescriptor
   783 */
   784 void TestFunction6L()
   785 	{
   786 	RClientMessageTestSession session;
   787 	_LIT8(KDes8, "Des8");
   788 	_LIT(KDes16, "Des16");
   789 
   790 	TInt err = session.Connect();
   791 	Test(err == KErrNone);
   792 
   793 	CleanupClosePushL(session);
   794 
   795 	err = session.TestFunction6(KDes8,KDes16);
   796 	Test(err == KErrArgument);
   797 
   798 	CleanupStack::PopAndDestroy(&session);
   799 	}
   800 
   801 /*
   802 This test function accepts 2 descriptor parameters as defined below
   803 {EParamDes8Read,2,16},{EParamDes16Read,0,32}
   804 Any calls to this function with parameters outside the constraints
   805 defined above should result in the client being panicked with
   806 KErrBadDescriptor
   807 */
   808 void TestFunction7L()
   809 	{
   810 	RClientMessageTestSession session;
   811 	_LIT8(KDes8, "Descriptor8");
   812 	_LIT(KDes16, "Descriptor16");
   813 
   814 	TInt err = session.Connect();
   815 	Test(err == KErrNone);
   816 
   817 	CleanupClosePushL(session);
   818 
   819 	err = session.TestFunction7(KDes8,KDes16);
   820 	Test(err == KErrNone);
   821 
   822 	CleanupStack::PopAndDestroy(&session);
   823 	}
   824 
   825 /*
   826 This test function accepts 1 descriptor parameter as defined below
   827 {EParamDes8Read,0,-16}
   828 As can be seen above, the schema is incorrectly defined as iMax is
   829 negative. This is a programming error and should result
   830 in the server panicking with ECMPanicBadMessageSchema in UDEB
   831 or the client being panicked with KErrBadDescriptor in UREL
   832 */
   833 void TestFunction8L()
   834 	{
   835 	RClientMessageTestSession session;
   836 	_LIT8(KDes8, "Descriptor8");
   837 	_LIT(KDes16, "Descriptor16");
   838 
   839 	TInt err = session.Connect();
   840 	Test(err == KErrNone);
   841 
   842 	CleanupClosePushL(session);
   843 
   844 	//this function is incorrectly defined in the
   845 	//message schema. This should result in the
   846 	//server panicking
   847 	err = session.TestFunction8(KDes8,KDes16);
   848 
   849 	//In debug builds the server should panic.
   850 	//In release builds the client will be panicked
   851 #ifdef _DEBUG
   852 	Test(err == KErrServerTerminated);
   853 
   854 	TInt type = serverProcess.ExitType();
   855 	Test(type == EExitPanic);
   856 
   857 	TInt reason = serverProcess.ExitReason();
   858 	Test(reason == ECMPanicBadMessageSchema);
   859 #endif
   860 
   861 	CleanupStack::PopAndDestroy(&session);
   862 	}
   863 
   864 
   865 /*
   866 This test function accepts 2 descriptor parameters and 2 TInt
   867 parameters as defined below
   868 {EParamDes8,64,64},{EParamInt,0,64},{EParamDes16,128,128},{EParamInt,0,128}
   869 Any calls to this function with descriptor parameters outside the constraints
   870 defined above should result in the client being paniced with
   871 KErrBadDescriptor or KErrOverflow
   872 */
   873 void TestFunction9AL()
   874 	{
   875 	TBuf8<64> buf8;
   876 	TBuf<128> buf;
   877 	TBuf8<64> buf82;
   878 	TBuf<128> buf2;
   879 
   880 	RClientMessageTestSession session;
   881 
   882 	TInt err = session.Connect();
   883 	Test(err == KErrNone);
   884 
   885 	CleanupClosePushL(session);
   886 
   887 	err = session.TestFunction9(buf8,0,buf,0);
   888 	Test(err == KErrNone);
   889 	Test(buf8.Find(_L8("CClientMessageTest")) == 0);
   890 	Test(buf.Find(_L("CClientMessageTest")) == 0);
   891 
   892 	err = session.TestFunction9(buf82,7,buf2,73);
   893 	Test(err == KErrNone);
   894 	Test(buf82.Find(_L8("CClientMessageTest")) == 7);
   895 	Test(buf2.Find(_L("CClientMessageTest")) == 73);
   896 
   897 	CleanupStack::PopAndDestroy(&session);
   898 	}
   899 
   900 /*
   901 This test function accepts 2 descriptor parameters and 2 TInt
   902 parameters as defined below
   903 {EParamDes8,64,64},{EParamInt,0,64},{EParamDes16,128,128},{EParamInt,0,128}
   904 Any calls to this function with descriptor parameters outside the constraints
   905 defined above should result in the client being paniced with
   906 KErrBadDescriptor
   907 */
   908 void TestFunction9BL()
   909 	{
   910 
   911 	TBuf8<32> smallBuf8;
   912 	TBuf<32> smallBuf;
   913 
   914 	RClientMessageTestSession session;
   915 
   916 	TInt err = session.Connect();
   917 	Test(err == KErrNone);
   918 
   919 	CleanupClosePushL(session);
   920 
   921 	//this should result in a  client panic with KErrBadDescriptor
   922 	err = session.TestFunction9(smallBuf8,0,smallBuf,0);
   923 
   924 	CleanupStack::PopAndDestroy(&session);
   925 	}
   926 
   927 /*
   928 This test function accepts 2 descriptor parameters and 2 TInt
   929 parameters as defined below
   930 {EParamDes8,64,64},{EParamInt,0,64},{EParamDes16,128,128},{EParamInt,0,128}
   931 The server function attempts to write to the supplied descriptors at the
   932 offsets specified by the two TInt values.  In this test the server will
   933 attempt to write to the first buffer with an offset of 60 which should
   934 result in the client being panicked with KErrOverflow
   935 */
   936 void TestFunction9CL()
   937 	{
   938 
   939 	TBuf8<64> buf8;
   940 	TBuf<128> buf;
   941 
   942 	RClientMessageTestSession session;
   943 
   944 	TInt err = session.Connect();
   945 	Test(err == KErrNone);
   946 
   947 	CleanupClosePushL(session);
   948 
   949 	//this will attempt to write a descriptor with an offset of 60
   950 	//which should tresult in a client panic KErrOverflow
   951 	err = session.TestFunction9(buf8,60,buf,10);
   952 
   953 	CleanupStack::PopAndDestroy(&session);
   954 	}
   955 
   956 /*
   957 This test function accepts 2 descriptor parameters and 2 TInt
   958 parameters as defined below
   959 {EParamDes8,64,64},{EParamInt,0,64},{EParamDes16,128,128},{EParamInt,0,128}
   960 The test function below calls this function but passed the 8 and 16 bit
   961 descriptors in the wrong order which should result in the client being
   962 panicked with KErrBadDescriptor
   963 */
   964 void TestFunction9DL()
   965 	{
   966 	TBuf8<64> buf8;
   967 	TBuf<128> buf;
   968 
   969 	RClientMessageTestSession session;
   970 
   971 	TInt err = session.Connect();
   972 	Test(err == KErrNone);
   973 
   974 	CleanupClosePushL(session);
   975 
   976 	//this should result in a client panic as the descriptors
   977 	//are passed in in the wrong order
   978 	err = session.TestFunction9(buf,0,buf8,10);
   979 
   980 	CleanupStack::PopAndDestroy(&session);
   981 	}
   982 
   983 /*
   984 This test function accepts 2 descriptor parameters and 2 TInt
   985 parameters as defined below
   986 {EParamDes8,64,64},{EParamInt,0,64},{EParamDes16,128,128},{EParamInt,0,128}
   987 The server function attempts to write a descriptor that is larger than the
   988 buffer supplied by the client which should result in the client being
   989 panicked with KErrOverflow
   990 */
   991 void TestFunction10L()
   992 	{
   993 
   994 	TBuf8<64> buf8;
   995 	TBuf<128> buf;
   996 
   997 	RClientMessageTestSession session;
   998 
   999 	TInt err = session.Connect();
  1000 	Test(err == KErrNone);
  1001 
  1002 	CleanupClosePushL(session);
  1003 
  1004 	//This function tries to write a descriptor
  1005 	//that is larger than the declared buffer
  1006 	//this should result in a panic
  1007 	err = session.TestFunction10(buf8,0,buf,0);
  1008 
  1009 	CleanupStack::PopAndDestroy(&session);
  1010 	}
  1011 
  1012 /*
  1013 This test function accepts 2 descriptor parameters and 2 TInt
  1014 parameters as defined below
  1015 {EParamDes8,64,64},{EParamInt,0,64},{EParamDes16,128,128},{EParamInt,0,128}
  1016 The server function attempts to read from a descriptor that is smaller
  1017 than the specified minimum length.  This is a programming error and
  1018 should result in the server panicking with ECMPanicBadDescriptor in UDEB
  1019 and returning KErrNone in UREL
  1020 */
  1021 void TestFunction11L()
  1022 	{
  1023 	_LIT8(KLongDes8,"This descriptor is longer than 32 characters");
  1024 	TBuf8<64> buf8(KLongDes8);
  1025 	TBuf<128> buf;
  1026 
  1027 	RClientMessageTestSession session;
  1028 
  1029 	TInt err = session.Connect();
  1030 	Test(err == KErrNone);
  1031 
  1032 	CleanupClosePushL(session);
  1033 
  1034 	//This function tries to read from a descriptor
  1035 	//into a buffer that is smaller than the allowed min length
  1036 	//this should result in a server panic
  1037 	err = session.TestFunction11(buf8,0,buf,0);
  1038 #ifdef _DEBUG
  1039 	Test(err == KErrServerTerminated);
  1040 
  1041 	TInt type = serverProcess.ExitType();
  1042 	Test(type == EExitPanic);
  1043 
  1044 	TInt reason = serverProcess.ExitReason();
  1045 	Test(reason == ECMPanicBadDescriptor);
  1046 #else
  1047 	Test(err == KErrNone);
  1048 #endif
  1049 
  1050 	CleanupStack::PopAndDestroy(&session);
  1051 	}
  1052 
  1053 /*
  1054 This test function accepts 1 descriptor parameter as defined below
  1055 {EParamDes8,-64,64}
  1056 As can be seen above, the schema is incorrectly defined as iMin is
  1057 negative. This is a programming error and should result
  1058 in the server panicking with ECMPanicBadMessageSchema in UDEB
  1059 or returning KErrNone in UREL
  1060 */
  1061 void TestFunction12L()
  1062 	{
  1063 
  1064 	TBuf8<64> buf8;
  1065 	TBuf<128> buf;
  1066 
  1067 	RClientMessageTestSession session;
  1068 
  1069 	TInt err = session.Connect();
  1070 	Test(err == KErrNone);
  1071 
  1072 	CleanupClosePushL(session);
  1073 
  1074 	//this function is incorrectly defined in the
  1075 	//message schema. This should result in the
  1076 	//server panicking in debug builds
  1077 	//In release builds KErrNone should be returned
  1078 	err = session.TestFunction12(buf8,0,buf,0);
  1079 
  1080 #ifdef _DEBUG
  1081 	Test(err == KErrServerTerminated);
  1082 
  1083 	TInt type = serverProcess.ExitType();
  1084 	Test(type == EExitPanic);
  1085 
  1086 	TInt reason = serverProcess.ExitReason();
  1087 	Test(reason == ECMPanicBadMessageSchema);
  1088 #else
  1089 	Test(err == KErrNone);
  1090 #endif
  1091 	CleanupStack::PopAndDestroy(&session);
  1092 	}
  1093 
  1094 /*
  1095 This test function accepts 1 descriptor parameter as defined below
  1096 {EParamDes8,64,-64}
  1097 As can be seen above, the schema is incorrectly defined as iMax is
  1098 negative. This is a programming error and should result
  1099 in the server panicking with ECMPanicBadMessageSchema in UDEB
  1100 or panicking the client with KErrBadDescriptor in UREL
  1101 */
  1102 void TestFunction13L()
  1103 	{
  1104 
  1105 	TBuf8<64> buf8;
  1106 	TBuf<128> buf;
  1107 
  1108 	RClientMessageTestSession session;
  1109 
  1110 	TInt err = session.Connect();
  1111 	Test(err == KErrNone);
  1112 
  1113 	CleanupClosePushL(session);
  1114 
  1115 	//this function is incorrectly defined in the
  1116 	//message schema. This should result in the
  1117 	//server panicking in debug builds
  1118 	err = session.TestFunction13(buf8,0,buf,0);
  1119 
  1120 #ifdef _DEBUG
  1121 	Test(err == KErrServerTerminated);
  1122 
  1123 	TInt type = serverProcess.ExitType();
  1124 	Test(type == EExitPanic);
  1125 
  1126 	TInt reason = serverProcess.ExitReason();
  1127 	Test(reason == ECMPanicBadMessageSchema);
  1128 #endif
  1129 
  1130 	CleanupStack::PopAndDestroy(&session);
  1131 	}
  1132 
  1133 /*
  1134 This test function accepts 2 8bit descriptor parameters and 1 TInt
  1135 parameter as defined below
  1136 {EParamDes8Read,0,16},{EParamInt,0,16},{EParamDes8,16,16}
  1137 The server function attempts reads from the first descriptor and
  1138 then writes into the second descriptor at the offset supplied by
  1139 the TInt value.  The test function below checks that the reading
  1140 and writing with offset occurs as expected by checking the strings
  1141 written by the server.
  1142 */
  1143 void TestFunction14L()
  1144 	{
  1145 
  1146 	_LIT8(KDes8, "Descriptor8");
  1147 	TBuf8<16> buf;
  1148 
  1149 	RClientMessageTestSession session;
  1150 
  1151 	TInt err = session.Connect();
  1152 	Test(err == KErrNone);
  1153 
  1154 	CleanupClosePushL(session);
  1155 
  1156 	err = session.TestFunction14(KDes8,0,buf);
  1157 	Test(err == KErrNone);
  1158 	Test(buf.Find(_L8("Descriptor8")) == 0);
  1159 
  1160 	err = session.TestFunction14(KDes8,3,buf);
  1161 	Test(err == KErrNone);
  1162 	Test(buf.Find(_L8("criptor8")) == 0);
  1163 
  1164 	err = session.TestFunction14(KDes8,8,buf);
  1165 	Test(err == KErrNone);
  1166 	Test(buf.Find(_L8("or8")) == 0);
  1167 
  1168 	CleanupStack::PopAndDestroy(&session);
  1169 	}
  1170 
  1171 /*
  1172 This test function accepts 2 16bit descriptor parameters and 1 TInt
  1173 parameter as defined below
  1174 {EParamDes16Read,0,64},{EParamInt,0,64},{EParamDes16,64,64}
  1175 The server function attempts reads from the first descriptor and
  1176 then writes into the second descriptor at the offset supplied by
  1177 the TInt value.  The test function below checks that the reading
  1178 and writing with offset occurs as expected by checking the strings
  1179 written by the server.
  1180 */
  1181 void TestFunction15L()
  1182 	{
  1183 
  1184 	_LIT(KDes, "Descriptor");
  1185 	TBuf<64> buf;
  1186 
  1187 	RClientMessageTestSession session;
  1188 
  1189 	TInt err = session.Connect();
  1190 	Test(err == KErrNone);
  1191 
  1192 	CleanupClosePushL(session);
  1193 
  1194 	err = session.TestFunction15(KDes,0,buf);
  1195 	Test(err == KErrNone);
  1196 	Test(buf.Find(_L("Descriptor")) == 0);
  1197 
  1198 	err = session.TestFunction15(KDes,3,buf);
  1199 	Test(err == KErrNone);
  1200 	Test(buf.Find(_L("criptor")) == 0);
  1201 
  1202 	err = session.TestFunction15(KDes,8,buf);
  1203 	Test(err == KErrNone);
  1204 	Test(buf.Find(_L("or")) == 0);
  1205 
  1206 	CleanupStack::PopAndDestroy(&session);
  1207 	}
  1208 
  1209 
  1210 /*
  1211 This test function accepts a single TAny* parameter as below
  1212 {EParamPtr,0,0}
  1213 The server function reads the pointer value.
  1214 */
  1215 void TestFunction16L()
  1216 	{
  1217 	RClientMessageTestSession session;
  1218 
  1219 	TInt err = session.Connect();
  1220 	Test(err == KErrNone);
  1221 
  1222 	CleanupClosePushL(session);
  1223 
  1224 	err = session.TestFunction16(0);
  1225 	Test(err == KErrNone);
  1226 
  1227 	CleanupStack::PopAndDestroy(&session);
  1228 	}
  1229 
  1230 
  1231 /*
  1232 This test function accepts a single TAny* parameter as below
  1233 {EParamPtr,0,0}
  1234 The server function attempts to call CMessageParameterBase::WriteL
  1235 which is not defined for a Ptr type. This is a programming error and
  1236 should result in the server panicking with ECMPanicWrongParameterType
  1237 in UDEB or returning KErrWrongParameterType in UREL
  1238 */
  1239 void TestFunction17L()
  1240 	{
  1241 	RClientMessageTestSession session;
  1242 
  1243 	TInt err = session.Connect();
  1244 	Test(err == KErrNone);
  1245 
  1246 	CleanupClosePushL(session);
  1247 
  1248 	//This should result in the server panicking with ECMPanicWrongParameterType
  1249 	//in UDEB or returning KErrWrongParameterType in UREL
  1250 	err = session.TestFunction17(0);
  1251 #ifdef _DEBUG
  1252 	Test(err == KErrServerTerminated);
  1253 
  1254 	TInt type = serverProcess.ExitType();
  1255 	Test(type == EExitPanic);
  1256 
  1257 	TInt reason = serverProcess.ExitReason();
  1258 	Test(reason == ECMPanicWrongParameterType);
  1259 #else
  1260 	Test(err == KErrWrongParameterType);
  1261 #endif
  1262 
  1263 	CleanupStack::PopAndDestroy(&session);
  1264 	}
  1265 
  1266 /*
  1267 This test function accepts a single custom TPckg parameter as below
  1268 {EParamCustom1,sizeof(CMTestStruct2),sizeof(CMTestStruct2)}.
  1269 CMTestStruct2 is defined as follows:
  1270 
  1271 struct CMTestStruct1
  1272 	{
  1273 	TInt iInt;
  1274 	TBuf<32> iDes;
  1275 	};
  1276 
  1277 struct CMTestStruct2
  1278 	{
  1279 	TInt iCount;
  1280 	CMTestStruct1* iStruct;
  1281 	TCMTestEnum iEnum;
  1282 	TBuf<32> iDes;
  1283 	};
  1284 
  1285 The EParamCustom1 parameter type is validated using a custom validation
  1286 function defined in the testclientmessageschema.cpp.  The validation
  1287 function checks that iEnum is in the valid range for TCMTestEnum,
  1288 that iCount >= 0 and that iDes.Length() > 0.  If any of these checks
  1289 fail the server should return KErrBadParameter.
  1290 */
  1291 void TestFunction18AL()
  1292 	{
  1293 	RClientMessageTestSession session;
  1294 
  1295 	TInt err = session.Connect();
  1296 	Test(err == KErrNone);
  1297 
  1298 	CleanupClosePushL(session);
  1299 
  1300 	CMTestStruct1 struct1;
  1301 	struct1.iInt = 7;
  1302 	struct1.iDes = _L("Test Struct");
  1303 
  1304 	CMTestStruct2 struct2;
  1305 	struct2.iCount = 1;
  1306 	struct2.iStruct = &struct1;
  1307 	struct2.iEnum = ETestVal1;
  1308 	struct2.iDes = _L("Test Struct 2");
  1309 
  1310 	TPckg<CMTestStruct2> pData(struct2);
  1311 
  1312 	err = session.TestFunction18(pData);
  1313 	Test(err == KErrNone);
  1314 
  1315 	Test(struct2.iCount == 0);
  1316 
  1317 	CMTestStruct1 struct3;
  1318 	struct3.iInt = -1;
  1319 	struct3.iDes = _L("");
  1320 
  1321 	CMTestStruct2 struct4;
  1322 	struct4.iCount = 1;
  1323 	struct4.iStruct = &struct3;
  1324 	struct4.iEnum = -1;
  1325 	struct4.iDes = _L("Test Struct 2");
  1326 
  1327 	TPckg<CMTestStruct2> pData2(struct4);
  1328 
  1329 	//As iEnum is not in the valid range this validation should fail
  1330 	err = session.TestFunction18(pData2);
  1331 	Test(err == KErrBadParameter);
  1332 
  1333 	CleanupStack::PopAndDestroy(&session);
  1334 	}
  1335 
  1336 /*
  1337 This test function accepts a single custom TPckg parameter as below
  1338 {EParamCustom1,sizeof(CMTestStruct2),sizeof(CMTestStruct2)}.
  1339 CMTestStruct2 is defined above.
  1340 The test function below passes in a TPckg<CMTestStruct1> which is an
  1341 incorrect type.  The server should return KErrBadDescriptor
  1342 */
  1343 void TestFunction18BL()
  1344 	{
  1345 	RClientMessageTestSession session;
  1346 
  1347 	TInt err = session.Connect();
  1348 	Test(err == KErrNone);
  1349 
  1350 	CleanupClosePushL(session);
  1351 
  1352 	CMTestStruct1 struct1;
  1353 	struct1.iInt = 0;
  1354 	struct1.iDes = _L("Test Struct");
  1355 
  1356 	TPckg<CMTestStruct1> pData(struct1);
  1357 
  1358 	//This should result in a panic
  1359 	err = session.TestFunction18(pData);
  1360 
  1361 	CleanupStack::PopAndDestroy(&session);
  1362 	}
  1363 
  1364 /*
  1365 This test function accepts a single custom TPckg parameter as below
  1366 {EParamCustom1,sizeof(CMTestStruct2),sizeof(CMTestStruct2)}.
  1367 CMTestStruct2 is defined above.
  1368 The test function below passes in an Empty TBuf the same size as a
  1369 CMTestStruct2. As this wont contain any valid data, the server should
  1370 panic the client with KErrBadParameter.
  1371 */
  1372 void TestFunction18CL()
  1373 	{
  1374 	RClientMessageTestSession session;
  1375 
  1376 	TInt err = session.Connect();
  1377 	Test(err == KErrNone);
  1378 
  1379 	CleanupClosePushL(session);
  1380 
  1381 	TBuf<sizeof(CMTestStruct2)> buf;
  1382 	buf.SetLength(sizeof(CMTestStruct2));
  1383 
  1384 	//This should result in a panic
  1385 	err = session.TestFunction18(buf);
  1386 
  1387 	CleanupStack::PopAndDestroy(&session);
  1388 	}
  1389 
  1390 /*
  1391 This test function accepts a single custom TPckg parameter as below
  1392 {EParamCustom2,sizeof(CMTestStruct1),sizeof(CMTestStruct1)}.
  1393 CMTestStruct1 is defined as follows:
  1394 
  1395 struct CMTestStruct1
  1396 	{
  1397 	TInt iInt;
  1398 	TBuf<32> iDes;
  1399 	};
  1400 
  1401 The EParamCustom1 parameter type is validated using a custom validation
  1402 function defined in the testclientmessageschema.cpp.  The validation
  1403 function checks that iInt is > 0.  If this check fails the server
  1404 should return KErrBadParameter.
  1405 The test function below passes the data to the server in a TPckgBuf
  1406 */
  1407 void TestFunction19L()
  1408 	{
  1409 	RClientMessageTestSession session;
  1410 
  1411 	TInt err = session.Connect();
  1412 	Test(err == KErrNone);
  1413 
  1414 	CleanupClosePushL(session);
  1415 
  1416 	CMTestStruct1 struct1;
  1417 	struct1.iInt = 4;
  1418 	struct1.iDes = _L("Test Struct");
  1419 
  1420 	TPckgBuf<CMTestStruct1> pData(struct1);
  1421 
  1422 	err = session.TestFunction19(pData);
  1423 	Test(err == KErrNone);
  1424 
  1425 	struct1.iInt = -4;
  1426 	TPckgBuf<CMTestStruct1> pData2(struct1);
  1427 
  1428 	err = session.TestFunction19(pData2);
  1429 	Test(err == KErrBadParameter);
  1430 
  1431 	CleanupStack::PopAndDestroy(&session);
  1432 	}
  1433 
  1434 /*
  1435 This test function does not expect any parameters.
  1436 The schema defines a single placeholder parameter
  1437 {EParamNull,0,0}
  1438 but the number of parameters is set to 0
  1439 */
  1440 void TestFunction25L()
  1441 	{
  1442 	RClientMessageTestSession session;
  1443 
  1444 	TInt err = session.Connect();
  1445 	Test(err == KErrNone);
  1446 
  1447 	CleanupClosePushL(session);
  1448 
  1449 	err = session.TestFunction25();
  1450 	Test(err == KErrNone);
  1451 
  1452 	CleanupStack::PopAndDestroy(&session);
  1453 	}
  1454 
  1455 /*
  1456 This test function does not expect any parameters.
  1457 The schema defines a single placeholder parameter
  1458 {EParamNull,0,0}
  1459 The schema is incorrectly defined as the number of parameters is
  1460 listed as 1 instead of 0.  This is a programming error and should result
  1461 in the server panicking with ECMPanicBadMessageSchema in UDEB
  1462 or the client being panicked with KErrBadDescriptor in UREL
  1463 */
  1464 void TestFunction26L()
  1465 	{
  1466 	RClientMessageTestSession session;
  1467 
  1468 	TInt err = session.Connect();
  1469 	Test(err == KErrNone);
  1470 
  1471 	CleanupClosePushL(session);
  1472 
  1473 	err = session.TestFunction26();
  1474 	//In debug builds the server should panic.
  1475 	//In release builds KErrBadParameter should be returned
  1476 #ifdef _DEBUG
  1477 	Test(err == KErrServerTerminated);
  1478 
  1479 	TInt type = serverProcess.ExitType();
  1480 	Test(type == EExitPanic);
  1481 
  1482 	TInt reason = serverProcess.ExitReason();
  1483 	Test(reason == ECMPanicBadMessageSchema);
  1484 #else
  1485 	Test(err == KErrBadMessageSchema);
  1486 #endif
  1487 
  1488 	CleanupStack::PopAndDestroy(&session);
  1489 	}
  1490 
  1491 /*
  1492 This test function does not expect any parameters.
  1493 The schema defines a single placeholder parameter
  1494 {453,0,0}
  1495 The schema is incorrectly defined as it contains an invalid
  1496 parameter type. This is a programming error and should result
  1497 in the server panicking with ECMPanicBadMessageSchema in UDEB
  1498 or returning KErrBadParameter in UREL
  1499 */
  1500 void TestFunction27L()
  1501 	{
  1502 	RClientMessageTestSession session;
  1503 
  1504 	TInt err = session.Connect();
  1505 	Test(err == KErrNone);
  1506 
  1507 	CleanupClosePushL(session);
  1508 
  1509 	err = session.TestFunction27();
  1510 	//In debug builds the server should panic.
  1511 	//In release builds KErrBadMessageSchema should be returned
  1512 #ifdef _DEBUG
  1513 	Test(err == KErrServerTerminated);
  1514 
  1515 	TInt type = serverProcess.ExitType();
  1516 	Test(type == EExitPanic);
  1517 
  1518 	TInt reason = serverProcess.ExitReason();
  1519 	Test(reason == ECMPanicBadMessageSchema);
  1520 #else
  1521 	Test(err == KErrBadMessageSchema);
  1522 #endif
  1523 
  1524 	CleanupStack::PopAndDestroy(&session);
  1525 	}
  1526 
  1527 /*
  1528 This test function accepts a single integer parameter with a
  1529 custom validation function.
  1530 {EParamCustom3,0,0}
  1531 The validation functions checks that the value passed in is a
  1532 multiple of 4.
  1533 Any calls to this function with a parameter that is not divisible
  1534 by 4 should fail with KErrBadParameter
  1535 */
  1536 void TestFunction28L()
  1537 	{
  1538 	RClientMessageTestSession session;
  1539 
  1540 	TInt err = session.Connect();
  1541 	Test(err == KErrNone);
  1542 
  1543 	CleanupClosePushL(session);
  1544 
  1545 	err = session.TestFunction28(4);
  1546 	Test(err == KErrNone);
  1547 
  1548 	err = session.TestFunction28(128);
  1549 	Test(err == KErrNone);
  1550 
  1551 	err = session.TestFunction28(73);
  1552 	Test(err == KErrBadParameter);
  1553 
  1554 	err = session.TestFunction28(-1);
  1555 	Test(err == KErrBadParameter);
  1556 
  1557 	err = session.TestFunction28(44444444);
  1558 	Test(err == KErrNone);
  1559 
  1560 	CleanupStack::PopAndDestroy(&session);
  1561 	}
  1562 
  1563 /*
  1564 This test function accepts a single descriptor parameter with a
  1565 custom validation function.
  1566 {EParamCustom4,0,0}
  1567 The validation functions checks that the descriptor passed in
  1568 contains the string 'Expected Data'
  1569 Any calls to this function with a descriptor that is not 'Expected Data'
  1570 should fail with KErrBadParameter
  1571 */
  1572 void TestFunction29L()
  1573 	{
  1574 	RClientMessageTestSession session;
  1575 
  1576 	TInt err = session.Connect();
  1577 	Test(err == KErrNone);
  1578 
  1579 	CleanupClosePushL(session);
  1580 
  1581 	TBuf<32> data = _L("Expected Data");
  1582 
  1583 	err = session.TestFunction29(data);
  1584 	Test(err == KErrNone);
  1585 
  1586 	data.SetLength(5);
  1587 
  1588 	err = session.TestFunction29(data);
  1589 	Test(err == KErrBadParameter);
  1590 
  1591 	data = _L("expected data");
  1592 
  1593 	err = session.TestFunction29(data);
  1594 	Test(err == KErrBadParameter);
  1595 
  1596 	data.Zero();
  1597 
  1598 	err = session.TestFunction29(data);
  1599 	Test(err == KErrBadParameter);
  1600 
  1601 	CleanupStack::PopAndDestroy(&session);
  1602 	}
  1603 
  1604 /*
  1605 This test function accepts a single custom TPckg parameter as below
  1606 {EParamPckg,sizeof(CMTestStruct1),sizeof(CMTestStruct1)}.
  1607 CMTestStruct1 is defined as follows:
  1608 
  1609 struct CMTestStruct1
  1610 	{
  1611 	TInt iInt;
  1612 	TBuf<32> iDes;
  1613 	};
  1614 
  1615 The EParamCustom1 parameter type is validated using the default validation
  1616 function.  This checks that the size of the TPckg passed in is
  1617 exactly that defined in the schema. If this check fails the server
  1618 should panic the client with KErrBadDescriptor.
  1619 */
  1620 void TestFunction30L()
  1621 	{
  1622 	RClientMessageTestSession session;
  1623 
  1624 	TInt err = session.Connect();
  1625 	Test(err == KErrNone);
  1626 
  1627 	CleanupClosePushL(session);
  1628 
  1629 	CMTestStruct1 struct1;
  1630 	struct1.iInt = 4;
  1631 	struct1.iDes = _L("Test Struct");
  1632 
  1633 	TPckg<CMTestStruct1> pData(struct1);
  1634 
  1635 	err = session.TestFunction30(pData);
  1636 	Test(err == KErrNone);
  1637 
  1638 	TBuf8<16> data;
  1639 	//This should cause a panic
  1640 	err = session.TestFunction30(data);
  1641 
  1642 	CleanupStack::PopAndDestroy(&session);
  1643 	}
  1644 
  1645 /*
  1646 This test function accepts an Intergeer parameter and a TAny* parameter
  1647 {EParamInt,EGetIntL,EWrite16L},{EParamPtr,0,0}
  1648 
  1649 The server function checks the value passed in the TInt parameter and calls
  1650 an appropriate CMessageParameterBase function on the second parameter.
  1651 As none of the functions called are defined for a pointer parameter, the
  1652 call defaults to the CMessageParameterBase implementation which panics the
  1653 client with ECMPanicWrongParameterType in UDEB or returns
  1654 KErrWrongParameterType in UREL
  1655 */
  1656 void DoTest31L(TInt aType)
  1657 	{
  1658 	RClientMessageTestSession session;
  1659 
  1660 	TInt err = session.Connect();
  1661 	Test(err == KErrNone);
  1662 
  1663 	CleanupClosePushL(session);
  1664 
  1665 	err = session.TestFunction31(aType);
  1666 #ifdef _DEBUG
  1667 	Test(err == KErrServerTerminated);
  1668 
  1669 	TInt type = serverProcess.ExitType();
  1670 	Test(type == EExitPanic);
  1671 
  1672 	TInt reason = serverProcess.ExitReason();
  1673 	Test(reason == ECMPanicWrongParameterType);
  1674 #else
  1675 	Test(err == KErrWrongParameterType);
  1676 #endif
  1677 
  1678 	CleanupStack::PopAndDestroy(&session);
  1679 	}
  1680 
  1681 void TestFunction31AL()
  1682 	{
  1683 	DoTest31L(EGetIntL);
  1684 	}
  1685 
  1686 void TestFunction31BL()
  1687 	{
  1688 	DoTest31L(EGetDes8L);
  1689 	}
  1690 
  1691 void TestFunction31CL()
  1692 	{
  1693 	DoTest31L(EGetDes16L);
  1694 	}
  1695 
  1696 void TestFunction31DL()
  1697 	{
  1698 	DoTest31L(EGetDesLengthL);
  1699 	}
  1700 
  1701 void TestFunction31EL()
  1702 	{
  1703 	DoTest31L(EGetDesMaxLengthL);
  1704 	}
  1705 
  1706 void TestFunction31FL()
  1707 	{
  1708 	DoTest31L(ERead8L);
  1709 	}
  1710 
  1711 void TestFunction31GL()
  1712 	{
  1713 	DoTest31L(ERead16L);
  1714 	}
  1715 
  1716 void TestFunction31HL()
  1717 	{
  1718 	DoTest31L(EWrite8L);
  1719 	}
  1720 
  1721 void TestFunction31IL()
  1722 	{
  1723 	DoTest31L(EWrite16L);
  1724 	}
  1725 /*
  1726 This test function accepts a single custom parameter as below
  1727 {EParamCustom5,sizeof(CMTestStruct1),sizeof(CMTestStruct1)}
  1728 CMTestStruct1 is defined as follows:
  1729 
  1730 struct CMTestStruct1
  1731 	{
  1732 	TInt iInt;
  1733 	TBuf<32> iDes;
  1734 	};
  1735 
  1736 The EParamCustom5 parameter type enum value is  defined as
  1737 (0x90000 | EParamPckg).  The upper 16 bits are the index of
  1738 the validation function in the array supplied by the server.
  1739 The array only contains 5 values so the above definition is
  1740 incorrect.  Calling this messge should result in the server
  1741 panicking with ECMPanicBadMessageSchema in UDEB or returning
  1742 KErrBadMessageSchema in UREL
  1743 */
  1744 void TestFunction32L()
  1745 	{
  1746 	RClientMessageTestSession session;
  1747 
  1748 	TInt err = session.Connect();
  1749 	Test(err == KErrNone);
  1750 
  1751 	CleanupClosePushL(session);
  1752 
  1753 	CMTestStruct1 struct1;
  1754 	TPckg<CMTestStruct1> pData(struct1);
  1755 
  1756 	err = session.TestFunction32(pData);
  1757 
  1758 #ifdef _DEBUG
  1759 	Test(err == KErrServerTerminated);
  1760 
  1761 	TInt type = serverProcess.ExitType();
  1762 	Test(type == EExitPanic);
  1763 
  1764 	TInt reason = serverProcess.ExitReason();
  1765 	Test(reason == ECMPanicBadMessageSchema);
  1766 #else
  1767 	Test(err == KErrBadMessageSchema);
  1768 #endif
  1769 
  1770 	CleanupStack::PopAndDestroy(&session);
  1771 	}
  1772 
  1773 /* Connect to the CClientMessageTestServer, launching
  1774  * the server process if necessary
  1775  */
  1776 TInt RClientMessageTestSession2::Connect()
  1777 	{
  1778 	TInt retry = 2;
  1779 	for(;;)
  1780 		{
  1781 		TInt r = CreateSession(KServer2Name,TVersion(1,0,0));
  1782 
  1783 		if((r != KErrNotFound)&&(r != KErrServerTerminated))
  1784 			{
  1785 			return r;
  1786 			}
  1787 
  1788 		if(--retry == 0)
  1789 			{
  1790 			return r;
  1791 			}
  1792 
  1793 		r = LaunchServer();
  1794 		if((r != KErrNone)&&(r != KErrAlreadyExists))
  1795 			{
  1796 			return r;
  1797 			}
  1798 		}
  1799 	}
  1800 
  1801 
  1802 
  1803 /* These functions are used to send IPC messages to the server.
  1804  * The messages are sent with different parameters to test the
  1805  * ClientMessage framework handling of bad messages
  1806  */
  1807 TInt RClientMessageTestSession2::TestFunction0(TInt aArg0, TInt aArg1)
  1808 	{
  1809 	return SendReceive(ETestMessage0,TIpcArgs(aArg0,aArg1));
  1810 	}
  1811 
  1812 TInt RClientMessageTestSession2::TestFunction1(const TDesC& aData0)
  1813 	{
  1814 	return SendReceive(ETestMessage1,TIpcArgs(&aData0));
  1815 	}
  1816 
  1817 
  1818 /**
  1819 @SYMTestCaseID SYSLIB-BAFL-CT-4040
  1820 @SYMTestCaseDesc Tests CClientMessage handling of EParamInt type parameters
  1821 @SYMTestPriority High
  1822 @SYMTestActions Call a series of test functions expecting integer parameters.
  1823 				Various argument values and types are passed to these functions.
  1824 				The Server should only accept messages containing integer
  1825 				values that fall within the bounds defined in the message schema.
  1826 @SYMTestExpectedResults The Server should return KErrNone if the message is
  1827 				accepted or KErrBadParameter if the int parameters are outside
  1828 				the bounds defined in the schema.  If the message is incorrectly
  1829 				defined in the mssage schema or the server code incorrectly uses
  1830 				the parameter type the server should panic.
  1831 @SYMDEF         INC117370
  1832 */
  1833 void DoIntParameterTestsL()
  1834 	{
  1835 	TExitDetails exitDetails;
  1836 
  1837 	exitDetails = LaunchTestThreadL(_L("TestFunction0"), &TestFunction0AL);
  1838 	Test(exitDetails.iExitType == EExitKill);
  1839 
  1840 	exitDetails = LaunchTestThreadL(_L("TestFunction1"), &TestFunction1L);
  1841 	Test(exitDetails.iExitType == EExitKill);
  1842 
  1843 	exitDetails = LaunchTestThreadL(_L("TestFunction2"), &TestFunction2L);
  1844 	Test(exitDetails.iExitType == EExitKill);
  1845 
  1846 	exitDetails = LaunchTestThreadL(_L("TestFunction3"), &TestFunction3L);
  1847 	Test(exitDetails.iExitType == EExitKill);
  1848 
  1849 	exitDetails = LaunchTestThreadL(_L("TestFunction28"), &TestFunction28L);
  1850 	Test(exitDetails.iExitType == EExitKill);
  1851 	}
  1852 
  1853 /**
  1854 @SYMTestCaseID SYSLIB-BAFL-CT-4041
  1855 @SYMTestCaseDesc Tests CClientMessage handling of EParamDes8Read and
  1856 				EParamDes16Read type parameters
  1857 @SYMTestPriority High
  1858 @SYMTestActions Call a series of test functions expecting Des*Read parameters.
  1859 				Various argument values and types are passed to these functions.
  1860 				The Server should only accept messages containing Des*Read
  1861 				values that fall within the bounds defined in the message schema.
  1862 @SYMTestExpectedResults The Server should return KErrNone if the message is
  1863 				accepted or panic the client with KErrBadDescriptor if the
  1864 				descriptor parameters are outside the bounds defined in the schema.
  1865 				If the message is incorrectly defined in the mssage schema or the
  1866 				server code incorrectly uses the parameter type the server should panic.
  1867 @SYMDEF         INC117370
  1868 */
  1869 void DoDesReadParameterTestsL()
  1870 	{
  1871 	TExitDetails exitDetails;
  1872 
  1873 	exitDetails = LaunchTestThreadL(_L("TestFunction4A"), &TestFunction4AL);
  1874 	Test(exitDetails.iExitType == EExitKill);
  1875 
  1876 	exitDetails = LaunchTestThreadL(_L("TestFunction4B"), &TestFunction4BL);
  1877 	Test(exitDetails.iExitType == EExitPanic);
  1878 	Test(exitDetails.iReason == KErrBadDescriptor);
  1879 
  1880 	exitDetails = LaunchTestThreadL(_L("TestFunction4C"), &TestFunction4CL);
  1881 	Test(exitDetails.iExitType == EExitPanic);
  1882 	Test(exitDetails.iReason == KErrBadDescriptor);
  1883 
  1884 	exitDetails = LaunchTestThreadL(_L("TestFunction4D"), &TestFunction4DL);
  1885 	Test(exitDetails.iExitType == EExitPanic);
  1886 	Test(exitDetails.iReason == KErrBadDescriptor);
  1887 
  1888 	exitDetails = LaunchTestThreadL(_L("TestFunction4E"), &TestFunction4EL);
  1889 	Test(exitDetails.iExitType == EExitPanic);
  1890 	Test(exitDetails.iReason == KErrBadDescriptor);
  1891 
  1892 	exitDetails = LaunchTestThreadL(_L("TestFunction4F"), &TestFunction4FL);
  1893 	Test(exitDetails.iExitType == EExitPanic);
  1894 	Test(exitDetails.iReason == KErrBadDescriptor);
  1895 
  1896 	exitDetails = LaunchTestThreadL(_L("TestFunction5"), &TestFunction5L);
  1897 	Test(exitDetails.iExitType == EExitKill);
  1898 
  1899 	exitDetails = LaunchTestThreadL(_L("TestFunction6"), &TestFunction6L);
  1900 	Test(exitDetails.iExitType == EExitKill);
  1901 
  1902 	exitDetails = LaunchTestThreadL(_L("TestFunction7"), &TestFunction7L);
  1903 	Test(exitDetails.iExitType == EExitKill);
  1904 
  1905 	exitDetails = LaunchTestThreadL(_L("TestFunction8"), &TestFunction8L);
  1906 #ifdef _DEBUG
  1907 	Test(exitDetails.iExitType == EExitKill);
  1908 #else
  1909 	Test(exitDetails.iExitType == EExitPanic);
  1910 	Test(exitDetails.iReason == KErrBadDescriptor);
  1911 #endif
  1912 
  1913 	exitDetails = LaunchTestThreadL(_L("TestFunction29"), &TestFunction29L);
  1914 	Test(exitDetails.iExitType == EExitKill);
  1915 
  1916 	}
  1917 
  1918 /**
  1919 @SYMTestCaseID SYSLIB-BAFL-CT-4042
  1920 @SYMTestCaseDesc Tests CClientMessage handling of EParamDes8 and
  1921 				EParamDes16 type parameters
  1922 @SYMTestPriority High
  1923 @SYMTestActions Call a series of test functions expecting Des* parameters.
  1924 				Various argument values and types are passed to these functions.
  1925 				The Server should only accept messages containing Des*
  1926 				values that fall within the bounds defined in the message schema.
  1927 @SYMTestExpectedResults The Server should return KErrNone if the message is
  1928 				accepted or panic the client with KErrBadDescriptor or KErrOverflow if the
  1929 				descriptor parameters are outside the bounds defined in the schema.
  1930 				If the message is incorrectly defined in the mssage schema or the
  1931 				server code incorrectly uses the parameter type the server should panic.
  1932 @SYMDEF         INC117370
  1933 */
  1934 void DoDesParameterTestsL()
  1935 	{
  1936 	TExitDetails exitDetails;
  1937 	exitDetails = LaunchTestThreadL(_L("TestFunction9A"), &TestFunction9AL);
  1938 	Test(exitDetails.iExitType == EExitKill);
  1939 
  1940 	exitDetails = LaunchTestThreadL(_L("TestFunction9B"), &TestFunction9BL);
  1941 	Test(exitDetails.iExitType == EExitPanic);
  1942 	Test(exitDetails.iReason == KErrBadDescriptor);
  1943 
  1944 	exitDetails = LaunchTestThreadL(_L("TestFunction9C"), &TestFunction9CL);
  1945 	Test(exitDetails.iExitType == EExitPanic);
  1946 	Test(exitDetails.iReason == KErrOverflow);
  1947 
  1948 	exitDetails = LaunchTestThreadL(_L("TestFunction9D"), &TestFunction9DL);
  1949 	Test(exitDetails.iExitType == EExitPanic);
  1950 	Test(exitDetails.iReason == KErrBadDescriptor);
  1951 
  1952 	exitDetails = LaunchTestThreadL(_L("TestFunction10"), &TestFunction10L);
  1953 	Test(exitDetails.iExitType == EExitPanic);
  1954 	Test(exitDetails.iReason == KErrOverflow);
  1955 
  1956 	exitDetails = LaunchTestThreadL(_L("TestFunction11"), &TestFunction11L);
  1957 	Test(exitDetails.iExitType == EExitKill);
  1958 
  1959 	exitDetails = LaunchTestThreadL(_L("TestFunction12"), &TestFunction12L);
  1960 	Test(exitDetails.iExitType == EExitKill);
  1961 
  1962 	exitDetails = LaunchTestThreadL(_L("TestFunction13"), &TestFunction13L);
  1963 #ifdef _DEBUG
  1964 	Test(exitDetails.iExitType == EExitKill);
  1965 #else
  1966 	Test(exitDetails.iExitType == EExitPanic);
  1967 	Test(exitDetails.iReason == KErrBadDescriptor);
  1968 #endif
  1969 
  1970 	exitDetails = LaunchTestThreadL(_L("TestFunction14"), &TestFunction14L);
  1971 	Test(exitDetails.iExitType == EExitKill);
  1972 
  1973 	exitDetails = LaunchTestThreadL(_L("TestFunction15"), &TestFunction15L);
  1974 	Test(exitDetails.iExitType == EExitKill);
  1975 	}
  1976 
  1977 /**
  1978 @SYMTestCaseID SYSLIB-BAFL-CT-4043
  1979 @SYMTestCaseDesc Tests CClientMessage handling of EParamPtr type parameters
  1980 @SYMTestPriority High
  1981 @SYMTestActions Call test functions accepting ptr parameter types
  1982 @SYMTestExpectedResults The Server should return KErrNone if the message is
  1983 				accepted. If the message is incorrectly defined in the message
  1984 				schema or the server code incorrectly uses the parameter type
  1985 				the server should panic
  1986 				expected
  1987 @SYMDEF         INC117370
  1988 */
  1989 void DoPtrParameterTestsL()
  1990 	{
  1991 	TExitDetails exitDetails;
  1992 	exitDetails = LaunchTestThreadL(_L("TestFunction16"), &TestFunction16L);
  1993 	Test(exitDetails.iExitType == EExitKill);
  1994 
  1995 	exitDetails = LaunchTestThreadL(_L("TestFunction17"), &TestFunction17L);
  1996 	Test(exitDetails.iExitType == EExitKill);
  1997 	}
  1998 
  1999 /**
  2000 @SYMTestCaseID SYSLIB-BAFL-CT-4044
  2001 @SYMTestCaseDesc Tests CClientMessage handling of EParamPckg type parameters
  2002 @SYMTestPriority High
  2003 @SYMTestActions Call a series of test functions expecting Pckg parameters.
  2004 				Various argument values and types are passed to these functions.
  2005 				The Server should only accept messages containing Pckg
  2006 				values that fall within the bounds defined in the message schema.
  2007 @SYMTestExpectedResults The Server should return KErrNone if the message is
  2008 				accepted, return KErrBadParameter if the packaged parameter is
  2009 				outside the bounds described in the schema or panic the client with
  2010 				KErrBadDescriptor if the descriptor parameter is outside the bounds
  2011 				defined in the schema.
  2012 @SYMDEF         INC117370
  2013 */
  2014 void DoPckgParameterTestsL()
  2015 	{
  2016 	TExitDetails exitDetails;
  2017 	exitDetails = LaunchTestThreadL(_L("TestFunction18A"), &TestFunction18AL);
  2018 	Test(exitDetails.iExitType == EExitKill);
  2019 
  2020 	exitDetails = LaunchTestThreadL(_L("TestFunction18B"), &TestFunction18BL);
  2021 	Test(exitDetails.iExitType == EExitPanic);
  2022 	Test(exitDetails.iReason == KErrBadDescriptor);
  2023 
  2024 	exitDetails = LaunchTestThreadL(_L("TestFunction18C"), &TestFunction18CL);
  2025 	Test(exitDetails.iExitType == EExitPanic);
  2026 	Test(exitDetails.iReason == KErrBadDescriptor);
  2027 
  2028 	exitDetails = LaunchTestThreadL(_L("TestFunction19"), &TestFunction19L);
  2029 	Test(exitDetails.iExitType == EExitKill);
  2030 
  2031 	exitDetails = LaunchTestThreadL(_L("TestFunction30"), &TestFunction30L);
  2032 	Test(exitDetails.iExitType == EExitPanic);
  2033 	Test(exitDetails.iReason == KErrBadDescriptor);
  2034 
  2035 	exitDetails = LaunchTestThreadL(_L("TestFunction32"), &TestFunction32L);
  2036 	Test(exitDetails.iExitType == EExitKill);
  2037 	}
  2038 
  2039 
  2040 /**
  2041 @SYMTestCaseID SYSLIB-BAFL-CT-4045
  2042 @SYMTestCaseDesc Tests CClientMessage handling of EParamNull type parameters
  2043 @SYMTestPriority High
  2044 @SYMTestActions Call a series of test functions expecting no parameters.
  2045 @SYMTestExpectedResults The Server should return KErrNone if the message is
  2046 				accepted. If the message is incorrectly defined in the message
  2047 				schema or the server code incorrectly uses the parameter type
  2048 				the server should panic.
  2049 @SYMDEF         INC117370
  2050 */
  2051 void DoNullParameterTestsL()
  2052 	{
  2053 
  2054 	TExitDetails exitDetails;
  2055 	exitDetails = LaunchTestThreadL(_L("TestFunction25"), &TestFunction25L);
  2056 	Test(exitDetails.iExitType == EExitKill);
  2057 
  2058 	exitDetails = LaunchTestThreadL(_L("TestFunction26"), &TestFunction26L);
  2059 	Test(exitDetails.iExitType == EExitKill);
  2060 
  2061 	exitDetails = LaunchTestThreadL(_L("TestFunction27"), &TestFunction27L);
  2062 	Test(exitDetails.iExitType == EExitKill);
  2063 
  2064 	}
  2065 
  2066 /**
  2067 @SYMTestCaseID SYSLIB-BAFL-CT-4046
  2068 @SYMTestCaseDesc Tests CClientMessage handling of Security policies
  2069 @SYMTestPriority High
  2070 @SYMTestActions Call several test functions with varying security policies and
  2071 				verify that the ClientMessage framework handles each case as
  2072 				expected
  2073 @SYMTestExpectedResults The server should return KErrNone if the client has
  2074 				the required security policy, otherwise return KErrPermissionDenied
  2075 @SYMDEF         INC117370
  2076 */
  2077 void DoSecurityPolicyTestsL()
  2078 	{
  2079 	RClientMessageTestSession session;
  2080 
  2081 	TInt err = session.Connect();
  2082 
  2083 	CleanupClosePushL(session);
  2084 
  2085 	//This function is incorrectly defined in the message table
  2086 	//for this server and so the CClientMessage Object creation will fail
  2087 	//This should reult in the server panicking
  2088 	RDebug::Print(_L("Testing Always Fail Policy..."));
  2089 	err = session.TestFunction20(0,0);
  2090 	Test(err == KErrPermissionDenied);
  2091 
  2092 	RDebug::Print(_L("Testing Valid SID Policy..."));
  2093 	err = session.TestFunction21(0,0);
  2094 	Test(err == KErrNone);
  2095 
  2096 	RDebug::Print(_L("Testing Invalid SID Policy..."));
  2097 	err = session.TestFunction22(0,0);
  2098 	Test(err == KErrPermissionDenied);
  2099 
  2100 	RDebug::Print(_L("Testing Valid Capability Policy..."));
  2101 	err = session.TestFunction23(0,0);
  2102 	Test(err == KErrNone);
  2103 
  2104 	RDebug::Print(_L("Testing Invalid Capability Policy..."));
  2105 	err = session.TestFunction24(0,0);
  2106 	Test(err == KErrPermissionDenied);
  2107 
  2108 	CleanupStack::PopAndDestroy(&session);
  2109 	}
  2110 
  2111 /**
  2112 @SYMTestCaseID SYSLIB-BAFL-CT-4047
  2113 @SYMTestCaseDesc Tests CClientMessage handling of undefined messagess
  2114 @SYMTestPriority High
  2115 @SYMTestActions Call a test function which sends an unknown message request to the
  2116 				server.
  2117 @SYMTestExpectedResults The ClientMessage framework should return KErrInvalidFunction
  2118 @SYMDEF         INC117370
  2119 */
  2120 void DoInvalidMessageTestsL()
  2121 	{
  2122 	RClientMessageTestSession session;
  2123 
  2124 	TInt err = session.Connect();
  2125 
  2126 	CleanupClosePushL(session);
  2127 
  2128 	//This function is not defined in the message table
  2129 	//for this server and so the CClientMessage Object creation will fail
  2130 	//This should result in the server panicking
  2131 	err = session.TestInvalidFunction(45);
  2132 	Test(err == KErrInvalidFunction);
  2133 
  2134 	err = session.TestInvalidFunction(5);
  2135 	Test(err == KErrInvalidFunction);
  2136 
  2137 	CleanupStack::PopAndDestroy(&session);
  2138 	}
  2139 
  2140 /**
  2141 @SYMTestCaseID SYSLIB-BAFL-CT-4050
  2142 @SYMTestCaseDesc Tests CMessageParameterBase default implementation of message access functions
  2143 @SYMTestPriority High
  2144 @SYMTestActions Calls test functions which signal the server to call one
  2145 				of the Message access methods on a EParamPtr parameter type.
  2146 				As none of these methods are explicitly defined for a EParamPtr
  2147 				type the call will be delegated to the base class implementation
  2148 				which will panic the client in UDEB and return an error in UREL
  2149 @SYMTestExpectedResults The server should panic the client with ECMPanicWrongParameterType
  2150 				in UDEB and return KErrWrongParameterType in UREL
  2151 @SYMDEF         INC117370
  2152 */
  2153 void DoCMessageParameterBaseTestL()
  2154 	{
  2155 
  2156 	TExitDetails exitDetails;
  2157 	exitDetails = LaunchTestThreadL(_L("TestFunction31A"), &TestFunction31AL);
  2158 	Test(exitDetails.iExitType == EExitKill);
  2159 
  2160 	exitDetails = LaunchTestThreadL(_L("TestFunction31B"), &TestFunction31BL);
  2161 	Test(exitDetails.iExitType == EExitKill);
  2162 
  2163 	exitDetails = LaunchTestThreadL(_L("TestFunction31C"), &TestFunction31CL);
  2164 	Test(exitDetails.iExitType == EExitKill);
  2165 
  2166 	exitDetails = LaunchTestThreadL(_L("TestFunction31D"), &TestFunction31DL);
  2167 	Test(exitDetails.iExitType == EExitKill);
  2168 
  2169 	exitDetails = LaunchTestThreadL(_L("TestFunction31E"), &TestFunction31EL);
  2170 	Test(exitDetails.iExitType == EExitKill);
  2171 
  2172 	exitDetails = LaunchTestThreadL(_L("TestFunction31F"), &TestFunction31FL);
  2173 	Test(exitDetails.iExitType == EExitKill);
  2174 
  2175 	exitDetails = LaunchTestThreadL(_L("TestFunction31G"), &TestFunction31GL);
  2176 	Test(exitDetails.iExitType == EExitKill);
  2177 
  2178 	exitDetails = LaunchTestThreadL(_L("TestFunction31H"), &TestFunction31HL);
  2179 	Test(exitDetails.iExitType == EExitKill);
  2180 
  2181 	exitDetails = LaunchTestThreadL(_L("TestFunction31I"), &TestFunction31IL);
  2182 	Test(exitDetails.iExitType == EExitKill);
  2183 
  2184 	}
  2185 
  2186 
  2187 /**
  2188 @SYMTestCaseID SYSLIB-BAFL-CT-4048
  2189 @SYMTestCaseDesc Tests CClientMessage handling of multiple servers
  2190 @SYMTestPriority High
  2191 @SYMTestActions Calls test functions which pass the same message to two different
  2192  				servers.  The servers have different message schemas and data is
  2193  				passed to the server to check that the correct schema is used
  2194  				for the given server.
  2195 @SYMTestExpectedResults The ClientMessage framework should validate the message
  2196 						against the correct schema for the given server
  2197 @SYMDEF         INC117370
  2198 */
  2199 void DoMultipleServerTestsL()
  2200 	{
  2201 
  2202 	RClientMessageTestSession session1;
  2203 	RClientMessageTestSession2 session2;
  2204 
  2205 	TInt err = session1.Connect();
  2206 	Test(err == KErrNone);
  2207 	CleanupClosePushL(session1);
  2208 
  2209 	err = session2.Connect();
  2210 	Test(err == KErrNone);
  2211 	CleanupClosePushL(session2);
  2212 
  2213 	err = session1.TestFunction0( 0, 150);
  2214 	Test(err == KErrNone);
  2215 
  2216 	err = session2.TestFunction0( 0, 150);
  2217 	Test(err == KErrBadParameter);
  2218 
  2219 	err = session1.TestFunction0( 0, -50);
  2220 	Test(err == KErrBadParameter);
  2221 
  2222 	err = session2.TestFunction0( 0, -50);
  2223 	Test(err == KErrNone);
  2224 
  2225 	CleanupStack::PopAndDestroy(2,&session1);
  2226 
  2227 	}
  2228 
  2229 /**
  2230 @SYMTestCaseID SYSLIB-BAFL-CT-4051
  2231 @SYMTestCaseDesc Tests CClientMessage allowing disabling of Panic.
  2232 @SYMTestPriority Medium
  2233 @SYMTestActions Calls test functions which pass a message to a server for which the 
  2234 				ESrvFlagDoNotPanicClientOnBadMessageErrors flag is set.Then invokes the client	API with 
  2235 				incorrect arguments to create an error scenario of KErrBadDescriptor.
  2236 @SYMTestExpectedResults The ClientMessage framework should check for the above flag, and in case 
  2237 			its not set simply return an error instead of panicing the client.
  2238 @SYMDEF         DEF125501
  2239 */
  2240 void DoDisablePanicTestsL()
  2241 	{
  2242 	
  2243 	RClientMessageTestSession2 session;
  2244 	_LIT(KDes16, "Descriptor");
  2245 	
  2246 	TInt err = session.Connect();
  2247 	Test(err == KErrNone);
  2248 
  2249 	CleanupClosePushL(session);
  2250 
  2251 	/* According to schema defined, this function accepts TDesC8 only.
  2252 	Validation failure occurs.Server should check if flag ESrvFlagDoNotPanicClientOnBadMessageErrors
  2253 	is set, and either return with KErrBadDescriptor or Panic the client.
  2254 	In this case the above flag is set for CClientMessageTestServer2.
  2255 	*/
  2256 	err = session.TestFunction1(KDes16);
  2257 	
  2258 #ifdef _DEBUG
  2259 	Test(err == KErrBadDescriptor);
  2260 
  2261 	// Server is not terminated, still alive
  2262 	TInt type = serverProcess.ExitType();
  2263 	Test(type == EExitPending);
  2264 #else
  2265 	Test(err == KErrBadDescriptor);
  2266 #endif
  2267 
  2268 	CleanupStack::PopAndDestroy(&session);
  2269 	
  2270 	}
  2271 
  2272 
  2273 static void DoTestsL()
  2274 	{
  2275 
  2276 	TExitDetails exitDetails;
  2277 
  2278 	Test.Title ();
  2279 	Test.Start (_L("ClientMessage Tests"));
  2280 
  2281 	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4040 Testing Message with Int Parameters "));
  2282 	DoIntParameterTestsL();
  2283 
  2284 	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4041 Testing Message with Read Only Des Parameters "));
  2285 	DoDesReadParameterTestsL();
  2286 
  2287 	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4042 Testing Message with Read/Write Des Parameters "));
  2288 	DoDesParameterTestsL();
  2289 
  2290 	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4043 Testing Message with Ptr Parameters "));
  2291 	DoPtrParameterTestsL();
  2292 
  2293 	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4044 Testing Message with Pckg Parameters "));
  2294 	DoPckgParameterTestsL();
  2295 
  2296 	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4045 Testing Message with Null Parameters "));
  2297 	DoNullParameterTestsL();
  2298 
  2299 	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4046 Testing Security Policy Checking "));
  2300 	exitDetails = LaunchTestThreadL(_L("SecurityPolicyTestL"), &DoSecurityPolicyTestsL);
  2301 	Test(exitDetails.iExitType == EExitKill);
  2302 
  2303 	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4047 Testing Invalid Message "));
  2304 	exitDetails = LaunchTestThreadL(_L("InvalidMessageTestL"), &DoInvalidMessageTestsL);
  2305 	Test(exitDetails.iExitType == EExitKill);
  2306 
  2307 	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4050 Testing CMessageParameterBase Default Implementations "));
  2308 	exitDetails = LaunchTestThreadL(_L("CMessageParameterBaseTestL"), &DoCMessageParameterBaseTestL);
  2309 	Test(exitDetails.iExitType == EExitKill);
  2310 
  2311 	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4048 Testing Multiple Servers "));
  2312 	exitDetails = LaunchTestThreadL(_L("MultipleServerTestingL"), &DoMultipleServerTestsL);
  2313 	Test(exitDetails.iExitType == EExitKill);
  2314 
  2315 	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4051 Testing Disable Client Panic"));
  2316 	exitDetails = LaunchTestThreadL(_L("DisablePanicTesting"), &DoDisablePanicTestsL);
  2317 	Test(exitDetails.iExitType == EExitKill);
  2318 	
  2319 	
  2320 	Test.Printf(_L("Tests Completed O.K."));
  2321 
  2322 	Test.End();
  2323 	Test.Close();
  2324 
  2325 	}
  2326 
  2327 
  2328 TInt E32Main()
  2329    //
  2330    // Server process entry-point
  2331    //
  2332    	{
  2333    	//
  2334    	CTrapCleanup* cleanup=CTrapCleanup::New();
  2335    	TInt r=KErrNoMemory;
  2336    	if (cleanup)
  2337    		{
  2338  		TRAP(r,DoTestsL());
  2339    		delete cleanup;
  2340    		}
  2341    	//
  2342    	return r;
  2343    	}