loggingservices/eventlogger/test/src/t_logbadclient.cpp
changeset 55 44f437012c90
parent 51 7d4490026038
equal deleted inserted replaced
51:7d4490026038 55:44f437012c90
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    22 
    22 
    23 ///////////////////////////////////////////////////////////////////////////////////////
    23 ///////////////////////////////////////////////////////////////////////////////////////
    24 
    24 
    25 RTest TheTest(_L("t_logbadclient test"));
    25 RTest TheTest(_L("t_logbadclient test"));
    26 
    26 
       
    27 #if defined __WINS__ || defined __WINSCW__
    27 const TInt KTestIterCount = 5000;
    28 const TInt KTestIterCount = 5000;
       
    29 #else
       
    30 const TInt KTestIterCount = 2500;
       
    31 #endif
    28 const TInt KMaxDesArgLen = 1000;
    32 const TInt KMaxDesArgLen = 1000;
    29 enum TArgType 
    33 enum TArgType 
    30 	{
    34 	{
    31 	EIntArgType, 
    35 	EIntArgType, 
    32 	ETextArgType, 
    36 	ETextArgType, 
    70 	};
    74 	};
    71 //////////////////////////////////////////////////////////////////////////////////////
    75 //////////////////////////////////////////////////////////////////////////////////////
    72 
    76 
    73 _LIT(KPanicCategory, "SrvTerm");
    77 _LIT(KPanicCategory, "SrvTerm");
    74 _LIT(KPanicCategory2, "InvArg");
    78 _LIT(KPanicCategory2, "InvArg");
       
    79 _LIT(KPanicCategory3, "SessConn");
       
    80 _LIT(KPanicCategory4, "TcNull");
       
    81 _LIT(KPanicCategory5, "ThrDNull");
       
    82 
    75 const TInt KPanicCode = 1111;
    83 const TInt KPanicCode = 1111;
    76 const TInt KPanicCode2 = 2222;
    84 const TInt KPanicCode2 = 2222;
    77 
    85 
    78 static TLogClientServerData TheLogIpcData;
    86 static TLogClientServerData TheLogIpcData;
    79 static TPtrC8 TheLogIpcDataPtr((const TUint8*)&TheLogIpcData, sizeof(TheLogIpcData));
    87 static TPtrC8 TheLogIpcDataPtr((const TUint8*)&TheLogIpcData, sizeof(TheLogIpcData));
    80 
    88 
    81 ///////////////////////////////////////////////////////////////////////////////////////
    89 ///////////////////////////////////////////////////////////////////////////////////////
    82 
    90 
    83 void PrintIterationCount(TInt aIteration)
    91 void PrintIterationCount(TInt aIteration)
    84 	{
    92 	{
    85 	if((aIteration % 100) == 0)
    93 	static TInt lastIteration = 0;
    86 		{
    94 	if((aIteration - lastIteration) >= 100)
       
    95 		{
       
    96 		lastIteration = aIteration;
    87 		TTime time;
    97 		TTime time;
    88 		time.HomeTime();
    98 		time.HomeTime();
    89 		TDateTime dt = time.DateTime();
    99 		TDateTime dt = time.DateTime();
    90 		TBuf<16> tbuf;
   100 		TBuf<16> tbuf;
    91 		tbuf.Format(_L("%02d:%02d:%02d.%06d"), dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond());
   101 		tbuf.Format(_L("%02d:%02d:%02d.%06d"), dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond());
   105 TInt ThreadFunc1(void* aData)
   115 TInt ThreadFunc1(void* aData)
   106 	{
   116 	{
   107 	__UHEAP_MARK;
   117 	__UHEAP_MARK;
   108 	
   118 	
   109 	CTrapCleanup* tc = CTrapCleanup::New();
   119 	CTrapCleanup* tc = CTrapCleanup::New();
   110 	TTEST(tc != NULL);
   120 	if(!tc)
       
   121 		{
       
   122 		User::Panic(KPanicCategory4, KErrNoMemory);
       
   123 		}
   111 
   124 
   112 	TThreadData* p = static_cast <TThreadData*> (aData);
   125 	TThreadData* p = static_cast <TThreadData*> (aData);
   113 	TTEST(p != NULL);
   126 	if(!p)
       
   127 		{
       
   128 		User::Panic(KPanicCategory5, KErrArgument);
       
   129 		}
   114 	TThreadData& data = *p;
   130 	TThreadData& data = *p;
   115 	
   131 	
   116 	RLogSession sess;
   132 	RLogSession sess;
   117 	TInt err = sess.Connect();
   133 	TInt err = sess.Connect();
   118 	TTEST2(err, KErrNone);
   134 	if(err != KErrNone)
       
   135 		{
       
   136 		User::Panic(KPanicCategory3, err);
       
   137 		}
   119 
   138 
   120 	while(++data.iIteration <= KTestIterCount)
   139 	while(++data.iIteration <= KTestIterCount)
   121 		{
   140 		{
   122 		TIpcArgs args;
   141 		TIpcArgs args;
   123 		const TInt KFnCnt = sizeof(KLogIpcMsgCodes) / sizeof(KLogIpcMsgCodes[0]);
   142 		const TInt KFnCnt = sizeof(KLogIpcMsgCodes) / sizeof(KLogIpcMsgCodes[0]);
   124 		TInt fnIdx = Math::Rand(data.iSeed) % KFnCnt;
   143 		TInt fnIdx = Math::Rand(data.iSeed) % KFnCnt;
   125 		data.iFunction = KLogIpcMsgCodes[fnIdx];
   144 		data.iFunction = KLogIpcMsgCodes[fnIdx];
   126 		PrintIterationCount(data.iIteration);
       
   127 		for(TInt argIdx=0;argIdx<KMaxMessageArguments;++argIdx)
   145 		for(TInt argIdx=0;argIdx<KMaxMessageArguments;++argIdx)
   128 			{
   146 			{
   129 			//Initialize arguments
   147 			//Initialize arguments
   130 			data.iArgType[argIdx] = EBinArgType;
   148 			data.iArgType[argIdx] = EBinArgType;
   131 			if(argIdx > 0)
   149 			if(argIdx > 0)