44 CBaseTestCase::CBaseTestCase(const TDesC& aTestCaseId,TBool aHostFlag, TBool aHostOnly) |
48 CBaseTestCase::CBaseTestCase(const TDesC& aTestCaseId,TBool aHostFlag, TBool aHostOnly) |
45 : CActive(EPriorityStandard), |
49 : CActive(EPriorityStandard), |
46 iHost(aHostFlag), |
50 iHost(aHostFlag), |
47 iHostOnly(aHostOnly) |
51 iHostOnly(aHostOnly) |
48 { |
52 { |
|
53 OstTraceFunctionEntryExt( CBASETESTCASE_CBASETESTCASE_ENTRY, this ); |
49 iTestCaseId.Copy(aTestCaseId); |
54 iTestCaseId.Copy(aTestCaseId); |
50 CActiveScheduler::Add(this); |
55 CActiveScheduler::Add(this); |
|
56 OstTraceFunctionExit1( CBASETESTCASE_CBASETESTCASE_EXIT, this ); |
51 } |
57 } |
52 |
58 |
53 void CBaseTestCase::BaseConstructL() |
59 void CBaseTestCase::BaseConstructL() |
54 { |
60 { |
55 LOG_FUNC |
61 OstTraceFunctionEntry1( CBASETESTCASE_BASECONSTRUCTL_ENTRY, this ); |
56 RDebug::Printf("Creating test case timer"); |
62 OstTrace0(TRACE_NORMAL, CBASETESTCASE_BASECONSTRUCTL, "Creating test case timer"); |
57 TInt err(iTimer.CreateLocal()); |
63 TInt err(iTimer.CreateLocal()); |
58 if(err == KErrNone) |
64 if(err == KErrNone) |
59 { |
65 { |
60 RDebug::Printf("Test case timer created"); |
66 OstTrace0(TRACE_NORMAL, CBASETESTCASE_BASECONSTRUCTL_DUP01, "Test case timer created"); |
61 } |
67 } |
62 else |
68 else |
63 { |
69 { |
64 RDebug::Printf("<Error %d> Test case timer could not be created",err); |
70 OstTrace1(TRACE_NORMAL, CBASETESTCASE_BASECONSTRUCTL_DUP02, "<Error %d> Test case timer could not be created",err); |
65 User::Leave(err); |
71 User::Leave(err); |
66 } |
72 } |
|
73 OstTraceFunctionExit1( CBASETESTCASE_BASECONSTRUCTL_EXIT, this ); |
67 } |
74 } |
68 |
75 |
69 void CBaseTestCase::TimeoutIn(TInt aTimeoutPeriod) |
76 void CBaseTestCase::TimeoutIn(TInt aTimeoutPeriod) |
70 { |
77 { |
71 LOG_FUNC |
78 OstTraceFunctionEntryExt( CBASETESTCASE_TIMEOUTIN_ENTRY, this ); |
72 |
79 |
73 CancelTimeout(); |
80 CancelTimeout(); |
74 iTimer.After(iStatus,aTimeoutPeriod*1000000); |
81 iTimer.After(iStatus,aTimeoutPeriod*1000000); |
75 SetActive(); |
82 SetActive(); |
|
83 OstTraceFunctionExit1( CBASETESTCASE_TIMEOUTIN_EXIT, this ); |
76 } |
84 } |
77 |
85 |
78 |
86 |
79 void CBaseTestCase::CancelTimeout() |
87 void CBaseTestCase::CancelTimeout() |
80 { |
88 { |
|
89 OstTraceFunctionEntry1( CBASETESTCASE_CANCELTIMEOUT_ENTRY, this ); |
81 iTimer.Cancel(); |
90 iTimer.Cancel(); |
|
91 OstTraceFunctionExit1( CBASETESTCASE_CANCELTIMEOUT_EXIT, this ); |
82 } |
92 } |
83 |
93 |
84 TInt CBaseTestCase::GenerateRefFile(const TDesC& aFileName) |
94 TInt CBaseTestCase::GenerateRefFile(const TDesC& aFileName) |
85 { |
95 { |
86 |
96 OstTraceFunctionEntryExt( CBASETESTCASE_GENERATEREFFILE_ENTRY, this ); |
87 LOG_FUNC |
97 |
88 TBuf<256> refTreeFullFileName(KGeneratedFilesPath); |
98 TBuf<256> refTreeFullFileName(KGeneratedFilesPath); |
89 refTreeFullFileName.Append(aFileName); |
99 refTreeFullFileName.Append(aFileName); |
90 refTreeFullFileName.Append(KExtensionFile); |
100 refTreeFullFileName.Append(KExtensionFile); |
91 |
101 |
92 RFile refFile; |
102 RFile refFile; |
93 TInt ret = KErrNone; |
103 TInt ret = KErrNone; |
94 ret = iFs.Connect(); |
104 ret = iFs.Connect(); |
95 if(ret!=KErrNone && ret!=KErrAlreadyExists) |
105 if(ret!=KErrNone && ret!=KErrAlreadyExists) |
96 // if already connected, ignore |
106 // if already connected, ignore |
97 { |
107 { |
98 RDebug::Printf("iFs.Connect fails, ret = %d", ret); |
108 OstTrace1(TRACE_NORMAL, CBASETESTCASE_GENERATEREFFILE, "iFs.Connect fails, ret = %d", ret); |
|
109 OstTraceFunctionExitExt( CBASETESTCASE_GENERATEREFFILE_EXIT, this, ret ); |
99 return ret; |
110 return ret; |
100 } |
111 } |
101 |
112 |
102 ret = iFs.Delete(refTreeFullFileName); |
113 ret = iFs.Delete(refTreeFullFileName); |
103 if(ret == KErrNone || ret == KErrNotFound) |
114 if(ret == KErrNone || ret == KErrNotFound) |
105 ret = refFile.Create(iFs,refTreeFullFileName,EFileShareAny|EFileWrite); |
116 ret = refFile.Create(iFs,refTreeFullFileName,EFileShareAny|EFileWrite); |
106 } |
117 } |
107 |
118 |
108 if(ret!=KErrNone) |
119 if(ret!=KErrNone) |
109 { |
120 { |
110 RDebug::Printf("refFile.Create fails, ret = %d", ret); |
121 OstTrace1(TRACE_NORMAL, CBASETESTCASE_GENERATEREFFILE_DUP01, "refFile.Create fails, ret = %d", ret); |
|
122 OstTraceFunctionExitExt( CBASETESTCASE_GENERATEREFFILE_EXIT_DUP01, this, ret ); |
111 return ret; |
123 return ret; |
112 } |
124 } |
113 |
125 |
114 refFile.Write(iTreeBuffer); |
126 refFile.Write(iTreeBuffer); |
115 refFile.Flush(); |
127 refFile.Flush(); |
116 refFile.Close(); |
128 refFile.Close(); |
117 |
129 |
|
130 OstTraceFunctionExitExt( CBASETESTCASE_GENERATEREFFILE_EXIT_DUP02, this, KErrNone ); |
118 return KErrNone; |
131 return KErrNone; |
119 } |
132 } |
120 |
133 |
121 TInt CBaseTestCase::CompareCurrentTreeToRef(const TDesC& aFileName, TBool& aIsIdentical) |
134 TInt CBaseTestCase::CompareCurrentTreeToRef(const TDesC& aFileName, TBool& aIsIdentical) |
122 { |
135 { |
123 |
136 OstTraceFunctionEntryExt( CBASETESTCASE_COMPARECURRENTTREETOREF_ENTRY, this ); |
124 LOG_FUNC |
137 |
125 TBuf<256> refTreeFullFileName(KRefPath); |
138 TBuf<256> refTreeFullFileName(KRefPath); |
126 refTreeFullFileName.Append(aFileName); |
139 refTreeFullFileName.Append(aFileName); |
127 refTreeFullFileName.Append(KExtensionFile); |
140 refTreeFullFileName.Append(KExtensionFile); |
128 |
141 |
129 TInt ret = KErrNone; |
142 TInt ret = KErrNone; |
130 ret = iFs.Connect(); |
143 ret = iFs.Connect(); |
131 if(ret!=KErrNone && ret!=KErrAlreadyExists) |
144 if(ret!=KErrNone && ret!=KErrAlreadyExists) |
132 // if already connected, ignore |
145 // if already connected, ignore |
133 { |
146 { |
134 RDebug::Printf("iFs.Connect fails, ret = %d", ret); |
147 OstTrace1(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF, "iFs.Connect fails, ret = %d", ret); |
|
148 OstTraceFunctionExitExt( CBASETESTCASE_COMPARECURRENTTREETOREF_EXIT, this, ret ); |
135 return ret; |
149 return ret; |
136 } |
150 } |
137 |
151 |
138 RFile refFile; |
152 RFile refFile; |
139 ret = refFile.Open(iFs,refTreeFullFileName,EFileShareAny|EFileRead); |
153 ret = refFile.Open(iFs,refTreeFullFileName,EFileShareAny|EFileRead); |
140 |
154 |
141 if(ret!=KErrNone) |
155 if(ret!=KErrNone) |
142 { |
156 { |
143 RDebug::Printf("Reference File path: %S", &refTreeFullFileName); |
157 OstTraceExt1(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP01, "Reference File path: %S", refTreeFullFileName); |
144 RDebug::Printf("refFile.Open fails ret = %d", ret); |
158 OstTrace1(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP02, "refFile.Open fails ret = %d", ret); |
|
159 OstTraceFunctionExitExt( CBASETESTCASE_COMPARECURRENTTREETOREF_EXIT_DUP01, this, ret ); |
145 return ret; |
160 return ret; |
146 } |
161 } |
147 |
162 |
148 TInt refFileSize; |
163 TInt refFileSize; |
149 refFile.Size(refFileSize); |
164 refFile.Size(refFileSize); |
150 |
165 |
151 // check size is identical |
166 // check size is identical |
152 if(refFileSize != iTreeBuffer.Size()) |
167 if(refFileSize != iTreeBuffer.Size()) |
153 { |
168 { |
154 RDebug::Printf("sizes are NOT identical, refFileSize = %d, iTreeBuffer.Size() = %d ", refFileSize, iTreeBuffer.Size()); |
169 OstTraceExt2(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP03, "sizes are NOT identical, refFileSize = %d, iTreeBuffer.Size() = %d ", refFileSize, iTreeBuffer.Size()); |
155 //return KErrGeneral; not an issue, \n encoded differently by perforce... x0D x0A. (x0A only in generated ref file) |
170 //return KErrGeneral; not an issue, \n encoded differently by perforce... x0D x0A. (x0A only in generated ref file) |
156 } |
171 } |
157 |
172 |
158 // read the file, and put it in a local buffer |
173 // read the file, and put it in a local buffer |
159 RBuf8 refBuf; |
174 RBuf8 refBuf; |
160 refBuf.CreateL(refFileSize); |
175 refBuf.CreateL(refFileSize); |
161 ret = refFile.Read(0, refBuf, refFileSize); |
176 ret = refFile.Read(0, refBuf, refFileSize); |
162 |
177 |
163 if(ret!=KErrNone) |
178 if(ret!=KErrNone) |
164 { |
179 { |
165 RDebug::Printf("refFile.Read fails %d", ret); |
180 OstTrace1(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP04, "refFile.Read fails %d", ret); |
|
181 OstTraceFunctionExitExt( CBASETESTCASE_COMPARECURRENTTREETOREF_EXIT_DUP02, this, ret ); |
166 return ret; |
182 return ret; |
167 } |
183 } |
168 |
184 |
169 // find occurences of \n now |
185 // find occurences of \n now |
170 RBuf8 copyRefBuf; |
186 RBuf8 copyRefBuf; |
187 } |
203 } |
188 copyRefBuf.AppendFormat(_L8("%c"), refBuf[iRefBuffer]); |
204 copyRefBuf.AppendFormat(_L8("%c"), refBuf[iRefBuffer]); |
189 } |
205 } |
190 refBuf.Close(); |
206 refBuf.Close(); |
191 |
207 |
192 RDebug::Printf("copyRefBuf.Size %d", copyRefBuf.Size()); |
208 OstTrace1(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP05, "copyRefBuf.Size %d", copyRefBuf.Size()); |
193 |
209 |
194 |
210 |
195 // check size is identical, should be identical now |
211 // check size is identical, should be identical now |
196 if(copyRefBuf.Size() != iTreeBuffer.Size()) |
212 if(copyRefBuf.Size() != iTreeBuffer.Size()) |
197 { |
213 { |
198 RDebug::Printf("sizes are NOT identical, copyRefBuf.Size() = %d, iTreeBuffer.Size() = %d ", refFileSize, iTreeBuffer.Size()); |
214 OstTraceExt2(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP06, "sizes are NOT identical, copyRefBuf.Size() = %d, iTreeBuffer.Size() = %d ", refFileSize, iTreeBuffer.Size()); |
|
215 OstTraceFunctionExitExt( CBASETESTCASE_COMPARECURRENTTREETOREF_EXIT_DUP03, this, KErrGeneral ); |
199 return KErrGeneral; |
216 return KErrGeneral; |
200 } |
217 } |
201 |
218 |
202 // now compare the 2 buffers |
219 // now compare the 2 buffers |
203 // Can only go as far as the smallest buffer |
220 // Can only go as far as the smallest buffer |
204 TInt bufferSizeToCheck = Min(copyRefBuf.Size(), iTreeBuffer.Size()); |
221 TInt bufferSizeToCheck = Min(copyRefBuf.Size(), iTreeBuffer.Size()); |
205 RDebug::Print(_L("bufferSizeToCheck = %d"), bufferSizeToCheck); |
222 OstTrace1(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP07, "bufferSizeToCheck = %d", bufferSizeToCheck); |
206 |
223 |
207 aIsIdentical = ETrue; |
224 aIsIdentical = ETrue; |
208 for(TInt iRefBuffer=0; iRefBuffer < bufferSizeToCheck; iRefBuffer++) |
225 for(TInt iRefBuffer=0; iRefBuffer < bufferSizeToCheck; iRefBuffer++) |
209 { |
226 { |
210 if(iTreeBuffer[iRefBuffer] != copyRefBuf[iRefBuffer]) |
227 if(iTreeBuffer[iRefBuffer] != copyRefBuf[iRefBuffer]) |
211 { |
228 { |
212 RDebug::Print(_L("Failed buffer comparison at position %d"), iRefBuffer); |
229 OstTrace1(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP08, "Failed buffer comparison at position %d", iRefBuffer); |
213 RDebug::Print(_L("Missmatching chars (%d %d) (%c %c)"), iTreeBuffer[iRefBuffer], copyRefBuf[iRefBuffer], iTreeBuffer[iRefBuffer], copyRefBuf[iRefBuffer]); |
230 OstTraceExt4(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP09, "Missmatching chars (%d %d) (%c %c)", iTreeBuffer[iRefBuffer], copyRefBuf[iRefBuffer], iTreeBuffer[iRefBuffer], copyRefBuf[iRefBuffer]); |
214 aIsIdentical = EFalse; |
231 aIsIdentical = EFalse; |
215 break; |
232 break; |
216 } |
233 } |
217 } |
234 } |
218 |
235 |
219 RDebug::Print(_L("Finished Buffer comparison aIsIdentical=%d"), aIsIdentical); |
236 OstTrace1(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP10, "Finished Buffer comparison aIsIdentical=%d", aIsIdentical); |
220 |
237 |
221 copyRefBuf.Close(); |
238 copyRefBuf.Close(); |
222 |
239 |
|
240 OstTraceFunctionExitExt( CBASETESTCASE_COMPARECURRENTTREETOREF_EXIT_DUP04, this, KErrNone ); |
223 return KErrNone; |
241 return KErrNone; |
224 } |
242 } |
225 |
243 |
226 CBaseTestCase::~CBaseTestCase() |
244 CBaseTestCase::~CBaseTestCase() |
227 { |
245 { |
228 LOG_FUNC |
246 OstTraceFunctionEntry1( CBASETESTCASE_CBASETESTCASE_ENTRY_DUP01, this ); |
229 Cancel(); |
247 Cancel(); |
230 iTimer.Close(); |
248 iTimer.Close(); |
231 iTreeBuffer.Close(); |
249 iTreeBuffer.Close(); |
232 iFs.Close(); |
250 iFs.Close(); |
|
251 OstTraceFunctionExit1( CBASETESTCASE_CBASETESTCASE_EXIT_DUP01, this ); |
233 } |
252 } |
234 |
253 |
235 void CBaseTestCase::SelfComplete() |
254 void CBaseTestCase::SelfComplete() |
236 { |
255 { |
|
256 OstTraceFunctionEntry1( CBASETESTCASE_SELFCOMPLETE_ENTRY, this ); |
237 SelfComplete(KErrNone); |
257 SelfComplete(KErrNone); |
|
258 OstTraceFunctionExit1( CBASETESTCASE_SELFCOMPLETE_EXIT, this ); |
238 } |
259 } |
239 |
260 |
240 void CBaseTestCase::SelfComplete(TInt aError) |
261 void CBaseTestCase::SelfComplete(TInt aError) |
241 { |
262 { |
|
263 OstTraceFunctionEntryExt( CBASETESTCASE_SELFCOMPLETE_ENTRY_DUP01, this ); |
242 TRequestStatus* s = &iStatus; |
264 TRequestStatus* s = &iStatus; |
243 iStatus = KRequestPending; |
265 iStatus = KRequestPending; |
244 User::RequestComplete(s,aError); |
266 User::RequestComplete(s,aError); |
245 SetActive(); |
267 SetActive(); |
|
268 OstTraceFunctionExit1( CBASETESTCASE_SELFCOMPLETE_EXIT_DUP01, this ); |
246 } |
269 } |
247 |
270 |
248 |
271 |
249 void CBaseTestCase::DoCancel() |
272 void CBaseTestCase::DoCancel() |
250 { |
273 { |
251 LOG_FUNC |
274 OstTraceFunctionEntry1( CBASETESTCASE_DOCANCEL_ENTRY, this ); |
252 iTimer.Cancel(); |
275 iTimer.Cancel(); |
253 if(iHost) |
276 if(iHost) |
254 { |
277 { |
255 HostDoCancel(); |
278 HostDoCancel(); |
256 } |
279 } |
257 else |
280 else |
258 { |
281 { |
259 DeviceDoCancel(); |
282 DeviceDoCancel(); |
260 } |
283 } |
|
284 OstTraceFunctionExit1( CBASETESTCASE_DOCANCEL_EXIT, this ); |
261 } |
285 } |
262 |
286 |
263 void CBaseTestCase::RunL() |
287 void CBaseTestCase::RunL() |
264 { |
288 { |
|
289 OstTraceFunctionEntry1( CBASETESTCASE_RUNL_ENTRY, this ); |
265 if(iHost) |
290 if(iHost) |
266 { |
291 { |
267 HostRunL(); |
292 HostRunL(); |
268 } |
293 } |
269 else |
294 else |
270 { |
295 { |
271 DeviceRunL(); |
296 DeviceRunL(); |
272 } |
297 } |
|
298 OstTraceFunctionExit1( CBASETESTCASE_RUNL_EXIT, this ); |
273 } |
299 } |
274 |
300 |
275 TInt CBaseTestCase::RunError(TInt aError) |
301 TInt CBaseTestCase::RunError(TInt aError) |
276 { |
302 { |
277 LOG_FUNC |
303 OstTraceFunctionEntryExt( CBASETESTCASE_RUNERROR_ENTRY, this ); |
278 RDebug::Printf("Test case C%lS::RunL left with %d",&iTestCaseId,aError); |
304 OstTraceExt2(TRACE_NORMAL, CBASETESTCASE_RUNERROR, "Test case C%lS::RunL left with %d",iTestCaseId,aError); |
279 iTestPolicy->SignalTestComplete(aError); |
305 iTestPolicy->SignalTestComplete(aError); |
|
306 OstTraceFunctionExitExt( CBASETESTCASE_RUNERROR_EXIT, this, KErrNone ); |
280 return KErrNone; |
307 return KErrNone; |
281 } |
308 } |
282 |
309 |
283 TDesC& CBaseTestCase::TestCaseId() |
310 TDesC& CBaseTestCase::TestCaseId() |
284 { |
311 { |
|
312 OstTraceFunctionEntry1( CBASETESTCASE_TESTCASEID_ENTRY, this ); |
|
313 OstTraceFunctionExitExt( CBASETESTCASE_TESTCASEID_EXIT, this, ( TUint )&( iTestCaseId ) ); |
285 return iTestCaseId; |
314 return iTestCaseId; |
286 } |
315 } |
287 |
316 |
288 |
317 |
289 TInt CBaseTestCase::TestResult() const |
318 TInt CBaseTestCase::TestResult() const |
290 { |
319 { |
|
320 OstTraceFunctionEntry1( CBASETESTCASE_TESTRESULT_ENTRY, this ); |
|
321 OstTraceFunctionExitExt( CBASETESTCASE_TESTRESULT_EXIT, this, iTestResult ); |
291 return iTestResult; |
322 return iTestResult; |
292 } |
323 } |
293 |
324 |
294 TBool CBaseTestCase::IsHostOnly() const |
325 TBool CBaseTestCase::IsHostOnly() const |
295 { |
326 { |
|
327 OstTraceFunctionEntry1( CBASETESTCASE_ISHOSTONLY_ENTRY, this ); |
|
328 OstTraceFunctionExitExt( CBASETESTCASE_ISHOSTONLY_EXIT, this, iHostOnly ); |
296 return iHostOnly; |
329 return iHostOnly; |
297 } |
330 } |
298 |
331 |
299 TBool CBaseTestCase::IsHost() const |
332 TBool CBaseTestCase::IsHost() const |
300 { |
333 { |
|
334 OstTraceFunctionEntry1( CBASETESTCASE_ISHOST_ENTRY, this ); |
|
335 OstTraceFunctionExitExt( CBASETESTCASE_ISHOST_EXIT, this, iHost ); |
301 return iHost; |
336 return iHost; |
302 } |
337 } |
303 |
338 |
304 void CBaseTestCase::PerformTestL() |
339 void CBaseTestCase::PerformTestL() |
305 { |
340 { |
|
341 OstTraceFunctionEntry1( CBASETESTCASE_PERFORMTESTL_ENTRY, this ); |
306 |
342 |
307 if(iHost) |
343 if(iHost) |
308 { |
344 { |
309 iTreeBuffer.CreateL(KTreeBufferSize); //32k |
345 iTreeBuffer.CreateL(KTreeBufferSize); //32k |
310 ExecuteHostTestCaseL(); |
346 ExecuteHostTestCaseL(); |
311 } |
347 } |
312 else |
348 else |
313 { |
349 { |
314 ExecuteDeviceTestCaseL(); |
350 ExecuteDeviceTestCaseL(); |
315 } |
351 } |
|
352 OstTraceFunctionExit1( CBASETESTCASE_PERFORMTESTL_EXIT, this ); |
316 } |
353 } |
317 |
354 |
318 void CBaseTestCase::SetTestPolicy(CBasicTestPolicy* aTestPolicy) |
355 void CBaseTestCase::SetTestPolicy(CBasicTestPolicy* aTestPolicy) |
319 { |
356 { |
|
357 OstTraceFunctionEntryExt( CBASETESTCASE_SETTESTPOLICY_ENTRY, this ); |
320 iTestPolicy = aTestPolicy; |
358 iTestPolicy = aTestPolicy; |
|
359 OstTraceFunctionExit1( CBASETESTCASE_SETTESTPOLICY_EXIT, this ); |
321 } |
360 } |
322 |
361 |
323 void CBaseTestCase::TestFailed(TInt aFailResult) |
362 void CBaseTestCase::TestFailed(TInt aFailResult) |
324 { |
363 { |
325 LOG_FUNC |
364 OstTraceFunctionEntryExt( CBASETESTCASE_TESTFAILED_ENTRY, this ); |
326 iTestResult = aFailResult; |
365 iTestResult = aFailResult; |
327 if(!iHostOnly) |
366 if(!iHostOnly) |
328 { |
367 { |
329 RDebug::Printf("CActiveScheduler::Stop CBaseTestCase::TestFailed"); |
368 OstTrace0(TRACE_NORMAL, CBASETESTCASE_TESTFAILED, "CActiveScheduler::Stop CBaseTestCase::TestFailed"); |
330 CActiveScheduler::Stop(); |
369 CActiveScheduler::Stop(); |
331 } |
370 } |
|
371 OstTraceFunctionExit1( CBASETESTCASE_TESTFAILED_EXIT, this ); |
332 } |
372 } |
333 |
373 |
334 void CBaseTestCase::TestPassed() |
374 void CBaseTestCase::TestPassed() |
335 { |
375 { |
336 LOG_FUNC |
376 OstTraceFunctionEntry1( CBASETESTCASE_TESTPASSED_ENTRY, this ); |
337 iTestResult = KErrNone; |
377 iTestResult = KErrNone; |
338 if(!iHostOnly) |
378 if(!iHostOnly) |
339 { |
379 { |
340 RDebug::Printf("CActiveScheduler::Stop CBaseTestCase::TestPassed"); |
380 OstTrace0(TRACE_NORMAL, CBASETESTCASE_TESTPASSED, "CActiveScheduler::Stop CBaseTestCase::TestPassed"); |
341 CActiveScheduler::Stop(); |
381 CActiveScheduler::Stop(); |
342 } |
382 } |
|
383 OstTraceFunctionExit1( CBASETESTCASE_TESTPASSED_EXIT, this ); |
343 } |
384 } |
344 |
385 |
345 CBasicTestPolicy& CBaseTestCase::TestPolicy() |
386 CBasicTestPolicy& CBaseTestCase::TestPolicy() |
346 { |
387 { |
|
388 OstTraceFunctionEntry1( CBASETESTCASE_TESTPOLICY_ENTRY, this ); |
|
389 OstTraceFunctionExit1( CBASETESTCASE_TESTPOLICY_EXIT, this ); |
347 return *iTestPolicy; |
390 return *iTestPolicy; |
348 } |
391 } |
349 |
392 |
350 |
393 |
351 /** |
394 /** |
368 one endpoint of the given type exists on the interface setting |
411 one endpoint of the given type exists on the interface setting |
369 */ |
412 */ |
370 TInt CBaseTestCase::GetEndpointAddress(RUsbInterface& aUsbInterface,TInt aInterfaceSetting, |
413 TInt CBaseTestCase::GetEndpointAddress(RUsbInterface& aUsbInterface,TInt aInterfaceSetting, |
371 TUint8 aTransferType,TUint8 aDirection,TUint8 aIndex,TInt& aEndpointAddress) |
414 TUint8 aTransferType,TUint8 aDirection,TUint8 aIndex,TInt& aEndpointAddress) |
372 { |
415 { |
373 LOG_FUNC |
416 OstTraceFunctionEntryExt( CBASETESTCASE_GETENDPOINTADDRESS_ENTRY_DUP01, this ); |
374 |
417 |
375 // Get the interface descriptor |
418 // Get the interface descriptor |
376 RDebug::Printf("Getting the interface descriptor for this alternate setting"); |
419 OstTrace0(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS, "Getting the interface descriptor for this alternate setting"); |
377 |
420 |
378 TUsbInterfaceDescriptor alternateInterfaceDescriptor; |
421 TUsbInterfaceDescriptor alternateInterfaceDescriptor; |
379 TInt err = aUsbInterface.GetAlternateInterfaceDescriptor(aInterfaceSetting, alternateInterfaceDescriptor); |
422 TInt err = aUsbInterface.GetAlternateInterfaceDescriptor(aInterfaceSetting, alternateInterfaceDescriptor); |
380 |
423 |
381 if(err) |
424 if(err) |
382 { |
425 { |
383 RDebug::Printf("<Error %d> Unable to get alternate interface (%d) descriptor",err,aInterfaceSetting); |
426 OstTraceExt2(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP01, "<Error %d> Unable to get alternate interface (%d) descriptor",err,aInterfaceSetting); |
|
427 OstTraceFunctionExitExt( CBASETESTCASE_GETENDPOINTADDRESS_EXIT, this, err ); |
384 return err; |
428 return err; |
385 } |
429 } |
386 |
430 |
387 // Parse the descriptor tree from the interface |
431 // Parse the descriptor tree from the interface |
388 RDebug::Printf("Search the child descriptors for matching endpoint attributes"); |
432 OstTrace0(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP02, "Search the child descriptors for matching endpoint attributes"); |
389 |
433 |
390 TUsbGenericDescriptor* descriptor = alternateInterfaceDescriptor.iFirstChild; |
434 TUsbGenericDescriptor* descriptor = alternateInterfaceDescriptor.iFirstChild; |
391 TUint8 indexCount = 0; |
435 TUint8 indexCount = 0; |
392 while(descriptor) |
436 while(descriptor) |
393 { |
437 { |
394 RDebug::Printf("Check descriptor type for endpoint"); |
438 OstTrace0(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP03, "Check descriptor type for endpoint"); |
395 |
439 |
396 // Cast the descriptor to an endpoint descriptor |
440 // Cast the descriptor to an endpoint descriptor |
397 TUsbEndpointDescriptor* endpoint = TUsbEndpointDescriptor::Cast(descriptor); |
441 TUsbEndpointDescriptor* endpoint = TUsbEndpointDescriptor::Cast(descriptor); |
398 |
442 |
399 if(endpoint) |
443 if(endpoint) |
400 { |
444 { |
401 RDebug::Printf("Match attributes for transfer type"); |
445 OstTrace0(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP04, "Match attributes for transfer type"); |
402 |
446 |
403 if( (endpoint->Attributes() & aTransferType) == aTransferType) |
447 if( (endpoint->Attributes() & aTransferType) == aTransferType) |
404 { |
448 { |
405 RDebug::Printf("Match attributes for endpoint direction"); |
449 OstTrace0(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP05, "Match attributes for endpoint direction"); |
406 |
450 |
407 if( (endpoint->EndpointAddress() & aDirection) == aDirection) |
451 if( (endpoint->EndpointAddress() & aDirection) == aDirection) |
408 { |
452 { |
409 if(indexCount==aIndex) |
453 if(indexCount==aIndex) |
410 { |
454 { |
411 aEndpointAddress = endpoint->EndpointAddress(); |
455 aEndpointAddress = endpoint->EndpointAddress(); |
412 RDebug::Printf("Endpoint address found"); |
456 OstTrace0(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP06, "Endpoint address found"); |
|
457 OstTraceFunctionExitExt( CBASETESTCASE_GETENDPOINTADDRESS_EXIT_DUP01, this, KErrNone ); |
413 return KErrNone; |
458 return KErrNone; |
414 } |
459 } |
415 else |
460 else |
416 { |
461 { |
417 indexCount++; |
462 indexCount++; |
449 //##==TBuf16<40> unicodeBuf; |
498 //##==TBuf16<40> unicodeBuf; |
450 TBuf8<40> unicodeBuf; |
499 TBuf8<40> unicodeBuf; |
451 unicodeBuf.Copy(buf); // Ideally this needs conversion to UNICODE |
500 unicodeBuf.Copy(buf); // Ideally this needs conversion to UNICODE |
452 if(aDesc.iRecognisedAndParsed == TUsbGenericDescriptor::ERecognised) |
501 if(aDesc.iRecognisedAndParsed == TUsbGenericDescriptor::ERecognised) |
453 { |
502 { |
454 RDebug::Printf("%S+ length=%d, type=0x%02x", &unicodeBuf, aDesc.ibLength, aDesc.ibDescriptorType); |
503 OstTraceExt3(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP09, "%s+ length=%u, type=0x%02x", unicodeBuf, aDesc.ibLength, (TUint32)aDesc.ibDescriptorType); |
455 iTreeBuffer.AppendFormat(_L8("%S+ length=%d, type=0x%02x\n"), &buf, aDesc.ibLength, aDesc.ibDescriptorType); |
504 iTreeBuffer.AppendFormat(_L8("%S+ length=%d, type=0x%02x\n"), &buf, aDesc.ibLength, aDesc.ibDescriptorType); |
456 } |
505 } |
457 else |
506 else |
458 { |
507 { |
459 RDebug::Printf("%S- length=%d, type=0x%02x", &unicodeBuf, aDesc.ibLength, aDesc.ibDescriptorType); |
508 OstTraceExt3(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP10, "%s- length=%u, type=0x%02x", unicodeBuf, aDesc.ibLength, (TUint32)aDesc.ibDescriptorType); |
460 iTreeBuffer.AppendFormat(_L8("%S- length=%d, type=0x%02x\n"), &buf, aDesc.ibLength, aDesc.ibDescriptorType); |
509 iTreeBuffer.AppendFormat(_L8("%S- length=%d, type=0x%02x\n"), &buf, aDesc.ibLength, aDesc.ibDescriptorType); |
461 } |
510 } |
462 |
511 |
463 PrintAndStoreBlob(buf ,aDesc.iBlob); |
512 PrintAndStoreBlob(buf ,aDesc.iBlob); |
464 |
513 |
465 if(aDesc.iFirstChild) |
514 if(aDesc.iFirstChild) |
466 { |
515 { |
467 RDebug::Printf("%S \\ ", &unicodeBuf); |
516 OstTraceExt1(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP11, "%s \n", unicodeBuf); |
468 iTreeBuffer.AppendFormat(_L8("%S \\ \n"), &buf); |
517 iTreeBuffer.AppendFormat(_L8("%S \\ \n"), &buf); |
469 |
518 |
470 PrintAndStoreTree(*(aDesc.iFirstChild), aDepth+1); |
519 PrintAndStoreTree(*(aDesc.iFirstChild), aDepth+1); |
471 |
520 |
472 RDebug::Printf("%S / ", &unicodeBuf); |
521 OstTraceExt1(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP12, "%s \n", unicodeBuf); |
473 iTreeBuffer.AppendFormat(_L8("%S / \n"), &buf); |
522 iTreeBuffer.AppendFormat(_L8("%S / \n"), &buf); |
474 } |
523 } |
475 if(aDesc.iNextPeer) |
524 if(aDesc.iNextPeer) |
476 { |
525 { |
477 PrintAndStoreTree(*(aDesc.iNextPeer), aDepth); |
526 PrintAndStoreTree(*(aDesc.iNextPeer), aDepth); |
478 } |
527 } |
|
528 OstTraceFunctionExit1( CBASETESTCASE_PRINTANDSTORETREE_EXIT, 0 ); |
479 } |
529 } |
480 |
530 |
481 void CBaseTestCase::PrintAndStoreBlob(TDes8& aBuf, TPtrC8& aBlob) |
531 void CBaseTestCase::PrintAndStoreBlob(TDes8& aBuf, TPtrC8& aBlob) |
482 { |
532 { |
|
533 OstTraceFunctionEntryExt( CBASETESTCASE_PRINTANDSTOREBLOB_ENTRY, this ); |
483 |
534 |
484 HBufC8* chunk = HBufC8::New(KChunkSize); |
535 HBufC8* chunk = HBufC8::New(KChunkSize); |
485 |
536 |
486 TUint nbIter = aBlob.Length()/(KChunkSize/2); |
537 TUint nbIter = aBlob.Length()/(KChunkSize/2); |
487 TUint remainderSize = aBlob.Length()%(KChunkSize/2); |
538 TUint remainderSize = aBlob.Length()%(KChunkSize/2); |
550 |
604 |
551 // compare tree to ref. |
605 // compare tree to ref. |
552 TBool isIdentical; |
606 TBool isIdentical; |
553 if(KErrNone != CompareCurrentTreeToRef(aFileName, isIdentical)) |
607 if(KErrNone != CompareCurrentTreeToRef(aFileName, isIdentical)) |
554 { |
608 { |
555 RDebug::Printf("CompareCurrentTreeToRef error"); |
609 OstTrace0(TRACE_NORMAL, CBASETESTCASE_CHECKTREE, "CompareCurrentTreeToRef error"); |
556 ret = KErrGeneral; |
610 ret = KErrGeneral; |
557 } |
611 } |
558 if(!isIdentical) |
612 if(!isIdentical) |
559 { |
613 { |
560 RDebug::Printf("!isIdentical"); |
614 OstTrace0(TRACE_NORMAL, CBASETESTCASE_CHECKTREE_DUP01, "!isIdentical"); |
561 ret = KErrGeneral; |
615 ret = KErrGeneral; |
562 } |
616 } |
|
617 OstTraceFunctionExitExt( CBASETESTCASE_CHECKTREE_EXIT, this, ret ); |
563 return ret; |
618 return ret; |
564 } |
619 } |
565 |
620 |
566 |
621 |
567 TInt CBaseTestCase::ParseConfigDescriptorAndCheckTree(TUsbDeviceDescriptor *devDesc, const TDesC8& configSet, TUint indexTest) |
622 TInt CBaseTestCase::ParseConfigDescriptorAndCheckTree(TUsbDeviceDescriptor *devDesc, const TDesC8& configSet, TUint indexTest) |
568 { |
623 { |
569 LOG_FUNC |
624 OstTraceFunctionEntryExt( CBASETESTCASE_PARSECONFIGDESCRIPTORANDCHECKTREE_ENTRY, this ); |
570 // Parse config. descriptor |
625 // Parse config. descriptor |
571 TUsbGenericDescriptor* parsed = NULL; |
626 TUsbGenericDescriptor* parsed = NULL; |
572 TInt err = UsbDescriptorParser::Parse(configSet, parsed); |
627 TInt err = UsbDescriptorParser::Parse(configSet, parsed); |
573 if(err != KErrNone) |
628 if(err != KErrNone) |
574 { |
629 { |
575 RDebug::Printf("parsing error : UsbDescriptorParser::Parse"); |
630 OstTrace0(TRACE_NORMAL, CBASETESTCASE_PARSECONFIGDESCRIPTORANDCHECKTREE, "parsing error : UsbDescriptorParser::Parse"); |
|
631 OstTraceFunctionExitExt( CBASETESTCASE_PARSECONFIGDESCRIPTORANDCHECKTREE_EXIT, this, err ); |
576 return err; |
632 return err; |
577 } |
633 } |
578 TUsbConfigurationDescriptor* configDesc = TUsbConfigurationDescriptor::Cast(parsed); |
634 TUsbConfigurationDescriptor* configDesc = TUsbConfigurationDescriptor::Cast(parsed); |
579 // checks |
635 // checks |
580 if(configDesc == 0) |
636 if(configDesc == 0) |
581 { |
637 { |
582 RDebug::Printf("configDesc == 0"); |
638 OstTrace0(TRACE_NORMAL, CBASETESTCASE_PARSECONFIGDESCRIPTORANDCHECKTREE_DUP01, "configDesc == 0"); |
|
639 OstTraceFunctionExitExt( CBASETESTCASE_PARSECONFIGDESCRIPTORANDCHECKTREE_EXIT_DUP01, this, KErrGeneral ); |
583 return KErrGeneral; |
640 return KErrGeneral; |
584 } |
641 } |
585 |
642 |
586 // checking tree |
643 // checking tree |
587 TBuf<KMaxName> fname(iTestCaseId); |
644 TBuf<KMaxName> fname(iTestCaseId); |