equal
deleted
inserted
replaced
1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2009-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". |
83 TName name = th.Name(); |
83 TName name = th.Name(); |
84 RDebug::Print(_L("*** Expression evaluated to false. Thread %S, Line %d\r\n"), &name, aLine); |
84 RDebug::Print(_L("*** Expression evaluated to false. Thread %S, Line %d\r\n"), &name, aLine); |
85 } |
85 } |
86 else |
86 else |
87 { |
87 { |
88 RDebug::Print(_L("*** Expression evaluated to false. Line %d\r\n"), aLine); |
88 TheTest.Printf(_L("*** Expression evaluated to false. Line %d\r\n"), aLine); |
89 } |
89 } |
90 TheTest(EFalse, aLine); |
90 TheTest(EFalse, aLine); |
91 } |
91 } |
92 } |
92 } |
93 void Check2(TInt aValue, TInt aExpected, TInt aLine, TBool aPrintThreadName = EFalse) |
93 void Check2(TInt aValue, TInt aExpected, TInt aLine, TBool aPrintThreadName = EFalse) |
166 public: |
166 public: |
167 TInt Connect(); |
167 TInt Connect(); |
168 void Close(); |
168 void Close(); |
169 TInt SendReceive(TInt aFunction); |
169 TInt SendReceive(TInt aFunction); |
170 TInt SendReceive(TInt aFunction, const TIpcArgs& aArgs); |
170 TInt SendReceive(TInt aFunction, const TIpcArgs& aArgs); |
|
171 void SendReceive(TInt aFunction, const TIpcArgs& aArgs, TRequestStatus& aStatus); |
171 |
172 |
172 private: |
173 private: |
173 TInt DoCreateSession(); |
174 TInt DoCreateSession(); |
174 }; |
175 }; |
175 |
176 |
194 } |
195 } |
195 |
196 |
196 TInt RTestFeatMgrSession::SendReceive(TInt aFunction, const TIpcArgs& aArgs) |
197 TInt RTestFeatMgrSession::SendReceive(TInt aFunction, const TIpcArgs& aArgs) |
197 { |
198 { |
198 return RSessionBase::SendReceive(aFunction, aArgs); |
199 return RSessionBase::SendReceive(aFunction, aArgs); |
|
200 } |
|
201 |
|
202 void RTestFeatMgrSession::SendReceive(TInt aFunction, const TIpcArgs& aArgs, TRequestStatus& aStatus) |
|
203 { |
|
204 RSessionBase::SendReceive(aFunction, aArgs, aStatus); |
199 } |
205 } |
200 |
206 |
201 TInt RTestFeatMgrSession::DoCreateSession() |
207 TInt RTestFeatMgrSession::DoCreateSession() |
202 { |
208 { |
203 const TInt KRetry( 2 ); |
209 const TInt KRetry( 2 ); |
234 } |
240 } |
235 |
241 |
236 return err; |
242 return err; |
237 } |
243 } |
238 |
244 |
239 void PrintIterationCount(TInt aIteration) |
245 void PrintIterationCount(TInt aIteration, TBool aFromThread = EFalse) |
240 { |
246 { |
241 if((aIteration % 100) == 0) |
247 if((aIteration % 100) == 0) |
242 { |
248 { |
243 TTime time; |
249 TTime time; |
244 time.HomeTime(); |
250 time.HomeTime(); |
245 TDateTime dt = time.DateTime(); |
251 TDateTime dt = time.DateTime(); |
246 TBuf<16> tbuf; |
252 TBuf<16> tbuf; |
247 tbuf.Format(_L("%02d:%02d:%02d.%06d"), dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond()); |
253 tbuf.Format(_L("%02d:%02d:%02d.%06d"), dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond()); |
248 RDebug::Print(_L("-----[%S] Test iterations: %d\r\n"), &tbuf, aIteration); |
254 if(aFromThread) |
|
255 { |
|
256 RDebug::Print(_L("-----[%S] Test iterations: %d\r\n"), &tbuf, aIteration); |
|
257 } |
|
258 else |
|
259 { |
|
260 TheTest.Printf(_L("-----[%S] Test iterations: %d\r\n"), &tbuf, aIteration); |
|
261 } |
249 } |
262 } |
250 } |
263 } |
251 |
264 |
252 //Worker thread function. |
265 //Worker thread function. |
253 //It behaves as a malicious client. Connects to the FeatMgr server. In each test iteration generates some random values |
266 //It behaves as a malicious client. Connects to the FeatMgr server. In each test iteration generates some random values |
270 TInt err = sess.Connect(); |
283 TInt err = sess.Connect(); |
271 TTEST2(err, KErrNone); |
284 TTEST2(err, KErrNone); |
272 |
285 |
273 while(++data.iIteration <= KTestIterCount) |
286 while(++data.iIteration <= KTestIterCount) |
274 { |
287 { |
275 RDebug::Print(_L("++++ %d\r\n"), data.iIteration); |
288 PrintIterationCount(data.iIteration, ETrue); |
276 |
|
277 PrintIterationCount(data.iIteration); |
|
278 TIpcArgs args; |
289 TIpcArgs args; |
279 data.iFunction = Math::Rand(data.iSeed) % (EFeatMgrSWIEnd + 1);//EFeatMgrSWIEnd - the last server message number (without resource checking IPCs)) |
290 data.iFunction = Math::Rand(data.iSeed) % (EFeatMgrSWIEnd + 1);//EFeatMgrSWIEnd - the last server message number (without resource checking IPCs)) |
280 for(TInt i=0;i<KMaxMessageArguments;++i) |
291 for(TInt i=0;i<KMaxMessageArguments;++i) |
281 { |
292 { |
282 //Initialize arguments |
293 //Initialize arguments |
307 } |
318 } |
308 } |
319 } |
309 //Send arguments |
320 //Send arguments |
310 User::SetJustInTime(EFalse); |
321 User::SetJustInTime(EFalse); |
311 TInt err = KErrNone; |
322 TInt err = KErrNone; |
312 err = sess.SendReceive(data.iFunction, args); |
323 if(data.iFunction == EFeatMgrReqNotify) |
|
324 { |
|
325 TRequestStatus status; |
|
326 sess.SendReceive(data.iFunction, args, status); |
|
327 if(status == KRequestPending) |
|
328 { |
|
329 err = sess.SendReceive(EFeatMgrReqNotifyCancelAll); |
|
330 } |
|
331 else |
|
332 { |
|
333 err = status.Int(); |
|
334 } |
|
335 } |
|
336 else |
|
337 { |
|
338 err = sess.SendReceive(data.iFunction, args); |
|
339 } |
313 if(err == KErrServerTerminated) |
340 if(err == KErrServerTerminated) |
314 { |
341 { |
315 User::Panic(KPanicCategory, KPanicCode); |
342 User::Panic(KPanicCategory, KPanicCode); |
316 } |
343 } |
317 User::SetJustInTime(ETrue); |
344 User::SetJustInTime(ETrue); |
393 delete p; |
420 delete p; |
394 } |
421 } |
395 |
422 |
396 void DoTestsL() |
423 void DoTestsL() |
397 { |
424 { |
398 //TODO: this test won't pass |
425 //This test won't pass |
399 TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4065 Bad client test")); |
426 TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4065 Bad client test")); |
400 BadClientTest(); |
427 BadClientTest(); |
401 } |
428 } |
402 |
429 |
403 TInt E32Main() |
430 TInt E32Main() |