616 |
622 |
617 |
623 |
618 void TestPhysicalDevices() |
624 void TestPhysicalDevices() |
619 { |
625 { |
620 TFullName name; |
626 TFullName name; |
|
627 TInt r; |
|
628 |
621 test.Start(_L("Test find named object")); |
629 test.Start(_L("Test find named object")); |
622 TFindPhysicalDevice find(_L("*")); |
630 TFindPhysicalDevice find(_L("*")); |
623 test((find.Next(name))==KErrNone); |
631 test((r=find.Next(name))==KErrNone); |
624 |
632 |
625 test.Next(_L("Try open found object")); |
633 test.Next(_L("Try open found object")); |
626 RTestHandle testObject; |
634 RTestHandle testObject; |
627 test((testObject.Open(find))==PlatSecProcessIsolationError); |
635 test((r=testObject.Open(find))==PlatSecProcessIsolationError); |
628 testObject.Close(); |
636 testObject.Close(); |
629 |
637 |
630 test.End(); |
638 test.End(); |
631 } |
639 } |
632 |
640 |
633 |
641 |
634 |
642 |
635 void TestLogicalDevices() |
643 void TestLogicalDevices() |
636 { |
644 { |
637 TFullName name; |
645 TFullName name; |
|
646 TInt r; |
638 RDevice device; |
647 RDevice device; |
639 |
648 |
640 test.Start(_L("Test find named object")); |
649 test.Start(_L("Test find named object")); |
641 TFindLogicalDevice find(_L("*")); |
650 TFindLogicalDevice find(_L("*")); |
642 test((find.Next(name))==KErrNone); |
651 test((r=find.Next(name))==KErrNone); |
643 |
652 |
644 test.Next(_L("Test open found object")); |
653 test.Next(_L("Test open found object")); |
645 test((device.Open(find))==KErrNone); |
654 test((r=device.Open(find))==KErrNone); |
646 |
655 |
647 test.Next(_L("Test duplicate object in other thread")); |
656 test.Next(_L("Test duplicate object in other thread")); |
648 test((DuplicateInOtherThread(device))==KErrNone); |
657 test((r=DuplicateInOtherThread(device))==KErrNone); |
649 |
658 |
650 test.Next(_L("Test duplicate object in other process")); |
659 test.Next(_L("Test duplicate object in other process")); |
651 test((DuplicateInOtherProcess(device))==KErrNone); |
660 test((r=DuplicateInOtherProcess(device))==KErrNone); |
652 |
661 |
653 device.Close(); |
662 device.Close(); |
654 |
663 |
655 test.Next(_L("Test open device by name")); |
664 test.Next(_L("Test open device by name")); |
656 test((device.Open(name))==KErrNone); |
665 test((r=device.Open(name))==KErrNone); |
657 device.Close(); |
666 device.Close(); |
658 |
667 |
659 test.End(); |
668 test.End(); |
660 } |
669 } |
661 |
670 |
662 |
671 |
663 |
672 |
664 void TestLibraries() |
673 void TestLibraries() |
665 { |
674 { |
666 TFullName name; |
675 TFullName name; |
|
676 TInt r; |
|
677 |
667 test.Start(_L("Test find named object")); |
678 test.Start(_L("Test find named object")); |
668 TFindLibrary find(_L("*")); |
679 TFindLibrary find(_L("*")); |
669 test((find.Next(name))==KErrNone); |
680 test((r=find.Next(name))==KErrNone); |
670 |
681 |
671 test.Next(_L("Try open found object")); |
682 test.Next(_L("Try open found object")); |
672 RTestHandle testObject; |
683 RTestHandle testObject; |
673 test((testObject.Open(find))==PlatSecProcessIsolationError); |
684 test((r=testObject.Open(find))==PlatSecProcessIsolationError); |
674 testObject.Close(); |
685 testObject.Close(); |
675 |
686 |
676 test.End(); |
687 test.End(); |
677 } |
688 } |
678 |
689 |
679 |
690 |
680 |
691 |
681 void TestServers() |
692 void TestServers() |
682 { |
693 { |
683 TFullName name; |
694 TFullName name; |
|
695 TInt r; |
684 RServer2 localObject(Servers[EAnonymousServer]); |
696 RServer2 localObject(Servers[EAnonymousServer]); |
685 |
697 |
686 test.Start(_L("Test find named object")); |
698 test.Start(_L("Test find named object")); |
687 TFindServer find(ServerName(EMainServer)); |
699 TFindServer find(ServerName(EMainServer)); |
688 test((find.Next(name))==KErrNone); |
700 test((r=find.Next(name))==KErrNone); |
689 |
701 |
690 test.Next(_L("Try open found object")); |
702 test.Next(_L("Try open found object")); |
691 RTestHandle testObject; |
703 RTestHandle testObject; |
692 test((testObject.Open(find))==KErrPermissionDenied); |
704 test((r=testObject.Open(find))==KErrPermissionDenied); |
693 |
705 |
694 test.Next(_L("Test duplicate named server in other thread")); |
706 test.Next(_L("Test duplicate named server in other thread")); |
695 test((Session.Send(CTestSession::ETestServerDuplicateInThread))==KErrNone); |
707 test((r=Session.Send(CTestSession::ETestServerDuplicateInThread))==KErrNone); |
696 |
708 |
697 test.Next(_L("Try duplicate named server in other process")); |
709 test.Next(_L("Try duplicate named server in other process")); |
698 test((Session.Send(CTestSession::ETestServerDuplicateInProcess))==KErrPermissionDenied); |
710 test((r=Session.Send(CTestSession::ETestServerDuplicateInProcess))==KErrPermissionDenied); |
699 |
711 |
700 test.Next(_L("Test duplicate unnamed server in other thread")); |
712 test.Next(_L("Test duplicate unnamed server in other thread")); |
701 test((DuplicateInOtherThread(localObject))==KErrNone); |
713 test((r=DuplicateInOtherThread(localObject))==KErrNone); |
702 |
714 |
703 test.Next(_L("Try duplicate unnamed server in other process")); |
715 test.Next(_L("Try duplicate unnamed server in other process")); |
704 test((DuplicateInOtherProcess(localObject))==KErrPermissionDenied); |
716 test((r=DuplicateInOtherProcess(localObject))==KErrPermissionDenied); |
705 |
717 |
706 test.End(); |
718 test.End(); |
707 } |
719 } |
708 |
720 |
709 |
721 |
710 |
722 |
711 void TestProcesses() |
723 void TestProcesses() |
712 { |
724 { |
713 TFullName name; |
725 TFullName name; |
|
726 TInt r; |
714 RProcess process; |
727 RProcess process; |
715 |
728 |
716 test.Start(_L("Test find named object")); |
729 test.Start(_L("Test find named object")); |
717 TFindProcess find(_L("EKern*")); |
730 TFindProcess find(_L("EKern*")); |
718 test((find.Next(name))==KErrNone); |
731 test((r=find.Next(name))==KErrNone); |
719 |
732 |
720 test.Next(_L("Test open found object")); |
733 test.Next(_L("Test open found object")); |
721 test((process.Open(find))==KErrNone); |
734 test((r=process.Open(find))==KErrNone); |
722 |
735 |
723 test.Next(_L("Test duplicate object in other thread")); |
736 test.Next(_L("Test duplicate object in other thread")); |
724 test((DuplicateInOtherThread(process))==KErrNone); |
737 test((r=DuplicateInOtherThread(process))==KErrNone); |
725 |
738 |
726 test.Next(_L("Test duplicate object in other process")); |
739 test.Next(_L("Test duplicate object in other process")); |
727 test((DuplicateInOtherProcess(process))==KErrNone); |
740 test((r=DuplicateInOtherProcess(process))==KErrNone); |
728 |
741 |
729 process.Close(); |
742 process.Close(); |
730 |
743 |
731 test.Next(_L("Test open process by name")); |
744 test.Next(_L("Test open process by name")); |
732 test((process.Open(name))==KErrNone); |
745 test((r=process.Open(name))==KErrNone); |
733 TProcessId id=process.Id(); |
746 TProcessId id=process.Id(); |
734 process.Close(); |
747 process.Close(); |
735 |
748 |
736 test.Next(_L("Test open process by id")); |
749 test.Next(_L("Test open process by id")); |
737 test((process.Open(id))==KErrNone); |
750 test((r=process.Open(id))==KErrNone); |
738 test(name==process.FullName()); |
751 test(name==process.FullName()); |
739 process.Close(); |
752 process.Close(); |
740 |
753 |
741 test.End(); |
754 test.End(); |
742 } |
755 } |
744 |
757 |
745 |
758 |
746 void TestThreads() |
759 void TestThreads() |
747 { |
760 { |
748 TFullName name; |
761 TFullName name; |
749 |
762 TInt r; |
|
763 |
750 test.Start(_L("Creating threads")); |
764 test.Start(_L("Creating threads")); |
751 RThread globalObject; |
765 RThread globalObject; |
752 RThread localObject; |
766 RThread localObject; |
753 RThread testObject; |
767 RThread testObject; |
754 test((globalObject.Create(_L("T_SOBJECT-test-global-thread"),TestThreadDuplicate,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,NULL))==KErrNone); |
768 test((r=globalObject.Create(_L("T_SOBJECT-test-global-thread"),TestThreadDuplicate,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,NULL))==KErrNone); |
755 test((localObject.Create(_L(""),TestThreadDuplicate,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,NULL))==KErrNone); |
769 test((r=localObject.Create(_L(""),TestThreadDuplicate,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,NULL))==KErrNone); |
756 |
770 |
757 test.Next(_L("Test find named thread")); |
771 test.Next(_L("Test find named thread")); |
758 TFindThread find(globalObject.FullName()); |
772 TFindThread find(globalObject.FullName()); |
759 test((find.Next(name))==KErrNone); |
773 test((r=find.Next(name))==KErrNone); |
760 |
774 |
761 test.Next(_L("Test open found object")); |
775 test.Next(_L("Test open found object")); |
762 test((testObject.Open(find))==KErrNone); |
776 test((r=testObject.Open(find))==KErrNone); |
763 testObject.Close(); |
777 testObject.Close(); |
764 |
778 |
765 test.Next(_L("Check can't find unnamed thread")); |
779 test.Next(_L("Check can't find unnamed thread")); |
766 TName objectName(localObject.FullName()); |
780 TName objectName(localObject.FullName()); |
767 find.Find(objectName); |
781 find.Find(objectName); |
768 test((find.Next(name))==PlatSecFindError); |
782 test((r=find.Next(name))==PlatSecFindError); |
769 |
783 |
770 test.Next(_L("Test open named thread by name")); |
784 test.Next(_L("Test open named thread by name")); |
771 test((testObject.Open(globalObject.FullName()))==KErrNone); |
785 test((r=testObject.Open(globalObject.FullName()))==KErrNone); |
772 testObject.Close(); |
786 testObject.Close(); |
773 |
787 |
774 test.Next(_L("Check can't open unnamed thread by name")); |
788 test.Next(_L("Check can't open unnamed thread by name")); |
775 test((testObject.Open(localObject.FullName()))==PlatSecFindError); |
789 test((r=testObject.Open(localObject.FullName()))==PlatSecFindError); |
776 testObject.Close(); |
790 testObject.Close(); |
777 |
791 |
778 test.Next(_L("Check can't open with no name")); |
792 test.Next(_L("Check can't open with no name")); |
779 test((testObject.Open(KNullDesC))==KErrNotFound); |
793 test((r=testObject.Open(KNullDesC))==KErrNotFound); |
780 testObject.Close(); |
794 testObject.Close(); |
781 |
795 |
782 test.Next(_L("Test open named thread by id (in same process)")); |
796 test.Next(_L("Test open named thread by id (in same process)")); |
783 test((testObject.Open(globalObject.Id()))==KErrNone); |
797 test((r=testObject.Open(globalObject.Id()))==KErrNone); |
784 testObject.Close(); |
798 testObject.Close(); |
785 |
799 |
786 test.Next(_L("Test open named thread by id (in other process)")); |
800 test.Next(_L("Test open named thread by id (in other process)")); |
787 test((OpenThreadByIdInOtherProcess(globalObject.Id()))==KErrNone); |
801 test((r=OpenThreadByIdInOtherProcess(globalObject.Id()))==KErrNone); |
788 |
802 |
789 test.Next(_L("Test open unnamed thread by id (in same process)")); |
803 test.Next(_L("Test open unnamed thread by id (in same process)")); |
790 test((testObject.Open(localObject.Id()))==KErrNone); |
804 test((r=testObject.Open(localObject.Id()))==KErrNone); |
791 |
805 |
792 test.Next(_L("Check can't open unnamed thread by id (in other process)")); |
806 test.Next(_L("Check can't open unnamed thread by id (in other process)")); |
793 test((OpenThreadByIdInOtherProcess(localObject.Id()))==PlatSecProcessIsolationError); |
807 test((r=OpenThreadByIdInOtherProcess(localObject.Id()))==PlatSecProcessIsolationError); |
794 |
808 |
795 test.Next(_L("Test duplicate named thread in other process")); |
809 test.Next(_L("Test duplicate named thread in other process")); |
796 test((DuplicateInOtherProcess(globalObject))==KErrNone); |
810 test((r=DuplicateInOtherProcess(globalObject))==KErrNone); |
797 |
811 |
798 test.Next(_L("Check can't duplicate unnamed thread in other process")); |
812 test.Next(_L("Check can't duplicate unnamed thread in other process")); |
799 test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); |
813 test((r=DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); |
800 |
814 |
801 test.Next(_L("Test duplicate named thread in other thread")); |
815 test.Next(_L("Test duplicate named thread in other thread")); |
802 test((DuplicateInOtherThread(globalObject))==KErrNone); |
816 test((r=DuplicateInOtherThread(globalObject))==KErrNone); |
803 |
817 |
804 test.Next(_L("Test duplicate unnamed thread in other thead")); |
818 test.Next(_L("Test duplicate unnamed thread in other thead")); |
805 test((DuplicateInOtherThread(localObject))==KErrNone); |
819 test((r=DuplicateInOtherThread(localObject))==KErrNone); |
806 |
820 |
807 test.Next(_L("Closing threads")); |
821 test.Next(_L("Closing threads")); |
808 globalObject.Close(); |
822 globalObject.Close(); |
809 localObject.Close(); |
823 localObject.Close(); |
810 |
824 |
814 |
828 |
815 |
829 |
816 void TestChunks() |
830 void TestChunks() |
817 { |
831 { |
818 TFullName name; |
832 TFullName name; |
819 |
833 TInt r; |
|
834 |
820 test.Start(_L("Creating chunks")); |
835 test.Start(_L("Creating chunks")); |
821 RChunk globalObject; |
836 RChunk globalObject; |
822 RChunk localObject; |
837 RChunk localObject; |
823 RChunk testObject; |
838 RChunk testObject; |
824 test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-chunk"),4096,1024*1024))==KErrNone); |
839 test((r=globalObject.CreateGlobal(_L("T_SOBJECT-test-global-chunk"),4096,1024*1024))==KErrNone); |
825 test((localObject.CreateLocal(4096,1024*1024))==KErrNone); |
840 test((r=localObject.CreateLocal(4096,1024*1024))==KErrNone); |
826 |
841 |
827 test.Next(_L("Test find global object")); |
842 test.Next(_L("Test find global object")); |
828 TFindChunk find(globalObject.FullName()); |
843 TFindChunk find(globalObject.FullName()); |
829 test((find.Next(name))==KErrNone); |
844 test((r=find.Next(name))==KErrNone); |
830 |
845 |
831 test.Next(_L("Test open found object")); |
846 test.Next(_L("Test open found object")); |
832 test((testObject.Open(find))==KErrNone); |
847 test((r=testObject.Open(find))==KErrNone); |
833 testObject.Close(); |
848 testObject.Close(); |
834 |
849 |
835 test.Next(_L("Check can't find local object")); |
850 test.Next(_L("Check can't find local object")); |
836 TName objectName(localObject.FullName()); |
851 TName objectName(localObject.FullName()); |
837 find.Find(objectName); |
852 find.Find(objectName); |
838 test((find.Next(name))==PlatSecFindError); |
853 test((r=find.Next(name))==PlatSecFindError); |
839 |
854 |
840 test.Next(_L("Test open with null name")); |
855 test.Next(_L("Test open with null name")); |
841 test((testObject.OpenGlobal(KNullDesC,ETrue))==KErrNotFound); |
856 test((r=testObject.OpenGlobal(KNullDesC,ETrue))==KErrNotFound); |
842 testObject.Close(); |
857 testObject.Close(); |
843 |
858 |
844 test.Next(_L("Test open global object by name")); |
859 test.Next(_L("Test open global object by name")); |
845 test((testObject.OpenGlobal(globalObject.FullName(),ETrue))==KErrNone); |
860 test((r=testObject.OpenGlobal(globalObject.FullName(),ETrue))==KErrNone); |
846 testObject.Close(); |
861 testObject.Close(); |
847 |
862 |
848 test.Next(_L("Check can't open local object by name")); |
863 test.Next(_L("Check can't open local object by name")); |
849 test((testObject.OpenGlobal(localObject.FullName(),ETrue))==PlatSecFindError); |
864 test((r=testObject.OpenGlobal(localObject.FullName(),ETrue))==PlatSecFindError); |
850 testObject.Close(); |
865 testObject.Close(); |
851 |
866 |
852 test.Next(_L("Test duplicate global object in other process")); |
867 test.Next(_L("Test duplicate global object in other process")); |
853 test((DuplicateInOtherProcess(globalObject))==KErrNone); |
868 test((r=DuplicateInOtherProcess(globalObject))==KErrNone); |
854 |
869 |
855 test.Next(_L("Check can't duplicate local object in other process")); |
870 test.Next(_L("Check can't duplicate local object in other process")); |
856 test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); |
871 test((r=DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); |
857 |
872 |
858 test.Next(_L("Test duplicate global object in other thread")); |
873 test.Next(_L("Test duplicate global object in other thread")); |
859 test((DuplicateInOtherThread(globalObject))==KErrNone); |
874 test((r=DuplicateInOtherThread(globalObject))==KErrNone); |
860 |
875 |
861 test.Next(_L("Test duplicate local object in other thead")); |
876 test.Next(_L("Test duplicate local object in other thead")); |
862 test((DuplicateInOtherThread(localObject))==KErrNone); |
877 test((r=DuplicateInOtherThread(localObject))==KErrNone); |
863 |
878 |
864 test.Next(_L("Test Chunk protection")); |
879 test.Next(_L("Test Chunk protection")); |
865 { |
880 { |
866 RChunk protectedChunk; |
881 RChunk protectedChunk; |
867 test((protectedChunk.CreateGlobal(KNullDesC,0x1000,0x100000,EOwnerProcess))==KErrNone); |
882 test((r=protectedChunk.CreateGlobal(KNullDesC,0x1000,0x100000,EOwnerProcess))==KErrNone); |
868 test((Session.Send(CTestSession::ETestChunkAdjust,TIpcArgs(protectedChunk)))==KErrNone); |
883 test((r=Session.Send(CTestSession::ETestChunkAdjust,TIpcArgs(protectedChunk)))==KErrNone); |
869 protectedChunk.SetRestrictions(RChunk::EPreventAdjust); |
884 protectedChunk.SetRestrictions(RChunk::EPreventAdjust); |
870 test((Session.Send(CTestSession::ETestChunkAdjust,TIpcArgs(protectedChunk)))==KErrAccessDenied); |
885 test((r=Session.Send(CTestSession::ETestChunkAdjust,TIpcArgs(protectedChunk)))==KErrAccessDenied); |
871 protectedChunk.Close(); |
886 protectedChunk.Close(); |
872 } |
887 } |
873 |
888 |
874 test.Next(_L("Closing chunks")); |
889 test.Next(_L("Closing chunks")); |
875 globalObject.Close(); |
890 globalObject.Close(); |
881 |
896 |
882 |
897 |
883 void TestSemaphores() |
898 void TestSemaphores() |
884 { |
899 { |
885 TFullName name; |
900 TFullName name; |
886 |
901 TInt r; |
|
902 |
887 test.Start(_L("Creating semaphores")); |
903 test.Start(_L("Creating semaphores")); |
888 RSemaphore globalObject; |
904 RSemaphore globalObject; |
889 RSemaphore localObject; |
905 RSemaphore localObject; |
890 RSemaphore testObject; |
906 RSemaphore testObject; |
891 test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-semaphore"),1))==KErrNone); |
907 test((r=globalObject.CreateGlobal(_L("T_SOBJECT-test-global-semaphore"),1))==KErrNone); |
892 test((localObject.CreateLocal(1))==KErrNone); |
908 test((r=localObject.CreateLocal(1))==KErrNone); |
893 |
909 |
894 test.Next(_L("Test find global object")); |
910 test.Next(_L("Test find global object")); |
895 TFindSemaphore find(globalObject.FullName()); |
911 TFindSemaphore find(globalObject.FullName()); |
896 test((find.Next(name))==KErrNone); |
912 test((r=find.Next(name))==KErrNone); |
897 |
913 |
898 test.Next(_L("Test open found object")); |
914 test.Next(_L("Test open found object")); |
899 test((testObject.Open(find))==KErrNone); |
915 test((r=testObject.Open(find))==KErrNone); |
900 testObject.Close(); |
916 testObject.Close(); |
901 |
917 |
902 test.Next(_L("Check can't find local object")); |
918 test.Next(_L("Check can't find local object")); |
903 TName objectName(localObject.FullName()); |
919 TName objectName(localObject.FullName()); |
904 find.Find(objectName); |
920 find.Find(objectName); |
905 test((find.Next(name))==PlatSecFindError); |
921 test((r=find.Next(name))==PlatSecFindError); |
906 |
922 |
907 test.Next(_L("Test open with null name")); |
923 test.Next(_L("Test open with null name")); |
908 test((testObject.OpenGlobal(KNullDesC))==KErrNotFound); |
924 test((r=testObject.OpenGlobal(KNullDesC))==KErrNotFound); |
909 testObject.Close(); |
925 testObject.Close(); |
910 |
926 |
911 test.Next(_L("Test open global object by name")); |
927 test.Next(_L("Test open global object by name")); |
912 test((testObject.OpenGlobal(globalObject.FullName()))==KErrNone); |
928 test((r=testObject.OpenGlobal(globalObject.FullName()))==KErrNone); |
913 testObject.Close(); |
929 testObject.Close(); |
914 |
930 |
915 test.Next(_L("Check can't open local object by name")); |
931 test.Next(_L("Check can't open local object by name")); |
916 test((testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); |
932 test((r=testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); |
917 testObject.Close(); |
933 testObject.Close(); |
918 |
934 |
919 test.Next(_L("Test duplicate global object in other process")); |
935 test.Next(_L("Test duplicate global object in other process")); |
920 test((DuplicateInOtherProcess(globalObject))==KErrNone); |
936 test((r=DuplicateInOtherProcess(globalObject))==KErrNone); |
921 |
937 |
922 test.Next(_L("Check can't duplicate local object in other process")); |
938 test.Next(_L("Check can't duplicate local object in other process")); |
923 test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); |
939 test((r=DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); |
924 |
940 |
925 test.Next(_L("Test duplicate global object in other thread")); |
941 test.Next(_L("Test duplicate global object in other thread")); |
926 test((DuplicateInOtherThread(globalObject))==KErrNone); |
942 test((r=DuplicateInOtherThread(globalObject))==KErrNone); |
927 |
943 |
928 test.Next(_L("Test duplicate local object in other thead")); |
944 test.Next(_L("Test duplicate local object in other thead")); |
929 test((DuplicateInOtherThread(localObject))==KErrNone); |
945 test((r=DuplicateInOtherThread(localObject))==KErrNone); |
930 |
946 |
931 test.Next(_L("Closing Semaphores")); |
947 test.Next(_L("Closing Semaphores")); |
932 globalObject.Close(); |
948 globalObject.Close(); |
933 localObject.Close(); |
949 localObject.Close(); |
934 |
950 |
938 |
954 |
939 |
955 |
940 void TestMutexes() |
956 void TestMutexes() |
941 { |
957 { |
942 TFullName name; |
958 TFullName name; |
943 |
959 TInt r; |
|
960 |
944 test.Start(_L("Creating mutexes")); |
961 test.Start(_L("Creating mutexes")); |
945 RMutex globalObject; |
962 RMutex globalObject; |
946 RMutex localObject; |
963 RMutex localObject; |
947 RMutex testObject; |
964 RMutex testObject; |
948 test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-mutex")))==KErrNone); |
965 test((r=globalObject.CreateGlobal(_L("T_SOBJECT-test-global-mutex")))==KErrNone); |
949 test((localObject.CreateLocal())==KErrNone); |
966 test((r=localObject.CreateLocal())==KErrNone); |
950 |
967 |
951 test.Next(_L("Test find global object")); |
968 test.Next(_L("Test find global object")); |
952 TFindMutex find(globalObject.FullName()); |
969 TFindMutex find(globalObject.FullName()); |
953 test((find.Next(name))==KErrNone); |
970 test((r=find.Next(name))==KErrNone); |
954 |
971 |
955 test.Next(_L("Test open found object")); |
972 test.Next(_L("Test open found object")); |
956 test((testObject.Open(find))==KErrNone); |
973 test((r=testObject.Open(find))==KErrNone); |
957 testObject.Close(); |
974 testObject.Close(); |
958 |
975 |
959 test.Next(_L("Check can't find local object")); |
976 test.Next(_L("Check can't find local object")); |
960 TName objectName(localObject.FullName()); |
977 TName objectName(localObject.FullName()); |
961 find.Find(objectName); |
978 find.Find(objectName); |
962 test((find.Next(name))==PlatSecFindError); |
979 test((r=find.Next(name))==PlatSecFindError); |
963 |
980 |
964 test.Next(_L("Test open with null name")); |
981 test.Next(_L("Test open with null name")); |
965 test((testObject.OpenGlobal(KNullDesC))==KErrNotFound); |
982 test((r=testObject.OpenGlobal(KNullDesC))==KErrNotFound); |
966 testObject.Close(); |
983 testObject.Close(); |
967 |
984 |
968 test.Next(_L("Test open global object by name")); |
985 test.Next(_L("Test open global object by name")); |
969 test((testObject.OpenGlobal(globalObject.FullName()))==KErrNone); |
986 test((r=testObject.OpenGlobal(globalObject.FullName()))==KErrNone); |
970 testObject.Close(); |
987 testObject.Close(); |
971 |
988 |
972 test.Next(_L("Check can't open local object by name")); |
989 test.Next(_L("Check can't open local object by name")); |
973 test((testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); |
990 test((r=testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); |
974 testObject.Close(); |
991 testObject.Close(); |
975 |
992 |
976 test.Next(_L("Test duplicate global object in other process")); |
993 test.Next(_L("Test duplicate global object in other process")); |
977 test((DuplicateInOtherProcess(globalObject))==KErrNone); |
994 test((r=DuplicateInOtherProcess(globalObject))==KErrNone); |
978 |
995 |
979 test.Next(_L("Check can't duplicate local object in other process")); |
996 test.Next(_L("Check can't duplicate local object in other process")); |
980 test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); |
997 test((r=DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); |
981 |
998 |
982 test.Next(_L("Test duplicate global object in other thread")); |
999 test.Next(_L("Test duplicate global object in other thread")); |
983 test((DuplicateInOtherThread(globalObject))==KErrNone); |
1000 test((r=DuplicateInOtherThread(globalObject))==KErrNone); |
984 |
1001 |
985 test.Next(_L("Test duplicate local object in other thead")); |
1002 test.Next(_L("Test duplicate local object in other thead")); |
986 test((DuplicateInOtherThread(localObject))==KErrNone); |
1003 test((r=DuplicateInOtherThread(localObject))==KErrNone); |
987 |
1004 |
988 test.Next(_L("Closing mutexes")); |
1005 test.Next(_L("Closing mutexes")); |
989 globalObject.Close(); |
1006 globalObject.Close(); |
990 localObject.Close(); |
1007 localObject.Close(); |
991 |
1008 |
994 |
1011 |
995 |
1012 |
996 |
1013 |
997 void TestMessageQueues() |
1014 void TestMessageQueues() |
998 { |
1015 { |
|
1016 TInt r; |
|
1017 |
999 test.Start(_L("Creating message queues")); |
1018 test.Start(_L("Creating message queues")); |
1000 RMsgQueue<TInt> globalObject; |
1019 RMsgQueue<TInt> globalObject; |
1001 RMsgQueue<TInt> localObject; |
1020 RMsgQueue<TInt> localObject; |
1002 RMsgQueue<TInt> testObject; |
1021 RMsgQueue<TInt> testObject; |
1003 test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-msgqueue"),1))==KErrNone); |
1022 test((r=globalObject.CreateGlobal(_L("T_SOBJECT-test-global-msgqueue"),1))==KErrNone); |
1004 test((localObject.CreateLocal(1))==KErrNone); |
1023 test((r=localObject.CreateLocal(1))==KErrNone); |
1005 |
1024 |
1006 test.Next(_L("Test open with null name")); |
1025 test.Next(_L("Test open with null name")); |
1007 test((testObject.OpenGlobal(KNullDesC))==KErrNotFound); |
1026 test((r=testObject.OpenGlobal(KNullDesC))==KErrNotFound); |
1008 testObject.Close(); |
1027 testObject.Close(); |
1009 |
1028 |
1010 test.Next(_L("Test open global object by name")); |
1029 test.Next(_L("Test open global object by name")); |
1011 test((testObject.OpenGlobal(globalObject.FullName()))==KErrNone); |
1030 test((r=testObject.OpenGlobal(globalObject.FullName()))==KErrNone); |
1012 testObject.Close(); |
1031 testObject.Close(); |
1013 |
1032 |
1014 test.Next(_L("Check can't open local object by name")); |
1033 test.Next(_L("Check can't open local object by name")); |
1015 test((testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); |
1034 test((r=testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); |
1016 testObject.Close(); |
1035 testObject.Close(); |
1017 |
1036 |
1018 test.Next(_L("Test duplicate global object in other process")); |
1037 test.Next(_L("Test duplicate global object in other process")); |
1019 test((DuplicateInOtherProcess(globalObject))==KErrNone); |
1038 test((r=DuplicateInOtherProcess(globalObject))==KErrNone); |
1020 |
1039 |
1021 test.Next(_L("Check can't duplicate local object in other process")); |
1040 test.Next(_L("Check can't duplicate local object in other process")); |
1022 test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); |
1041 test((r=DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); |
1023 |
1042 |
1024 test.Next(_L("Test duplicate global object in other thread")); |
1043 test.Next(_L("Test duplicate global object in other thread")); |
1025 test((DuplicateInOtherThread(globalObject))==KErrNone); |
1044 test((r=DuplicateInOtherThread(globalObject))==KErrNone); |
1026 |
1045 |
1027 test.Next(_L("Test duplicate local object in other thead")); |
1046 test.Next(_L("Test duplicate local object in other thead")); |
1028 test((DuplicateInOtherThread(localObject))==KErrNone); |
1047 test((r=DuplicateInOtherThread(localObject))==KErrNone); |
1029 |
1048 |
1030 test.Next(_L("Closing message queues")); |
1049 test.Next(_L("Closing message queues")); |
1031 globalObject.Close(); |
1050 globalObject.Close(); |
1032 localObject.Close(); |
1051 localObject.Close(); |
1033 |
1052 |
1035 } |
1054 } |
1036 |
1055 |
1037 |
1056 |
1038 |
1057 |
1039 void TestConditionVariables() |
1058 void TestConditionVariables() |
1040 { |
1059 { |
|
1060 TInt r; |
|
1061 |
1041 test.Start(_L("Creating condition variables")); |
1062 test.Start(_L("Creating condition variables")); |
1042 RCondVar globalObject; |
1063 RCondVar globalObject; |
1043 RCondVar localObject; |
1064 RCondVar localObject; |
1044 RCondVar testObject; |
1065 RCondVar testObject; |
1045 test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-condvar")))==KErrNone); |
1066 test((r=globalObject.CreateGlobal(_L("T_SOBJECT-test-global-condvar")))==KErrNone); |
1046 test((localObject.CreateLocal())==KErrNone); |
1067 test((r=localObject.CreateLocal())==KErrNone); |
1047 |
1068 |
1048 test.Next(_L("Test open with null name")); |
1069 test.Next(_L("Test open with null name")); |
1049 test((testObject.OpenGlobal(KNullDesC))==KErrNotFound); |
1070 test((r=testObject.OpenGlobal(KNullDesC))==KErrNotFound); |
1050 testObject.Close(); |
1071 testObject.Close(); |
1051 |
1072 |
1052 test.Next(_L("Test open global object by name")); |
1073 test.Next(_L("Test open global object by name")); |
1053 test((testObject.OpenGlobal(globalObject.FullName()))==KErrNone); |
1074 test((r=testObject.OpenGlobal(globalObject.FullName()))==KErrNone); |
1054 testObject.Close(); |
1075 testObject.Close(); |
1055 |
1076 |
1056 test.Next(_L("Check can't open local object by name")); |
1077 test.Next(_L("Check can't open local object by name")); |
1057 test((testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); |
1078 test((r=testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); |
1058 testObject.Close(); |
1079 testObject.Close(); |
1059 |
1080 |
1060 test.Next(_L("Test duplicate global object in other process")); |
1081 test.Next(_L("Test duplicate global object in other process")); |
1061 test((DuplicateInOtherProcess(globalObject))==KErrNone); |
1082 test((r=DuplicateInOtherProcess(globalObject))==KErrNone); |
1062 |
1083 |
1063 test.Next(_L("Check can't duplicate local object in other process")); |
1084 test.Next(_L("Check can't duplicate local object in other process")); |
1064 test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); |
1085 test((r=DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); |
1065 |
1086 |
1066 test.Next(_L("Test duplicate global object in other thread")); |
1087 test.Next(_L("Test duplicate global object in other thread")); |
1067 test((DuplicateInOtherThread(globalObject))==KErrNone); |
1088 test((r=DuplicateInOtherThread(globalObject))==KErrNone); |
1068 |
1089 |
1069 test.Next(_L("Test duplicate local object in other thead")); |
1090 test.Next(_L("Test duplicate local object in other thead")); |
1070 test((DuplicateInOtherThread(localObject))==KErrNone); |
1091 test((r=DuplicateInOtherThread(localObject))==KErrNone); |
1071 |
1092 |
1072 test.Next(_L("Closing message queues")); |
1093 test.Next(_L("Closing message queues")); |
1073 globalObject.Close(); |
1094 globalObject.Close(); |
1074 localObject.Close(); |
1095 localObject.Close(); |
1075 |
1096 |