diff -r c1f20ce4abcf -r 3e88ff8f41d5 kerneltest/e32test/secure/t_sobject.cpp --- a/kerneltest/e32test/secure/t_sobject.cpp Tue Aug 31 16:34:26 2010 +0300 +++ b/kerneltest/e32test/secure/t_sobject.cpp Wed Sep 01 12:34:56 2010 +0100 @@ -55,7 +55,6 @@ // // -#define __E32TEST_EXTENSION__ #include #include #include @@ -239,6 +238,11 @@ { } +const TInt KTestDataMaxLength8 = 20; +const TInt KTestDataMaxLength16 = 40; +_LIT8(KTestData8,"12345678"); +_LIT16(KTestData16,"1234567890123456"); +_LIT(KTestPanicCategory,"TEST PANIC"); void CTestSession::ServiceL(const RMessage2& aMessage) { @@ -284,6 +288,7 @@ object.Close(); return; } + break; case CTestSession::ETestSemaphore: { @@ -313,6 +318,7 @@ object.Close(); return; } + break; case CTestSession::ETestMsgQueue: { @@ -342,7 +348,7 @@ object.Close(); return; } - + break; case CTestSession::ETestCondVar: { @@ -372,7 +378,7 @@ object.Close(); return; } - + break; case CTestSession::ETestChunk: { @@ -402,7 +408,7 @@ object.Close(); return; } - + break; case CTestSession::ETestChunkAdjust: { @@ -618,13 +624,15 @@ void TestPhysicalDevices() { TFullName name; + TInt r; + test.Start(_L("Test find named object")); TFindPhysicalDevice find(_L("*")); - test((find.Next(name))==KErrNone); + test((r=find.Next(name))==KErrNone); test.Next(_L("Try open found object")); RTestHandle testObject; - test((testObject.Open(find))==PlatSecProcessIsolationError); + test((r=testObject.Open(find))==PlatSecProcessIsolationError); testObject.Close(); test.End(); @@ -634,26 +642,27 @@ void TestLogicalDevices() { - TFullName name; + TFullName name; + TInt r; RDevice device; test.Start(_L("Test find named object")); TFindLogicalDevice find(_L("*")); - test((find.Next(name))==KErrNone); + test((r=find.Next(name))==KErrNone); test.Next(_L("Test open found object")); - test((device.Open(find))==KErrNone); + test((r=device.Open(find))==KErrNone); test.Next(_L("Test duplicate object in other thread")); - test((DuplicateInOtherThread(device))==KErrNone); + test((r=DuplicateInOtherThread(device))==KErrNone); test.Next(_L("Test duplicate object in other process")); - test((DuplicateInOtherProcess(device))==KErrNone); + test((r=DuplicateInOtherProcess(device))==KErrNone); device.Close(); test.Next(_L("Test open device by name")); - test((device.Open(name))==KErrNone); + test((r=device.Open(name))==KErrNone); device.Close(); test.End(); @@ -664,13 +673,15 @@ void TestLibraries() { TFullName name; + TInt r; + test.Start(_L("Test find named object")); TFindLibrary find(_L("*")); - test((find.Next(name))==KErrNone); + test((r=find.Next(name))==KErrNone); test.Next(_L("Try open found object")); RTestHandle testObject; - test((testObject.Open(find))==PlatSecProcessIsolationError); + test((r=testObject.Open(find))==PlatSecProcessIsolationError); testObject.Close(); test.End(); @@ -681,27 +692,28 @@ void TestServers() { TFullName name; + TInt r; RServer2 localObject(Servers[EAnonymousServer]); test.Start(_L("Test find named object")); TFindServer find(ServerName(EMainServer)); - test((find.Next(name))==KErrNone); + test((r=find.Next(name))==KErrNone); test.Next(_L("Try open found object")); RTestHandle testObject; - test((testObject.Open(find))==KErrPermissionDenied); + test((r=testObject.Open(find))==KErrPermissionDenied); test.Next(_L("Test duplicate named server in other thread")); - test((Session.Send(CTestSession::ETestServerDuplicateInThread))==KErrNone); + test((r=Session.Send(CTestSession::ETestServerDuplicateInThread))==KErrNone); test.Next(_L("Try duplicate named server in other process")); - test((Session.Send(CTestSession::ETestServerDuplicateInProcess))==KErrPermissionDenied); + test((r=Session.Send(CTestSession::ETestServerDuplicateInProcess))==KErrPermissionDenied); test.Next(_L("Test duplicate unnamed server in other thread")); - test((DuplicateInOtherThread(localObject))==KErrNone); + test((r=DuplicateInOtherThread(localObject))==KErrNone); test.Next(_L("Try duplicate unnamed server in other process")); - test((DuplicateInOtherProcess(localObject))==KErrPermissionDenied); + test((r=DuplicateInOtherProcess(localObject))==KErrPermissionDenied); test.End(); } @@ -710,31 +722,32 @@ void TestProcesses() { - TFullName name; + TFullName name; + TInt r; RProcess process; test.Start(_L("Test find named object")); TFindProcess find(_L("EKern*")); - test((find.Next(name))==KErrNone); + test((r=find.Next(name))==KErrNone); test.Next(_L("Test open found object")); - test((process.Open(find))==KErrNone); + test((r=process.Open(find))==KErrNone); test.Next(_L("Test duplicate object in other thread")); - test((DuplicateInOtherThread(process))==KErrNone); + test((r=DuplicateInOtherThread(process))==KErrNone); test.Next(_L("Test duplicate object in other process")); - test((DuplicateInOtherProcess(process))==KErrNone); + test((r=DuplicateInOtherProcess(process))==KErrNone); process.Close(); test.Next(_L("Test open process by name")); - test((process.Open(name))==KErrNone); + test((r=process.Open(name))==KErrNone); TProcessId id=process.Id(); process.Close(); test.Next(_L("Test open process by id")); - test((process.Open(id))==KErrNone); + test((r=process.Open(id))==KErrNone); test(name==process.FullName()); process.Close(); @@ -746,63 +759,64 @@ void TestThreads() { TFullName name; - + TInt r; + test.Start(_L("Creating threads")); RThread globalObject; RThread localObject; RThread testObject; - test((globalObject.Create(_L("T_SOBJECT-test-global-thread"),TestThreadDuplicate,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,NULL))==KErrNone); - test((localObject.Create(_L(""),TestThreadDuplicate,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,NULL))==KErrNone); + test((r=globalObject.Create(_L("T_SOBJECT-test-global-thread"),TestThreadDuplicate,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,NULL))==KErrNone); + test((r=localObject.Create(_L(""),TestThreadDuplicate,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,NULL))==KErrNone); test.Next(_L("Test find named thread")); TFindThread find(globalObject.FullName()); - test((find.Next(name))==KErrNone); + test((r=find.Next(name))==KErrNone); test.Next(_L("Test open found object")); - test((testObject.Open(find))==KErrNone); + test((r=testObject.Open(find))==KErrNone); testObject.Close(); test.Next(_L("Check can't find unnamed thread")); TName objectName(localObject.FullName()); find.Find(objectName); - test((find.Next(name))==PlatSecFindError); + test((r=find.Next(name))==PlatSecFindError); test.Next(_L("Test open named thread by name")); - test((testObject.Open(globalObject.FullName()))==KErrNone); + test((r=testObject.Open(globalObject.FullName()))==KErrNone); testObject.Close(); test.Next(_L("Check can't open unnamed thread by name")); - test((testObject.Open(localObject.FullName()))==PlatSecFindError); + test((r=testObject.Open(localObject.FullName()))==PlatSecFindError); testObject.Close(); test.Next(_L("Check can't open with no name")); - test((testObject.Open(KNullDesC))==KErrNotFound); + test((r=testObject.Open(KNullDesC))==KErrNotFound); testObject.Close(); test.Next(_L("Test open named thread by id (in same process)")); - test((testObject.Open(globalObject.Id()))==KErrNone); + test((r=testObject.Open(globalObject.Id()))==KErrNone); testObject.Close(); test.Next(_L("Test open named thread by id (in other process)")); - test((OpenThreadByIdInOtherProcess(globalObject.Id()))==KErrNone); + test((r=OpenThreadByIdInOtherProcess(globalObject.Id()))==KErrNone); test.Next(_L("Test open unnamed thread by id (in same process)")); - test((testObject.Open(localObject.Id()))==KErrNone); + test((r=testObject.Open(localObject.Id()))==KErrNone); test.Next(_L("Check can't open unnamed thread by id (in other process)")); - test((OpenThreadByIdInOtherProcess(localObject.Id()))==PlatSecProcessIsolationError); + test((r=OpenThreadByIdInOtherProcess(localObject.Id()))==PlatSecProcessIsolationError); test.Next(_L("Test duplicate named thread in other process")); - test((DuplicateInOtherProcess(globalObject))==KErrNone); + test((r=DuplicateInOtherProcess(globalObject))==KErrNone); test.Next(_L("Check can't duplicate unnamed thread in other process")); - test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); + test((r=DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); test.Next(_L("Test duplicate named thread in other thread")); - test((DuplicateInOtherThread(globalObject))==KErrNone); + test((r=DuplicateInOtherThread(globalObject))==KErrNone); test.Next(_L("Test duplicate unnamed thread in other thead")); - test((DuplicateInOtherThread(localObject))==KErrNone); + test((r=DuplicateInOtherThread(localObject))==KErrNone); test.Next(_L("Closing threads")); globalObject.Close(); @@ -816,58 +830,59 @@ void TestChunks() { TFullName name; - + TInt r; + test.Start(_L("Creating chunks")); RChunk globalObject; RChunk localObject; RChunk testObject; - test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-chunk"),4096,1024*1024))==KErrNone); - test((localObject.CreateLocal(4096,1024*1024))==KErrNone); + test((r=globalObject.CreateGlobal(_L("T_SOBJECT-test-global-chunk"),4096,1024*1024))==KErrNone); + test((r=localObject.CreateLocal(4096,1024*1024))==KErrNone); test.Next(_L("Test find global object")); TFindChunk find(globalObject.FullName()); - test((find.Next(name))==KErrNone); + test((r=find.Next(name))==KErrNone); test.Next(_L("Test open found object")); - test((testObject.Open(find))==KErrNone); + test((r=testObject.Open(find))==KErrNone); testObject.Close(); test.Next(_L("Check can't find local object")); TName objectName(localObject.FullName()); find.Find(objectName); - test((find.Next(name))==PlatSecFindError); + test((r=find.Next(name))==PlatSecFindError); test.Next(_L("Test open with null name")); - test((testObject.OpenGlobal(KNullDesC,ETrue))==KErrNotFound); + test((r=testObject.OpenGlobal(KNullDesC,ETrue))==KErrNotFound); testObject.Close(); test.Next(_L("Test open global object by name")); - test((testObject.OpenGlobal(globalObject.FullName(),ETrue))==KErrNone); + test((r=testObject.OpenGlobal(globalObject.FullName(),ETrue))==KErrNone); testObject.Close(); test.Next(_L("Check can't open local object by name")); - test((testObject.OpenGlobal(localObject.FullName(),ETrue))==PlatSecFindError); + test((r=testObject.OpenGlobal(localObject.FullName(),ETrue))==PlatSecFindError); testObject.Close(); test.Next(_L("Test duplicate global object in other process")); - test((DuplicateInOtherProcess(globalObject))==KErrNone); + test((r=DuplicateInOtherProcess(globalObject))==KErrNone); test.Next(_L("Check can't duplicate local object in other process")); - test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); + test((r=DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); test.Next(_L("Test duplicate global object in other thread")); - test((DuplicateInOtherThread(globalObject))==KErrNone); + test((r=DuplicateInOtherThread(globalObject))==KErrNone); test.Next(_L("Test duplicate local object in other thead")); - test((DuplicateInOtherThread(localObject))==KErrNone); + test((r=DuplicateInOtherThread(localObject))==KErrNone); test.Next(_L("Test Chunk protection")); { RChunk protectedChunk; - test((protectedChunk.CreateGlobal(KNullDesC,0x1000,0x100000,EOwnerProcess))==KErrNone); - test((Session.Send(CTestSession::ETestChunkAdjust,TIpcArgs(protectedChunk)))==KErrNone); + test((r=protectedChunk.CreateGlobal(KNullDesC,0x1000,0x100000,EOwnerProcess))==KErrNone); + test((r=Session.Send(CTestSession::ETestChunkAdjust,TIpcArgs(protectedChunk)))==KErrNone); protectedChunk.SetRestrictions(RChunk::EPreventAdjust); - test((Session.Send(CTestSession::ETestChunkAdjust,TIpcArgs(protectedChunk)))==KErrAccessDenied); + test((r=Session.Send(CTestSession::ETestChunkAdjust,TIpcArgs(protectedChunk)))==KErrAccessDenied); protectedChunk.Close(); } @@ -883,50 +898,51 @@ void TestSemaphores() { TFullName name; - + TInt r; + test.Start(_L("Creating semaphores")); RSemaphore globalObject; RSemaphore localObject; RSemaphore testObject; - test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-semaphore"),1))==KErrNone); - test((localObject.CreateLocal(1))==KErrNone); + test((r=globalObject.CreateGlobal(_L("T_SOBJECT-test-global-semaphore"),1))==KErrNone); + test((r=localObject.CreateLocal(1))==KErrNone); test.Next(_L("Test find global object")); TFindSemaphore find(globalObject.FullName()); - test((find.Next(name))==KErrNone); + test((r=find.Next(name))==KErrNone); test.Next(_L("Test open found object")); - test((testObject.Open(find))==KErrNone); + test((r=testObject.Open(find))==KErrNone); testObject.Close(); test.Next(_L("Check can't find local object")); TName objectName(localObject.FullName()); find.Find(objectName); - test((find.Next(name))==PlatSecFindError); + test((r=find.Next(name))==PlatSecFindError); test.Next(_L("Test open with null name")); - test((testObject.OpenGlobal(KNullDesC))==KErrNotFound); + test((r=testObject.OpenGlobal(KNullDesC))==KErrNotFound); testObject.Close(); test.Next(_L("Test open global object by name")); - test((testObject.OpenGlobal(globalObject.FullName()))==KErrNone); + test((r=testObject.OpenGlobal(globalObject.FullName()))==KErrNone); testObject.Close(); test.Next(_L("Check can't open local object by name")); - test((testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); + test((r=testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); testObject.Close(); test.Next(_L("Test duplicate global object in other process")); - test((DuplicateInOtherProcess(globalObject))==KErrNone); + test((r=DuplicateInOtherProcess(globalObject))==KErrNone); test.Next(_L("Check can't duplicate local object in other process")); - test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); + test((r=DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); test.Next(_L("Test duplicate global object in other thread")); - test((DuplicateInOtherThread(globalObject))==KErrNone); + test((r=DuplicateInOtherThread(globalObject))==KErrNone); test.Next(_L("Test duplicate local object in other thead")); - test((DuplicateInOtherThread(localObject))==KErrNone); + test((r=DuplicateInOtherThread(localObject))==KErrNone); test.Next(_L("Closing Semaphores")); globalObject.Close(); @@ -940,50 +956,51 @@ void TestMutexes() { TFullName name; - + TInt r; + test.Start(_L("Creating mutexes")); RMutex globalObject; RMutex localObject; RMutex testObject; - test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-mutex")))==KErrNone); - test((localObject.CreateLocal())==KErrNone); + test((r=globalObject.CreateGlobal(_L("T_SOBJECT-test-global-mutex")))==KErrNone); + test((r=localObject.CreateLocal())==KErrNone); test.Next(_L("Test find global object")); TFindMutex find(globalObject.FullName()); - test((find.Next(name))==KErrNone); + test((r=find.Next(name))==KErrNone); test.Next(_L("Test open found object")); - test((testObject.Open(find))==KErrNone); + test((r=testObject.Open(find))==KErrNone); testObject.Close(); test.Next(_L("Check can't find local object")); TName objectName(localObject.FullName()); find.Find(objectName); - test((find.Next(name))==PlatSecFindError); + test((r=find.Next(name))==PlatSecFindError); test.Next(_L("Test open with null name")); - test((testObject.OpenGlobal(KNullDesC))==KErrNotFound); + test((r=testObject.OpenGlobal(KNullDesC))==KErrNotFound); testObject.Close(); test.Next(_L("Test open global object by name")); - test((testObject.OpenGlobal(globalObject.FullName()))==KErrNone); + test((r=testObject.OpenGlobal(globalObject.FullName()))==KErrNone); testObject.Close(); test.Next(_L("Check can't open local object by name")); - test((testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); + test((r=testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); testObject.Close(); test.Next(_L("Test duplicate global object in other process")); - test((DuplicateInOtherProcess(globalObject))==KErrNone); + test((r=DuplicateInOtherProcess(globalObject))==KErrNone); test.Next(_L("Check can't duplicate local object in other process")); - test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); + test((r=DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); test.Next(_L("Test duplicate global object in other thread")); - test((DuplicateInOtherThread(globalObject))==KErrNone); + test((r=DuplicateInOtherThread(globalObject))==KErrNone); test.Next(_L("Test duplicate local object in other thead")); - test((DuplicateInOtherThread(localObject))==KErrNone); + test((r=DuplicateInOtherThread(localObject))==KErrNone); test.Next(_L("Closing mutexes")); globalObject.Close(); @@ -996,36 +1013,38 @@ void TestMessageQueues() { + TInt r; + test.Start(_L("Creating message queues")); RMsgQueue globalObject; RMsgQueue localObject; RMsgQueue testObject; - test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-msgqueue"),1))==KErrNone); - test((localObject.CreateLocal(1))==KErrNone); + test((r=globalObject.CreateGlobal(_L("T_SOBJECT-test-global-msgqueue"),1))==KErrNone); + test((r=localObject.CreateLocal(1))==KErrNone); test.Next(_L("Test open with null name")); - test((testObject.OpenGlobal(KNullDesC))==KErrNotFound); + test((r=testObject.OpenGlobal(KNullDesC))==KErrNotFound); testObject.Close(); test.Next(_L("Test open global object by name")); - test((testObject.OpenGlobal(globalObject.FullName()))==KErrNone); + test((r=testObject.OpenGlobal(globalObject.FullName()))==KErrNone); testObject.Close(); test.Next(_L("Check can't open local object by name")); - test((testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); + test((r=testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); testObject.Close(); test.Next(_L("Test duplicate global object in other process")); - test((DuplicateInOtherProcess(globalObject))==KErrNone); + test((r=DuplicateInOtherProcess(globalObject))==KErrNone); test.Next(_L("Check can't duplicate local object in other process")); - test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); + test((r=DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); test.Next(_L("Test duplicate global object in other thread")); - test((DuplicateInOtherThread(globalObject))==KErrNone); + test((r=DuplicateInOtherThread(globalObject))==KErrNone); test.Next(_L("Test duplicate local object in other thead")); - test((DuplicateInOtherThread(localObject))==KErrNone); + test((r=DuplicateInOtherThread(localObject))==KErrNone); test.Next(_L("Closing message queues")); globalObject.Close(); @@ -1037,37 +1056,39 @@ void TestConditionVariables() - { + { + TInt r; + test.Start(_L("Creating condition variables")); RCondVar globalObject; RCondVar localObject; RCondVar testObject; - test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-condvar")))==KErrNone); - test((localObject.CreateLocal())==KErrNone); + test((r=globalObject.CreateGlobal(_L("T_SOBJECT-test-global-condvar")))==KErrNone); + test((r=localObject.CreateLocal())==KErrNone); test.Next(_L("Test open with null name")); - test((testObject.OpenGlobal(KNullDesC))==KErrNotFound); + test((r=testObject.OpenGlobal(KNullDesC))==KErrNotFound); testObject.Close(); test.Next(_L("Test open global object by name")); - test((testObject.OpenGlobal(globalObject.FullName()))==KErrNone); + test((r=testObject.OpenGlobal(globalObject.FullName()))==KErrNone); testObject.Close(); test.Next(_L("Check can't open local object by name")); - test((testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); + test((r=testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); testObject.Close(); test.Next(_L("Test duplicate global object in other process")); - test((DuplicateInOtherProcess(globalObject))==KErrNone); + test((r=DuplicateInOtherProcess(globalObject))==KErrNone); test.Next(_L("Check can't duplicate local object in other process")); - test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); + test((r=DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); test.Next(_L("Test duplicate global object in other thread")); - test((DuplicateInOtherThread(globalObject))==KErrNone); + test((r=DuplicateInOtherThread(globalObject))==KErrNone); test.Next(_L("Test duplicate local object in other thead")); - test((DuplicateInOtherThread(localObject))==KErrNone); + test((r=DuplicateInOtherThread(localObject))==KErrNone); test.Next(_L("Closing message queues")); globalObject.Close(); @@ -1083,7 +1104,7 @@ RTestProcess server; TRequestStatus rendezvous; TInt r; - + test.Next(_L("Test sending LogicalChannel handles")); { RLddTest localLdd; @@ -1379,6 +1400,7 @@ test.Title(); + TInt r; test.Start(_L("Starting test servers")); RTestProcess server; @@ -1391,10 +1413,10 @@ User::WaitForRequest(rendezvous); test(rendezvous==KServerRendezvous); server.Close(); - test((StartServerInThread(EAnonymousServer))==KErrNone); + test((r=StartServerInThread(EAnonymousServer))==KErrNone); test.Next(_L("Openning server session")); - test((Session.Connect())==KErrNone); + test((r=Session.Connect())==KErrNone); test.Next(_L("Test Find and Open PhysicalDevices")); TestPhysicalDevices();