kerneltest/e32test/secure/t_sobject.cpp
changeset 109 b3a1d9898418
parent 0 a41df078684a
child 257 3e88ff8f41d5
equal deleted inserted replaced
102:ef2a444a7410 109:b3a1d9898418
    53 // Failures and causes:
    53 // Failures and causes:
    54 // Base Port information:
    54 // Base Port information:
    55 // 
    55 // 
    56 //
    56 //
    57 
    57 
       
    58 #define __E32TEST_EXTENSION__
    58 #include <e32test.h>
    59 #include <e32test.h>
    59 #include <e32msgqueue.h>
    60 #include <e32msgqueue.h>
    60 #include <f32file.h>
    61 #include <f32file.h>
    61 #include "d_sldd.h"
    62 #include "d_sldd.h"
    62 
    63 
   236 CTestSession::CTestSession()
   237 CTestSession::CTestSession()
   237 	: CSession2()
   238 	: CSession2()
   238 	{
   239 	{
   239 	}
   240 	}
   240 
   241 
   241 const TInt KTestDataMaxLength8 = 20;
       
   242 const TInt KTestDataMaxLength16 = 40;
       
   243 _LIT8(KTestData8,"12345678");
       
   244 _LIT16(KTestData16,"1234567890123456");
       
   245 _LIT(KTestPanicCategory,"TEST PANIC");
       
   246 
   242 
   247 void CTestSession::ServiceL(const RMessage2& aMessage)
   243 void CTestSession::ServiceL(const RMessage2& aMessage)
   248 	{
   244 	{
   249 	RMessagePtr2 m(aMessage);
   245 	RMessagePtr2 m(aMessage);
   250 	TFullName name;
   246 	TFullName name;
   286 
   282 
   287 			m.Complete(object);
   283 			m.Complete(object);
   288 			object.Close();
   284 			object.Close();
   289 			return;
   285 			return;
   290 			}
   286 			}
   291 			break;
       
   292 
   287 
   293 		case CTestSession::ETestSemaphore:
   288 		case CTestSession::ETestSemaphore:
   294 			{
   289 			{
   295 			RSemaphore object;
   290 			RSemaphore object;
   296 
   291 
   316 
   311 
   317 			m.Complete(object);
   312 			m.Complete(object);
   318 			object.Close();
   313 			object.Close();
   319 			return;
   314 			return;
   320 			}
   315 			}
   321 			break;
       
   322 
   316 
   323 		case CTestSession::ETestMsgQueue:
   317 		case CTestSession::ETestMsgQueue:
   324 			{
   318 			{
   325 			RMsgQueue<TInt> object;
   319 			RMsgQueue<TInt> object;
   326 
   320 
   346 
   340 
   347 			m.Complete(object);
   341 			m.Complete(object);
   348 			object.Close();
   342 			object.Close();
   349 			return;
   343 			return;
   350 			}
   344 			}
   351 			break;
   345 
   352 
   346 
   353 		case CTestSession::ETestCondVar:
   347 		case CTestSession::ETestCondVar:
   354 			{
   348 			{
   355 			RCondVar object;
   349 			RCondVar object;
   356 
   350 
   376 
   370 
   377 			m.Complete(object);
   371 			m.Complete(object);
   378 			object.Close();
   372 			object.Close();
   379 			return;
   373 			return;
   380 			}
   374 			}
   381 			break;
   375 
   382 
   376 
   383 		case CTestSession::ETestChunk:
   377 		case CTestSession::ETestChunk:
   384 			{
   378 			{
   385 			RChunk object;
   379 			RChunk object;
   386 
   380 
   406 
   400 
   407 			m.Complete(object);
   401 			m.Complete(object);
   408 			object.Close();
   402 			object.Close();
   409 			return;
   403 			return;
   410 			}
   404 			}
   411 			break;
   405 
   412 
   406 
   413 		case CTestSession::ETestChunkAdjust:
   407 		case CTestSession::ETestChunkAdjust:
   414 			{
   408 			{
   415 			RChunk object;
   409 			RChunk object;
   416 			r = object.Open(m,0,EOwnerThread);
   410 			r = object.Open(m,0,EOwnerThread);
   622 
   616 
   623 
   617 
   624 void TestPhysicalDevices()
   618 void TestPhysicalDevices()
   625 	{
   619 	{
   626 	TFullName name;
   620 	TFullName name;
   627 	TInt r;
       
   628 
       
   629 	test.Start(_L("Test find named object"));
   621 	test.Start(_L("Test find named object"));
   630 	TFindPhysicalDevice find(_L("*"));
   622 	TFindPhysicalDevice find(_L("*"));
   631 	test((r=find.Next(name))==KErrNone);
   623 	test((find.Next(name))==KErrNone);
   632 
   624 
   633 	test.Next(_L("Try open found object"));
   625 	test.Next(_L("Try open found object"));
   634 	RTestHandle testObject;
   626 	RTestHandle testObject;
   635 	test((r=testObject.Open(find))==PlatSecProcessIsolationError);
   627 	test((testObject.Open(find))==PlatSecProcessIsolationError);
   636 	testObject.Close();
   628 	testObject.Close();
   637 
   629 
   638 	test.End();
   630 	test.End();
   639 	}
   631 	}
   640 
   632 
   641 
   633 
   642 
   634 
   643 void TestLogicalDevices()
   635 void TestLogicalDevices()
   644 	{
   636 	{
   645 	TFullName name;
   637 	TFullName name;	
   646 	TInt r;
       
   647 	RDevice device;
   638 	RDevice device;
   648 
   639 
   649 	test.Start(_L("Test find named object"));
   640 	test.Start(_L("Test find named object"));
   650 	TFindLogicalDevice find(_L("*"));
   641 	TFindLogicalDevice find(_L("*"));
   651 	test((r=find.Next(name))==KErrNone);
   642 	test((find.Next(name))==KErrNone);
   652 
   643 
   653 	test.Next(_L("Test open found object"));
   644 	test.Next(_L("Test open found object"));
   654 	test((r=device.Open(find))==KErrNone);
   645 	test((device.Open(find))==KErrNone);
   655 
   646 
   656 	test.Next(_L("Test duplicate object in other thread"));
   647 	test.Next(_L("Test duplicate object in other thread"));
   657 	test((r=DuplicateInOtherThread(device))==KErrNone);
   648 	test((DuplicateInOtherThread(device))==KErrNone);
   658 
   649 
   659 	test.Next(_L("Test duplicate object in other process"));
   650 	test.Next(_L("Test duplicate object in other process"));
   660 	test((r=DuplicateInOtherProcess(device))==KErrNone);
   651 	test((DuplicateInOtherProcess(device))==KErrNone);
   661 
   652 
   662 	device.Close();
   653 	device.Close();
   663 
   654 
   664 	test.Next(_L("Test open device by name"));
   655 	test.Next(_L("Test open device by name"));
   665 	test((r=device.Open(name))==KErrNone);
   656 	test((device.Open(name))==KErrNone);
   666 	device.Close();
   657 	device.Close();
   667 
   658 
   668 	test.End();
   659 	test.End();
   669 	}
   660 	}
   670 
   661 
   671 
   662 
   672 
   663 
   673 void TestLibraries()
   664 void TestLibraries()
   674 	{
   665 	{
   675 	TFullName name;
   666 	TFullName name;
   676 	TInt r;
       
   677 
       
   678 	test.Start(_L("Test find named object"));
   667 	test.Start(_L("Test find named object"));
   679 	TFindLibrary find(_L("*"));
   668 	TFindLibrary find(_L("*"));
   680 	test((r=find.Next(name))==KErrNone);
   669 	test((find.Next(name))==KErrNone);
   681 
   670 
   682 	test.Next(_L("Try open found object"));
   671 	test.Next(_L("Try open found object"));
   683 	RTestHandle testObject;
   672 	RTestHandle testObject;
   684 	test((r=testObject.Open(find))==PlatSecProcessIsolationError);
   673 	test((testObject.Open(find))==PlatSecProcessIsolationError);
   685 	testObject.Close();
   674 	testObject.Close();
   686 
   675 
   687 	test.End();
   676 	test.End();
   688 	}
   677 	}
   689 
   678 
   690 
   679 
   691 
   680 
   692 void TestServers()
   681 void TestServers()
   693 	{
   682 	{
   694 	TFullName name;
   683 	TFullName name;
   695 	TInt r;
       
   696 	RServer2 localObject(Servers[EAnonymousServer]);
   684 	RServer2 localObject(Servers[EAnonymousServer]);
   697 
   685 
   698 	test.Start(_L("Test find named object"));
   686 	test.Start(_L("Test find named object"));
   699 	TFindServer find(ServerName(EMainServer));
   687 	TFindServer find(ServerName(EMainServer));
   700 	test((r=find.Next(name))==KErrNone);
   688 	test((find.Next(name))==KErrNone);
   701 
   689 
   702 	test.Next(_L("Try open found object"));
   690 	test.Next(_L("Try open found object"));
   703 	RTestHandle testObject;
   691 	RTestHandle testObject;
   704 	test((r=testObject.Open(find))==KErrPermissionDenied);
   692 	test((testObject.Open(find))==KErrPermissionDenied);
   705 
   693 
   706 	test.Next(_L("Test duplicate named server in other thread"));
   694 	test.Next(_L("Test duplicate named server in other thread"));
   707 	test((r=Session.Send(CTestSession::ETestServerDuplicateInThread))==KErrNone);
   695 	test((Session.Send(CTestSession::ETestServerDuplicateInThread))==KErrNone);
   708 
   696 
   709 	test.Next(_L("Try duplicate named server in other process"));
   697 	test.Next(_L("Try duplicate named server in other process"));
   710 	test((r=Session.Send(CTestSession::ETestServerDuplicateInProcess))==KErrPermissionDenied);
   698 	test((Session.Send(CTestSession::ETestServerDuplicateInProcess))==KErrPermissionDenied);
   711 
   699 
   712 	test.Next(_L("Test duplicate unnamed server in other thread"));
   700 	test.Next(_L("Test duplicate unnamed server in other thread"));
   713 	test((r=DuplicateInOtherThread(localObject))==KErrNone);
   701 	test((DuplicateInOtherThread(localObject))==KErrNone);
   714 
   702 
   715 	test.Next(_L("Try duplicate unnamed server in other process"));
   703 	test.Next(_L("Try duplicate unnamed server in other process"));
   716 	test((r=DuplicateInOtherProcess(localObject))==KErrPermissionDenied);
   704 	test((DuplicateInOtherProcess(localObject))==KErrPermissionDenied);
   717 
   705 
   718 	test.End();
   706 	test.End();
   719 	}
   707 	}
   720 
   708 
   721 
   709 
   722 
   710 
   723 void TestProcesses()
   711 void TestProcesses()
   724 	{
   712 	{
   725 	TFullName name;
   713 	TFullName name;	
   726 	TInt r;
       
   727 	RProcess process;
   714 	RProcess process;
   728 
   715 
   729 	test.Start(_L("Test find named object"));
   716 	test.Start(_L("Test find named object"));
   730 	TFindProcess find(_L("EKern*"));
   717 	TFindProcess find(_L("EKern*"));
   731 	test((r=find.Next(name))==KErrNone);
   718 	test((find.Next(name))==KErrNone);
   732 
   719 
   733 	test.Next(_L("Test open found object"));
   720 	test.Next(_L("Test open found object"));
   734 	test((r=process.Open(find))==KErrNone);
   721 	test((process.Open(find))==KErrNone);
   735 
   722 
   736 	test.Next(_L("Test duplicate object in other thread"));
   723 	test.Next(_L("Test duplicate object in other thread"));
   737 	test((r=DuplicateInOtherThread(process))==KErrNone);
   724 	test((DuplicateInOtherThread(process))==KErrNone);
   738 
   725 
   739 	test.Next(_L("Test duplicate object in other process"));
   726 	test.Next(_L("Test duplicate object in other process"));
   740 	test((r=DuplicateInOtherProcess(process))==KErrNone);
   727 	test((DuplicateInOtherProcess(process))==KErrNone);
   741 
   728 
   742 	process.Close();
   729 	process.Close();
   743 
   730 
   744 	test.Next(_L("Test open process by name"));
   731 	test.Next(_L("Test open process by name"));
   745 	test((r=process.Open(name))==KErrNone);
   732 	test((process.Open(name))==KErrNone);
   746 	TProcessId id=process.Id();
   733 	TProcessId id=process.Id();
   747 	process.Close();
   734 	process.Close();
   748 
   735 
   749 	test.Next(_L("Test open process by id"));
   736 	test.Next(_L("Test open process by id"));
   750 	test((r=process.Open(id))==KErrNone);
   737 	test((process.Open(id))==KErrNone);
   751 	test(name==process.FullName());
   738 	test(name==process.FullName());
   752 	process.Close();
   739 	process.Close();
   753 
   740 
   754 	test.End();
   741 	test.End();
   755 	}
   742 	}
   757 
   744 
   758 
   745 
   759 void TestThreads()
   746 void TestThreads()
   760 	{
   747 	{
   761 	TFullName name;
   748 	TFullName name;
   762 	TInt r;
   749 	
   763 
       
   764 	test.Start(_L("Creating threads"));
   750 	test.Start(_L("Creating threads"));
   765 	RThread globalObject;
   751 	RThread globalObject;
   766 	RThread localObject;
   752 	RThread localObject;
   767 	RThread testObject;
   753 	RThread testObject;
   768 	test((r=globalObject.Create(_L("T_SOBJECT-test-global-thread"),TestThreadDuplicate,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,NULL))==KErrNone);
   754 	test((globalObject.Create(_L("T_SOBJECT-test-global-thread"),TestThreadDuplicate,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,NULL))==KErrNone);
   769 	test((r=localObject.Create(_L(""),TestThreadDuplicate,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,NULL))==KErrNone);
   755 	test((localObject.Create(_L(""),TestThreadDuplicate,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,NULL))==KErrNone);
   770 
   756 
   771 	test.Next(_L("Test find named thread"));
   757 	test.Next(_L("Test find named thread"));
   772 	TFindThread find(globalObject.FullName());
   758 	TFindThread find(globalObject.FullName());
   773 	test((r=find.Next(name))==KErrNone);
   759 	test((find.Next(name))==KErrNone);
   774 
   760 
   775 	test.Next(_L("Test open found object"));
   761 	test.Next(_L("Test open found object"));
   776 	test((r=testObject.Open(find))==KErrNone);
   762 	test((testObject.Open(find))==KErrNone);
   777 	testObject.Close();
   763 	testObject.Close();
   778 
   764 
   779 	test.Next(_L("Check can't find unnamed thread"));
   765 	test.Next(_L("Check can't find unnamed thread"));
   780 	TName objectName(localObject.FullName());
   766 	TName objectName(localObject.FullName());
   781 	find.Find(objectName);
   767 	find.Find(objectName);
   782 	test((r=find.Next(name))==PlatSecFindError);
   768 	test((find.Next(name))==PlatSecFindError);
   783 
   769 
   784 	test.Next(_L("Test open named thread by name"));
   770 	test.Next(_L("Test open named thread by name"));
   785 	test((r=testObject.Open(globalObject.FullName()))==KErrNone);
   771 	test((testObject.Open(globalObject.FullName()))==KErrNone);
   786 	testObject.Close();
   772 	testObject.Close();
   787 
   773 
   788 	test.Next(_L("Check can't open unnamed thread by name"));
   774 	test.Next(_L("Check can't open unnamed thread by name"));
   789 	test((r=testObject.Open(localObject.FullName()))==PlatSecFindError);
   775 	test((testObject.Open(localObject.FullName()))==PlatSecFindError);
   790 	testObject.Close();
   776 	testObject.Close();
   791 
   777 
   792 	test.Next(_L("Check can't open with no name"));
   778 	test.Next(_L("Check can't open with no name"));
   793 	test((r=testObject.Open(KNullDesC))==KErrNotFound);
   779 	test((testObject.Open(KNullDesC))==KErrNotFound);
   794 	testObject.Close();
   780 	testObject.Close();
   795 
   781 
   796 	test.Next(_L("Test open named thread by id (in same process)"));
   782 	test.Next(_L("Test open named thread by id (in same process)"));
   797 	test((r=testObject.Open(globalObject.Id()))==KErrNone);
   783 	test((testObject.Open(globalObject.Id()))==KErrNone);
   798 	testObject.Close();
   784 	testObject.Close();
   799 
   785 
   800 	test.Next(_L("Test open named thread by id (in other process)"));
   786 	test.Next(_L("Test open named thread by id (in other process)"));
   801 	test((r=OpenThreadByIdInOtherProcess(globalObject.Id()))==KErrNone);
   787 	test((OpenThreadByIdInOtherProcess(globalObject.Id()))==KErrNone);
   802 
   788 
   803 	test.Next(_L("Test open unnamed thread by id (in same process)"));
   789 	test.Next(_L("Test open unnamed thread by id (in same process)"));
   804 	test((r=testObject.Open(localObject.Id()))==KErrNone);
   790 	test((testObject.Open(localObject.Id()))==KErrNone);
   805 
   791 
   806 	test.Next(_L("Check can't open unnamed thread by id (in other process)"));
   792 	test.Next(_L("Check can't open unnamed thread by id (in other process)"));
   807 	test((r=OpenThreadByIdInOtherProcess(localObject.Id()))==PlatSecProcessIsolationError);
   793 	test((OpenThreadByIdInOtherProcess(localObject.Id()))==PlatSecProcessIsolationError);
   808 
   794 
   809 	test.Next(_L("Test duplicate named thread in other process"));
   795 	test.Next(_L("Test duplicate named thread in other process"));
   810 	test((r=DuplicateInOtherProcess(globalObject))==KErrNone);
   796 	test((DuplicateInOtherProcess(globalObject))==KErrNone);
   811 
   797 
   812 	test.Next(_L("Check can't duplicate unnamed thread in other process"));
   798 	test.Next(_L("Check can't duplicate unnamed thread in other process"));
   813 	test((r=DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError);
   799 	test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError);
   814 
   800 
   815 	test.Next(_L("Test duplicate named thread in other thread"));
   801 	test.Next(_L("Test duplicate named thread in other thread"));
   816 	test((r=DuplicateInOtherThread(globalObject))==KErrNone);
   802 	test((DuplicateInOtherThread(globalObject))==KErrNone);
   817 
   803 
   818 	test.Next(_L("Test duplicate unnamed thread in other thead"));
   804 	test.Next(_L("Test duplicate unnamed thread in other thead"));
   819 	test((r=DuplicateInOtherThread(localObject))==KErrNone);
   805 	test((DuplicateInOtherThread(localObject))==KErrNone);
   820 
   806 
   821 	test.Next(_L("Closing threads"));
   807 	test.Next(_L("Closing threads"));
   822 	globalObject.Close();
   808 	globalObject.Close();
   823 	localObject.Close();
   809 	localObject.Close();
   824 
   810 
   828 
   814 
   829 
   815 
   830 void TestChunks()
   816 void TestChunks()
   831 	{
   817 	{
   832 	TFullName name;
   818 	TFullName name;
   833 	TInt r;
   819 	
   834 
       
   835 	test.Start(_L("Creating chunks"));
   820 	test.Start(_L("Creating chunks"));
   836 	RChunk globalObject;
   821 	RChunk globalObject;
   837 	RChunk localObject;
   822 	RChunk localObject;
   838 	RChunk testObject;
   823 	RChunk testObject;
   839 	test((r=globalObject.CreateGlobal(_L("T_SOBJECT-test-global-chunk"),4096,1024*1024))==KErrNone);
   824 	test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-chunk"),4096,1024*1024))==KErrNone);
   840 	test((r=localObject.CreateLocal(4096,1024*1024))==KErrNone);
   825 	test((localObject.CreateLocal(4096,1024*1024))==KErrNone);
   841 
   826 
   842 	test.Next(_L("Test find global object"));
   827 	test.Next(_L("Test find global object"));
   843 	TFindChunk find(globalObject.FullName());
   828 	TFindChunk find(globalObject.FullName());
   844 	test((r=find.Next(name))==KErrNone);
   829 	test((find.Next(name))==KErrNone);
   845 
   830 
   846 	test.Next(_L("Test open found object"));
   831 	test.Next(_L("Test open found object"));
   847 	test((r=testObject.Open(find))==KErrNone);
   832 	test((testObject.Open(find))==KErrNone);
   848 	testObject.Close();
   833 	testObject.Close();
   849 
   834 
   850 	test.Next(_L("Check can't find local object"));
   835 	test.Next(_L("Check can't find local object"));
   851 	TName objectName(localObject.FullName());
   836 	TName objectName(localObject.FullName());
   852 	find.Find(objectName);
   837 	find.Find(objectName);
   853 	test((r=find.Next(name))==PlatSecFindError);
   838 	test((find.Next(name))==PlatSecFindError);
   854 
   839 
   855 	test.Next(_L("Test open with null name"));
   840 	test.Next(_L("Test open with null name"));
   856 	test((r=testObject.OpenGlobal(KNullDesC,ETrue))==KErrNotFound);
   841 	test((testObject.OpenGlobal(KNullDesC,ETrue))==KErrNotFound);
   857 	testObject.Close();
   842 	testObject.Close();
   858 
   843 
   859 	test.Next(_L("Test open global object by name"));
   844 	test.Next(_L("Test open global object by name"));
   860 	test((r=testObject.OpenGlobal(globalObject.FullName(),ETrue))==KErrNone);
   845 	test((testObject.OpenGlobal(globalObject.FullName(),ETrue))==KErrNone);
   861 	testObject.Close();
   846 	testObject.Close();
   862 
   847 
   863 	test.Next(_L("Check can't open local object by name"));
   848 	test.Next(_L("Check can't open local object by name"));
   864 	test((r=testObject.OpenGlobal(localObject.FullName(),ETrue))==PlatSecFindError);
   849 	test((testObject.OpenGlobal(localObject.FullName(),ETrue))==PlatSecFindError);
   865 	testObject.Close();
   850 	testObject.Close();
   866 
   851 
   867 	test.Next(_L("Test duplicate global object in other process"));
   852 	test.Next(_L("Test duplicate global object in other process"));
   868 	test((r=DuplicateInOtherProcess(globalObject))==KErrNone);
   853 	test((DuplicateInOtherProcess(globalObject))==KErrNone);
   869 
   854 
   870 	test.Next(_L("Check can't duplicate local object in other process"));
   855 	test.Next(_L("Check can't duplicate local object in other process"));
   871 	test((r=DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError);
   856 	test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError);
   872 
   857 
   873 	test.Next(_L("Test duplicate global object in other thread"));
   858 	test.Next(_L("Test duplicate global object in other thread"));
   874 	test((r=DuplicateInOtherThread(globalObject))==KErrNone);
   859 	test((DuplicateInOtherThread(globalObject))==KErrNone);
   875 
   860 
   876 	test.Next(_L("Test duplicate local object in other thead"));
   861 	test.Next(_L("Test duplicate local object in other thead"));
   877 	test((r=DuplicateInOtherThread(localObject))==KErrNone);
   862 	test((DuplicateInOtherThread(localObject))==KErrNone);
   878 
   863 
   879 	test.Next(_L("Test Chunk protection"));
   864 	test.Next(_L("Test Chunk protection"));
   880 	{
   865 	{
   881 	RChunk protectedChunk;
   866 	RChunk protectedChunk;
   882 	test((r=protectedChunk.CreateGlobal(KNullDesC,0x1000,0x100000,EOwnerProcess))==KErrNone);
   867 	test((protectedChunk.CreateGlobal(KNullDesC,0x1000,0x100000,EOwnerProcess))==KErrNone);
   883 	test((r=Session.Send(CTestSession::ETestChunkAdjust,TIpcArgs(protectedChunk)))==KErrNone);
   868 	test((Session.Send(CTestSession::ETestChunkAdjust,TIpcArgs(protectedChunk)))==KErrNone);
   884 	protectedChunk.SetRestrictions(RChunk::EPreventAdjust);
   869 	protectedChunk.SetRestrictions(RChunk::EPreventAdjust);
   885 	test((r=Session.Send(CTestSession::ETestChunkAdjust,TIpcArgs(protectedChunk)))==KErrAccessDenied);
   870 	test((Session.Send(CTestSession::ETestChunkAdjust,TIpcArgs(protectedChunk)))==KErrAccessDenied);
   886 	protectedChunk.Close();
   871 	protectedChunk.Close();
   887 	}
   872 	}
   888 
   873 
   889 	test.Next(_L("Closing chunks"));
   874 	test.Next(_L("Closing chunks"));
   890 	globalObject.Close();
   875 	globalObject.Close();
   896 
   881 
   897 
   882 
   898 void TestSemaphores()
   883 void TestSemaphores()
   899 	{
   884 	{
   900 	TFullName name;
   885 	TFullName name;
   901 	TInt r;
   886 	
   902 
       
   903 	test.Start(_L("Creating semaphores"));
   887 	test.Start(_L("Creating semaphores"));
   904 	RSemaphore globalObject;
   888 	RSemaphore globalObject;
   905 	RSemaphore localObject;
   889 	RSemaphore localObject;
   906 	RSemaphore testObject;
   890 	RSemaphore testObject;
   907 	test((r=globalObject.CreateGlobal(_L("T_SOBJECT-test-global-semaphore"),1))==KErrNone);
   891 	test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-semaphore"),1))==KErrNone);
   908 	test((r=localObject.CreateLocal(1))==KErrNone);
   892 	test((localObject.CreateLocal(1))==KErrNone);
   909 
   893 
   910 	test.Next(_L("Test find global object"));
   894 	test.Next(_L("Test find global object"));
   911 	TFindSemaphore find(globalObject.FullName());
   895 	TFindSemaphore find(globalObject.FullName());
   912 	test((r=find.Next(name))==KErrNone);
   896 	test((find.Next(name))==KErrNone);
   913 
   897 
   914 	test.Next(_L("Test open found object"));
   898 	test.Next(_L("Test open found object"));
   915 	test((r=testObject.Open(find))==KErrNone);
   899 	test((testObject.Open(find))==KErrNone);
   916 	testObject.Close();
   900 	testObject.Close();
   917 
   901 
   918 	test.Next(_L("Check can't find local object"));
   902 	test.Next(_L("Check can't find local object"));
   919 	TName objectName(localObject.FullName());
   903 	TName objectName(localObject.FullName());
   920 	find.Find(objectName);
   904 	find.Find(objectName);
   921 	test((r=find.Next(name))==PlatSecFindError);
   905 	test((find.Next(name))==PlatSecFindError);
   922 
   906 
   923 	test.Next(_L("Test open with null name"));
   907 	test.Next(_L("Test open with null name"));
   924 	test((r=testObject.OpenGlobal(KNullDesC))==KErrNotFound);
   908 	test((testObject.OpenGlobal(KNullDesC))==KErrNotFound);
   925 	testObject.Close();
   909 	testObject.Close();
   926 
   910 
   927 	test.Next(_L("Test open global object by name"));
   911 	test.Next(_L("Test open global object by name"));
   928 	test((r=testObject.OpenGlobal(globalObject.FullName()))==KErrNone);
   912 	test((testObject.OpenGlobal(globalObject.FullName()))==KErrNone);
   929 	testObject.Close();
   913 	testObject.Close();
   930 
   914 
   931 	test.Next(_L("Check can't open local object by name"));
   915 	test.Next(_L("Check can't open local object by name"));
   932 	test((r=testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError);
   916 	test((testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError);
   933 	testObject.Close();
   917 	testObject.Close();
   934 
   918 
   935 	test.Next(_L("Test duplicate global object in other process"));
   919 	test.Next(_L("Test duplicate global object in other process"));
   936 	test((r=DuplicateInOtherProcess(globalObject))==KErrNone);
   920 	test((DuplicateInOtherProcess(globalObject))==KErrNone);
   937 
   921 
   938 	test.Next(_L("Check can't duplicate local object in other process"));
   922 	test.Next(_L("Check can't duplicate local object in other process"));
   939 	test((r=DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError);
   923 	test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError);
   940 
   924 
   941 	test.Next(_L("Test duplicate global object in other thread"));
   925 	test.Next(_L("Test duplicate global object in other thread"));
   942 	test((r=DuplicateInOtherThread(globalObject))==KErrNone);
   926 	test((DuplicateInOtherThread(globalObject))==KErrNone);
   943 
   927 
   944 	test.Next(_L("Test duplicate local object in other thead"));
   928 	test.Next(_L("Test duplicate local object in other thead"));
   945 	test((r=DuplicateInOtherThread(localObject))==KErrNone);
   929 	test((DuplicateInOtherThread(localObject))==KErrNone);
   946 
   930 
   947 	test.Next(_L("Closing Semaphores"));
   931 	test.Next(_L("Closing Semaphores"));
   948 	globalObject.Close();
   932 	globalObject.Close();
   949 	localObject.Close();
   933 	localObject.Close();
   950 
   934 
   954 
   938 
   955 
   939 
   956 void TestMutexes()
   940 void TestMutexes()
   957 	{
   941 	{
   958 	TFullName name;
   942 	TFullName name;
   959 	TInt r;
   943 	
   960 
       
   961 	test.Start(_L("Creating mutexes"));
   944 	test.Start(_L("Creating mutexes"));
   962 	RMutex globalObject;
   945 	RMutex globalObject;
   963 	RMutex localObject;
   946 	RMutex localObject;
   964 	RMutex testObject;
   947 	RMutex testObject;
   965 	test((r=globalObject.CreateGlobal(_L("T_SOBJECT-test-global-mutex")))==KErrNone);
   948 	test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-mutex")))==KErrNone);
   966 	test((r=localObject.CreateLocal())==KErrNone);
   949 	test((localObject.CreateLocal())==KErrNone);
   967 
   950 
   968 	test.Next(_L("Test find global object"));
   951 	test.Next(_L("Test find global object"));
   969 	TFindMutex find(globalObject.FullName());
   952 	TFindMutex find(globalObject.FullName());
   970 	test((r=find.Next(name))==KErrNone);
   953 	test((find.Next(name))==KErrNone);
   971 
   954 
   972 	test.Next(_L("Test open found object"));
   955 	test.Next(_L("Test open found object"));
   973 	test((r=testObject.Open(find))==KErrNone);
   956 	test((testObject.Open(find))==KErrNone);
   974 	testObject.Close();
   957 	testObject.Close();
   975 
   958 
   976 	test.Next(_L("Check can't find local object"));
   959 	test.Next(_L("Check can't find local object"));
   977 	TName objectName(localObject.FullName());
   960 	TName objectName(localObject.FullName());
   978 	find.Find(objectName);
   961 	find.Find(objectName);
   979 	test((r=find.Next(name))==PlatSecFindError);
   962 	test((find.Next(name))==PlatSecFindError);
   980 
   963 
   981 	test.Next(_L("Test open with null name"));
   964 	test.Next(_L("Test open with null name"));
   982 	test((r=testObject.OpenGlobal(KNullDesC))==KErrNotFound);
   965 	test((testObject.OpenGlobal(KNullDesC))==KErrNotFound);
   983 	testObject.Close();
   966 	testObject.Close();
   984 
   967 
   985 	test.Next(_L("Test open global object by name"));
   968 	test.Next(_L("Test open global object by name"));
   986 	test((r=testObject.OpenGlobal(globalObject.FullName()))==KErrNone);
   969 	test((testObject.OpenGlobal(globalObject.FullName()))==KErrNone);
   987 	testObject.Close();
   970 	testObject.Close();
   988 
   971 
   989 	test.Next(_L("Check can't open local object by name"));
   972 	test.Next(_L("Check can't open local object by name"));
   990 	test((r=testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError);
   973 	test((testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError);
   991 	testObject.Close();
   974 	testObject.Close();
   992 
   975 
   993 	test.Next(_L("Test duplicate global object in other process"));
   976 	test.Next(_L("Test duplicate global object in other process"));
   994 	test((r=DuplicateInOtherProcess(globalObject))==KErrNone);
   977 	test((DuplicateInOtherProcess(globalObject))==KErrNone);
   995 
   978 
   996 	test.Next(_L("Check can't duplicate local object in other process"));
   979 	test.Next(_L("Check can't duplicate local object in other process"));
   997 	test((r=DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError);
   980 	test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError);
   998 
   981 
   999 	test.Next(_L("Test duplicate global object in other thread"));
   982 	test.Next(_L("Test duplicate global object in other thread"));
  1000 	test((r=DuplicateInOtherThread(globalObject))==KErrNone);
   983 	test((DuplicateInOtherThread(globalObject))==KErrNone);
  1001 
   984 
  1002 	test.Next(_L("Test duplicate local object in other thead"));
   985 	test.Next(_L("Test duplicate local object in other thead"));
  1003 	test((r=DuplicateInOtherThread(localObject))==KErrNone);
   986 	test((DuplicateInOtherThread(localObject))==KErrNone);
  1004 
   987 
  1005 	test.Next(_L("Closing mutexes"));
   988 	test.Next(_L("Closing mutexes"));
  1006 	globalObject.Close();
   989 	globalObject.Close();
  1007 	localObject.Close();
   990 	localObject.Close();
  1008 
   991 
  1011 
   994 
  1012 
   995 
  1013 
   996 
  1014 void TestMessageQueues()
   997 void TestMessageQueues()
  1015 	{
   998 	{
  1016 	TInt r;
       
  1017 
       
  1018 	test.Start(_L("Creating message queues"));
   999 	test.Start(_L("Creating message queues"));
  1019 	RMsgQueue<TInt> globalObject;
  1000 	RMsgQueue<TInt> globalObject;
  1020 	RMsgQueue<TInt> localObject;
  1001 	RMsgQueue<TInt> localObject;
  1021 	RMsgQueue<TInt> testObject;
  1002 	RMsgQueue<TInt> testObject;
  1022 	test((r=globalObject.CreateGlobal(_L("T_SOBJECT-test-global-msgqueue"),1))==KErrNone);
  1003 	test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-msgqueue"),1))==KErrNone);
  1023 	test((r=localObject.CreateLocal(1))==KErrNone);
  1004 	test((localObject.CreateLocal(1))==KErrNone);
  1024 
  1005 
  1025 	test.Next(_L("Test open with null name"));
  1006 	test.Next(_L("Test open with null name"));
  1026 	test((r=testObject.OpenGlobal(KNullDesC))==KErrNotFound);
  1007 	test((testObject.OpenGlobal(KNullDesC))==KErrNotFound);
  1027 	testObject.Close();
  1008 	testObject.Close();
  1028 
  1009 
  1029 	test.Next(_L("Test open global object by name"));
  1010 	test.Next(_L("Test open global object by name"));
  1030 	test((r=testObject.OpenGlobal(globalObject.FullName()))==KErrNone);
  1011 	test((testObject.OpenGlobal(globalObject.FullName()))==KErrNone);
  1031 	testObject.Close();
  1012 	testObject.Close();
  1032 
  1013 
  1033 	test.Next(_L("Check can't open local object by name"));
  1014 	test.Next(_L("Check can't open local object by name"));
  1034 	test((r=testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError);
  1015 	test((testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError);
  1035 	testObject.Close();
  1016 	testObject.Close();
  1036 
  1017 
  1037 	test.Next(_L("Test duplicate global object in other process"));
  1018 	test.Next(_L("Test duplicate global object in other process"));
  1038 	test((r=DuplicateInOtherProcess(globalObject))==KErrNone);
  1019 	test((DuplicateInOtherProcess(globalObject))==KErrNone);
  1039 
  1020 
  1040 	test.Next(_L("Check can't duplicate local object in other process"));
  1021 	test.Next(_L("Check can't duplicate local object in other process"));
  1041 	test((r=DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError);
  1022 	test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError);
  1042 
  1023 
  1043 	test.Next(_L("Test duplicate global object in other thread"));
  1024 	test.Next(_L("Test duplicate global object in other thread"));
  1044 	test((r=DuplicateInOtherThread(globalObject))==KErrNone);
  1025 	test((DuplicateInOtherThread(globalObject))==KErrNone);
  1045 
  1026 
  1046 	test.Next(_L("Test duplicate local object in other thead"));
  1027 	test.Next(_L("Test duplicate local object in other thead"));
  1047 	test((r=DuplicateInOtherThread(localObject))==KErrNone);
  1028 	test((DuplicateInOtherThread(localObject))==KErrNone);
  1048 
  1029 
  1049 	test.Next(_L("Closing message queues"));
  1030 	test.Next(_L("Closing message queues"));
  1050 	globalObject.Close();
  1031 	globalObject.Close();
  1051 	localObject.Close();
  1032 	localObject.Close();
  1052 
  1033 
  1054 	}
  1035 	}
  1055 
  1036 
  1056 
  1037 
  1057 
  1038 
  1058 void TestConditionVariables()
  1039 void TestConditionVariables()
  1059 	{
  1040 	{	
  1060 	TInt r;
       
  1061 
       
  1062 	test.Start(_L("Creating condition variables"));
  1041 	test.Start(_L("Creating condition variables"));
  1063 	RCondVar globalObject;
  1042 	RCondVar globalObject;
  1064 	RCondVar localObject;
  1043 	RCondVar localObject;
  1065 	RCondVar testObject;
  1044 	RCondVar testObject;
  1066 	test((r=globalObject.CreateGlobal(_L("T_SOBJECT-test-global-condvar")))==KErrNone);
  1045 	test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-condvar")))==KErrNone);
  1067 	test((r=localObject.CreateLocal())==KErrNone);
  1046 	test((localObject.CreateLocal())==KErrNone);
  1068 
  1047 
  1069 	test.Next(_L("Test open with null name"));
  1048 	test.Next(_L("Test open with null name"));
  1070 	test((r=testObject.OpenGlobal(KNullDesC))==KErrNotFound);
  1049 	test((testObject.OpenGlobal(KNullDesC))==KErrNotFound);
  1071 	testObject.Close();
  1050 	testObject.Close();
  1072 
  1051 
  1073 	test.Next(_L("Test open global object by name"));
  1052 	test.Next(_L("Test open global object by name"));
  1074 	test((r=testObject.OpenGlobal(globalObject.FullName()))==KErrNone);
  1053 	test((testObject.OpenGlobal(globalObject.FullName()))==KErrNone);
  1075 	testObject.Close();
  1054 	testObject.Close();
  1076 
  1055 
  1077 	test.Next(_L("Check can't open local object by name"));
  1056 	test.Next(_L("Check can't open local object by name"));
  1078 	test((r=testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError);
  1057 	test((testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError);
  1079 	testObject.Close();
  1058 	testObject.Close();
  1080 
  1059 
  1081 	test.Next(_L("Test duplicate global object in other process"));
  1060 	test.Next(_L("Test duplicate global object in other process"));
  1082 	test((r=DuplicateInOtherProcess(globalObject))==KErrNone);
  1061 	test((DuplicateInOtherProcess(globalObject))==KErrNone);
  1083 
  1062 
  1084 	test.Next(_L("Check can't duplicate local object in other process"));
  1063 	test.Next(_L("Check can't duplicate local object in other process"));
  1085 	test((r=DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError);
  1064 	test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError);
  1086 
  1065 
  1087 	test.Next(_L("Test duplicate global object in other thread"));
  1066 	test.Next(_L("Test duplicate global object in other thread"));
  1088 	test((r=DuplicateInOtherThread(globalObject))==KErrNone);
  1067 	test((DuplicateInOtherThread(globalObject))==KErrNone);
  1089 
  1068 
  1090 	test.Next(_L("Test duplicate local object in other thead"));
  1069 	test.Next(_L("Test duplicate local object in other thead"));
  1091 	test((r=DuplicateInOtherThread(localObject))==KErrNone);
  1070 	test((DuplicateInOtherThread(localObject))==KErrNone);
  1092 
  1071 
  1093 	test.Next(_L("Closing message queues"));
  1072 	test.Next(_L("Closing message queues"));
  1094 	globalObject.Close();
  1073 	globalObject.Close();
  1095 	localObject.Close();
  1074 	localObject.Close();
  1096 
  1075 
  1102 void TestIPCHandles()
  1081 void TestIPCHandles()
  1103 	{
  1082 	{
  1104 	RTestProcess server;
  1083 	RTestProcess server;
  1105 	TRequestStatus rendezvous;
  1084 	TRequestStatus rendezvous;
  1106 	TInt r;
  1085 	TInt r;
  1107 
  1086 	
  1108 	test.Next(_L("Test sending LogicalChannel handles"));
  1087 	test.Next(_L("Test sending LogicalChannel handles"));
  1109 	{
  1088 	{
  1110 	RLddTest localLdd;
  1089 	RLddTest localLdd;
  1111 	RLddTest protectedLdd;
  1090 	RLddTest protectedLdd;
  1112 	RLddTest returnLdd;
  1091 	RLddTest returnLdd;
  1398 		return DoTestProcess(function,arg1,arg2);
  1377 		return DoTestProcess(function,arg1,arg2);
  1399 		}
  1378 		}
  1400 
  1379 
  1401 
  1380 
  1402 	test.Title();
  1381 	test.Title();
  1403 	TInt r;
       
  1404 	
  1382 	
  1405 	test.Start(_L("Starting test servers"));
  1383 	test.Start(_L("Starting test servers"));
  1406 	RTestProcess server;
  1384 	RTestProcess server;
  1407 	TRequestStatus rendezvous;
  1385 	TRequestStatus rendezvous;
  1408 	TRequestStatus svrstat;
  1386 	TRequestStatus svrstat;
  1411 	server.Rendezvous(rendezvous);
  1389 	server.Rendezvous(rendezvous);
  1412 	server.Resume();
  1390 	server.Resume();
  1413 	User::WaitForRequest(rendezvous);
  1391 	User::WaitForRequest(rendezvous);
  1414 	test(rendezvous==KServerRendezvous);
  1392 	test(rendezvous==KServerRendezvous);
  1415 	server.Close();
  1393 	server.Close();
  1416 	test((r=StartServerInThread(EAnonymousServer))==KErrNone);
  1394 	test((StartServerInThread(EAnonymousServer))==KErrNone);
  1417 
  1395 
  1418 	test.Next(_L("Openning server session"));
  1396 	test.Next(_L("Openning server session"));
  1419 	test((r=Session.Connect())==KErrNone);
  1397 	test((Session.Connect())==KErrNone);
  1420 
  1398 
  1421 	test.Next(_L("Test Find and Open PhysicalDevices"));
  1399 	test.Next(_L("Test Find and Open PhysicalDevices"));
  1422 	TestPhysicalDevices();
  1400 	TestPhysicalDevices();
  1423 
  1401 
  1424 	test.Next(_L("Test Find and Open LogicalDevices"));
  1402 	test.Next(_L("Test Find and Open LogicalDevices"));