sl@0: // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include "LogCliServShared.h" sl@0: #include "logservpanic.h" sl@0: #include "logpackage.h" sl@0: #include "t_logutil.h" sl@0: sl@0: RTest TheTest(_L("t_logservipc")); sl@0: sl@0: _LIT(KServerName, "!LogServ"); sl@0: _LIT(KServerProcess, "LogServ"); sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: // sl@0: sl@0: struct TTestInfo sl@0: { sl@0: TInt iFunction; sl@0: TInt iType; sl@0: TInt iArgCount; sl@0: }; sl@0: sl@0: struct TExitDetails sl@0: { sl@0: TExitCategoryName iCategory; sl@0: TExitType iExitType; sl@0: TInt iReason; sl@0: }; sl@0: sl@0: const TInt KAsynchDelay = 500000; sl@0: sl@0: const TInt KFunctionNumbers [] = {ELogOperationCancel, sl@0: ELogOperationGetResult, sl@0: ELogOperationInitiate, sl@0: ELogNotify, sl@0: ELogNotifyCancel, sl@0: ELogViewCreate, sl@0: ELogViewDelete, sl@0: ELogViewCount, sl@0: ELogViewOperationInitiate, sl@0: ELogViewChangeNotificationsRequest, sl@0: ELogViewChangeNotificationsCancel, sl@0: ELogViewFetchChanges, sl@0: ELogViewNotifyLockStatusChange, sl@0: ELogViewNotifyLockStatusChangeCancel, sl@0: ELogNotifyExtended, sl@0: ELogNotifyExtendedCancel}; sl@0: sl@0: const TInt KNumFunctions = sizeof(KFunctionNumbers)/sizeof(KFunctionNumbers[0]); sl@0: sl@0: //=============================================================================== sl@0: sl@0: TBool IsFunctionAsynchronous(TInt aFunc) sl@0: { sl@0: TBool asynch = EFalse; sl@0: switch(aFunc) sl@0: { sl@0: case ELogOperationInitiate: sl@0: case ELogNotify: sl@0: case ELogViewOperationInitiate: sl@0: case ELogViewChangeNotificationsRequest: sl@0: case ELogViewNotifyLockStatusChange: sl@0: case ELogNotifyExtended: sl@0: asynch = ETrue; sl@0: break; sl@0: sl@0: default: sl@0: break; sl@0: } sl@0: return asynch; sl@0: } sl@0: sl@0: class RIpcFuzzTest : public RSessionBase sl@0: { sl@0: public: // Constructors and destructor sl@0: sl@0: /** sl@0: * Constructor for performing 1st stage construction sl@0: */ sl@0: RIpcFuzzTest(); sl@0: sl@0: /** sl@0: * Destructor. sl@0: */ sl@0: ~RIpcFuzzTest(); sl@0: sl@0: /** sl@0: * Performs test steps sl@0: */ sl@0: sl@0: void RunTestL(const TDesC& aTargetSrvName, TInt aFunc, sl@0: TInt aTestType, TInt aArgCount); sl@0: sl@0: private: sl@0: TInt Fuzz(TInt aMsg, TInt aArgCount); sl@0: TInt FuzzL(TInt aMsg, TInt aArgCount); sl@0: TInt Fuzz8L(TInt aMsg, TInt aArgCount); sl@0: }; sl@0: sl@0: RIpcFuzzTest::RIpcFuzzTest() sl@0: { sl@0: // No implementation required sl@0: } sl@0: sl@0: sl@0: RIpcFuzzTest::~RIpcFuzzTest() sl@0: { sl@0: Close(); sl@0: } sl@0: sl@0: TInt RIpcFuzzTest::Fuzz(TInt aMsg, TInt aArgCount) sl@0: { sl@0: TIpcArgs args; sl@0: sl@0: for(TInt i = 0; i < aArgCount;i++) sl@0: { sl@0: args.Set(i,Math::Random()); sl@0: } sl@0: sl@0: TInt ret; sl@0: sl@0: if(IsFunctionAsynchronous(aMsg)) sl@0: { sl@0: ret = Send(aMsg, args); sl@0: User::After(KAsynchDelay); sl@0: } sl@0: else sl@0: { sl@0: ret = SendReceive(aMsg, args); sl@0: } sl@0: return ret; sl@0: } sl@0: sl@0: TInt RIpcFuzzTest::Fuzz8L(TInt aMsg, TInt aArgCount) sl@0: { sl@0: HBufC8* buf = HBufC8::NewLC(255); sl@0: TPtr8 ptr = buf->Des(); sl@0: ptr.Fill(Math::Random(),255); sl@0: sl@0: TIpcArgs args; sl@0: sl@0: for(TInt i = 0; i < aArgCount;i++) sl@0: { sl@0: args.Set(i,&ptr); sl@0: } sl@0: sl@0: TInt ret; sl@0: sl@0: if(IsFunctionAsynchronous(aMsg)) sl@0: { sl@0: ret = Send(aMsg, args); sl@0: User::After(KAsynchDelay); sl@0: } sl@0: else sl@0: { sl@0: ret = SendReceive(aMsg, args); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(buf); sl@0: return ret; sl@0: } sl@0: sl@0: TInt RIpcFuzzTest::FuzzL(TInt aMsg, TInt aArgCount) sl@0: { sl@0: HBufC* buf = HBufC::NewLC(255); sl@0: TPtr ptr = buf->Des(); sl@0: ptr.Fill(Math::Random(),255); sl@0: sl@0: TIpcArgs args; sl@0: sl@0: for(TInt i = 0; i < aArgCount;i++) sl@0: { sl@0: args.Set(i,&ptr); sl@0: } sl@0: sl@0: TInt ret; sl@0: sl@0: if(IsFunctionAsynchronous(aMsg)) sl@0: { sl@0: ret = Send(aMsg, args); sl@0: User::After(KAsynchDelay); sl@0: } sl@0: else sl@0: { sl@0: ret = SendReceive(aMsg, args); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(buf); sl@0: return ret; sl@0: } sl@0: sl@0: void RIpcFuzzTest::RunTestL(const TDesC& aTargetSrvName, sl@0: TInt aFunc, TInt aTestType, TInt aArgCount) sl@0: { sl@0: TVersion version(0,0,0); sl@0: sl@0: TInt err = CreateSession(aTargetSrvName, version); sl@0: sl@0: LEAVE_IF_ERROR(err); sl@0: sl@0: switch(aTestType) sl@0: { sl@0: case 0: sl@0: Fuzz(aFunc,aArgCount); sl@0: break; sl@0: sl@0: case 1: sl@0: Fuzz8L(aFunc,aArgCount); sl@0: break; sl@0: sl@0: case 2: sl@0: FuzzL(aFunc,aArgCount); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: TInt FuzzServerL(TAny* aTestInfo) sl@0: { sl@0: CTrapCleanup* cleanup=CTrapCleanup::New(); sl@0: TInt err=KErrNoMemory; sl@0: if (cleanup) sl@0: { sl@0: sl@0: TTestInfo* info = (TTestInfo*)aTestInfo; sl@0: RIpcFuzzTest fuzzer; sl@0: sl@0: TRAP(err,fuzzer.RunTestL(KServerName,info->iFunction sl@0: ,info->iType, info->iArgCount)); sl@0: sl@0: fuzzer.Close(); sl@0: sl@0: delete cleanup; sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: sl@0: void TestServerApi(TInt aFunctionNumber, sl@0: TInt aTestType,TInt aArgCount, TExitDetails& aExitDetails) sl@0: { sl@0: sl@0: TTestInfo testInfo; sl@0: testInfo.iFunction = aFunctionNumber; sl@0: testInfo.iType = aTestType; sl@0: testInfo.iArgCount = aArgCount; sl@0: sl@0: RThread thread; sl@0: _LIT(KThreadName,"FuzzerThread" ); sl@0: TInt err = thread.Create(KThreadName,&FuzzServerL, KDefaultStackSize, NULL,&testInfo); sl@0: TEST2(err, KErrNone); sl@0: sl@0: TRequestStatus threadStat; sl@0: thread.Logon(threadStat); sl@0: sl@0: TBool jit = User::JustInTime(); sl@0: User::SetJustInTime(EFalse); sl@0: sl@0: thread.Resume(); sl@0: sl@0: User::WaitForRequest(threadStat); sl@0: sl@0: User::SetJustInTime(jit); sl@0: sl@0: aExitDetails.iCategory = thread.ExitCategory(); sl@0: aExitDetails.iReason = thread.ExitReason(); sl@0: aExitDetails.iExitType = thread.ExitType(); sl@0: sl@0: thread.Close(); sl@0: sl@0: } sl@0: sl@0: sl@0: TInt LaunchServer(RProcess& aServer) sl@0: { sl@0: sl@0: TheTest.Printf(_L("Launching LogServer...\n")); sl@0: sl@0: const TUid KServerUid3 = {0x0101f401d}; sl@0: const TUidType serverUid(KNullUid,KNullUid,KServerUid3); sl@0: sl@0: TInt err = aServer.Create(KServerProcess, _L(""),serverUid); sl@0: sl@0: if(err == KErrNone) sl@0: { sl@0: aServer.SetPriority(EPriorityForeground); sl@0: sl@0: //Start server and wait until it is running sl@0: TRequestStatus serverStat; sl@0: aServer.SetJustInTime(false); sl@0: aServer.Resume(); sl@0: sl@0: aServer.Rendezvous(serverStat); sl@0: User::WaitForRequest(serverStat); sl@0: } sl@0: sl@0: return err; sl@0: sl@0: } sl@0: sl@0: void PrintTestMessage(TInt iFunc, TInt iType, TInt iArgCount) sl@0: { sl@0: switch(iType) sl@0: { sl@0: case 0: sl@0: TheTest.Printf(_L("\nFuzz Test on function number %d using random Int data. Number of Args = %d"), iFunc, iArgCount); sl@0: break; sl@0: sl@0: case 1: sl@0: TheTest.Printf(_L("\nFuzz Test on function number %d using random Des8 data. Number of Args = %d"), iFunc, iArgCount); sl@0: break; sl@0: sl@0: case 2: sl@0: TheTest.Printf(_L("\nFuzz Test on function number %d using random Des data. Number of Args = %d"), iFunc, iArgCount); sl@0: break; sl@0: sl@0: } sl@0: sl@0: } sl@0: sl@0: /** sl@0: Invoke the tests sl@0: */ sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-4002 sl@0: @SYMTestCaseDesc Tests LogEng APIs for IPC Robustness sl@0: @SYMTestPriority High sl@0: @SYMTestActions The function calls each of the Logeng APIs through a custom session object sl@0: passing random TInt, Des8 and Des16 data . sl@0: @SYMTestExpectedResults The server should be robust to all malformed messages and should not sl@0: hang or panic. sl@0: @SYMDEF INC114113 sl@0: */ sl@0: LOCAL_C void DoFuzzTestsL () sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-4002 ")); sl@0: RProcess server; sl@0: sl@0: LEAVE_IF_ERROR(LaunchServer(server)); sl@0: sl@0: TExitDetails exitDetails; sl@0: sl@0: for(TInt i = 0;i< KNumFunctions;i++) sl@0: { sl@0: sl@0: //Carry out each type of test sl@0: for(TInt testType = 0; testType < 3;testType++) sl@0: { sl@0: //Carry out each test with number of arguments 1 - 4 sl@0: for(TInt argCount = 1;argCount <= 4;argCount++) sl@0: { sl@0: PrintTestMessage(KFunctionNumbers[i], testType, argCount); sl@0: sl@0: TestServerApi(KFunctionNumbers[i], testType, argCount, exitDetails); sl@0: //Kill the server process and verify that it was still running sl@0: //If the server was already dead it would return the reason it exited sl@0: if(server.ExitType() != EExitPending) sl@0: { sl@0: server.Kill(0); sl@0: TInt exitReason = server.ExitReason(); sl@0: server.Close(); sl@0: TEST2(exitReason, 0); sl@0: LEAVE_IF_ERROR(LaunchServer(server)); sl@0: } sl@0: } sl@0: sl@0: TheTest.Printf(_L("\nFuzz Test Successful\n")); sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: /* sl@0: * SERVER API TESTING sl@0: */ sl@0: sl@0: typedef void (*TestFunction)(); sl@0: sl@0: class RClientMessageTestSession : public RSessionBase sl@0: { sl@0: public: sl@0: TInt Connect(); sl@0: sl@0: TInt TestMakeTransient(TInt aArg0); sl@0: TInt TestMakeTransient(const TDesC8& aArg0); sl@0: sl@0: TInt TestCliServDataParam(TInt aFunc, TDes8& aArg0); sl@0: TInt TestCliServDataParam(TInt aFunc, TDes8& aArg0, TUint32 aArg1); sl@0: TInt TestCliServDataParam(TInt aFunc, TDes8& aArg0, TDes8& aArg1, TInt aArg2); sl@0: TInt TestCliServDataParam(TInt aFunc, TDes& aArg0, TDes8& aArg1, TInt aArg2); sl@0: sl@0: TInt TestLogNotify(TInt aArg0); sl@0: TInt TestLogNotifyCancel(); sl@0: sl@0: TInt TestLogViewCreate(TInt aArg0, TInt aArg1); sl@0: sl@0: TInt TestLogViewIdParam(TInt aFunc, TInt aArg0); sl@0: TInt TestLogViewIdParam(TInt aFunc, TDes8& aArg1); sl@0: sl@0: TInt TestLogViewFetchChanges(TInt aArg0, TInt aArg1, TDes8& aArg2); sl@0: TInt TestLogViewFetchChanges(TInt aArg0, TInt aArg1, const TDesC8& aArg2); sl@0: sl@0: TInt TestLogNotifyExtended(TDes8& aArg0, TDes8& aArg1, TDes8& aArg2,TDes8& aArg3); sl@0: TInt TestLogNotifyExtended(TDes& aArg0, TDes& aArg1, TDes& aArg2,TDes& aArg3); sl@0: TInt TestLogNotifyExtended(TDes8& aArg0, TInt aArg1, TInt aArg2,const TDesC8& aArg3); sl@0: sl@0: TInt TestFunction45(TAny* aData); sl@0: sl@0: sl@0: }; sl@0: sl@0: static TInt LaunchLogServer() sl@0: { sl@0: sl@0: RProcess process; sl@0: sl@0: TInt err = process.Create(KServerProcess,_L("")); sl@0: sl@0: if(err == KErrNone) sl@0: { sl@0: TRequestStatus serverStat; sl@0: sl@0: process.SetJustInTime(EFalse); sl@0: process.Resume(); sl@0: process.Rendezvous(serverStat); sl@0: User::WaitForRequest(serverStat); sl@0: } sl@0: sl@0: return err; sl@0: } sl@0: sl@0: sl@0: TInt RClientMessageTestSession::Connect() sl@0: { sl@0: TInt retry = 2; sl@0: for(;;) sl@0: { sl@0: TInt r = CreateSession(KServerName,TVersion(1,0,0)); sl@0: sl@0: if((r != KErrNotFound)&&(r != KErrServerTerminated)) sl@0: { sl@0: return r; sl@0: } sl@0: sl@0: if(--retry == 0) sl@0: { sl@0: return r; sl@0: } sl@0: sl@0: r = LaunchLogServer(); sl@0: if((r != KErrNone)&&(r != KErrAlreadyExists)) sl@0: { sl@0: return r; sl@0: } sl@0: } sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestMakeTransient(TInt aArg0) sl@0: { sl@0: return SendReceive(ELogMakeTransient,TIpcArgs(aArg0)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestMakeTransient(const TDesC8& aArg0) sl@0: { sl@0: return SendReceive(ELogMakeTransient,TIpcArgs(&aArg0)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestCliServDataParam(TInt aFunc, TDes8& aArg0) sl@0: { sl@0: return SendReceive(aFunc,TIpcArgs(&aArg0)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestCliServDataParam(TInt aFunc, TDes8& aArg0, TUint32 aArg1) sl@0: { sl@0: return SendReceive(aFunc,TIpcArgs(&aArg0, aArg1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestCliServDataParam(TInt aFunc, TDes8& aArg0, TDes8& aArg1, TInt aArg2) sl@0: { sl@0: return SendReceive(aFunc,TIpcArgs(&aArg0, &aArg1, aArg2)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestLogNotify(TInt aArg0) sl@0: { sl@0: return Send(ELogNotify,TIpcArgs(aArg0)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestLogNotifyCancel() sl@0: { sl@0: return Send(ELogNotifyCancel); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestLogViewCreate(TInt aArg0, TInt aArg1) sl@0: { sl@0: return SendReceive(ELogViewCreate,TIpcArgs(aArg0,aArg1)); sl@0: } sl@0: sl@0: sl@0: TInt RClientMessageTestSession::TestLogViewIdParam(TInt aFunc, TInt aArg0) sl@0: { sl@0: return SendReceive(aFunc,TIpcArgs(aArg0)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestLogViewIdParam(TInt aFunc, TDes8& aArg0) sl@0: { sl@0: return SendReceive(aFunc,TIpcArgs(&aArg0)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestLogViewFetchChanges(TInt aArg0, TInt aArg1, TDes8& aArg2) sl@0: { sl@0: return SendReceive(ELogViewFetchChanges,TIpcArgs(aArg0,aArg1, &aArg2)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestLogViewFetchChanges(TInt aArg0, TInt aArg1, const TDesC8& aArg2) sl@0: { sl@0: return SendReceive(ELogViewFetchChanges,TIpcArgs(aArg0,aArg1, &aArg2)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestLogNotifyExtended(TDes8& aArg0, sl@0: TDes8& aArg1, TDes8& aArg2,TDes8& aArg3) sl@0: { sl@0: return Send(ELogNotifyExtended,TIpcArgs(&aArg0,&aArg1,&aArg2,&aArg3)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestLogNotifyExtended(TDes& aArg0, sl@0: TDes& aArg1, TDes& aArg2,TDes& aArg3) sl@0: { sl@0: return Send(ELogNotifyExtended,TIpcArgs(&aArg0,&aArg1,&aArg2,&aArg3)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestLogNotifyExtended(TDes8& aArg0, sl@0: TInt aArg1, TInt aArg2,const TDesC8& aArg3) sl@0: { sl@0: return Send(ELogNotifyExtended,TIpcArgs(&aArg0,&aArg1,&aArg2,&aArg3)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction45(TAny* aData) sl@0: { sl@0: return SendReceive(45,TIpcArgs(aData)); sl@0: } sl@0: sl@0: sl@0: TInt TestFunctionLauncherL(TAny* aTestFunction) sl@0: { sl@0: CTrapCleanup* cleanup=CTrapCleanup::New(); sl@0: TInt r=KErrNoMemory; sl@0: if (cleanup) sl@0: { sl@0: TestFunction function = (TestFunction)aTestFunction; sl@0: sl@0: __UHEAP_MARK; sl@0: TRAP(r,function()); sl@0: __UHEAP_MARKEND; sl@0: sl@0: delete cleanup; sl@0: } sl@0: return r; sl@0: } sl@0: sl@0: sl@0: TExitDetails LaunchTestThreadL(const TDesC& aThreadName, TestFunction aFunction) sl@0: { sl@0: RThread thread; sl@0: TInt err = thread.Create(aThreadName, &TestFunctionLauncherL, KDefaultStackSize, NULL, (TAny*)aFunction); sl@0: TEST2(err, KErrNone); sl@0: sl@0: TRequestStatus threadStat; sl@0: thread.Logon(threadStat); sl@0: sl@0: TBool jit = User::JustInTime(); sl@0: User::SetJustInTime(EFalse); sl@0: sl@0: thread.Resume(); sl@0: User::WaitForRequest(threadStat); sl@0: sl@0: User::SetJustInTime(jit); sl@0: sl@0: TExitDetails exitDetails; sl@0: exitDetails.iCategory = thread.ExitCategory(); sl@0: exitDetails.iReason = thread.ExitReason(); sl@0: exitDetails.iExitType = thread.ExitType(); sl@0: sl@0: return exitDetails; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-4003 sl@0: @SYMTestCaseDesc Tests Message schema validation for the ELogMakeTransient message. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Sends messages to the test server to test the validation of messages sl@0: against the message schema. sl@0: @SYMTestExpectedResults The server should validate the message and handle bad messages appropriately sl@0: @SYMDEF INC114113 sl@0: */ sl@0: void TestMakeTransientL() sl@0: { sl@0: sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: err = session.TestMakeTransient(0); sl@0: TEST2(err, KErrNone); sl@0: sl@0: //anything different from 0 should be considered as ETrue sl@0: err = session.TestMakeTransient(1); sl@0: TEST2(err, KErrNone); sl@0: sl@0: err = session.TestMakeTransient(-5); sl@0: TEST2(err, KErrNone); sl@0: sl@0: err = session.TestMakeTransient(3); sl@0: TEST2(err, KErrNone); sl@0: sl@0: err = session.TestMakeTransient( _L8("Des8")); sl@0: TEST2(err, KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-4004 sl@0: @SYMTestCaseDesc Tests Message schema validation for the messages accepting sl@0: TLogClientServerData parameters. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Sends messages to the test server to test the validation of messages sl@0: against the message schema. The messages contain either valid or invalid sl@0: parameters. sl@0: @SYMTestExpectedResults The server should validate the message and handle bad messages appropriately sl@0: @SYMDEF INC114113 sl@0: */ sl@0: void TestCliServDataParamL() sl@0: { sl@0: sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: TLogClientServerData data; sl@0: TPckg pData(data); sl@0: sl@0: TBuf8 buf; sl@0: sl@0: buf.SetLength(sizeof(TLogClientServerData)); sl@0: sl@0: buf.Fill(0xFF); sl@0: sl@0: data.iOperationType = ELogOperationEventAdd; sl@0: data.iOperationId = 1; sl@0: err = session.TestCliServDataParam(ELogOperationInitiate,pData); sl@0: TEST2(err, KErrBadDescriptor); sl@0: sl@0: data.iOperationType = ELogOperationViewWindowFetch; sl@0: data.iOperationId = 5; sl@0: err = session.TestCliServDataParam(ELogOperationInitiate,pData); sl@0: TEST2(err, KErrArgument); sl@0: sl@0: data.iOperationType = ELogOperationEventAdd; sl@0: data.iOperationId = 0x8FFFFFFF; sl@0: err = session.TestCliServDataParam(ELogOperationInitiate,pData); sl@0: TEST2(err, KErrBadDescriptor); sl@0: sl@0: data.iOperationType = ELogOperationEventAdd; sl@0: data.iOperationId = 0x8FFFFFFF; sl@0: err = session.TestCliServDataParam(ELogOperationInitiate,buf); sl@0: TEST2(err, KErrArgument); sl@0: sl@0: data.iOperationType = ELogOperationEventAdd; sl@0: data.iOperationId = 1; sl@0: err = session.TestCliServDataParam(ELogOperationCancel,pData); sl@0: TEST2(err, KErrCancel); sl@0: sl@0: data.iOperationType = ELogOperationEventAdd; sl@0: data.iOperationId = 1; sl@0: err = session.TestCliServDataParam(ELogOperationCancel,buf); sl@0: TEST2(err, KErrArgument); sl@0: sl@0: CLogPackage* package = CLogPackage::NewL(); sl@0: TPtr8 ptr(package->Ptr()); sl@0: sl@0: data.iOperationType = ELogOperationEventAdd; sl@0: data.iOperationId = 1; sl@0: err = session.TestCliServDataParam(ELogOperationGetResult,buf, ptr, 0); sl@0: TEST2(err, KErrArgument); sl@0: sl@0: data.iOperationType = ELogOperationEventAdd; sl@0: data.iOperationId = 1; sl@0: err = session.TestCliServDataParam(ELogOperationGetResult,pData, ptr, -1 ); sl@0: TEST2(err, KErrNone); sl@0: sl@0: delete package; sl@0: sl@0: TBuf8<8> smallBuf; sl@0: data.iOperationType = ELogOperationEventAdd; sl@0: data.iOperationId = 1; sl@0: err = session.TestCliServDataParam(ELogOperationGetResult,buf, smallBuf, 0); sl@0: TEST2(err, KErrArgument); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-LEGACY-T_LOGSERVIPC-0001 sl@0: @SYMTestCaseDesc Tests Message schema validation for the messages accepting sl@0: TLogClientServerData parameters. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Sends messages to the test server to test the validation of messages sl@0: against the message schema. The messages contain either valid or invalid sl@0: parameters. sl@0: @SYMTestExpectedResults The server should validate the message and handle bad messages appropriately sl@0: @SYMDEF INC114113 sl@0: */ sl@0: void TestCliServDataParam2L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: TBuf8 buf; sl@0: sl@0: buf.FillZ(); sl@0: sl@0: //This should panic with Logserv 63 sl@0: err = session.TestCliServDataParam(ELogOperationInitiate,buf); sl@0: TEST2(err, KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-LEGACY-T_LOGSERVIPC-0002 sl@0: @SYMTestCaseDesc Tests Message schema validation for the messages accepting sl@0: TLogClientServerData parameters. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Sends messages to the test server to test the validation of messages sl@0: against the message schema. The messages contain either valid or invalid sl@0: parameters. sl@0: @SYMTestExpectedResults The server should validate the message and handle bad messages appropriately sl@0: @SYMDEF INC114113 sl@0: */ sl@0: void TestCliServDataParam3L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: TBuf8 buf; sl@0: sl@0: buf.FillZ(); sl@0: sl@0: err = session.TestCliServDataParam(ELogOperationInitiate,buf); sl@0: TEST2(err, KErrArgument); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-4005 sl@0: @SYMTestCaseDesc Tests Message schema validation for the ELogNotify message. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Sends messages to the test server to test the validation of messages sl@0: against the message schema. The messages contain either valid or invalid sl@0: parameters. sl@0: @SYMTestExpectedResults The server should validate the message and handle bad messages appropriately sl@0: @SYMDEF INC114113 sl@0: */ sl@0: void TestLogNotifyL() sl@0: { sl@0: sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: err = session.TestLogNotify(0); sl@0: TEST2(err, KErrNone); sl@0: sl@0: //Cancel the pending notification sl@0: err = session.TestLogNotifyCancel(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: err = session.TestLogNotify(1000000); sl@0: TEST2(err, KErrNone); sl@0: sl@0: //Cancel the pending notification sl@0: err = session.TestLogNotifyCancel(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: err = session.TestLogNotify(-1); sl@0: TEST2(err, KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-4006 sl@0: @SYMTestCaseDesc Tests Message schema validation for the ELogViewCreate message. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Sends messages to the test server to test the validation of messages sl@0: against the message schema. The messages contain either valid or invalid sl@0: parameters. sl@0: @SYMTestExpectedResults The server should validate the message and handle bad messages appropriately sl@0: @SYMDEF INC114113 sl@0: */ sl@0: void TestLogViewCreateL() sl@0: { sl@0: sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: err = session.TestLogViewCreate(0,ELogViewTypeEvent); sl@0: TEST2(err, KErrNone); sl@0: sl@0: err = session.TestLogViewCreate(100000,ELogViewTypeDuplicate); sl@0: TEST2(err, KErrNone); sl@0: sl@0: err = session.TestLogViewCreate(0,ELogViewTypeDuplicate + 1); sl@0: TEST2(err, KErrArgument); sl@0: sl@0: err = session.TestLogViewCreate(-1,ELogViewTypeRecent); sl@0: TEST2(err, KErrNone); sl@0: sl@0: err = session.TestLogViewCreate(20,-1); sl@0: TEST2(err, KErrArgument); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-4012 sl@0: @SYMTestCaseDesc Tests Message schema validation for the ELogNotifyExtended message. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Sends a message to the test server to test the validation of messages sl@0: against the message schema. The message contains an invalid descriptor. sl@0: @SYMTestExpectedResults The server should panic the client with KErrBadDescriptor sl@0: @SYMDEF INC114113 sl@0: */ sl@0: void TestLogNotifyExtended2L() sl@0: { sl@0: sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: _LIT8(KDes8,"Des8"); sl@0: TPckgBuf int0(0); sl@0: sl@0: err = session.TestLogNotifyExtended(int0, 0, -1, KDes8); sl@0: TEST2(err, KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-4013 sl@0: @SYMTestCaseDesc Tests Message schema validation for an invalid message sl@0: @SYMTestPriority High sl@0: @SYMTestActions Sends a message to the test server with a message number not sl@0: defined in the schema. sl@0: @SYMTestExpectedResults The server should return KErrInvalidFunction sl@0: @SYMDEF INC114113 sl@0: */ sl@0: void InvalidMessageTestL() sl@0: { sl@0: sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //This should cause the server to panic the client sl@0: err = session.TestFunction45(0); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: sl@0: sl@0: static void DoAPITestsL() sl@0: { sl@0: sl@0: TExitDetails exitDetails; sl@0: sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-4004 ")); sl@0: exitDetails = LaunchTestThreadL(_L("TestCliServDataParamL"), &TestCliServDataParamL); sl@0: TEST2(exitDetails.iExitType, EExitKill); sl@0: sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-LEGACY-T_LOGSERVIPC-0001 ")); sl@0: exitDetails = LaunchTestThreadL(_L("TestCliServDataParam2L"), &TestCliServDataParam2L); sl@0: TEST2(exitDetails.iExitType, EExitPanic); sl@0: TEST2(exitDetails.iReason, ELogBadDescriptor); sl@0: sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-LEGACY-T_LOGSERVIPC-0002 ")); sl@0: exitDetails = LaunchTestThreadL(_L("TestCliServDataParam3L"), &TestCliServDataParam3L); sl@0: TEST2(exitDetails.iExitType, EExitPanic); sl@0: TEST2(exitDetails.iReason, ELogBadDescriptor); sl@0: sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-4005 ")); sl@0: exitDetails = LaunchTestThreadL(_L("TestLogNotifyL"), &TestLogNotifyL); sl@0: TEST2(exitDetails.iExitType, EExitKill); sl@0: sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-4006 ")); sl@0: exitDetails = LaunchTestThreadL(_L("TestLogViewCreateL"), &TestLogViewCreateL); sl@0: TEST2(exitDetails.iExitType, EExitKill); sl@0: sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-4012 ")); sl@0: exitDetails = LaunchTestThreadL(_L("TestLogNotifyExtended2L"), &TestLogNotifyExtended2L); sl@0: TEST2(exitDetails.iExitType, EExitKill); sl@0: sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-4013 ")); sl@0: exitDetails = LaunchTestThreadL(_L("InvalidMessageTestL"), &InvalidMessageTestL); sl@0: TEST2(exitDetails.iExitType, EExitPanic); sl@0: TEST2(exitDetails.iReason, ELogIllegalFunction); sl@0: sl@0: //test for debug-only API sl@0: #ifdef _DEBUG sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-4003 ")); sl@0: exitDetails = LaunchTestThreadL(_L("TestMakeTransientL"), &TestMakeTransientL); sl@0: TEST2(exitDetails.iExitType, EExitKill); sl@0: #endif//_DEBUG sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: GLDEF_C TInt E32Main () sl@0: { sl@0: sl@0: TheTest.Printf (_L ("\n")); sl@0: TheTest.Title (); sl@0: TheTest.Start (_L("IPC Fuzz Tests")); sl@0: sl@0: CTrapCleanup* cleanup=CTrapCleanup::New(); sl@0: TEST(cleanup != NULL); sl@0: sl@0: TInt err=KErrNoMemory; sl@0: if (cleanup) sl@0: { sl@0: sl@0: // Construct and install the active scheduler sl@0: CActiveScheduler* scheduler = new CActiveScheduler; sl@0: TEST(scheduler != NULL); sl@0: CActiveScheduler::Install (scheduler); sl@0: sl@0: KillProcess(KServerProcess); sl@0: User::After(1000000); sl@0: sl@0: TRAP (err, DoFuzzTestsL ()); sl@0: TEST2(err, KErrNone); sl@0: sl@0: TheTest.Next(_L("LogServ API Robustness Tests")); sl@0: TRAP (err, DoAPITestsL ()); sl@0: TEST2(err, KErrNone); sl@0: sl@0: TheTest.End (); sl@0: TheTest.Close (); sl@0: sl@0: delete scheduler; sl@0: delete cleanup; sl@0: sl@0: } sl@0: return err; sl@0: }