os/ossrv/lowlevellibsandfws/apputils/bsul/test/t_clientmessage/t_clientmessage.cpp
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 #include <bsul/bsul.h>
22 #include "t_clientmessagetestserver.h"
27 LOCAL_D RTest Test (_L("T_ClientMessage"));
30 _LIT(KServerName,"ClientMessageTestServer");
31 _LIT(KServer2Name,"SecondTestServer");
32 _LIT(KServerFileName,"T_ClientMessageTestServer.exe");
36 TExitCategoryName iCategory;
41 typedef void (*TestFunction)();
44 /*RClientMessageTestSession client side interface to
45 * CClientMessageTestServer server. This is used to pass
46 * messages to the server to testthe Client Message Framework.
48 class RClientMessageTestSession : public RSessionBase
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);
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);
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);
78 TInt TestFunction16(TAny* aData);
79 TInt TestFunction17(TAny* aData);
81 TInt TestFunction18(TDes8& aData);
82 TInt TestFunction18(TDes16& aData);
83 TInt TestFunction19(TDes8& aData);
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);
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);
100 TInt TestInvalidFunction(TInt aFn);
105 /*RClientMessageTestSession2 client side interface to
106 * CClientMessageTestServer2 server. This is used to pass
107 * messages to the server to testthe Client Message Framework.
109 class RClientMessageTestSession2 : public RSessionBase
114 TInt TestFunction0(TInt aArg0, TInt aArg1);
116 TInt TestFunction1(const TDesC& aData0);
120 //Global process that is accessible in test code to determine the
121 //exit reason and category on termination
122 RProcess serverProcess;
124 //Launch the server process
125 static TInt LaunchServer()
127 TInt err = serverProcess.Create(KServerFileName,_L(""));
131 TRequestStatus serverStat;
133 serverProcess.SetJustInTime(EFalse);
134 serverProcess.Rendezvous(serverStat);
135 serverProcess.Resume();
136 User::WaitForRequest(serverStat);
143 /* Connect to the CClientMessageTestServer, launching
144 * the sevrer process if necessary
146 TInt RClientMessageTestSession::Connect()
151 TInt r = CreateSession(KServerName,TVersion(1,0,0));
153 if((r != KErrNotFound)&&(r != KErrServerTerminated))
164 if((r != KErrNone)&&(r != KErrAlreadyExists))
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
175 TInt RClientMessageTestSession::TestFunction0(TInt aArg0, TInt aArg1)
177 return SendReceive(ETestMessage0,TIpcArgs(aArg0,aArg1));
180 TInt RClientMessageTestSession::TestFunction0(TInt aArg0)
182 return SendReceive(ETestMessage0,TIpcArgs(aArg0));
185 TInt RClientMessageTestSession::TestFunction0(TInt aArg0, TInt aArg1, TInt aArg2)
187 return SendReceive(ETestMessage0,TIpcArgs(aArg0,aArg1,aArg2));
190 TInt RClientMessageTestSession::TestFunction0(const TDesC8& aData0, const TDesC& aData1)
192 //Call the function passing invalid arguments
193 return SendReceive(ETestMessage0,TIpcArgs(&aData0,&aData1));
196 TInt RClientMessageTestSession::TestFunction1(TInt aArg0, TInt aArg1)
198 return SendReceive(ETestMessage1,TIpcArgs(aArg0,aArg1));
201 TInt RClientMessageTestSession::TestFunction2(TInt aArg0, TInt aArg1)
203 return SendReceive(ETestMessage2,TIpcArgs(aArg0,aArg1));
206 TInt RClientMessageTestSession::TestFunction3(TInt aArg0, TInt aArg1)
208 return SendReceive(ETestMessage3,TIpcArgs(aArg0,aArg1));
211 TInt RClientMessageTestSession::TestFunction4(const TDesC8& aData0, const TDesC& aData1)
213 return SendReceive(ETestMessage4,TIpcArgs(&aData0,&aData1));
216 TInt RClientMessageTestSession::TestFunction4(const TDesC& aData0, const TDesC8& aData1)
218 return SendReceive(ETestMessage4,TIpcArgs(&aData0,&aData1));
221 TInt RClientMessageTestSession::TestFunction4(const TDesC8& aData0)
223 return SendReceive(ETestMessage4,TIpcArgs(&aData0));
226 TInt RClientMessageTestSession::TestFunction5(const TDesC8& aData0, const TDesC& aData1)
228 return SendReceive(ETestMessage5,TIpcArgs(&aData0,&aData1));
231 TInt RClientMessageTestSession::TestFunction6(const TDesC8& aData0, const TDesC& aData1)
233 return SendReceive(ETestMessage6,TIpcArgs(&aData0,&aData1));
236 TInt RClientMessageTestSession::TestFunction7(const TDesC8& aData0, const TDesC& aData1)
238 return SendReceive(ETestMessage7,TIpcArgs(&aData0,&aData1));
241 TInt RClientMessageTestSession::TestFunction8(const TDesC8& aData0, const TDesC& aData1)
243 return SendReceive(ETestMessage8,TIpcArgs(&aData0,&aData1));
246 TInt RClientMessageTestSession::TestFunction9(TDes& aData0,TInt aOffset0, TDes8& aData1,TInt aOffset1)
248 return SendReceive(ETestMessage9,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1));
251 TInt RClientMessageTestSession::TestFunction9(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1)
253 return SendReceive(ETestMessage9,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1));
256 TInt RClientMessageTestSession::TestFunction10(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1)
258 return SendReceive(ETestMessage10,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1));
261 TInt RClientMessageTestSession::TestFunction11(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1)
263 return SendReceive(ETestMessage11,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1));
266 TInt RClientMessageTestSession::TestFunction12(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1)
268 return SendReceive(ETestMessage12,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1));
271 TInt RClientMessageTestSession::TestFunction13(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1)
273 return SendReceive(ETestMessage13,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1));
276 TInt RClientMessageTestSession::TestFunction14(const TDesC8& aData0,TInt aOffset0, TDes8& aData1)
278 return SendReceive(ETestMessage14,TIpcArgs(&aData0,aOffset0,&aData1));
281 TInt RClientMessageTestSession::TestFunction15(const TDesC& aData0,TInt aOffset0, TDes& aData1)
283 return SendReceive(ETestMessage15,TIpcArgs(&aData0,aOffset0,&aData1));
286 TInt RClientMessageTestSession::TestFunction16(TAny* aData)
288 return SendReceive(ETestMessage16,TIpcArgs(aData));
291 TInt RClientMessageTestSession::TestFunction17(TAny* aData)
293 return SendReceive(ETestMessage17,TIpcArgs(aData));
296 TInt RClientMessageTestSession::TestFunction18(TDes8& aData)
298 return SendReceive(ETestMessage18,TIpcArgs(&aData));
301 TInt RClientMessageTestSession::TestFunction18(TDes& aData)
303 return SendReceive(ETestMessage18,TIpcArgs(&aData));
306 TInt RClientMessageTestSession::TestFunction19(TDes8& aData)
308 return SendReceive(ETestMessage19,TIpcArgs(&aData));
311 TInt RClientMessageTestSession::TestFunction20(TInt aArg0, TInt aArg1)
313 return SendReceive(ETestMessage20,TIpcArgs(aArg0,aArg1));
316 TInt RClientMessageTestSession::TestFunction21(TInt aArg0, TInt aArg1)
318 return SendReceive(ETestMessage21,TIpcArgs(aArg0,aArg1));
321 TInt RClientMessageTestSession::TestFunction22(TInt aArg0, TInt aArg1)
323 return SendReceive(ETestMessage22,TIpcArgs(aArg0,aArg1));
326 TInt RClientMessageTestSession::TestFunction23(TInt aArg0, TInt aArg1)
328 return SendReceive(ETestMessage23,TIpcArgs(aArg0,aArg1));
331 TInt RClientMessageTestSession::TestFunction24(TInt aArg0, TInt aArg1)
333 return SendReceive(ETestMessage24,TIpcArgs(aArg0,aArg1));
336 TInt RClientMessageTestSession::TestFunction25()
338 return SendReceive(ETestMessage25,TIpcArgs());
341 TInt RClientMessageTestSession::TestFunction26()
343 return SendReceive(ETestMessage26,TIpcArgs());
346 TInt RClientMessageTestSession::TestFunction27()
348 return SendReceive(ETestMessage27,TIpcArgs());
351 TInt RClientMessageTestSession::TestFunction28(TInt aArg0)
353 return SendReceive(ETestMessage28,TIpcArgs(aArg0));
356 TInt RClientMessageTestSession::TestFunction29(TDes& aData)
358 return SendReceive(ETestMessage29,TIpcArgs(&aData));
361 TInt RClientMessageTestSession::TestFunction30(TDes8& aData)
363 return SendReceive(ETestMessage30,TIpcArgs(&aData));
366 TInt RClientMessageTestSession::TestFunction31(TInt aArg0)
368 return SendReceive(ETestMessage31,TIpcArgs(aArg0));
371 TInt RClientMessageTestSession::TestFunction32(TDes8& aData)
373 return SendReceive(ETestMessage32,TIpcArgs(&aData));
376 TInt RClientMessageTestSession::TestInvalidFunction(TInt aFn)
378 return SendReceive(aFn,TIpcArgs());
381 /* This function is the entry point for a new thread. It calls the
382 * function passed to it as a TAny*.
384 TInt TestFunctionLauncherL(TAny* aTestFunction)
386 CTrapCleanup* cleanup=CTrapCleanup::New();
390 TestFunction function = (TestFunction)aTestFunction;
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
405 TExitDetails LaunchTestThreadL(const TDesC& aThreadName, TestFunction aFunction)
408 TInt err = thread.Create(aThreadName, &TestFunctionLauncherL, KDefaultStackSize, NULL, (TAny*)aFunction);
410 if(err != KErrAlreadyExists)
412 User::LeaveIfError(err);
415 TRequestStatus threadStat;
416 thread.Logon(threadStat);
418 TBool jit = User::JustInTime();
419 User::SetJustInTime(EFalse);
422 User::WaitForRequest(threadStat);
424 User::SetJustInTime(jit);
426 TExitDetails exitDetails;
427 exitDetails.iCategory = thread.ExitCategory();
428 exitDetails.iReason = thread.ExitReason();
429 exitDetails.iExitType = thread.ExitType();
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
441 void TestFunction0AL()
443 RClientMessageTestSession session;
445 TInt err = session.Connect();
446 Test(err == KErrNone);
448 CleanupClosePushL(session);
450 err = session.TestFunction0( 0, 100);
451 Test(err == KErrNone);
453 err = session.TestFunction0( 100, 0);
454 Test(err == KErrNone);
456 err = session.TestFunction0( -5, 10);
457 Test(err == KErrNone);
459 err = session.TestFunction0( -5, -10);
460 Test(err == KErrBadParameter);
462 err = session.TestFunction0( -15, 10);
463 Test(err == KErrBadParameter);
465 err = session.TestFunction0( -10, 200);
466 Test(err == KErrNone);
468 err = session.TestFunction0( 101, 102);
469 Test(err == KErrBadParameter);
471 err = session.TestFunction0(11, 56, 43);
472 Test(err == KErrNone);
474 err = session.TestFunction0( _L8("Des8"), _L("Des"));
475 Test(err == KErrBadParameter);
477 CleanupStack::PopAndDestroy(&session);
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
489 void TestFunction1L()
491 RClientMessageTestSession session;
493 TInt err = session.Connect();
494 Test(err == KErrNone);
496 CleanupClosePushL(session);
498 err = session.TestFunction1(10,100);
501 Test(err == KErrServerTerminated);
503 TInt type = serverProcess.ExitType();
504 Test(type == EExitPanic);
506 TInt reason = serverProcess.ExitReason();
507 Test(reason == ECMPanicWrongParameterType);
509 Test(err == KErrWrongParameterType);
511 CleanupStack::PopAndDestroy(&session);
515 This test function accepts 1 integer parameter as defined below
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
522 void TestFunction2L()
524 RClientMessageTestSession session;
526 TInt err = session.Connect();
527 Test(err == KErrNone);
529 CleanupClosePushL(session);
531 //this function is incorrectly defined in the
532 //message schema. This should result in the
534 err = session.TestFunction2(10,100);
536 //In debug builds the server should panic.
537 //In release builds KErrBadParameter should be returned
539 Test(err == KErrServerTerminated);
541 TInt type = serverProcess.ExitType();
542 Test(type == EExitPanic);
544 TInt reason = serverProcess.ExitReason();
545 Test(reason == ECMPanicBadMessageSchema);
547 Test(err == KErrBadParameter);
550 CleanupStack::PopAndDestroy(&session);
554 This test function accepts 1 integer parameter as defined below
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
561 void TestFunction3L()
563 RClientMessageTestSession session;
565 TInt err = session.Connect();
566 Test(err == KErrNone);
568 CleanupClosePushL(session);
570 //this function is incorrectly defined in the
571 //message schema. This should result in the
573 err = session.TestFunction3(10,100);
575 //In debug builds the server should panic.
576 //In release builds KErrBadParameter should be returned
578 Test(err == KErrServerTerminated);
580 TInt type = serverProcess.ExitType();
581 Test(type == EExitPanic);
583 TInt reason = serverProcess.ExitReason();
584 Test(reason == ECMPanicBadMessageSchema);
586 Test(err == KErrBadParameter);
589 CleanupStack::PopAndDestroy(&session);
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
599 void TestFunction4AL()
601 RClientMessageTestSession session;
602 _LIT8(KDes8, "Des8");
603 _LIT8(KShortDes8, "De");
604 _LIT(KDes16, "Des16");
605 _LIT(KLongDes16, "Des16 - A longer version");
607 TInt err = session.Connect();
608 Test(err == KErrNone);
610 CleanupClosePushL(session);
612 err = session.TestFunction4(KDes8,KDes16);
613 Test(err == KErrNone);
615 err = session.TestFunction4(KShortDes8,KLongDes16);
616 Test(err == KErrNone);
618 CleanupStack::PopAndDestroy(&session);
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
628 void TestFunction4BL()
630 RClientMessageTestSession session;
631 _LIT8(KDes8, "Des8");
632 _LIT(KDes16, "Des16");
634 TInt err = session.Connect();
635 Test(err == KErrNone);
637 CleanupClosePushL(session);
639 //This should result in the server panicking the client
640 err = session.TestFunction4(KDes16,KDes8);
642 CleanupStack::PopAndDestroy(&session);
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
652 void TestFunction4CL()
654 RClientMessageTestSession session;
655 _LIT(KDes16, "Des16");
656 _LIT8(KLongDes8, "This is a long Des8");
658 TInt err = session.Connect();
659 Test(err == KErrNone);
661 CleanupClosePushL(session);
663 //This should result in the server panicing the client
664 err = session.TestFunction4(KLongDes8,KDes16);
666 CleanupStack::PopAndDestroy(&session);
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
676 void TestFunction4DL()
678 RClientMessageTestSession session;
679 _LIT8(KDes8, "Des8");
680 _LIT(KLongDes16, "This is a long Des16 that should cause an issue");
682 TInt err = session.Connect();
683 Test(err == KErrNone);
685 CleanupClosePushL(session);
687 //This should result in the server panicing the client
688 err = session.TestFunction4(KDes8,KLongDes16);
690 CleanupStack::PopAndDestroy(&session);
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
700 void TestFunction4EL()
702 RClientMessageTestSession session;
703 _LIT(KDes16, "Des16");
704 _LIT8(KEmptyDes8, "");
705 TInt err = session.Connect();
706 Test(err == KErrNone);
708 CleanupClosePushL(session);
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);
714 CleanupStack::PopAndDestroy(&session);
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
724 void TestFunction4FL()
726 RClientMessageTestSession session;
727 _LIT8(KDes8, "Des8");
728 TInt err = session.Connect();
729 Test(err == KErrNone);
731 CleanupClosePushL(session);
733 //This should result in the server panicing the client
734 //as the function expects 2 descriptor arguments
735 err = session.TestFunction4(KDes8);
737 CleanupStack::PopAndDestroy(&session);
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
750 void TestFunction5L()
752 RClientMessageTestSession session;
753 _LIT8(KDes8, "Des8");
754 _LIT(KDes16, "Des16");
756 TInt err = session.Connect();
757 Test(err == KErrNone);
759 CleanupClosePushL(session);
761 err = session.TestFunction5(KDes8,KDes16);
763 Test(err == KErrServerTerminated);
765 TInt type = serverProcess.ExitType();
766 Test(type == EExitPanic);
768 TInt reason = serverProcess.ExitReason();
769 Test(reason == ECMPanicBadDescriptor);
771 Test(err == KErrNone);
774 CleanupStack::PopAndDestroy(&session);
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
784 void TestFunction6L()
786 RClientMessageTestSession session;
787 _LIT8(KDes8, "Des8");
788 _LIT(KDes16, "Des16");
790 TInt err = session.Connect();
791 Test(err == KErrNone);
793 CleanupClosePushL(session);
795 err = session.TestFunction6(KDes8,KDes16);
796 Test(err == KErrArgument);
798 CleanupStack::PopAndDestroy(&session);
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
808 void TestFunction7L()
810 RClientMessageTestSession session;
811 _LIT8(KDes8, "Descriptor8");
812 _LIT(KDes16, "Descriptor16");
814 TInt err = session.Connect();
815 Test(err == KErrNone);
817 CleanupClosePushL(session);
819 err = session.TestFunction7(KDes8,KDes16);
820 Test(err == KErrNone);
822 CleanupStack::PopAndDestroy(&session);
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
833 void TestFunction8L()
835 RClientMessageTestSession session;
836 _LIT8(KDes8, "Descriptor8");
837 _LIT(KDes16, "Descriptor16");
839 TInt err = session.Connect();
840 Test(err == KErrNone);
842 CleanupClosePushL(session);
844 //this function is incorrectly defined in the
845 //message schema. This should result in the
847 err = session.TestFunction8(KDes8,KDes16);
849 //In debug builds the server should panic.
850 //In release builds the client will be panicked
852 Test(err == KErrServerTerminated);
854 TInt type = serverProcess.ExitType();
855 Test(type == EExitPanic);
857 TInt reason = serverProcess.ExitReason();
858 Test(reason == ECMPanicBadMessageSchema);
861 CleanupStack::PopAndDestroy(&session);
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
873 void TestFunction9AL()
880 RClientMessageTestSession session;
882 TInt err = session.Connect();
883 Test(err == KErrNone);
885 CleanupClosePushL(session);
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);
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);
897 CleanupStack::PopAndDestroy(&session);
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
908 void TestFunction9BL()
914 RClientMessageTestSession session;
916 TInt err = session.Connect();
917 Test(err == KErrNone);
919 CleanupClosePushL(session);
921 //this should result in a client panic with KErrBadDescriptor
922 err = session.TestFunction9(smallBuf8,0,smallBuf,0);
924 CleanupStack::PopAndDestroy(&session);
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
936 void TestFunction9CL()
942 RClientMessageTestSession session;
944 TInt err = session.Connect();
945 Test(err == KErrNone);
947 CleanupClosePushL(session);
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);
953 CleanupStack::PopAndDestroy(&session);
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
964 void TestFunction9DL()
969 RClientMessageTestSession session;
971 TInt err = session.Connect();
972 Test(err == KErrNone);
974 CleanupClosePushL(session);
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);
980 CleanupStack::PopAndDestroy(&session);
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
991 void TestFunction10L()
997 RClientMessageTestSession session;
999 TInt err = session.Connect();
1000 Test(err == KErrNone);
1002 CleanupClosePushL(session);
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);
1009 CleanupStack::PopAndDestroy(&session);
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
1021 void TestFunction11L()
1023 _LIT8(KLongDes8,"This descriptor is longer than 32 characters");
1024 TBuf8<64> buf8(KLongDes8);
1027 RClientMessageTestSession session;
1029 TInt err = session.Connect();
1030 Test(err == KErrNone);
1032 CleanupClosePushL(session);
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);
1039 Test(err == KErrServerTerminated);
1041 TInt type = serverProcess.ExitType();
1042 Test(type == EExitPanic);
1044 TInt reason = serverProcess.ExitReason();
1045 Test(reason == ECMPanicBadDescriptor);
1047 Test(err == KErrNone);
1050 CleanupStack::PopAndDestroy(&session);
1054 This test function accepts 1 descriptor parameter as defined below
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
1061 void TestFunction12L()
1067 RClientMessageTestSession session;
1069 TInt err = session.Connect();
1070 Test(err == KErrNone);
1072 CleanupClosePushL(session);
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);
1081 Test(err == KErrServerTerminated);
1083 TInt type = serverProcess.ExitType();
1084 Test(type == EExitPanic);
1086 TInt reason = serverProcess.ExitReason();
1087 Test(reason == ECMPanicBadMessageSchema);
1089 Test(err == KErrNone);
1091 CleanupStack::PopAndDestroy(&session);
1095 This test function accepts 1 descriptor parameter as defined below
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
1102 void TestFunction13L()
1108 RClientMessageTestSession session;
1110 TInt err = session.Connect();
1111 Test(err == KErrNone);
1113 CleanupClosePushL(session);
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);
1121 Test(err == KErrServerTerminated);
1123 TInt type = serverProcess.ExitType();
1124 Test(type == EExitPanic);
1126 TInt reason = serverProcess.ExitReason();
1127 Test(reason == ECMPanicBadMessageSchema);
1130 CleanupStack::PopAndDestroy(&session);
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.
1143 void TestFunction14L()
1146 _LIT8(KDes8, "Descriptor8");
1149 RClientMessageTestSession session;
1151 TInt err = session.Connect();
1152 Test(err == KErrNone);
1154 CleanupClosePushL(session);
1156 err = session.TestFunction14(KDes8,0,buf);
1157 Test(err == KErrNone);
1158 Test(buf.Find(_L8("Descriptor8")) == 0);
1160 err = session.TestFunction14(KDes8,3,buf);
1161 Test(err == KErrNone);
1162 Test(buf.Find(_L8("criptor8")) == 0);
1164 err = session.TestFunction14(KDes8,8,buf);
1165 Test(err == KErrNone);
1166 Test(buf.Find(_L8("or8")) == 0);
1168 CleanupStack::PopAndDestroy(&session);
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.
1181 void TestFunction15L()
1184 _LIT(KDes, "Descriptor");
1187 RClientMessageTestSession session;
1189 TInt err = session.Connect();
1190 Test(err == KErrNone);
1192 CleanupClosePushL(session);
1194 err = session.TestFunction15(KDes,0,buf);
1195 Test(err == KErrNone);
1196 Test(buf.Find(_L("Descriptor")) == 0);
1198 err = session.TestFunction15(KDes,3,buf);
1199 Test(err == KErrNone);
1200 Test(buf.Find(_L("criptor")) == 0);
1202 err = session.TestFunction15(KDes,8,buf);
1203 Test(err == KErrNone);
1204 Test(buf.Find(_L("or")) == 0);
1206 CleanupStack::PopAndDestroy(&session);
1211 This test function accepts a single TAny* parameter as below
1213 The server function reads the pointer value.
1215 void TestFunction16L()
1217 RClientMessageTestSession session;
1219 TInt err = session.Connect();
1220 Test(err == KErrNone);
1222 CleanupClosePushL(session);
1224 err = session.TestFunction16(0);
1225 Test(err == KErrNone);
1227 CleanupStack::PopAndDestroy(&session);
1232 This test function accepts a single TAny* parameter as below
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
1239 void TestFunction17L()
1241 RClientMessageTestSession session;
1243 TInt err = session.Connect();
1244 Test(err == KErrNone);
1246 CleanupClosePushL(session);
1248 //This should result in the server panicking with ECMPanicWrongParameterType
1249 //in UDEB or returning KErrWrongParameterType in UREL
1250 err = session.TestFunction17(0);
1252 Test(err == KErrServerTerminated);
1254 TInt type = serverProcess.ExitType();
1255 Test(type == EExitPanic);
1257 TInt reason = serverProcess.ExitReason();
1258 Test(reason == ECMPanicWrongParameterType);
1260 Test(err == KErrWrongParameterType);
1263 CleanupStack::PopAndDestroy(&session);
1267 This test function accepts a single custom TPckg parameter as below
1268 {EParamCustom1,sizeof(CMTestStruct2),sizeof(CMTestStruct2)}.
1269 CMTestStruct2 is defined as follows:
1271 struct CMTestStruct1
1277 struct CMTestStruct2
1280 CMTestStruct1* iStruct;
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.
1291 void TestFunction18AL()
1293 RClientMessageTestSession session;
1295 TInt err = session.Connect();
1296 Test(err == KErrNone);
1298 CleanupClosePushL(session);
1300 CMTestStruct1 struct1;
1302 struct1.iDes = _L("Test Struct");
1304 CMTestStruct2 struct2;
1306 struct2.iStruct = &struct1;
1307 struct2.iEnum = ETestVal1;
1308 struct2.iDes = _L("Test Struct 2");
1310 TPckg<CMTestStruct2> pData(struct2);
1312 err = session.TestFunction18(pData);
1313 Test(err == KErrNone);
1315 Test(struct2.iCount == 0);
1317 CMTestStruct1 struct3;
1319 struct3.iDes = _L("");
1321 CMTestStruct2 struct4;
1323 struct4.iStruct = &struct3;
1325 struct4.iDes = _L("Test Struct 2");
1327 TPckg<CMTestStruct2> pData2(struct4);
1329 //As iEnum is not in the valid range this validation should fail
1330 err = session.TestFunction18(pData2);
1331 Test(err == KErrBadParameter);
1333 CleanupStack::PopAndDestroy(&session);
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
1343 void TestFunction18BL()
1345 RClientMessageTestSession session;
1347 TInt err = session.Connect();
1348 Test(err == KErrNone);
1350 CleanupClosePushL(session);
1352 CMTestStruct1 struct1;
1354 struct1.iDes = _L("Test Struct");
1356 TPckg<CMTestStruct1> pData(struct1);
1358 //This should result in a panic
1359 err = session.TestFunction18(pData);
1361 CleanupStack::PopAndDestroy(&session);
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.
1372 void TestFunction18CL()
1374 RClientMessageTestSession session;
1376 TInt err = session.Connect();
1377 Test(err == KErrNone);
1379 CleanupClosePushL(session);
1381 TBuf<sizeof(CMTestStruct2)> buf;
1382 buf.SetLength(sizeof(CMTestStruct2));
1384 //This should result in a panic
1385 err = session.TestFunction18(buf);
1387 CleanupStack::PopAndDestroy(&session);
1391 This test function accepts a single custom TPckg parameter as below
1392 {EParamCustom2,sizeof(CMTestStruct1),sizeof(CMTestStruct1)}.
1393 CMTestStruct1 is defined as follows:
1395 struct CMTestStruct1
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
1407 void TestFunction19L()
1409 RClientMessageTestSession session;
1411 TInt err = session.Connect();
1412 Test(err == KErrNone);
1414 CleanupClosePushL(session);
1416 CMTestStruct1 struct1;
1418 struct1.iDes = _L("Test Struct");
1420 TPckgBuf<CMTestStruct1> pData(struct1);
1422 err = session.TestFunction19(pData);
1423 Test(err == KErrNone);
1426 TPckgBuf<CMTestStruct1> pData2(struct1);
1428 err = session.TestFunction19(pData2);
1429 Test(err == KErrBadParameter);
1431 CleanupStack::PopAndDestroy(&session);
1435 This test function does not expect any parameters.
1436 The schema defines a single placeholder parameter
1438 but the number of parameters is set to 0
1440 void TestFunction25L()
1442 RClientMessageTestSession session;
1444 TInt err = session.Connect();
1445 Test(err == KErrNone);
1447 CleanupClosePushL(session);
1449 err = session.TestFunction25();
1450 Test(err == KErrNone);
1452 CleanupStack::PopAndDestroy(&session);
1456 This test function does not expect any parameters.
1457 The schema defines a single placeholder parameter
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
1464 void TestFunction26L()
1466 RClientMessageTestSession session;
1468 TInt err = session.Connect();
1469 Test(err == KErrNone);
1471 CleanupClosePushL(session);
1473 err = session.TestFunction26();
1474 //In debug builds the server should panic.
1475 //In release builds KErrBadParameter should be returned
1477 Test(err == KErrServerTerminated);
1479 TInt type = serverProcess.ExitType();
1480 Test(type == EExitPanic);
1482 TInt reason = serverProcess.ExitReason();
1483 Test(reason == ECMPanicBadMessageSchema);
1485 Test(err == KErrBadMessageSchema);
1488 CleanupStack::PopAndDestroy(&session);
1492 This test function does not expect any parameters.
1493 The schema defines a single placeholder parameter
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
1500 void TestFunction27L()
1502 RClientMessageTestSession session;
1504 TInt err = session.Connect();
1505 Test(err == KErrNone);
1507 CleanupClosePushL(session);
1509 err = session.TestFunction27();
1510 //In debug builds the server should panic.
1511 //In release builds KErrBadMessageSchema should be returned
1513 Test(err == KErrServerTerminated);
1515 TInt type = serverProcess.ExitType();
1516 Test(type == EExitPanic);
1518 TInt reason = serverProcess.ExitReason();
1519 Test(reason == ECMPanicBadMessageSchema);
1521 Test(err == KErrBadMessageSchema);
1524 CleanupStack::PopAndDestroy(&session);
1528 This test function accepts a single integer parameter with a
1529 custom validation function.
1531 The validation functions checks that the value passed in is a
1533 Any calls to this function with a parameter that is not divisible
1534 by 4 should fail with KErrBadParameter
1536 void TestFunction28L()
1538 RClientMessageTestSession session;
1540 TInt err = session.Connect();
1541 Test(err == KErrNone);
1543 CleanupClosePushL(session);
1545 err = session.TestFunction28(4);
1546 Test(err == KErrNone);
1548 err = session.TestFunction28(128);
1549 Test(err == KErrNone);
1551 err = session.TestFunction28(73);
1552 Test(err == KErrBadParameter);
1554 err = session.TestFunction28(-1);
1555 Test(err == KErrBadParameter);
1557 err = session.TestFunction28(44444444);
1558 Test(err == KErrNone);
1560 CleanupStack::PopAndDestroy(&session);
1564 This test function accepts a single descriptor parameter with a
1565 custom validation function.
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
1572 void TestFunction29L()
1574 RClientMessageTestSession session;
1576 TInt err = session.Connect();
1577 Test(err == KErrNone);
1579 CleanupClosePushL(session);
1581 TBuf<32> data = _L("Expected Data");
1583 err = session.TestFunction29(data);
1584 Test(err == KErrNone);
1588 err = session.TestFunction29(data);
1589 Test(err == KErrBadParameter);
1591 data = _L("expected data");
1593 err = session.TestFunction29(data);
1594 Test(err == KErrBadParameter);
1598 err = session.TestFunction29(data);
1599 Test(err == KErrBadParameter);
1601 CleanupStack::PopAndDestroy(&session);
1605 This test function accepts a single custom TPckg parameter as below
1606 {EParamPckg,sizeof(CMTestStruct1),sizeof(CMTestStruct1)}.
1607 CMTestStruct1 is defined as follows:
1609 struct CMTestStruct1
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.
1620 void TestFunction30L()
1622 RClientMessageTestSession session;
1624 TInt err = session.Connect();
1625 Test(err == KErrNone);
1627 CleanupClosePushL(session);
1629 CMTestStruct1 struct1;
1631 struct1.iDes = _L("Test Struct");
1633 TPckg<CMTestStruct1> pData(struct1);
1635 err = session.TestFunction30(pData);
1636 Test(err == KErrNone);
1639 //This should cause a panic
1640 err = session.TestFunction30(data);
1642 CleanupStack::PopAndDestroy(&session);
1646 This test function accepts an Intergeer parameter and a TAny* parameter
1647 {EParamInt,EGetIntL,EWrite16L},{EParamPtr,0,0}
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
1656 void DoTest31L(TInt aType)
1658 RClientMessageTestSession session;
1660 TInt err = session.Connect();
1661 Test(err == KErrNone);
1663 CleanupClosePushL(session);
1665 err = session.TestFunction31(aType);
1667 Test(err == KErrServerTerminated);
1669 TInt type = serverProcess.ExitType();
1670 Test(type == EExitPanic);
1672 TInt reason = serverProcess.ExitReason();
1673 Test(reason == ECMPanicWrongParameterType);
1675 Test(err == KErrWrongParameterType);
1678 CleanupStack::PopAndDestroy(&session);
1681 void TestFunction31AL()
1683 DoTest31L(EGetIntL);
1686 void TestFunction31BL()
1688 DoTest31L(EGetDes8L);
1691 void TestFunction31CL()
1693 DoTest31L(EGetDes16L);
1696 void TestFunction31DL()
1698 DoTest31L(EGetDesLengthL);
1701 void TestFunction31EL()
1703 DoTest31L(EGetDesMaxLengthL);
1706 void TestFunction31FL()
1711 void TestFunction31GL()
1713 DoTest31L(ERead16L);
1716 void TestFunction31HL()
1718 DoTest31L(EWrite8L);
1721 void TestFunction31IL()
1723 DoTest31L(EWrite16L);
1726 This test function accepts a single custom parameter as below
1727 {EParamCustom5,sizeof(CMTestStruct1),sizeof(CMTestStruct1)}
1728 CMTestStruct1 is defined as follows:
1730 struct CMTestStruct1
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
1744 void TestFunction32L()
1746 RClientMessageTestSession session;
1748 TInt err = session.Connect();
1749 Test(err == KErrNone);
1751 CleanupClosePushL(session);
1753 CMTestStruct1 struct1;
1754 TPckg<CMTestStruct1> pData(struct1);
1756 err = session.TestFunction32(pData);
1759 Test(err == KErrServerTerminated);
1761 TInt type = serverProcess.ExitType();
1762 Test(type == EExitPanic);
1764 TInt reason = serverProcess.ExitReason();
1765 Test(reason == ECMPanicBadMessageSchema);
1767 Test(err == KErrBadMessageSchema);
1770 CleanupStack::PopAndDestroy(&session);
1773 /* Connect to the CClientMessageTestServer, launching
1774 * the server process if necessary
1776 TInt RClientMessageTestSession2::Connect()
1781 TInt r = CreateSession(KServer2Name,TVersion(1,0,0));
1783 if((r != KErrNotFound)&&(r != KErrServerTerminated))
1794 if((r != KErrNone)&&(r != KErrAlreadyExists))
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
1807 TInt RClientMessageTestSession2::TestFunction0(TInt aArg0, TInt aArg1)
1809 return SendReceive(ETestMessage0,TIpcArgs(aArg0,aArg1));
1812 TInt RClientMessageTestSession2::TestFunction1(const TDesC& aData0)
1814 return SendReceive(ETestMessage1,TIpcArgs(&aData0));
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.
1833 void DoIntParameterTestsL()
1835 TExitDetails exitDetails;
1837 exitDetails = LaunchTestThreadL(_L("TestFunction0"), &TestFunction0AL);
1838 Test(exitDetails.iExitType == EExitKill);
1840 exitDetails = LaunchTestThreadL(_L("TestFunction1"), &TestFunction1L);
1841 Test(exitDetails.iExitType == EExitKill);
1843 exitDetails = LaunchTestThreadL(_L("TestFunction2"), &TestFunction2L);
1844 Test(exitDetails.iExitType == EExitKill);
1846 exitDetails = LaunchTestThreadL(_L("TestFunction3"), &TestFunction3L);
1847 Test(exitDetails.iExitType == EExitKill);
1849 exitDetails = LaunchTestThreadL(_L("TestFunction28"), &TestFunction28L);
1850 Test(exitDetails.iExitType == EExitKill);
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.
1869 void DoDesReadParameterTestsL()
1871 TExitDetails exitDetails;
1873 exitDetails = LaunchTestThreadL(_L("TestFunction4A"), &TestFunction4AL);
1874 Test(exitDetails.iExitType == EExitKill);
1876 exitDetails = LaunchTestThreadL(_L("TestFunction4B"), &TestFunction4BL);
1877 Test(exitDetails.iExitType == EExitPanic);
1878 Test(exitDetails.iReason == KErrBadDescriptor);
1880 exitDetails = LaunchTestThreadL(_L("TestFunction4C"), &TestFunction4CL);
1881 Test(exitDetails.iExitType == EExitPanic);
1882 Test(exitDetails.iReason == KErrBadDescriptor);
1884 exitDetails = LaunchTestThreadL(_L("TestFunction4D"), &TestFunction4DL);
1885 Test(exitDetails.iExitType == EExitPanic);
1886 Test(exitDetails.iReason == KErrBadDescriptor);
1888 exitDetails = LaunchTestThreadL(_L("TestFunction4E"), &TestFunction4EL);
1889 Test(exitDetails.iExitType == EExitPanic);
1890 Test(exitDetails.iReason == KErrBadDescriptor);
1892 exitDetails = LaunchTestThreadL(_L("TestFunction4F"), &TestFunction4FL);
1893 Test(exitDetails.iExitType == EExitPanic);
1894 Test(exitDetails.iReason == KErrBadDescriptor);
1896 exitDetails = LaunchTestThreadL(_L("TestFunction5"), &TestFunction5L);
1897 Test(exitDetails.iExitType == EExitKill);
1899 exitDetails = LaunchTestThreadL(_L("TestFunction6"), &TestFunction6L);
1900 Test(exitDetails.iExitType == EExitKill);
1902 exitDetails = LaunchTestThreadL(_L("TestFunction7"), &TestFunction7L);
1903 Test(exitDetails.iExitType == EExitKill);
1905 exitDetails = LaunchTestThreadL(_L("TestFunction8"), &TestFunction8L);
1907 Test(exitDetails.iExitType == EExitKill);
1909 Test(exitDetails.iExitType == EExitPanic);
1910 Test(exitDetails.iReason == KErrBadDescriptor);
1913 exitDetails = LaunchTestThreadL(_L("TestFunction29"), &TestFunction29L);
1914 Test(exitDetails.iExitType == EExitKill);
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.
1934 void DoDesParameterTestsL()
1936 TExitDetails exitDetails;
1937 exitDetails = LaunchTestThreadL(_L("TestFunction9A"), &TestFunction9AL);
1938 Test(exitDetails.iExitType == EExitKill);
1940 exitDetails = LaunchTestThreadL(_L("TestFunction9B"), &TestFunction9BL);
1941 Test(exitDetails.iExitType == EExitPanic);
1942 Test(exitDetails.iReason == KErrBadDescriptor);
1944 exitDetails = LaunchTestThreadL(_L("TestFunction9C"), &TestFunction9CL);
1945 Test(exitDetails.iExitType == EExitPanic);
1946 Test(exitDetails.iReason == KErrOverflow);
1948 exitDetails = LaunchTestThreadL(_L("TestFunction9D"), &TestFunction9DL);
1949 Test(exitDetails.iExitType == EExitPanic);
1950 Test(exitDetails.iReason == KErrBadDescriptor);
1952 exitDetails = LaunchTestThreadL(_L("TestFunction10"), &TestFunction10L);
1953 Test(exitDetails.iExitType == EExitPanic);
1954 Test(exitDetails.iReason == KErrOverflow);
1956 exitDetails = LaunchTestThreadL(_L("TestFunction11"), &TestFunction11L);
1957 Test(exitDetails.iExitType == EExitKill);
1959 exitDetails = LaunchTestThreadL(_L("TestFunction12"), &TestFunction12L);
1960 Test(exitDetails.iExitType == EExitKill);
1962 exitDetails = LaunchTestThreadL(_L("TestFunction13"), &TestFunction13L);
1964 Test(exitDetails.iExitType == EExitKill);
1966 Test(exitDetails.iExitType == EExitPanic);
1967 Test(exitDetails.iReason == KErrBadDescriptor);
1970 exitDetails = LaunchTestThreadL(_L("TestFunction14"), &TestFunction14L);
1971 Test(exitDetails.iExitType == EExitKill);
1973 exitDetails = LaunchTestThreadL(_L("TestFunction15"), &TestFunction15L);
1974 Test(exitDetails.iExitType == EExitKill);
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
1989 void DoPtrParameterTestsL()
1991 TExitDetails exitDetails;
1992 exitDetails = LaunchTestThreadL(_L("TestFunction16"), &TestFunction16L);
1993 Test(exitDetails.iExitType == EExitKill);
1995 exitDetails = LaunchTestThreadL(_L("TestFunction17"), &TestFunction17L);
1996 Test(exitDetails.iExitType == EExitKill);
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.
2014 void DoPckgParameterTestsL()
2016 TExitDetails exitDetails;
2017 exitDetails = LaunchTestThreadL(_L("TestFunction18A"), &TestFunction18AL);
2018 Test(exitDetails.iExitType == EExitKill);
2020 exitDetails = LaunchTestThreadL(_L("TestFunction18B"), &TestFunction18BL);
2021 Test(exitDetails.iExitType == EExitPanic);
2022 Test(exitDetails.iReason == KErrBadDescriptor);
2024 exitDetails = LaunchTestThreadL(_L("TestFunction18C"), &TestFunction18CL);
2025 Test(exitDetails.iExitType == EExitPanic);
2026 Test(exitDetails.iReason == KErrBadDescriptor);
2028 exitDetails = LaunchTestThreadL(_L("TestFunction19"), &TestFunction19L);
2029 Test(exitDetails.iExitType == EExitKill);
2031 exitDetails = LaunchTestThreadL(_L("TestFunction30"), &TestFunction30L);
2032 Test(exitDetails.iExitType == EExitPanic);
2033 Test(exitDetails.iReason == KErrBadDescriptor);
2035 exitDetails = LaunchTestThreadL(_L("TestFunction32"), &TestFunction32L);
2036 Test(exitDetails.iExitType == EExitKill);
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.
2051 void DoNullParameterTestsL()
2054 TExitDetails exitDetails;
2055 exitDetails = LaunchTestThreadL(_L("TestFunction25"), &TestFunction25L);
2056 Test(exitDetails.iExitType == EExitKill);
2058 exitDetails = LaunchTestThreadL(_L("TestFunction26"), &TestFunction26L);
2059 Test(exitDetails.iExitType == EExitKill);
2061 exitDetails = LaunchTestThreadL(_L("TestFunction27"), &TestFunction27L);
2062 Test(exitDetails.iExitType == EExitKill);
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
2073 @SYMTestExpectedResults The server should return KErrNone if the client has
2074 the required security policy, otherwise return KErrPermissionDenied
2077 void DoSecurityPolicyTestsL()
2079 RClientMessageTestSession session;
2081 TInt err = session.Connect();
2083 CleanupClosePushL(session);
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);
2092 RDebug::Print(_L("Testing Valid SID Policy..."));
2093 err = session.TestFunction21(0,0);
2094 Test(err == KErrNone);
2096 RDebug::Print(_L("Testing Invalid SID Policy..."));
2097 err = session.TestFunction22(0,0);
2098 Test(err == KErrPermissionDenied);
2100 RDebug::Print(_L("Testing Valid Capability Policy..."));
2101 err = session.TestFunction23(0,0);
2102 Test(err == KErrNone);
2104 RDebug::Print(_L("Testing Invalid Capability Policy..."));
2105 err = session.TestFunction24(0,0);
2106 Test(err == KErrPermissionDenied);
2108 CleanupStack::PopAndDestroy(&session);
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
2117 @SYMTestExpectedResults The ClientMessage framework should return KErrInvalidFunction
2120 void DoInvalidMessageTestsL()
2122 RClientMessageTestSession session;
2124 TInt err = session.Connect();
2126 CleanupClosePushL(session);
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);
2134 err = session.TestInvalidFunction(5);
2135 Test(err == KErrInvalidFunction);
2137 CleanupStack::PopAndDestroy(&session);
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
2153 void DoCMessageParameterBaseTestL()
2156 TExitDetails exitDetails;
2157 exitDetails = LaunchTestThreadL(_L("TestFunction31A"), &TestFunction31AL);
2158 Test(exitDetails.iExitType == EExitKill);
2160 exitDetails = LaunchTestThreadL(_L("TestFunction31B"), &TestFunction31BL);
2161 Test(exitDetails.iExitType == EExitKill);
2163 exitDetails = LaunchTestThreadL(_L("TestFunction31C"), &TestFunction31CL);
2164 Test(exitDetails.iExitType == EExitKill);
2166 exitDetails = LaunchTestThreadL(_L("TestFunction31D"), &TestFunction31DL);
2167 Test(exitDetails.iExitType == EExitKill);
2169 exitDetails = LaunchTestThreadL(_L("TestFunction31E"), &TestFunction31EL);
2170 Test(exitDetails.iExitType == EExitKill);
2172 exitDetails = LaunchTestThreadL(_L("TestFunction31F"), &TestFunction31FL);
2173 Test(exitDetails.iExitType == EExitKill);
2175 exitDetails = LaunchTestThreadL(_L("TestFunction31G"), &TestFunction31GL);
2176 Test(exitDetails.iExitType == EExitKill);
2178 exitDetails = LaunchTestThreadL(_L("TestFunction31H"), &TestFunction31HL);
2179 Test(exitDetails.iExitType == EExitKill);
2181 exitDetails = LaunchTestThreadL(_L("TestFunction31I"), &TestFunction31IL);
2182 Test(exitDetails.iExitType == EExitKill);
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
2199 void DoMultipleServerTestsL()
2202 RClientMessageTestSession session1;
2203 RClientMessageTestSession2 session2;
2205 TInt err = session1.Connect();
2206 Test(err == KErrNone);
2207 CleanupClosePushL(session1);
2209 err = session2.Connect();
2210 Test(err == KErrNone);
2211 CleanupClosePushL(session2);
2213 err = session1.TestFunction0( 0, 150);
2214 Test(err == KErrNone);
2216 err = session2.TestFunction0( 0, 150);
2217 Test(err == KErrBadParameter);
2219 err = session1.TestFunction0( 0, -50);
2220 Test(err == KErrBadParameter);
2222 err = session2.TestFunction0( 0, -50);
2223 Test(err == KErrNone);
2225 CleanupStack::PopAndDestroy(2,&session1);
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.
2240 void DoDisablePanicTestsL()
2243 RClientMessageTestSession2 session;
2244 _LIT(KDes16, "Descriptor");
2246 TInt err = session.Connect();
2247 Test(err == KErrNone);
2249 CleanupClosePushL(session);
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.
2256 err = session.TestFunction1(KDes16);
2259 Test(err == KErrBadDescriptor);
2261 // Server is not terminated, still alive
2262 TInt type = serverProcess.ExitType();
2263 Test(type == EExitPending);
2265 Test(err == KErrBadDescriptor);
2268 CleanupStack::PopAndDestroy(&session);
2273 static void DoTestsL()
2276 TExitDetails exitDetails;
2279 Test.Start (_L("ClientMessage Tests"));
2281 Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4040 Testing Message with Int Parameters "));
2282 DoIntParameterTestsL();
2284 Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4041 Testing Message with Read Only Des Parameters "));
2285 DoDesReadParameterTestsL();
2287 Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4042 Testing Message with Read/Write Des Parameters "));
2288 DoDesParameterTestsL();
2290 Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4043 Testing Message with Ptr Parameters "));
2291 DoPtrParameterTestsL();
2293 Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4044 Testing Message with Pckg Parameters "));
2294 DoPckgParameterTestsL();
2296 Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4045 Testing Message with Null Parameters "));
2297 DoNullParameterTestsL();
2299 Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4046 Testing Security Policy Checking "));
2300 exitDetails = LaunchTestThreadL(_L("SecurityPolicyTestL"), &DoSecurityPolicyTestsL);
2301 Test(exitDetails.iExitType == EExitKill);
2303 Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4047 Testing Invalid Message "));
2304 exitDetails = LaunchTestThreadL(_L("InvalidMessageTestL"), &DoInvalidMessageTestsL);
2305 Test(exitDetails.iExitType == EExitKill);
2307 Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4050 Testing CMessageParameterBase Default Implementations "));
2308 exitDetails = LaunchTestThreadL(_L("CMessageParameterBaseTestL"), &DoCMessageParameterBaseTestL);
2309 Test(exitDetails.iExitType == EExitKill);
2311 Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4048 Testing Multiple Servers "));
2312 exitDetails = LaunchTestThreadL(_L("MultipleServerTestingL"), &DoMultipleServerTestsL);
2313 Test(exitDetails.iExitType == EExitKill);
2315 Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4051 Testing Disable Client Panic"));
2316 exitDetails = LaunchTestThreadL(_L("DisablePanicTesting"), &DoDisablePanicTestsL);
2317 Test(exitDetails.iExitType == EExitKill);
2320 Test.Printf(_L("Tests Completed O.K."));
2330 // Server process entry-point
2334 CTrapCleanup* cleanup=CTrapCleanup::New();
2335 TInt r=KErrNoMemory;