76 |
77 |
77 static TLogClientServerData TheLogIpcData; |
78 static TLogClientServerData TheLogIpcData; |
78 static TPtrC8 TheLogIpcDataPtr((const TUint8*)&TheLogIpcData, sizeof(TheLogIpcData)); |
79 static TPtrC8 TheLogIpcDataPtr((const TUint8*)&TheLogIpcData, sizeof(TheLogIpcData)); |
79 |
80 |
80 /////////////////////////////////////////////////////////////////////////////////////// |
81 /////////////////////////////////////////////////////////////////////////////////////// |
81 /////////////////////////////////////////////////////////////////////////////////////// |
|
82 //Test macros and functions |
|
83 void Check1(TInt aValue, TInt aLine, TBool aPrintThreadName = EFalse) |
|
84 { |
|
85 if(!aValue) |
|
86 { |
|
87 if(aPrintThreadName) |
|
88 { |
|
89 RThread th; |
|
90 TName name = th.Name(); |
|
91 RDebug::Print(_L("*** Thread %S, Line %d\r\n"), &name, aLine); |
|
92 } |
|
93 else |
|
94 { |
|
95 RDebug::Print(_L("*** Line %d\r\n"), aLine); |
|
96 } |
|
97 TheTest(EFalse, aLine); |
|
98 } |
|
99 } |
|
100 void Check2(TInt aValue, TInt aExpected, TInt aLine, TBool aPrintThreadName = EFalse) |
|
101 { |
|
102 if(aValue != aExpected) |
|
103 { |
|
104 if(aPrintThreadName) |
|
105 { |
|
106 RThread th; |
|
107 TName name = th.Name(); |
|
108 RDebug::Print(_L("*** Thread %S, Line %d Expected error: %d, got: %d\r\n"), &name, aLine, aExpected, aValue); |
|
109 } |
|
110 else |
|
111 { |
|
112 RDebug::Print(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue); |
|
113 } |
|
114 TheTest(EFalse, aLine); |
|
115 } |
|
116 } |
|
117 #define TEST(arg) ::Check1((arg), __LINE__) |
|
118 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__) |
|
119 #define TTEST(arg) ::Check1((arg), __LINE__, ETrue) |
|
120 #define TTEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__, ETrue) |
|
121 |
|
122 /////////////////////////////////////////////////////////////////////////////////////// |
|
123 |
82 |
124 void PrintIterationCount(TInt aIteration) |
83 void PrintIterationCount(TInt aIteration) |
125 { |
84 { |
126 if((aIteration % 100) == 0) |
85 if((aIteration % 100) == 0) |
127 { |
86 { |
128 TTime time; |
87 TTime time; |
129 time.HomeTime(); |
88 time.HomeTime(); |
130 TDateTime dt = time.DateTime(); |
89 TDateTime dt = time.DateTime(); |
131 TBuf<16> tbuf; |
90 TBuf<16> tbuf; |
132 tbuf.Format(_L("%02d:%02d:%02d.%06d"), dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond()); |
91 tbuf.Format(_L("%02d:%02d:%02d.%06d"), dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond()); |
133 RDebug::Print(_L("-----[%S] Test iterations: %d\r\n"), &tbuf, aIteration); |
92 TheTest.Printf(_L("-----[%S] Test iterations: %d\r\n"), &tbuf, aIteration); |
134 } |
93 } |
135 } |
94 } |
136 |
95 |
137 ////////////////////////////////////////////////////////////////////////////////////////////////// |
96 ////////////////////////////////////////////////////////////////////////////////////////////////// |
138 ////////////////////////////////////////////////////////////////////////////////////////////////// |
97 ////////////////////////////////////////////////////////////////////////////////////////////////// |
288 if(err == KErrAlreadyExists) |
247 if(err == KErrAlreadyExists) |
289 { |
248 { |
290 TheTest.Printf(_L("##Iteration %d. Function %d. Thread \"%S\" already exists!\r\n"), data.iIteration, data.iFunction, &KTestThreadName); |
249 TheTest.Printf(_L("##Iteration %d. Function %d. Thread \"%S\" already exists!\r\n"), data.iIteration, data.iFunction, &KTestThreadName); |
291 for(TInt i=0;i<KMaxMessageArguments;++i) |
250 for(TInt i=0;i<KMaxMessageArguments;++i) |
292 { |
251 { |
293 RDebug::Print(_L("##Arg %d, Type %d\r\n"), i + 1, data.iArgType[i]); |
252 TheTest.Printf(_L("##Arg %d, Type %d\r\n"), i + 1, data.iArgType[i]); |
294 switch(data.iArgType[i]) |
253 switch(data.iArgType[i]) |
295 { |
254 { |
296 case EIntArgType: |
255 case EIntArgType: |
297 RDebug::Print(_L("Integer, value=%d\r\n"), data.iIntArg[i]); |
256 TheTest.Printf(_L("Integer, value=%d\r\n"), data.iIntArg[i]); |
298 break; |
257 break; |
299 case ETextArgType: |
258 case ETextArgType: |
300 RDebug::Print(_L("Text, length=%d\r\n"), data.iTextArg[i].Length()); |
259 TheTest.Printf(_L("Text, length=%d\r\n"), data.iTextArg[i].Length()); |
301 break; |
260 break; |
302 case EBinArgType: |
261 case EBinArgType: |
303 RDebug::Print(_L("Binary, length=%d\r\n"), data.iBinArg[i].Length()); |
262 TheTest.Printf(_L("Binary, length=%d\r\n"), data.iBinArg[i].Length()); |
304 break; |
263 break; |
305 default: |
264 default: |
306 RDebug::Print(_L("Invalid argument type: %d\r\n"), data.iArgType[i]); |
265 TheTest.Printf(_L("Invalid argument type: %d\r\n"), data.iArgType[i]); |
307 break; |
266 break; |
308 } |
267 } |
309 } |
268 } |
310 break; |
269 break; |
311 } |
270 } |
323 |
282 |
324 if(exitType == EExitPanic) |
283 if(exitType == EExitPanic) |
325 { |
284 { |
326 if(exitReason == KPanicCode) |
285 if(exitReason == KPanicCode) |
327 { |
286 { |
328 RDebug::Print(_L("##Server terminated!\r\n")); |
287 TheTest.Printf(_L("##Server terminated!\r\n")); |
329 RDebug::Print(_L("##Iteration=%d, Function=%d\r\n"), data.iIteration, data.iFunction); |
288 TheTest.Printf(_L("##Iteration=%d, Function=%d\r\n"), data.iIteration, data.iFunction); |
330 for(TInt i=0;i<KMaxMessageArguments;++i) |
289 for(TInt i=0;i<KMaxMessageArguments;++i) |
331 { |
290 { |
332 RDebug::Print(_L("##Arg %d, Type %d\r\n"), i + 1, data.iArgType[i]); |
291 TheTest.Printf(_L("##Arg %d, Type %d\r\n"), i + 1, data.iArgType[i]); |
333 switch(data.iArgType[i]) |
292 switch(data.iArgType[i]) |
334 { |
293 { |
335 case EIntArgType: |
294 case EIntArgType: |
336 RDebug::Print(_L("Integer, value=%d\r\n"), data.iIntArg[i]); |
295 TheTest.Printf(_L("Integer, value=%d\r\n"), data.iIntArg[i]); |
337 break; |
296 break; |
338 case ETextArgType: |
297 case ETextArgType: |
339 RDebug::Print(_L("Text, length=%d\r\n"), data.iTextArg[i].Length()); |
298 TheTest.Printf(_L("Text, length=%d\r\n"), data.iTextArg[i].Length()); |
340 break; |
299 break; |
341 case EBinArgType: |
300 case EBinArgType: |
342 RDebug::Print(_L("Binary, length=%d\r\n"), data.iBinArg[i].Length()); |
301 TheTest.Printf(_L("Binary, length=%d\r\n"), data.iBinArg[i].Length()); |
343 break; |
302 break; |
344 default: |
303 default: |
345 RDebug::Print(_L("Invalid argument type: %d\r\n"), data.iArgType[i]); |
304 TheTest.Printf(_L("Invalid argument type: %d\r\n"), data.iArgType[i]); |
346 break; |
305 break; |
347 } |
306 } |
348 } |
307 } |
349 TEST(0); |
308 TEST(0); |
350 } |
309 } |