15 // |
15 // |
16 |
16 |
17 #include "d_hcrsim.h" |
17 #include "d_hcrsim.h" |
18 #include <kernel/kernel.h> |
18 #include <kernel/kernel.h> |
19 #include <plat_priv.h> |
19 #include <plat_priv.h> |
|
20 #ifndef HCRTEST_USERSIDE_INTERFACE |
20 #include "hcr_debug.h" |
21 #include "hcr_debug.h" |
21 #include "hcr_hai.h" |
22 #include "hcr_hai.h" |
22 #include "hcr_pil.h" |
23 #include "hcr_pil.h" |
|
24 #endif // HCRTEST_USERSIDE_INTERFACE |
|
25 #include "hcr_uids.h" |
23 |
26 |
24 #define TEST(a) CheckPoint(a, __LINE__) |
27 #define TEST(a) CheckPoint(a, __LINE__) |
25 #define TEST_KERRNONE(a) CheckPointError(a, __LINE__) |
28 #define TEST_KERRNONE(a) CheckPointError(a, __LINE__) |
26 |
29 |
|
30 #ifndef HCRTEST_USERSIDE_INTERFACE |
27 TInt InitExtension(); |
31 TInt InitExtension(); |
28 extern TUint32 PslConfigurationFlags; |
32 extern TUint32 PslConfigurationFlags; |
|
33 #endif // HCRTEST_USERSIDE_INTERFACE |
|
34 |
|
35 #ifdef HCRTEST_CLIENT_THREAD |
|
36 #define TEST_ENTERCS() NKern::ThreadEnterCS() |
|
37 #define TEST_LEAVECS() NKern::ThreadLeaveCS() |
|
38 #define TEST_MEMGET(s, d, l) kumemget(d, s, l) |
|
39 #define TEST_MEMPUT(d, s, l) kumemput(d, s, l) |
|
40 #define TEST_DESGET(s, d) Kern::KUDesGet(d, *(TDes8*) s) |
|
41 #define TEST_DESPUT(d, s) Kern::KUDesPut(*(TDes8*) d, s) |
|
42 #else |
|
43 #define TEST_ENTERCS() |
|
44 #define TEST_LEAVECS() |
|
45 #define TEST_MEMGET(s, d, l) Kern::ThreadRawRead(iClient, s, d, l) |
|
46 #define TEST_MEMPUT(d, s, l) Kern::ThreadRawWrite(iClient, d, s, l) |
|
47 #define TEST_DESGET(s, d) Kern::ThreadDesRead(iClient, s, d, 0) |
|
48 #define TEST_DESPUT(d, s) Kern::ThreadDesWrite(iClient, d, s, 0) |
|
49 #endif // HCRTEST_CLIENT_THREAD |
|
50 |
|
51 // Test results for the Kernel Extension initialisation routine |
|
52 TInt TestKernExtensionTestLine = -1; |
|
53 TInt TestKernExtensionTestError = -1; |
|
54 |
|
55 const TUint KTestBenchmarkIterations = 10000; |
|
56 const TUint KTestGetMultipleBenchmarkIterations = 100; |
29 |
57 |
30 class DHcrSimTestDrvFactory : public DLogicalDevice |
58 class DHcrSimTestDrvFactory : public DLogicalDevice |
31 { |
59 { |
32 public: |
60 public: |
33 DHcrSimTestDrvFactory(); |
61 DHcrSimTestDrvFactory(); |
34 ~DHcrSimTestDrvFactory(); |
62 ~DHcrSimTestDrvFactory(); |
35 virtual TInt Install(); |
63 virtual TInt Install(); |
36 virtual void GetCaps(TDes8& aDes) const; |
64 virtual void GetCaps(TDes8& aDes) const; |
37 virtual TInt Create(DLogicalChannelBase*& aChannel); |
65 virtual TInt Create(DLogicalChannelBase*& aChannel); |
38 public: |
66 public: |
|
67 #ifndef HCRTEST_CLIENT_THREAD |
39 TDynamicDfcQue* iDfcQ; |
68 TDynamicDfcQue* iDfcQ; |
|
69 #endif |
40 }; |
70 }; |
41 |
71 |
|
72 #ifdef HCRTEST_CLIENT_THREAD |
|
73 class DHcrSimTestDrvChannel : public DLogicalChannelBase |
|
74 #else |
42 class DHcrSimTestDrvChannel : public DLogicalChannel |
75 class DHcrSimTestDrvChannel : public DLogicalChannel |
|
76 #endif |
43 { |
77 { |
44 public: |
78 public: |
45 DHcrSimTestDrvChannel(); |
79 DHcrSimTestDrvChannel(); |
46 ~DHcrSimTestDrvChannel(); |
80 ~DHcrSimTestDrvChannel(); |
47 // Inherited from DLogicalChannel |
81 // Inherited from DLogicalChannel |
48 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); |
82 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); |
|
83 #ifdef HCRTEST_CLIENT_THREAD |
|
84 // Inherited from DLogicalChannelBase: process all DoControl in the user's context |
|
85 virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2); |
|
86 #else |
49 TInt DoControl(TInt aReqNo, TAny* a1, TAny* a2); |
87 TInt DoControl(TInt aReqNo, TAny* a1, TAny* a2); |
50 virtual void HandleMsg(TMessageBase* aMsg); |
88 virtual void HandleMsg(TMessageBase* aMsg); |
51 public: |
89 public: |
52 DThread* iClient; |
90 DThread* iClient; |
|
91 #endif // HCRTEST_CLIENT_THREAD |
53 }; |
92 }; |
54 |
93 |
55 void CheckPoint(TInt aCondition, TInt aLine) |
94 void CheckPoint(TInt aCondition, TInt aLine) |
56 { |
95 { |
57 if (!aCondition) |
96 if (!aCondition) |
166 } |
280 } |
167 case RHcrSimTestChannel::EHcrFindSettingsCategory: |
281 case RHcrSimTestChannel::EHcrFindSettingsCategory: |
168 { |
282 { |
169 // Get list of pointers |
283 // Get list of pointers |
170 TAny* args[6]; |
284 TAny* args[6]; |
171 Kern::ThreadRawRead(iClient, a1, args, sizeof(args)); |
285 TEST_MEMGET(a1, args, sizeof(args)); |
172 TInt aMaxNum = (TInt) args[1]; |
286 TInt aMaxNum = (TInt) args[1]; |
173 // Allocate temporary memory |
287 // Allocate temporary memory |
174 TUint32 numfound; |
288 |
175 HCR::TElementId* ids; |
289 HCR::TElementId* ids; |
176 HCR::TSettingType* types = NULL; |
290 HCR::TSettingType* types = NULL; |
177 TUint16* lens = NULL; |
291 TUint16* lens = NULL; |
|
292 TEST_ENTERCS(); |
178 ids = (HCR::TElementId*) Kern::Alloc(aMaxNum * sizeof(HCR::TElementId)); |
293 ids = (HCR::TElementId*) Kern::Alloc(aMaxNum * sizeof(HCR::TElementId)); |
|
294 TEST_LEAVECS(); |
179 if (ids == NULL) |
295 if (ids == NULL) |
180 { |
296 { |
181 r = KErrNoMemory; |
297 r = KErrNoMemory; |
182 } |
298 } |
183 else |
299 else |
184 { |
300 { |
185 if (args[4]) // aTypes |
301 if (args[4]) // aTypes |
186 { |
302 { |
|
303 TEST_ENTERCS(); |
187 types = (HCR::TSettingType*) Kern::Alloc(aMaxNum * sizeof(HCR::TSettingType)); |
304 types = (HCR::TSettingType*) Kern::Alloc(aMaxNum * sizeof(HCR::TSettingType)); |
|
305 TEST_LEAVECS(); |
188 } |
306 } |
189 if (types == NULL && args[4]) |
307 if (types == NULL && args[4]) |
190 { |
308 { |
191 r = KErrNoMemory; |
309 r = KErrNoMemory; |
192 } |
310 } |
193 else |
311 else |
194 { |
312 { |
195 if (args[5]) // aLens |
313 if (args[5]) // aLens |
196 { |
314 { |
|
315 TEST_ENTERCS(); |
197 lens = (TUint16*) Kern::Alloc(aMaxNum * sizeof(TUint16)); |
316 lens = (TUint16*) Kern::Alloc(aMaxNum * sizeof(TUint16)); |
|
317 TEST_LEAVECS(); |
198 } |
318 } |
199 if (lens == NULL && args[5]) |
319 if (lens == NULL && args[5]) |
200 { |
320 { |
201 r = KErrNoMemory; |
321 r = KErrNoMemory; |
202 } |
322 } |
203 else |
323 else |
204 { |
324 { |
205 // Actual API call |
325 // Actual API call |
206 r = HCR::FindSettings((HCR::TCategoryUid) args[0], |
326 r = HCR::FindSettings((HCR::TCategoryUid) args[0], |
207 aMaxNum, numfound, ids, types, lens); |
327 aMaxNum, ids, types, lens); |
208 TEST_KERRNONE(r); |
328 |
209 // Send values back to client |
329 // Send values back to client |
210 if (!r) |
330 if (r >= 0) |
211 { |
331 { |
212 Kern::ThreadRawWrite(iClient, args[2], &numfound, sizeof(TUint32)); |
332 TEST_MEMPUT(args[2], &r, sizeof(TUint32)); |
213 Kern::ThreadRawWrite(iClient, args[3], ids, aMaxNum * sizeof(HCR::TElementId)); |
333 TEST_MEMPUT(args[3], ids, aMaxNum * sizeof(HCR::TElementId)); |
214 if (args[4]) |
334 if (args[4]) |
215 { |
335 { |
216 Kern::ThreadRawWrite(iClient, args[4], types, aMaxNum * sizeof(HCR::TSettingType)); |
336 TEST_MEMPUT(args[4], types, aMaxNum * sizeof(HCR::TSettingType)); |
217 } |
337 } |
218 if (args[5]) |
338 if (args[5]) |
219 { |
339 { |
220 Kern::ThreadRawWrite(iClient, args[5], lens, aMaxNum * sizeof(TUint16)); |
340 TEST_MEMPUT(args[5], lens, aMaxNum * sizeof(TUint16)); |
221 } |
341 } |
222 } |
342 } |
223 if (args[5]) |
343 if (args[5]) |
224 { |
344 { |
|
345 TEST_ENTERCS(); |
225 Kern::Free(lens); |
346 Kern::Free(lens); |
|
347 TEST_LEAVECS(); |
226 } |
348 } |
227 } |
349 } |
228 if (args[4]) |
350 if (args[4]) |
229 { |
351 { |
|
352 TEST_ENTERCS(); |
230 Kern::Free(types); |
353 Kern::Free(types); |
|
354 TEST_LEAVECS(); |
231 } |
355 } |
232 } |
356 } |
|
357 TEST_ENTERCS(); |
233 Kern::Free(ids); |
358 Kern::Free(ids); |
|
359 TEST_LEAVECS(); |
234 } |
360 } |
235 break; |
361 break; |
236 } |
362 } |
237 case RHcrSimTestChannel::EHcrFindSettingsPattern: |
363 case RHcrSimTestChannel::EHcrFindSettingsPattern: |
238 { |
364 { |
239 // Get list of pointers |
365 // Get list of pointers |
240 TAny* args[9]; |
366 TAny* args[8]; |
241 Kern::ThreadRawRead(iClient, a1, args, sizeof(args)); |
367 TEST_MEMGET(a1, args, sizeof(args)); |
242 TInt aMaxNum = (TInt) args[1]; |
368 TInt aMaxNum = (TInt) args[1]; |
243 // Allocate temporary memory |
369 // Allocate temporary memory |
244 TUint32 numfound; |
370 TUint32 numfound; |
245 HCR::TElementId* ids; |
371 HCR::TElementId* ids; |
246 HCR::TSettingType* types = NULL; |
372 HCR::TSettingType* types = NULL; |
247 TUint16* lens = NULL; |
373 TUint16* lens = NULL; |
|
374 TEST_ENTERCS(); |
248 ids = (HCR::TElementId*) Kern::Alloc(aMaxNum * sizeof(HCR::TElementId)); |
375 ids = (HCR::TElementId*) Kern::Alloc(aMaxNum * sizeof(HCR::TElementId)); |
|
376 TEST_LEAVECS(); |
249 if (ids == NULL) |
377 if (ids == NULL) |
250 { |
378 { |
251 r = KErrNoMemory; |
379 r = KErrNoMemory; |
252 } |
380 } |
253 else |
381 else |
254 { |
382 { |
255 if (args[7]) // aTypes |
383 if (args[6]) // aTypes |
256 { |
384 { |
|
385 TEST_ENTERCS(); |
257 types = (HCR::TSettingType*) Kern::Alloc(aMaxNum * sizeof(HCR::TSettingType)); |
386 types = (HCR::TSettingType*) Kern::Alloc(aMaxNum * sizeof(HCR::TSettingType)); |
258 } |
387 TEST_LEAVECS(); |
259 if (types == NULL && args[7]) |
388 } |
|
389 if (types == NULL && args[6]) |
260 { |
390 { |
261 r = KErrNoMemory; |
391 r = KErrNoMemory; |
262 } |
392 } |
263 else |
393 else |
264 { |
394 { |
265 if (args[8]) // aLens |
395 if (args[7]) // aLens |
266 { |
396 { |
|
397 TEST_ENTERCS(); |
267 lens = (TUint16*) Kern::Alloc(aMaxNum * sizeof(TUint16)); |
398 lens = (TUint16*) Kern::Alloc(aMaxNum * sizeof(TUint16)); |
|
399 TEST_LEAVECS(); |
268 } |
400 } |
269 if (lens == NULL && args[8]) |
401 if (lens == NULL && args[7]) |
270 { |
402 { |
271 r = KErrNoMemory; |
403 r = KErrNoMemory; |
272 } |
404 } |
273 else |
405 else |
274 { |
406 { |
275 // Actual API call |
407 // Actual API call |
276 r = HCR::FindSettings((HCR::TCategoryUid) args[0], |
408 r = HCR::FindSettings((HCR::TCategoryUid) args[0], |
277 aMaxNum, (TUint32) args[2], (TUint32) args[3], (TUint32) args[4], |
409 aMaxNum, (TUint32) args[2], (TUint32) args[3], |
278 numfound, ids, types, lens); |
410 ids, types, lens); |
279 TEST_KERRNONE(r); |
411 |
280 // Send values back to client |
412 // Send values back to client |
281 if (!r) |
413 if (r > 0) |
282 { |
414 { |
283 Kern::ThreadRawWrite(iClient, args[5], &numfound, sizeof(TUint32)); |
415 TEST_MEMPUT(args[4], &numfound, sizeof(TUint32)); |
284 Kern::ThreadRawWrite(iClient, args[6], ids, aMaxNum * sizeof(HCR::TElementId)); |
416 TEST_MEMPUT(args[5], ids, aMaxNum * sizeof(HCR::TElementId)); |
|
417 if (args[6]) |
|
418 { |
|
419 TEST_MEMPUT(args[6], types, aMaxNum * sizeof(HCR::TSettingType)); |
|
420 } |
285 if (args[7]) |
421 if (args[7]) |
286 { |
422 { |
287 Kern::ThreadRawWrite(iClient, args[7], types, aMaxNum * sizeof(HCR::TSettingType)); |
423 TEST_MEMPUT(args[7], lens, aMaxNum * sizeof(TUint16)); |
288 } |
|
289 if (args[8]) |
|
290 { |
|
291 Kern::ThreadRawWrite(iClient, args[8], lens, aMaxNum * sizeof(TUint16)); |
|
292 } |
424 } |
293 } |
425 } |
294 if (args[8]) |
426 if (args[7]) |
295 { |
427 { |
|
428 TEST_ENTERCS(); |
296 Kern::Free(lens); |
429 Kern::Free(lens); |
|
430 TEST_LEAVECS(); |
297 } |
431 } |
298 } |
432 } |
299 if (args[7]) |
433 if (args[6]) |
300 { |
434 { |
|
435 TEST_ENTERCS(); |
301 Kern::Free(types); |
436 Kern::Free(types); |
|
437 TEST_LEAVECS(); |
302 } |
438 } |
303 } |
439 } |
|
440 TEST_ENTERCS(); |
304 Kern::Free(ids); |
441 Kern::Free(ids); |
|
442 TEST_LEAVECS(); |
305 } |
443 } |
306 break; |
444 break; |
307 } |
445 } |
308 case RHcrSimTestChannel::EHcrGetTypeAndSize: |
446 case RHcrSimTestChannel::EHcrGetTypeAndSize: |
309 { |
447 { |
310 // Get list of pointers |
448 // Get list of pointers |
311 TAny* args[3]; |
449 TAny* args[3]; |
312 Kern::ThreadRawRead(iClient, a1, args, sizeof(args)); |
450 TEST_MEMGET(a1, args, sizeof(args)); |
313 HCR::TSettingId id; |
451 HCR::TSettingId id; |
314 Kern::ThreadRawRead(iClient, args[0], &id, sizeof(HCR::TSettingId)); |
452 TEST_MEMGET(args[0], &id, sizeof(HCR::TSettingId)); |
315 HCR::TSettingType type; |
453 HCR::TSettingType type; |
316 TUint16 len; |
454 TUint16 len; |
317 TEST_KERRNONE(r = HCR::GetTypeAndSize(id, type, len)); |
455 r = HCR::GetTypeAndSize(id, type, len); |
318 Kern::ThreadRawWrite(iClient, args[1], &type, sizeof(HCR::TSettingType)); |
456 TEST_MEMPUT(args[1], &type, sizeof(HCR::TSettingType)); |
319 Kern::ThreadRawWrite(iClient, args[2], &len, sizeof(TUint16)); |
457 TEST_MEMPUT(args[2], &len, sizeof(TUint16)); |
320 break; |
458 break; |
321 } |
459 } |
322 case RHcrSimTestChannel::EHcrGetWordSettings: |
460 case RHcrSimTestChannel::EHcrGetWordSettings: |
323 { |
461 { |
324 // Get list of pointers |
462 // Get list of pointers |
325 TAny* args[5]; |
463 TAny* args[5]; |
326 Kern::ThreadRawRead(iClient, a1, args, sizeof(args)); |
464 TEST_MEMGET(a1, args, sizeof(args)); |
327 TInt aNum = (TInt) args[0]; |
465 TInt aNum = (TInt) args[0]; |
328 // Allocate temporary memory |
466 // Allocate temporary memory |
329 HCR::SSettingId* ids; |
467 HCR::SSettingId* ids; |
|
468 HCR::SSettingId* inIds = (HCR::SSettingId*)args[1]; |
330 TInt32* vals; |
469 TInt32* vals; |
331 HCR::TSettingType* types= NULL; |
470 HCR::TSettingType* types= NULL; |
332 TInt* errors = NULL; |
471 TInt* errors = NULL; |
333 ids = (HCR::SSettingId*) Kern::Alloc(aNum * sizeof(HCR::SSettingId*)); |
472 |
334 if (ids == NULL) |
473 TEST_ENTERCS(); |
335 { |
474 if(inIds) |
336 r = KErrNoMemory; |
475 { |
337 } |
476 ids = (HCR::SSettingId*) Kern::Alloc((aNum>=0?aNum:-aNum) * sizeof(HCR::SSettingId)); |
338 else |
477 //Read data from the user side |
339 { |
478 if (ids == NULL) |
340 vals = (TInt32*) Kern::Alloc(aNum * sizeof(TInt32)); |
479 { |
341 if (vals == NULL) |
480 r = KErrNoMemory; |
342 { |
481 break; |
343 r = KErrNoMemory; |
482 } |
344 } |
483 |
345 else |
484 TEST_MEMGET(inIds, ids, (aNum>=0?aNum:-aNum) * sizeof(HCR::SSettingId)); |
346 { |
485 } |
347 if (args[3]) // aTypes |
486 else |
348 { |
487 ids = NULL; |
349 types = (HCR::TSettingType*) Kern::Alloc(aNum * sizeof(HCR::TSettingType)); |
488 TEST_LEAVECS(); |
350 } |
489 |
351 if (types == NULL && args[3]) |
490 if (args[2]) //values |
352 { |
491 { |
353 r = KErrNoMemory; |
492 TEST_ENTERCS(); |
354 } |
493 vals = (TInt32*) Kern::Alloc((aNum>=0?aNum:-aNum) * sizeof(TInt32)); |
355 else |
494 TEST_LEAVECS(); |
356 { |
495 if (vals == NULL) |
357 if (args[4]) // aErrors |
496 { |
358 { |
497 r = KErrNoMemory; |
359 errors = (TInt*) Kern::Alloc(aNum * sizeof(TInt)); |
498 break; |
360 } |
499 } |
361 if (errors == NULL && args[4]) |
500 } |
362 { |
501 else |
363 r = KErrNoMemory; |
502 vals = NULL; |
364 } |
503 |
365 else |
504 if (args[3]) // aTypes |
366 { |
505 { |
367 // Actual API call |
506 TEST_ENTERCS(); |
368 TEST_KERRNONE(r = HCR::GetWordSettings(aNum, ids, vals, types, errors)); |
507 types = (HCR::TSettingType*) Kern::Alloc((aNum>=0?aNum:-aNum) * |
369 // Send values back to client |
508 sizeof(HCR::TSettingType)); |
370 if (!r) |
509 TEST_LEAVECS(); |
371 { |
510 } |
372 Kern::ThreadRawWrite(iClient, args[1], ids, aNum * sizeof(HCR::SSettingId)); |
511 if (types == NULL && args[3]) |
373 Kern::ThreadRawWrite(iClient, args[2], vals, aNum * sizeof(TInt32)); |
512 { |
374 if (args[3]) |
513 r = KErrNoMemory; |
375 { |
514 } |
376 Kern::ThreadRawWrite(iClient, args[3], types, aNum * sizeof(HCR::TSettingType)); |
515 else |
377 } |
516 { |
378 if (args[4]) |
517 if (args[4]) // aErrors |
379 { |
518 { |
380 Kern::ThreadRawWrite(iClient, args[4], errors, aNum * sizeof(TInt)); |
519 TEST_ENTERCS(); |
381 } |
520 errors = (TInt*) Kern::Alloc((aNum>=0?aNum:-aNum) * sizeof(TInt)); |
382 } |
521 TEST_LEAVECS(); |
383 if (args[4]) |
522 } |
384 { |
523 if (errors == NULL && args[4]) |
385 Kern::Free(errors); |
524 { |
386 } |
525 r = KErrNoMemory; |
387 } |
526 } |
388 if (args[3]) |
527 else |
389 { |
528 { |
390 Kern::Free(types); |
529 // Actual API call |
391 } |
530 r = HCR::GetWordSettings(aNum, ids, vals, types, errors); |
392 } |
531 // Send values back to client |
393 Kern::Free(vals); |
532 if (r >= 0) |
394 } |
533 { |
395 Kern::Free(ids); |
534 TEST_MEMPUT(args[1], ids, aNum * sizeof(HCR::SSettingId)); |
396 } |
535 TEST_MEMPUT(args[2], vals, aNum * sizeof(TInt32)); |
|
536 if (args[3]) |
|
537 { |
|
538 TEST_MEMPUT(args[3], types,(aNum>=0?aNum:-aNum) * sizeof(HCR::TSettingType)); |
|
539 } |
|
540 if (args[4]) |
|
541 { |
|
542 TEST_MEMPUT(args[4], errors, (aNum>=0?aNum:-aNum) * sizeof(TInt)); |
|
543 } |
|
544 } |
|
545 if (args[4]) |
|
546 { |
|
547 TEST_ENTERCS(); |
|
548 Kern::Free(errors); |
|
549 TEST_LEAVECS(); |
|
550 } |
|
551 } |
|
552 if (args[3]) |
|
553 { |
|
554 TEST_ENTERCS(); |
|
555 Kern::Free(types); |
|
556 TEST_LEAVECS(); |
|
557 } |
|
558 } |
|
559 if (args[2]) |
|
560 { |
|
561 TEST_ENTERCS(); |
|
562 Kern::Free(vals); |
|
563 TEST_LEAVECS(); |
|
564 } |
|
565 TEST_ENTERCS(); |
|
566 if(inIds) |
|
567 Kern::Free(ids); |
|
568 TEST_LEAVECS(); |
|
569 |
397 break; |
570 break; |
398 } |
571 } |
399 case RHcrSimTestChannel::EHcrGetInt64: |
572 case RHcrSimTestChannel::EHcrGetInt64: |
400 { |
573 { |
401 HCR::TSettingId setting; |
574 HCR::TSettingId setting; |
402 TInt64 value; |
575 TInt64 value; |
403 Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId)); |
576 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
404 r = HCR::GetInt(setting, value); |
577 r = HCR::GetInt(setting, value); |
405 Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value)); |
578 TEST_MEMPUT(a2, &value, sizeof(value)); |
406 break; |
579 break; |
407 } |
580 } |
408 case RHcrSimTestChannel::EHcrGetInt32: |
581 case RHcrSimTestChannel::EHcrGetInt32: |
409 { |
582 { |
410 HCR::TSettingId setting; |
583 HCR::TSettingId setting; |
411 TInt32 value; |
584 TInt32 value; |
412 Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId)); |
585 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
413 r = HCR::GetInt(setting, value); |
586 r = HCR::GetInt(setting, value); |
414 Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value)); |
587 TEST_MEMPUT(a2, &value, sizeof(value)); |
415 break; |
588 break; |
416 } |
589 } |
417 case RHcrSimTestChannel::EHcrGetInt16: |
590 case RHcrSimTestChannel::EHcrGetInt16: |
418 { |
591 { |
419 HCR::TSettingId setting; |
592 HCR::TSettingId setting; |
420 TInt16 value; |
593 TInt16 value; |
421 Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId)); |
594 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
422 r = HCR::GetInt(setting, value); |
595 r = HCR::GetInt(setting, value); |
423 Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value)); |
596 TEST_MEMPUT(a2, &value, sizeof(value)); |
424 break; |
597 break; |
425 } |
598 } |
426 case RHcrSimTestChannel::EHcrGetInt8: |
599 case RHcrSimTestChannel::EHcrGetInt8: |
427 { |
600 { |
428 HCR::TSettingId setting; |
601 HCR::TSettingId setting; |
429 TInt8 value; |
602 TInt8 value; |
430 Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId)); |
603 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
431 r = HCR::GetInt(setting, value); |
604 r = HCR::GetInt(setting, value); |
432 Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value)); |
605 TEST_MEMPUT(a2, &value, sizeof(value)); |
433 break; |
606 break; |
434 } |
607 } |
435 case RHcrSimTestChannel::EHcrGetBool: |
608 case RHcrSimTestChannel::EHcrGetBool: |
436 { |
609 { |
437 HCR::TSettingId setting; |
610 HCR::TSettingId setting; |
438 TBool value; |
611 TBool value; |
439 Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId)); |
612 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
440 r = HCR::GetBool(setting, value); |
613 r = HCR::GetBool(setting, value); |
441 Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value)); |
614 TEST_MEMPUT(a2, &value, sizeof(value)); |
442 break; |
615 break; |
443 } |
616 } |
444 case RHcrSimTestChannel::EHcrGetDataArray: |
617 case RHcrSimTestChannel::EHcrGetDataArray: |
445 { |
618 { |
446 // Get list of pointers |
619 // Get list of pointers |
447 TAny* args[4]; |
620 TAny* args[4]; |
448 Kern::ThreadRawRead(iClient, a1, args, sizeof(args)); |
621 TEST_MEMGET(a1, args, sizeof(args)); |
449 TUint maxlen = (TUint) args[1]; |
622 TUint maxlen = (TUint) args[1]; |
450 // Retrieve structures from client |
623 // Retrieve structures from client |
451 HCR::TSettingId id; |
624 HCR::TSettingId id; |
452 Kern::ThreadRawRead(iClient, args[0], &id, sizeof(HCR::TSettingId)); |
625 TEST_MEMGET(args[0], &id, sizeof(HCR::TSettingId)); |
453 // Allocate temporary memory |
626 // Allocate temporary memory |
454 TUint16 len; |
627 TUint16 len; |
455 TUint8* value; |
628 TUint8* value; |
|
629 TEST_ENTERCS(); |
456 value = (TUint8*) Kern::Alloc(maxlen * sizeof(TUint8)); |
630 value = (TUint8*) Kern::Alloc(maxlen * sizeof(TUint8)); |
|
631 TEST_LEAVECS(); |
457 if (value == NULL) |
632 if (value == NULL) |
458 { |
633 { |
459 r = KErrNoMemory; |
634 r = KErrNoMemory; |
460 } |
635 } |
461 else |
636 else |
464 r = HCR::GetData(id, (TUint16) maxlen, |
639 r = HCR::GetData(id, (TUint16) maxlen, |
465 value, len); |
640 value, len); |
466 // Send value back to client |
641 // Send value back to client |
467 if (!r) |
642 if (!r) |
468 { |
643 { |
469 Kern::ThreadRawWrite(iClient, args[2], value, maxlen * sizeof(TUint8)); |
644 TEST_MEMPUT(args[2], value, maxlen * sizeof(TUint8)); |
470 Kern::ThreadRawWrite(iClient, args[3], &len, sizeof(TUint16)); |
645 TEST_MEMPUT(args[3], &len, sizeof(TUint16)); |
471 } |
646 } |
|
647 TEST_ENTERCS(); |
472 Kern::Free(value); |
648 Kern::Free(value); |
|
649 TEST_LEAVECS(); |
473 } |
650 } |
474 break; |
651 break; |
475 } |
652 } |
476 case RHcrSimTestChannel::EHcrGetDataDes: |
653 case RHcrSimTestChannel::EHcrGetDataDes: |
477 { |
654 { |
478 HCR::TSettingId setting; |
655 HCR::TSettingId setting; |
479 TBuf8<HCR::KMaxSettingLength> value; |
656 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
480 Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId)); |
657 TInt userdes[sizeof(TDes8) / sizeof(TInt) + 1]; |
481 r = HCR::GetData(setting, value); |
658 TEST_MEMGET(a2, userdes, sizeof(TDes8)); |
482 Kern::ThreadDesWrite(iClient, a2, value, 0); |
659 HBuf8* value; |
|
660 TEST_ENTERCS(); |
|
661 value = HBuf8::New(userdes[1]); |
|
662 TEST_LEAVECS(); |
|
663 if (value == NULL) |
|
664 { |
|
665 r = KErrNoMemory; |
|
666 } |
|
667 else |
|
668 { |
|
669 r = HCR::GetData(setting, *value); |
|
670 TEST_DESPUT(a2, *value); |
|
671 TEST_ENTERCS(); |
|
672 delete value; |
|
673 TEST_LEAVECS(); |
|
674 } |
483 break; |
675 break; |
484 } |
676 } |
485 case RHcrSimTestChannel::EHcrGetUInt64: |
677 case RHcrSimTestChannel::EHcrGetUInt64: |
486 { |
678 { |
487 HCR::TSettingId setting; |
679 HCR::TSettingId setting; |
488 TUint64 value; |
680 TUint64 value; |
489 Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId)); |
681 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
490 r = HCR::GetUInt(setting, value); |
682 r = HCR::GetUInt(setting, value); |
491 Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value)); |
683 TEST_MEMPUT(a2, &value, sizeof(value)); |
492 break; |
684 break; |
493 } |
685 } |
494 case RHcrSimTestChannel::EHcrGetUInt32: |
686 case RHcrSimTestChannel::EHcrGetUInt32: |
495 { |
687 { |
496 HCR::TSettingId setting; |
688 HCR::TSettingId setting; |
497 TUint32 value; |
689 TUint32 value; |
498 Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId)); |
690 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
499 r = HCR::GetUInt(setting, value); |
691 r = HCR::GetUInt(setting, value); |
500 Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value)); |
692 TEST_MEMPUT(a2, &value, sizeof(value)); |
501 break; |
693 break; |
502 } |
694 } |
503 case RHcrSimTestChannel::EHcrGetUInt16: |
695 case RHcrSimTestChannel::EHcrGetUInt16: |
504 { |
696 { |
505 HCR::TSettingId setting; |
697 HCR::TSettingId setting; |
506 TUint16 value; |
698 TUint16 value; |
507 Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId)); |
699 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
508 r = HCR::GetUInt(setting, value); |
700 r = HCR::GetUInt(setting, value); |
509 Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value)); |
701 TEST_MEMPUT(a2, &value, sizeof(value)); |
510 break; |
702 break; |
511 } |
703 } |
512 case RHcrSimTestChannel::EHcrGetUInt8: |
704 case RHcrSimTestChannel::EHcrGetUInt8: |
513 { |
705 { |
514 HCR::TSettingId setting; |
706 HCR::TSettingId setting; |
515 TUint8 value; |
707 TUint8 value; |
516 Kern::ThreadRawRead(iClient, a1, &setting, sizeof(HCR::TSettingId)); |
708 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
517 r = HCR::GetUInt(setting, value); |
709 r = HCR::GetUInt(setting, value); |
518 Kern::ThreadRawWrite(iClient, a2, &value, sizeof(value)); |
710 TEST_MEMPUT(a2, &value, sizeof(value)); |
519 break; |
711 break; |
520 } |
712 } |
521 case RHcrSimTestChannel::EHcrGetArrayInt: |
713 case RHcrSimTestChannel::EHcrGetArrayInt: |
522 { |
714 { |
523 // Get list of pointers |
715 // Get list of pointers |
524 TAny* args[4]; |
716 TAny* args[4]; |
525 Kern::ThreadRawRead(iClient, a1, args, sizeof(args)); |
717 TEST_MEMGET(a1, args, sizeof(args)); |
526 TUint maxlen = (TUint) args[1]; |
718 TUint maxlen = (TUint) args[1]; |
527 // Retrieve structures from client |
719 // Retrieve structures from client |
528 HCR::TSettingId id; |
720 HCR::TSettingId id; |
529 Kern::ThreadRawRead(iClient, args[0], &id, sizeof(HCR::TSettingId)); |
721 TEST_MEMGET(args[0], &id, sizeof(HCR::TSettingId)); |
530 // Allocate temporary memory |
722 // Allocate temporary memory |
531 TUint16 len; |
723 TUint16 len; |
532 TInt32* value; |
724 TInt32* value; |
|
725 TEST_ENTERCS(); |
533 value = (TInt32*) Kern::Alloc(maxlen); |
726 value = (TInt32*) Kern::Alloc(maxlen); |
|
727 TEST_LEAVECS(); |
534 if (value == NULL) |
728 if (value == NULL) |
535 { |
729 { |
536 r = KErrNoMemory; |
730 r = KErrNoMemory; |
537 } |
731 } |
538 else |
732 else |
654 case RHcrSimTestChannel::EHcrCheckIntegrity: |
876 case RHcrSimTestChannel::EHcrCheckIntegrity: |
655 { |
877 { |
656 r = HCRSingleton->CheckIntegrity(); |
878 r = HCRSingleton->CheckIntegrity(); |
657 break; |
879 break; |
658 } |
880 } |
|
881 #endif // HCRTEST_USERSIDE_INTERFACE |
|
882 case RHcrSimTestChannel::EHcrGetInitExtensionTestResults: |
|
883 { |
|
884 r = KErrNone; |
|
885 TEST_MEMPUT(a1, (TAny*) &TestKernExtensionTestLine, sizeof(TInt)); |
|
886 TEST_MEMPUT(a2, (TAny*) &TestKernExtensionTestError, sizeof(TInt)); |
|
887 } |
|
888 break; |
|
889 case RHcrSimTestChannel::EHcrBenchmarkGetSettingInt: |
|
890 { |
|
891 r = KErrNone; |
|
892 TUint i; |
|
893 HCR::TSettingId setting; |
|
894 TInt32 value; |
|
895 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
|
896 // |
|
897 TUint32 start = NKern::TickCount(); |
|
898 for (i = 0; i < KTestBenchmarkIterations; i++) |
|
899 { |
|
900 r |= HCR::GetInt(setting, value); |
|
901 } |
|
902 TUint32 end = NKern::TickCount(); |
|
903 // |
|
904 TUint32 ms; |
|
905 ms = ((end - start) * NKern::TickPeriod()) / 1000; |
|
906 TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32)); |
|
907 } |
|
908 break; |
|
909 case RHcrSimTestChannel::EHcrBenchmarkGetSettingArray: |
|
910 { |
|
911 r = KErrNone; |
|
912 TUint i; |
|
913 HCR::TSettingId setting; |
|
914 TText8* value; |
|
915 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
|
916 // Allocate temporary memory |
|
917 TEST_ENTERCS(); |
|
918 value = (TText8*) Kern::Alloc(HCR::KMaxSettingLength); |
|
919 TEST_LEAVECS(); |
|
920 if (value == NULL) |
|
921 { |
|
922 r = KErrNoMemory; |
|
923 } |
|
924 else |
|
925 { |
|
926 TUint16 len; |
|
927 TUint32 start = NKern::TickCount(); |
|
928 for (i = 0; i < KTestBenchmarkIterations; i++) |
|
929 { |
|
930 r |= HCR::GetString(setting, (TUint16) HCR::KMaxSettingLength, value, len); |
|
931 } |
|
932 TUint32 end = NKern::TickCount(); |
|
933 // |
|
934 TUint32 ms; |
|
935 ms = ((end - start) * NKern::TickPeriod()) / 1000; |
|
936 TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32)); |
|
937 TEST_ENTERCS(); |
|
938 Kern::Free(value); |
|
939 TEST_LEAVECS(); |
|
940 } |
|
941 } |
|
942 break; |
|
943 case RHcrSimTestChannel::EHcrBenchmarkGetSettingDes: |
|
944 { |
|
945 r = KErrNone; |
|
946 TUint i; |
|
947 HCR::TSettingId setting; |
|
948 TBuf8<HCR::KMaxSettingLength> value; |
|
949 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
|
950 TUint32 start = NKern::TickCount(); |
|
951 for (i = 0; i < KTestBenchmarkIterations; i++) |
|
952 { |
|
953 r |= HCR::GetString(setting, value); |
|
954 } |
|
955 TUint32 end = NKern::TickCount(); |
|
956 // |
|
957 TUint32 ms; |
|
958 ms = ((end - start) * NKern::TickPeriod()) / 1000; |
|
959 TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32)); |
|
960 } |
|
961 break; |
|
962 case RHcrSimTestChannel::EHcrBenchmarkFindNumSettingsInCategory: |
|
963 { |
|
964 r = 0; |
|
965 TUint i; |
|
966 TUint32 start = NKern::TickCount(); |
|
967 for (i = 0; i < KTestBenchmarkIterations; i++) |
|
968 { |
|
969 r |= HCR::FindNumSettingsInCategory((HCR::TCategoryUid) a1); |
|
970 } |
|
971 TUint32 end = NKern::TickCount(); |
|
972 // |
|
973 TUint32 ms; |
|
974 ms = ((end - start) * NKern::TickPeriod()) / 1000; |
|
975 TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32)); |
|
976 } |
|
977 break; |
|
978 case RHcrSimTestChannel::EHcrBenchmarkFindSettings: |
|
979 { |
|
980 r = 0; |
|
981 TUint i; |
|
982 |
|
983 HCR::TElementId* ids; |
|
984 HCR::TSettingType* types; |
|
985 TUint16* lens; |
|
986 TEST_ENTERCS(); |
|
987 ids = (HCR::TElementId*) Kern::Alloc(KTestBenchmarkNumberOfSettingsInCategory * sizeof(HCR::TElementId)); |
|
988 TEST_LEAVECS(); |
|
989 if (!ids) |
|
990 { |
|
991 TEST(EFalse); |
|
992 r = KErrNoMemory; |
|
993 } |
|
994 else |
|
995 { |
|
996 |
|
997 TEST_ENTERCS(); |
|
998 types = (HCR::TSettingType*) Kern::Alloc(KTestBenchmarkNumberOfSettingsInCategory * sizeof(HCR::TSettingType)); |
|
999 TEST_LEAVECS(); |
|
1000 if (!types) |
|
1001 { |
|
1002 TEST(EFalse); |
|
1003 r = KErrNoMemory; |
|
1004 } |
|
1005 else |
|
1006 { |
|
1007 TEST_ENTERCS(); |
|
1008 lens = (TUint16*) Kern::Alloc(KTestBenchmarkNumberOfSettingsInCategory * sizeof(TUint16)); |
|
1009 TEST_LEAVECS(); |
|
1010 if (!lens) |
|
1011 { |
|
1012 TEST(EFalse); |
|
1013 r = KErrNoMemory; |
|
1014 } |
|
1015 else |
|
1016 { |
|
1017 |
|
1018 TUint32 start = NKern::TickCount(); |
|
1019 for (i = 0; i < KTestBenchmarkIterations; i++) |
|
1020 { |
|
1021 r |= HCR::FindSettings((HCR::TCategoryUid) a1, |
|
1022 KTestBenchmarkNumberOfSettingsInCategory, |
|
1023 ids, types, lens); |
|
1024 } |
|
1025 TUint32 end = NKern::TickCount(); |
|
1026 // |
|
1027 |
|
1028 TUint32 ms; |
|
1029 ms = ((end - start) * NKern::TickPeriod()) / 1000; |
|
1030 TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32)); |
|
1031 TEST_ENTERCS(); |
|
1032 Kern::Free(lens); |
|
1033 TEST_LEAVECS(); |
|
1034 } |
|
1035 TEST_ENTERCS(); |
|
1036 Kern::Free(types); |
|
1037 TEST_LEAVECS(); |
|
1038 } |
|
1039 TEST_ENTERCS(); |
|
1040 Kern::Free(ids); |
|
1041 TEST_LEAVECS(); |
|
1042 } |
|
1043 } |
|
1044 break; |
|
1045 case RHcrSimTestChannel::EHcrBenchmarkGetTypeAndSize: |
|
1046 { |
|
1047 r = KErrNone; |
|
1048 TUint i; |
|
1049 HCR::TSettingId setting; |
|
1050 HCR::TSettingType type; |
|
1051 TUint16 len; |
|
1052 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
|
1053 // |
|
1054 TUint32 start = NKern::TickCount(); |
|
1055 for (i = 0; i < KTestBenchmarkIterations; i++) |
|
1056 { |
|
1057 r |= HCR::GetTypeAndSize(setting, type, len); |
|
1058 } |
|
1059 TUint32 end = NKern::TickCount(); |
|
1060 // |
|
1061 TUint32 ms; |
|
1062 ms = ((end - start) * NKern::TickPeriod()) / 1000; |
|
1063 TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32)); |
|
1064 } |
|
1065 break; |
|
1066 case RHcrSimTestChannel::EHcrBenchmarkGetWordSettings: |
|
1067 { |
|
1068 r = 0; |
|
1069 TUint i; |
|
1070 HCR::SSettingId* ids; |
|
1071 HCR::TSettingType* types; |
|
1072 HCR::TCategoryUid catId = (HCR::TCategoryUid)a1; |
|
1073 TInt32* values; |
|
1074 TInt* errors; |
|
1075 TEST_ENTERCS(); |
|
1076 //We allocate here KTestBenchmarkNumberOfSettingsInCategory - 1 because |
|
1077 //last element in the category is a large setting |
|
1078 ids = (HCR::SSettingId*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(HCR::SSettingId)); |
|
1079 TEST_LEAVECS(); |
|
1080 if (!ids) |
|
1081 { |
|
1082 TEST(EFalse); |
|
1083 r = KErrNoMemory; |
|
1084 } |
|
1085 else |
|
1086 { |
|
1087 for(TUint eId =0; eId < KTestBenchmarkNumberOfSettingsInCategory - 1; eId++ ) |
|
1088 { |
|
1089 ids[eId].iCat = catId; |
|
1090 //First element has value 1, second 2, third 3 and so on |
|
1091 ids[eId].iKey = eId + 1; |
|
1092 } |
|
1093 TEST_ENTERCS(); |
|
1094 types = (HCR::TSettingType*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(HCR::TSettingType)); |
|
1095 TEST_LEAVECS(); |
|
1096 if (!types) |
|
1097 { |
|
1098 TEST(EFalse); |
|
1099 r = KErrNoMemory; |
|
1100 } |
|
1101 else |
|
1102 { |
|
1103 TEST_ENTERCS(); |
|
1104 values = (TInt32*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(TInt32)); |
|
1105 TEST_LEAVECS(); |
|
1106 if (!values) |
|
1107 { |
|
1108 TEST(EFalse); |
|
1109 r = KErrNoMemory; |
|
1110 } |
|
1111 else |
|
1112 { |
|
1113 TEST_ENTERCS(); |
|
1114 errors = (TInt*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(TInt)); |
|
1115 TEST_LEAVECS(); |
|
1116 if (!errors) |
|
1117 { |
|
1118 TEST(EFalse); |
|
1119 r = KErrNoMemory; |
|
1120 } |
|
1121 else |
|
1122 { |
|
1123 TUint32 start = NKern::TickCount(); |
|
1124 for (i = 0; i < KTestGetMultipleBenchmarkIterations; i++) |
|
1125 { |
|
1126 r |= HCR::GetWordSettings(KTestBenchmarkNumberOfSettingsInCategory - 1, ids, values, types, errors); |
|
1127 } |
|
1128 TUint32 end = NKern::TickCount(); |
|
1129 // |
|
1130 TUint32 ms; |
|
1131 ms = ((end - start) * NKern::TickPeriod()) / 1000; |
|
1132 TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32)); |
|
1133 TEST_ENTERCS(); |
|
1134 Kern::Free(errors); |
|
1135 TEST_LEAVECS(); |
|
1136 } |
|
1137 TEST_ENTERCS(); |
|
1138 Kern::Free(values); |
|
1139 TEST_LEAVECS(); |
|
1140 } |
|
1141 TEST_ENTERCS(); |
|
1142 Kern::Free(types); |
|
1143 TEST_LEAVECS(); |
|
1144 } |
|
1145 TEST_ENTERCS(); |
|
1146 Kern::Free(ids); |
|
1147 TEST_LEAVECS(); |
|
1148 } |
|
1149 } |
|
1150 break; |
659 } |
1151 } |
660 return r; |
1152 return r; |
661 } |
1153 } |